[llvm] [llvm] annotate interfaces in llvm/Analysis for DLL export (PR #136623)

Andrew Rogers via llvm-commits llvm-commits at lists.llvm.org
Wed May 21 08:06:40 PDT 2025


================
@@ -956,7 +956,7 @@ class AAManager : public AnalysisInfoMixin<AAManager> {
 private:
   friend AnalysisInfoMixin<AAManager>;
 
-  static AnalysisKey Key;
+  LLVM_ABI static AnalysisKey Key;
----------------
andrurogerz wrote:

> Can we automate such changes in future?

I've thought about this case a bit since these private `AnalysisKey` fields show up a lot. The proper generic solution is to teach IDS to export private fields that are referenced in friend classes and functions, which is what's going on here. I suspect that's is achievable, but I haven't looked into it.

The simple, inelegant solution is to introduce an `--always-export=` argument to IDS to tell it to always export symbols of the specified type. We'd then always have to add `--always-export=llvm::AnalysisKey` whenever we run the tool on LLVM. This solution would catch the majority of cases but is more fragile and will miss new patterns in the future.

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


More information about the llvm-commits mailing list