[llvm] [llvm] annotate recently added interfaces for DLL export (PR #152179)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 5 11:33:42 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Andrew Rogers (andrurogerz)

<details>
<summary>Changes</summary>

## Purpose
This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates symbols that were recently added to LLVM and fixes incorrectly annotated symbols.

## Background
This effort is tracked in #<!-- -->109483. Additional context is provided in [this discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307), and documentation for `LLVM_ABI` and related annotations is found in the LLVM repo [here](https://github.com/llvm/llvm-project/blob/main/llvm/docs/InterfaceExportAnnotations.rst).  

## Overview

The bulk of these changes were generated automatically using the [Interface Definition Scanner (IDS)](https://github.com/compnerd/ids) tool, followed formatting with `git clang-format`.

The following manual adjustments were also applied after running IDS:
- Add `LLVM_EXPORT_TEMPLATE` and `LLVM_TEMPLATE_ABI` annotations to explicitly instantiated instances of `llvm::object::SFrameParser`.

## Validation

On Windows 11:
```
cmake -B build -S llvm -G Ninja -DLLVM_ENABLE_PROJECTS="llvm;clang;clang-tools-extra;lldb;lld" -DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_BUILD_LLVM_DYLIB_VIS=ON -DLLVM_LINK_LLVM_DYLIB=ON -DLLVM_BUILD_TESTS=ON -DCLANG_LINK_CLANG_DYLIB=OFF -DCMAKE_BUILD_TYPE=Release
ninja -C build
```

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


10 Files Affected:

- (modified) llvm/include/llvm/Analysis/DXILResource.h (+2-2) 
- (modified) llvm/include/llvm/CodeGen/MachineFunction.h (+1-1) 
- (modified) llvm/include/llvm/Frontend/HLSL/HLSLBinding.h (+3-2) 
- (modified) llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h (+4-3) 
- (modified) llvm/include/llvm/Frontend/Offloading/PropertySet.h (+5-2) 
- (modified) llvm/include/llvm/IR/IRBuilder.h (+2-1) 
- (modified) llvm/include/llvm/Object/DXContainer.h (+1-1) 
- (modified) llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h (+1-1) 
- (modified) llvm/include/llvm/Transforms/Utils/SplitModuleByCategory.h (+2-1) 
- (modified) llvm/lib/Transforms/Vectorize/VPlan.h (+5-4) 


``````````diff
diff --git a/llvm/include/llvm/Analysis/DXILResource.h b/llvm/include/llvm/Analysis/DXILResource.h
index 93c6bfb057ef5..9d07bc0013ca7 100644
--- a/llvm/include/llvm/Analysis/DXILResource.h
+++ b/llvm/include/llvm/Analysis/DXILResource.h
@@ -649,8 +649,8 @@ class DXILResourceBindingInfo {
   bool hasOverlappingBinding() const { return HasOverlappingBinding; }
   void setHasOverlappingBinding(bool Value) { HasOverlappingBinding = Value; }
 
-  LLVM_ABI std::optional<uint32_t>
-  findAvailableBinding(dxil::ResourceClass RC, uint32_t Space, int32_t Size) {
+  std::optional<uint32_t> findAvailableBinding(dxil::ResourceClass RC,
+                                               uint32_t Space, int32_t Size) {
     return Bindings.findAvailableBinding(RC, Space, Size);
   }
 
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index 06c4daf245fa0..69b7a3f570c89 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -523,7 +523,7 @@ class LLVM_ABI MachineFunction {
     /// Extracts the numeric type id from the CallBase's callee_type Metadata,
     /// and sets CalleeTypeIds. This is used as type id for the indirect call in
     /// the call graph section.
-    CallSiteInfo(const CallBase &CB);
+    LLVM_ABI CallSiteInfo(const CallBase &CB);
   };
 
   struct CalledGlobalInfo {
diff --git a/llvm/include/llvm/Frontend/HLSL/HLSLBinding.h b/llvm/include/llvm/Frontend/HLSL/HLSLBinding.h
index 70a2eeb632f1b..f4f46b35cf83d 100644
--- a/llvm/include/llvm/Frontend/HLSL/HLSLBinding.h
+++ b/llvm/include/llvm/Frontend/HLSL/HLSLBinding.h
@@ -15,6 +15,7 @@
 
 #include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/DXILABI.h"
 #include "llvm/Support/ErrorHandling.h"
 
@@ -138,7 +139,7 @@ class BindingInfoBuilder {
   }
   /// Calculate the binding info - \c ReportOverlap will be called once for each
   /// overlapping binding.
-  BindingInfo calculateBindingInfo(
+  LLVM_ABI BindingInfo calculateBindingInfo(
       llvm::function_ref<void(const BindingInfoBuilder &Builder,
                               const Binding &Overlapping)>
           ReportOverlap);
@@ -153,7 +154,7 @@ class BindingInfoBuilder {
 
   /// For use in the \c ReportOverlap callback of \c calculateBindingInfo -
   /// finds a binding that the \c ReportedBinding overlaps with.
-  const Binding &findOverlapping(const Binding &ReportedBinding) const;
+  LLVM_ABI const Binding &findOverlapping(const Binding &ReportedBinding) const;
 };
 
 } // namespace hlsl
diff --git a/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h b/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h
index 0bd0774641287..c6d7c32c4ad95 100644
--- a/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h
+++ b/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h
@@ -18,6 +18,7 @@
 #include "llvm/Frontend/HLSL/HLSLRootSignature.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/MC/DXContainerRootSignature.h"
+#include "llvm/Support/Compiler.h"
 
 namespace llvm {
 class LLVMContext;
@@ -49,7 +50,7 @@ class RootSignatureValidationError
 
 class GenericRSMetadataError : public ErrorInfo<GenericRSMetadataError> {
 public:
-  static char ID;
+  LLVM_ABI static char ID;
   StringRef Message;
   MDNode *MD;
 
@@ -71,7 +72,7 @@ class GenericRSMetadataError : public ErrorInfo<GenericRSMetadataError> {
 
 class InvalidRSMetadataFormat : public ErrorInfo<InvalidRSMetadataFormat> {
 public:
-  static char ID;
+  LLVM_ABI static char ID;
   StringRef ElementName;
 
   InvalidRSMetadataFormat(StringRef ElementName) : ElementName(ElementName) {}
@@ -87,7 +88,7 @@ class InvalidRSMetadataFormat : public ErrorInfo<InvalidRSMetadataFormat> {
 
 class InvalidRSMetadataValue : public ErrorInfo<InvalidRSMetadataValue> {
 public:
-  static char ID;
+  LLVM_ABI static char ID;
   StringRef ParamName;
 
   InvalidRSMetadataValue(StringRef ParamName) : ParamName(ParamName) {}
diff --git a/llvm/include/llvm/Frontend/Offloading/PropertySet.h b/llvm/include/llvm/Frontend/Offloading/PropertySet.h
index d198d3e603264..fbc1cf0f09211 100644
--- a/llvm/include/llvm/Frontend/Offloading/PropertySet.h
+++ b/llvm/include/llvm/Frontend/Offloading/PropertySet.h
@@ -10,6 +10,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 
 #include <map>
@@ -26,8 +27,10 @@ using PropertyValue = std::variant<uint32_t, ByteArray>;
 using PropertySet = std::map<std::string, PropertyValue>;
 using PropertySetRegistry = std::map<std::string, PropertySet>;
 
-void writePropertiesToJSON(const PropertySetRegistry &P, raw_ostream &O);
-Expected<PropertySetRegistry> readPropertiesFromJSON(MemoryBufferRef Buf);
+LLVM_ABI void writePropertiesToJSON(const PropertySetRegistry &P,
+                                    raw_ostream &O);
+LLVM_ABI Expected<PropertySetRegistry>
+readPropertiesFromJSON(MemoryBufferRef Buf);
 
 } // namespace offloading
 } // namespace llvm
diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index 6d3d864b46559..d106dedf814e5 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -2614,7 +2614,8 @@ class IRBuilderBase {
     return CreateShuffleVector(V, PoisonValue::get(V->getType()), Mask, Name);
   }
 
-  Value *CreateVectorInterleave(ArrayRef<Value *> Ops, const Twine &Name = "");
+  LLVM_ABI Value *CreateVectorInterleave(ArrayRef<Value *> Ops,
+                                         const Twine &Name = "");
 
   Value *CreateExtractValue(Value *Agg, ArrayRef<unsigned> Idxs,
                             const Twine &Name = "") {
diff --git a/llvm/include/llvm/Object/DXContainer.h b/llvm/include/llvm/Object/DXContainer.h
index 3c8cd174afede..ad1b2361ff064 100644
--- a/llvm/include/llvm/Object/DXContainer.h
+++ b/llvm/include/llvm/Object/DXContainer.h
@@ -586,7 +586,7 @@ class DXContainer {
   }
 };
 
-class DXContainerObjectFile : public ObjectFile {
+class LLVM_ABI DXContainerObjectFile : public ObjectFile {
 private:
   friend class ObjectFile;
   DXContainer Container;
diff --git a/llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h b/llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h
index a9a370b27988a..b6b753c6f5cfe 100644
--- a/llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h
+++ b/llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h
@@ -43,7 +43,7 @@ class HipStdParAllocationInterpositionPass
 
 class HipStdParMathFixupPass : public PassInfoMixin<HipStdParMathFixupPass> {
 public:
-  PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
+  LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 
   static bool isRequired() { return true; }
 };
diff --git a/llvm/include/llvm/Transforms/Utils/SplitModuleByCategory.h b/llvm/include/llvm/Transforms/Utils/SplitModuleByCategory.h
index b32cfaf7859ab..cfcd1611e27fe 100644
--- a/llvm/include/llvm/Transforms/Utils/SplitModuleByCategory.h
+++ b/llvm/include/llvm/Transforms/Utils/SplitModuleByCategory.h
@@ -12,6 +12,7 @@
 #define LLVM_TRANSFORM_UTILS_SPLIT_MODULE_BY_CATEGORY_H
 
 #include "llvm/ADT/STLFunctionalExtras.h"
+#include "llvm/Support/Compiler.h"
 
 #include <memory>
 #include <optional>
@@ -54,7 +55,7 @@ class Function;
 ///
 /// FIXME: For now, the algorithm assumes no recursion in the input Module. This
 /// will be addressed in the near future.
-void splitModuleTransitiveFromEntryPoints(
+LLVM_ABI void splitModuleTransitiveFromEntryPoints(
     std::unique_ptr<Module> M,
     function_ref<std::optional<int>(const Function &F)> EntryPointCategorizer,
     function_ref<void(std::unique_ptr<Module> Part)> Callback);
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 8dfb982a7d2f9..46dd11425aa2c 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1279,7 +1279,7 @@ class VPIRInstruction : public VPRecipeBase {
 
   /// Create a new VPIRPhi for \p \I, if it is a PHINode, otherwise create a
   /// VPIRInstruction.
-  static VPIRInstruction *create(Instruction &I);
+  LLVM_ABI_FOR_TEST static VPIRInstruction *create(Instruction &I);
 
   VP_CLASSOF_IMPL(VPDef::VPIRInstructionSC)
 
@@ -1293,8 +1293,8 @@ class VPIRInstruction : public VPRecipeBase {
   void execute(VPTransformState &State) override;
 
   /// Return the cost of this VPIRInstruction.
-  InstructionCost computeCost(ElementCount VF,
-                              VPCostContext &Ctx) const override;
+  LLVM_ABI_FOR_TEST InstructionCost
+  computeCost(ElementCount VF, VPCostContext &Ctx) const override;
 
   Instruction &getInstruction() const { return I; }
 
@@ -1332,7 +1332,8 @@ class VPIRInstruction : public VPRecipeBase {
 /// cast/dyn_cast/isa and execute() implementation. A single VPValue operand is
 /// allowed, and it is used to add a new incoming value for the single
 /// predecessor VPBB.
-struct VPIRPhi : public VPIRInstruction, public VPPhiAccessors {
+struct LLVM_ABI_FOR_TEST VPIRPhi : public VPIRInstruction,
+                                   public VPPhiAccessors {
   VPIRPhi(PHINode &PN) : VPIRInstruction(PN) {}
 
   static inline bool classof(const VPRecipeBase *U) {

``````````

</details>


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


More information about the llvm-commits mailing list