Skip to content

Conversation

@Steelskin
Copy link
Contributor

This patch updates various LLVM headers to properly add the LLVM_ABI and LLVM_ABI_FOR_TEST annotations to build LLVM as a DLL on Windows.

This effort is tracked in #109483.

@Steelskin Steelskin requested a review from fhahn December 10, 2025 14:48
@llvmbot llvmbot added debuginfo llvm:support llvm:analysis Includes value tracking, cost tables and constant folding llvm:transforms llvm:SandboxIR labels Dec 10, 2025
@llvmbot
Copy link
Member

llvmbot commented Dec 10, 2025

@llvm/pr-subscribers-debuginfo

@llvm/pr-subscribers-llvm-support

Author: Fabrice de Gans (Steelskin)

Changes

This patch updates various LLVM headers to properly add the LLVM_ABI and LLVM_ABI_FOR_TEST annotations to build LLVM as a DLL on Windows.

This effort is tracked in #109483.


Full diff: https://github.com/llvm/llvm-project/pull/171629.diff

5 Files Affected:

  • (modified) llvm/include/llvm/Analysis/RuntimeLibcallInfo.h (+4-3)
  • (modified) llvm/include/llvm/CodeGen/LibcallLoweringInfo.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/Constant.h (+1-1)
  • (modified) llvm/include/llvm/Support/Hash.h (+3-2)
  • (modified) llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h (+2-1)
diff --git a/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h b/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h
index 609568ebc21a8..da17e4bdc749a 100644
--- a/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h
+++ b/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h
@@ -22,18 +22,19 @@ class LLVM_ABI RuntimeLibraryAnalysis
   RuntimeLibraryAnalysis() = default;
   RuntimeLibraryAnalysis(RTLIB::RuntimeLibcallsInfo &&BaselineInfoImpl)
       : LibcallsInfo(std::move(BaselineInfoImpl)) {}
-  RuntimeLibraryAnalysis(
+  LLVM_ABI RuntimeLibraryAnalysis(
       const Triple &TT,
       ExceptionHandling ExceptionModel = ExceptionHandling::None,
       FloatABI::ABIType FloatABI = FloatABI::Default,
       EABI EABIVersion = EABI::Default, StringRef ABIName = "",
       VectorLibrary VecLib = VectorLibrary::NoLibrary);
 
-  RTLIB::RuntimeLibcallsInfo run(const Module &M, ModuleAnalysisManager &);
+  LLVM_ABI RTLIB::RuntimeLibcallsInfo run(const Module &M,
+                                          ModuleAnalysisManager &);
 
 private:
   friend AnalysisInfoMixin<RuntimeLibraryAnalysis>;
-  static AnalysisKey Key;
+  LLVM_ABI static AnalysisKey Key;
 
   std::optional<RTLIB::RuntimeLibcallsInfo> LibcallsInfo;
 };
diff --git a/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h b/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h
index 3e0137710e8eb..13225c072cf78 100644
--- a/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h
+++ b/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h
@@ -110,7 +110,7 @@ class LibcallLoweringModuleAnalysis
     : public AnalysisInfoMixin<LibcallLoweringModuleAnalysis> {
 private:
   friend AnalysisInfoMixin<LibcallLoweringModuleAnalysis>;
-  static AnalysisKey Key;
+  LLVM_ABI static AnalysisKey Key;
 
   LibcallLoweringModuleAnalysisResult LibcallLoweringMap;
 
diff --git a/llvm/include/llvm/SandboxIR/Constant.h b/llvm/include/llvm/SandboxIR/Constant.h
index 2fe923f6c3866..c9ceba2dabed3 100644
--- a/llvm/include/llvm/SandboxIR/Constant.h
+++ b/llvm/include/llvm/SandboxIR/Constant.h
@@ -1379,7 +1379,7 @@ class ConstantPtrAuth final : public Constant {
   /// the only global-initializer user of the ptrauth signed pointer.
   LLVM_ABI Constant *getAddrDiscriminator() const;
 
-  Constant *getDeactivationSymbol() const;
+  LLVM_ABI_FOR_TEST Constant *getDeactivationSymbol() const;
 
   /// Whether there is any non-null address discriminator.
   bool hasAddressDiscriminator() const {
diff --git a/llvm/include/llvm/Support/Hash.h b/llvm/include/llvm/Support/Hash.h
index bf98f0dcef836..f30a2597a9b30 100644
--- a/llvm/include/llvm/Support/Hash.h
+++ b/llvm/include/llvm/Support/Hash.h
@@ -25,11 +25,12 @@ enum class KCFIHashAlgorithm { xxHash64, FNV1a };
 KCFIHashAlgorithm parseKCFIHashAlgorithm(StringRef Name);
 
 /// Convert a KCFI hash algorithm enum to its string representation.
-StringRef stringifyKCFIHashAlgorithm(KCFIHashAlgorithm Algorithm);
+LLVM_ABI StringRef stringifyKCFIHashAlgorithm(KCFIHashAlgorithm Algorithm);
 
 /// Compute KCFI type ID from mangled type name.
 /// The algorithm can be xxHash64 or FNV-1a.
-uint32_t getKCFITypeID(StringRef MangledTypeName, KCFIHashAlgorithm Algorithm);
+LLVM_ABI uint32_t getKCFITypeID(StringRef MangledTypeName,
+                                KCFIHashAlgorithm Algorithm);
 
 } // end namespace llvm
 
diff --git a/llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h b/llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h
index 2d25ce3245793..3d88df91c2da5 100644
--- a/llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h
+++ b/llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h
@@ -29,6 +29,7 @@
 #include "llvm/IR/Instruction.h"
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/IR/ValueMap.h"
+#include "llvm/Support/Compiler.h"
 #include <cstdint>
 
 namespace llvm {
@@ -342,7 +343,7 @@ class DbgValueRangeTable {
   DenseMap<DebugVariableAggregate, DbgValueDef> OrigSingleLocVariableValueTable;
 
 public:
-  void addVariable(Function *F, DebugVariableAggregate DVA);
+  LLVM_ABI_FOR_TEST void addVariable(Function *F, DebugVariableAggregate DVA);
   bool hasVariableEntry(DebugVariableAggregate DVA) const {
     return OrigVariableValueRangeTable.contains(DVA) ||
            OrigSingleLocVariableValueTable.contains(DVA);

@llvmbot
Copy link
Member

llvmbot commented Dec 10, 2025

@llvm/pr-subscribers-llvm-analysis

Author: Fabrice de Gans (Steelskin)

Changes

This patch updates various LLVM headers to properly add the LLVM_ABI and LLVM_ABI_FOR_TEST annotations to build LLVM as a DLL on Windows.

This effort is tracked in #109483.


Full diff: https://github.com/llvm/llvm-project/pull/171629.diff

5 Files Affected:

  • (modified) llvm/include/llvm/Analysis/RuntimeLibcallInfo.h (+4-3)
  • (modified) llvm/include/llvm/CodeGen/LibcallLoweringInfo.h (+1-1)
  • (modified) llvm/include/llvm/SandboxIR/Constant.h (+1-1)
  • (modified) llvm/include/llvm/Support/Hash.h (+3-2)
  • (modified) llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h (+2-1)
diff --git a/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h b/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h
index 609568ebc21a8..da17e4bdc749a 100644
--- a/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h
+++ b/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h
@@ -22,18 +22,19 @@ class LLVM_ABI RuntimeLibraryAnalysis
   RuntimeLibraryAnalysis() = default;
   RuntimeLibraryAnalysis(RTLIB::RuntimeLibcallsInfo &&BaselineInfoImpl)
       : LibcallsInfo(std::move(BaselineInfoImpl)) {}
-  RuntimeLibraryAnalysis(
+  LLVM_ABI RuntimeLibraryAnalysis(
       const Triple &TT,
       ExceptionHandling ExceptionModel = ExceptionHandling::None,
       FloatABI::ABIType FloatABI = FloatABI::Default,
       EABI EABIVersion = EABI::Default, StringRef ABIName = "",
       VectorLibrary VecLib = VectorLibrary::NoLibrary);
 
-  RTLIB::RuntimeLibcallsInfo run(const Module &M, ModuleAnalysisManager &);
+  LLVM_ABI RTLIB::RuntimeLibcallsInfo run(const Module &M,
+                                          ModuleAnalysisManager &);
 
 private:
   friend AnalysisInfoMixin<RuntimeLibraryAnalysis>;
-  static AnalysisKey Key;
+  LLVM_ABI static AnalysisKey Key;
 
   std::optional<RTLIB::RuntimeLibcallsInfo> LibcallsInfo;
 };
diff --git a/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h b/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h
index 3e0137710e8eb..13225c072cf78 100644
--- a/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h
+++ b/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h
@@ -110,7 +110,7 @@ class LibcallLoweringModuleAnalysis
     : public AnalysisInfoMixin<LibcallLoweringModuleAnalysis> {
 private:
   friend AnalysisInfoMixin<LibcallLoweringModuleAnalysis>;
-  static AnalysisKey Key;
+  LLVM_ABI static AnalysisKey Key;
 
   LibcallLoweringModuleAnalysisResult LibcallLoweringMap;
 
diff --git a/llvm/include/llvm/SandboxIR/Constant.h b/llvm/include/llvm/SandboxIR/Constant.h
index 2fe923f6c3866..c9ceba2dabed3 100644
--- a/llvm/include/llvm/SandboxIR/Constant.h
+++ b/llvm/include/llvm/SandboxIR/Constant.h
@@ -1379,7 +1379,7 @@ class ConstantPtrAuth final : public Constant {
   /// the only global-initializer user of the ptrauth signed pointer.
   LLVM_ABI Constant *getAddrDiscriminator() const;
 
-  Constant *getDeactivationSymbol() const;
+  LLVM_ABI_FOR_TEST Constant *getDeactivationSymbol() const;
 
   /// Whether there is any non-null address discriminator.
   bool hasAddressDiscriminator() const {
diff --git a/llvm/include/llvm/Support/Hash.h b/llvm/include/llvm/Support/Hash.h
index bf98f0dcef836..f30a2597a9b30 100644
--- a/llvm/include/llvm/Support/Hash.h
+++ b/llvm/include/llvm/Support/Hash.h
@@ -25,11 +25,12 @@ enum class KCFIHashAlgorithm { xxHash64, FNV1a };
 KCFIHashAlgorithm parseKCFIHashAlgorithm(StringRef Name);
 
 /// Convert a KCFI hash algorithm enum to its string representation.
-StringRef stringifyKCFIHashAlgorithm(KCFIHashAlgorithm Algorithm);
+LLVM_ABI StringRef stringifyKCFIHashAlgorithm(KCFIHashAlgorithm Algorithm);
 
 /// Compute KCFI type ID from mangled type name.
 /// The algorithm can be xxHash64 or FNV-1a.
-uint32_t getKCFITypeID(StringRef MangledTypeName, KCFIHashAlgorithm Algorithm);
+LLVM_ABI uint32_t getKCFITypeID(StringRef MangledTypeName,
+                                KCFIHashAlgorithm Algorithm);
 
 } // end namespace llvm
 
diff --git a/llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h b/llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h
index 2d25ce3245793..3d88df91c2da5 100644
--- a/llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h
+++ b/llvm/include/llvm/Transforms/Utils/DebugSSAUpdater.h
@@ -29,6 +29,7 @@
 #include "llvm/IR/Instruction.h"
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/IR/ValueMap.h"
+#include "llvm/Support/Compiler.h"
 #include <cstdint>
 
 namespace llvm {
@@ -342,7 +343,7 @@ class DbgValueRangeTable {
   DenseMap<DebugVariableAggregate, DbgValueDef> OrigSingleLocVariableValueTable;
 
 public:
-  void addVariable(Function *F, DebugVariableAggregate DVA);
+  LLVM_ABI_FOR_TEST void addVariable(Function *F, DebugVariableAggregate DVA);
   bool hasVariableEntry(DebugVariableAggregate DVA) const {
     return OrigVariableValueRangeTable.contains(DVA) ||
            OrigSingleLocVariableValueTable.contains(DVA);

@Steelskin Steelskin force-pushed the fabrice/upstream-llvm-abi-annotations-4 branch from 7c29522 to 1543c41 Compare December 11, 2025 14:19
@Steelskin Steelskin requested a review from nikic December 11, 2025 14:20
This patch updates various LLVM headers to properly add the `LLVM_ABI`
and `LLVM_ABI_FOR_TEST` annotations to build LLVM as a DLL on Windows.

This effort is tracked in llvm#109483.
@Steelskin Steelskin force-pushed the fabrice/upstream-llvm-abi-annotations-4 branch from 1543c41 to e98834c Compare December 11, 2025 15:12
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Co-authored-by: Nikita Popov <github@npopov.com>
@Steelskin Steelskin enabled auto-merge (squash) December 11, 2025 17:59
@Steelskin Steelskin merged commit 3a6c8c4 into llvm:main Dec 11, 2025
7 of 9 checks passed
@Steelskin Steelskin deleted the fabrice/upstream-llvm-abi-annotations-4 branch December 15, 2025 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

debuginfo llvm:analysis Includes value tracking, cost tables and constant folding llvm:SandboxIR llvm:support llvm:transforms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants