Skip to content

Commit 15dc2d5

Browse files
authored
[IR] Prevent implicit SymbolTableListTraits template instantiation (#111600)
The `SymbolTableListTraits` template is explicitly instantiated for the following types: * `llvm/lib/IR/Function.cpp` - `BasicBlock` * `llvm/lib/IR/Module.cpp` - `Function` - `GlobalAlias` - `GlobalIFunc` - `GlobalVariable` When LLVM is built on Windows with the `LLVM_EXPORT_SYMBOLS_FOR_PLUGINS` option enabled, the implicit instantiation of the template prevents the `SymbolTableListTraits` template from being exported. This causes link errors when the template or IR API is used in a plugin. This change prevents the template being implicitly instantiated for these types.
1 parent c47f3e8 commit 15dc2d5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

llvm/include/llvm/IR/SymbolTableListTraits.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ class SymbolTableListTraits : public ilist_alloc_traits<ValueSubClass> {
106106
static ValueSymbolTable *toPtr(ValueSymbolTable &R) { return &R; }
107107
};
108108

109+
// The SymbolTableListTraits template is explicitly instantiated for the
110+
// following data types, so add extern template statements to prevent implicit
111+
// instantiation.
112+
extern template class SymbolTableListTraits<BasicBlock>;
113+
extern template class SymbolTableListTraits<Function>;
114+
extern template class SymbolTableListTraits<GlobalAlias>;
115+
extern template class SymbolTableListTraits<GlobalIFunc>;
116+
extern template class SymbolTableListTraits<GlobalVariable>;
117+
109118
/// List that automatically updates parent links and symbol tables.
110119
///
111120
/// When nodes are inserted into and removed from this list, the associated

0 commit comments

Comments
 (0)