[llvm] [llvm] annotate interfaces in Passes for DLL export (PR #143794)

Andrew Rogers via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 12 08:43:07 PDT 2025


================
@@ -614,26 +616,22 @@ class StandardInstrumentations {
   bool VerifyEach;
 
 public:
+  LLVM_ABI
   StandardInstrumentations(LLVMContext &Context, bool DebugLogging,
                            bool VerifyEach = false,
                            PrintPassOptions PrintPassOpts = PrintPassOptions());
 
   // Register all the standard instrumentation callbacks. If \p FAM is nullptr
   // then PreservedCFGChecker is not enabled.
-  void registerCallbacks(PassInstrumentationCallbacks &PIC,
-                         ModuleAnalysisManager *MAM = nullptr);
+  LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC,
+                                  ModuleAnalysisManager *MAM = nullptr);
 
   TimePassesHandler &getTimePasses() { return TimePasses; }
 };
 
-extern template class ChangeReporter<std::string>;
-extern template class TextChangeReporter<std::string>;
-
 extern template class BlockDataT<EmptyData>;
 extern template class FuncDataT<EmptyData>;
 extern template class IRDataT<EmptyData>;
-extern template class ChangeReporter<IRDataT<EmptyData>>;
-extern template class TextChangeReporter<IRDataT<EmptyData>>;
----------------
andrurogerz wrote:

> Were these templates unused. Why they disappeared?

`ChangeReporter` and `TextChangeReporter` templates have methods defined outside the header in StandardInstrumentation.cpp. MSVC doesn't let you `extern` declare a template with `__declspec(dllexport)` if it isn't fully defined. So I had to remove these declarations and instead annotate the template class itself with `LLVM_ABI`. I don't believe it alters the behavior of the build on Linux since the explicit instantiations are still present in the implementation file.

https://github.com/llvm/llvm-project/pull/143794


More information about the llvm-commits mailing list