[llvm] [SandboxIR] Add extern templates for GlobalWithNodeAPI (PR #111940)
Thomas Fransham via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 22 23:26:50 PDT 2024
fsfod wrote:
idk if this helps much but these are the linker errors i get without this change, this is a debug build so a lot of stuff is not inlined:
```
llvm\lld-link : error : undefined symbol: public: class llvm::sandboxir::GlobalIFunc & __cdecl llvm::sandboxir::GlobalWithNodeAPI<class llvm::sandboxir::GlobalIFunc, class llvm::GlobalIFunc, class llvm::sandboxir::GlobalObject, class llvm::GlobalObject>::LLVMGVToGV::operator()(class llvm::GlobalIFunc &) const
>>> referenced by llvm\include\llvm\ADT\STLExtras.h:363
>>> unittests\SandboxIR\CMakeFiles\SandboxIRTests.dir\SandboxIRTest.cpp.obj:(public: class llvm::sandboxir::GlobalIFunc & __cdecl llvm::mapped_iterator<class llvm::ilist_iterator<struct llvm::ilist_detail::node_options<class llvm::GlobalIFunc, 1, 0, void, 0, void>, 0, 0>, struct llvm::sandboxir::GlobalWithNodeAPI<class llvm::sandboxir::GlobalIFunc, class llvm::GlobalIFunc, class llvm::sandboxir::GlobalObject, class llvm::GlobalObject>::LLVMGVToGV, class llvm::sandboxir::GlobalIFunc &>::operator*(void) const)
>>> referenced by llvm\include\llvm\ADT\STLExtras.h:363
>>> unittests\SandboxIR\CMakeFiles\SandboxIRTests.dir\SandboxIRTest.cpp.obj:(public: class llvm::sandboxir::GlobalIFunc & __cdecl llvm::mapped_iterator<class llvm::ilist_iterator<struct llvm::ilist_detail::node_options<class llvm::GlobalIFunc, 1, 0, void, 0, void>, 1, 0>, struct llvm::sandboxir::GlobalWithNodeAPI<class llvm::sandboxir::GlobalIFunc, class llvm::GlobalIFunc, class llvm::sandboxir::GlobalObject, class llvm::GlobalObject>::LLVMGVToGV, class llvm::sandboxir::GlobalIFunc &>::operator*(void) const)
llvm\lld-link : error : undefined symbol: public: class llvm::sandboxir::GlobalVariable & __cdecl llvm::sandboxir::GlobalWithNodeAPI<class llvm::sandboxir::GlobalVariable, class llvm::GlobalVariable, class llvm::sandboxir::GlobalObject, class llvm::GlobalObject>::LLVMGVToGV::operator()(class llvm::GlobalVariable &) const
>>> referenced by llvm\include\llvm\ADT\STLExtras.h:363
>>> unittests\SandboxIR\CMakeFiles\SandboxIRTests.dir\SandboxIRTest.cpp.obj:(public: class llvm::sandboxir::GlobalVariable & __cdecl llvm::mapped_iterator<class llvm::ilist_iterator<struct llvm::ilist_detail::node_options<class llvm::GlobalVariable, 1, 0, void, 0, void>, 0, 0>, struct llvm::sandboxir::GlobalWithNodeAPI<class llvm::sandboxir::GlobalVariable, class llvm::GlobalVariable, class llvm::sandboxir::GlobalObject, class llvm::GlobalObject>::LLVMGVToGV, class llvm::sandboxir::GlobalVariable &>::operator*(void) const)
>>> referenced by llvm\include\llvm\ADT\STLExtras.h:363
>>> unittests\SandboxIR\CMakeFiles\SandboxIRTests.dir\SandboxIRTest.cpp.obj:(public: class llvm::sandboxir::GlobalVariable & __cdecl llvm::mapped_iterator<class llvm::ilist_iterator<struct llvm::ilist_detail::node_options<class llvm::GlobalVariable, 1, 0, void, 0, void>, 1, 0>, struct llvm::sandboxir::GlobalWithNodeAPI<class llvm::sandboxir::GlobalVariable, class llvm::GlobalVariable, class llvm::sandboxir::GlobalObject, class llvm::GlobalObject>::LLVMGVToGV, class llvm::sandboxir::GlobalVariable &>::operator*(void) const)
llvm\lld-link : error : undefined symbol: public: class llvm::sandboxir::GlobalAlias & __cdecl llvm::sandboxir::GlobalWithNodeAPI<class llvm::sandboxir::GlobalAlias, class llvm::GlobalAlias, class llvm::sandboxir::GlobalValue, class llvm::GlobalValue>::LLVMGVToGV::operator()(class llvm::GlobalAlias &) const
>>> referenced by llvm\include\llvm\ADT\STLExtras.h:363
>>> unittests\SandboxIR\CMakeFiles\SandboxIRTests.dir\SandboxIRTest.cpp.obj:(public: class llvm::sandboxir::GlobalAlias & __cdecl llvm::mapped_iterator<class llvm::ilist_iterator<struct llvm::ilist_detail::node_options<class llvm::GlobalAlias, 1, 0, void, 0, void>, 0, 0>, struct llvm::sandboxir::GlobalWithNodeAPI<class llvm::sandboxir::GlobalAlias, class llvm::GlobalAlias, class llvm::sandboxir::GlobalValue, class llvm::GlobalValue>::LLVMGVToGV, class llvm::sandboxir::GlobalAlias &>::operator*(void) const)
>>> referenced by llvm\include\llvm\ADT\STLExtras.h:363
>>> unittests\SandboxIR\CMakeFiles\SandboxIRTests.dir\SandboxIRTest.cpp.obj:(public: class llvm::sandboxir::GlobalAlias & __cdecl llvm::mapped_iterator<class llvm::ilist_iterator<struct llvm::ilist_detail::node_options<class llvm::GlobalAlias, 1, 0, void, 0, void>, 1, 0>, struct llvm::sandboxir::GlobalWithNodeAPI<class llvm::sandboxir::GlobalAlias, class llvm::GlobalAlias, class llvm::sandboxir::GlobalValue, class llvm::GlobalValue>::LLVMGVToGV, class llvm::sandboxir::GlobalAlias &>::operator*(void) const)
llvm\lld-link : error : undefined symbol: public: class llvm::sandboxir::Function & __cdecl llvm::sandboxir::GlobalWithNodeAPI<class llvm::sandboxir::Function, class llvm::Function, class llvm::sandboxir::GlobalObject, class llvm::GlobalObject>::LLVMGVToGV::operator()(class llvm::Function &) const
>>> referenced by llvm\include\llvm\ADT\STLExtras.h:363
>>> unittests\SandboxIR\CMakeFiles\SandboxIRTests.dir\SandboxIRTest.cpp.obj:(public: class llvm::sandboxir::Function & __cdecl llvm::mapped_iterator<class llvm::ilist_iterator<struct llvm::ilist_detail::node_options<class llvm::Function, 1, 0, void, 0, void>, 0, 0>, struct llvm::sandboxir::GlobalWithNodeAPI<class llvm::sandboxir::Function, class llvm::Function, class llvm::sandboxir::GlobalObject, class llvm::GlobalObject>::LLVMGVToGV, class llvm::sandboxir::Function &>::operator*(void) const)
>>> referenced by llvm\include\llvm\ADT\STLExtras.h:363
>>> unittests\SandboxIR\CMakeFiles\SandboxIRTests.dir\SandboxIRTest.cpp.obj:(public: class llvm::sandboxir::Function & __cdecl llvm::mapped_iterator<class llvm::ilist_iterator<struct llvm::ilist_detail::node_options<class llvm::Function, 1, 0, void, 0, void>, 1, 0>, struct llvm::sandboxir::GlobalWithNodeAPI<class llvm::sandboxir::Function, class llvm::Function, class llvm::sandboxir::GlobalObject, class llvm::GlobalObject>::LLVMGVToGV, class llvm::sandboxir::Function &>::operator*(void) const)
```
> There are other similar CRTPs, like the `SingleLLVMInstructionImpl` in `llvm//SandboxIR/Instruction.h`, would they also need to be explicitly exported too?
I think those might of got exported from visibility macros that will be added on classes that derived from an instantiation of them like here https://github.com/fsfod/llvm-project/blob/fdf88b914978d57c6c75892a3133d4476b8995d1/llvm/include/llvm/SandboxIR/Instruction.h#L411 I just didn't want add them all in this PR.
https://github.com/llvm/llvm-project/pull/111940
More information about the llvm-commits
mailing list