[llvm] [IR] Prevent implicit SymbolTableListTraits template instantiation (PR #111600)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 8 15:52:25 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Victor Mustya (vmustya)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/111600.diff
1 Files Affected:
- (modified) llvm/include/llvm/IR/SymbolTableListTraits.h (+9)
``````````diff
diff --git a/llvm/include/llvm/IR/SymbolTableListTraits.h b/llvm/include/llvm/IR/SymbolTableListTraits.h
index bd31fca5e525b6..fcf6f0fb152804 100644
--- a/llvm/include/llvm/IR/SymbolTableListTraits.h
+++ b/llvm/include/llvm/IR/SymbolTableListTraits.h
@@ -106,6 +106,15 @@ class SymbolTableListTraits : public ilist_alloc_traits<ValueSubClass> {
static ValueSymbolTable *toPtr(ValueSymbolTable &R) { return &R; }
};
+// The SymbolTableListTraits template is explicitly instantiated for the
+// following data types, so add extern template statements to prevent implicit
+// instantiation.
+extern template class SymbolTableListTraits<BasicBlock>;
+extern template class SymbolTableListTraits<Function>;
+extern template class SymbolTableListTraits<GlobalAlias>;
+extern template class SymbolTableListTraits<GlobalIFunc>;
+extern template class SymbolTableListTraits<GlobalVariable>;
+
/// List that automatically updates parent links and symbol tables.
///
/// When nodes are inserted into and removed from this list, the associated
``````````
</details>
https://github.com/llvm/llvm-project/pull/111600
More information about the llvm-commits
mailing list