From d743892ecf539b9419c157b50d2dba5fa7f065fd Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Mon, 4 Aug 2025 09:24:05 -0700 Subject: [PATCH 1/3] annotation new LLVM symbols for export --- llvm/include/llvm/Analysis/DXILResource.h | 2 +- llvm/include/llvm/CodeGen/MachineFunction.h | 2 +- llvm/include/llvm/Frontend/HLSL/HLSLBinding.h | 5 +++-- llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h | 7 ++++--- llvm/include/llvm/Frontend/Offloading/PropertySet.h | 5 +++-- llvm/include/llvm/IR/IRBuilder.h | 2 +- llvm/include/llvm/Object/DXContainer.h | 2 +- llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h | 2 +- llvm/include/llvm/Transforms/Utils/SplitModuleByCategory.h | 3 ++- 9 files changed, 17 insertions(+), 13 deletions(-) diff --git a/llvm/include/llvm/Analysis/DXILResource.h b/llvm/include/llvm/Analysis/DXILResource.h index 93c6bfb057ef5..fbfde79b2309c 100644 --- a/llvm/include/llvm/Analysis/DXILResource.h +++ b/llvm/include/llvm/Analysis/DXILResource.h @@ -649,7 +649,7 @@ class DXILResourceBindingInfo { bool hasOverlappingBinding() const { return HasOverlappingBinding; } void setHasOverlappingBinding(bool Value) { HasOverlappingBinding = Value; } - LLVM_ABI std::optional + std::optional 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..ebad727ea7203 100644 --- a/llvm/include/llvm/Frontend/HLSL/HLSLBinding.h +++ b/llvm/include/llvm/Frontend/HLSL/HLSLBinding.h @@ -13,6 +13,7 @@ #ifndef LLVM_FRONTEND_HLSL_HLSLBINDING_H #define LLVM_FRONTEND_HLSL_HLSLBINDING_H +#include "llvm/Support/Compiler.h" #include "llvm/ADT/STLFunctionalExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/DXILABI.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 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..520dbea786333 100644 --- a/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h +++ b/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h @@ -14,6 +14,7 @@ #ifndef LLVM_FRONTEND_HLSL_ROOTSIGNATUREMETADATA_H #define LLVM_FRONTEND_HLSL_ROOTSIGNATUREMETADATA_H +#include "llvm/Support/Compiler.h" #include "llvm/ADT/StringRef.h" #include "llvm/Frontend/HLSL/HLSLRootSignature.h" #include "llvm/IR/Constants.h" @@ -49,7 +50,7 @@ class RootSignatureValidationError class GenericRSMetadataError : public ErrorInfo { public: - static char ID; + LLVM_ABI static char ID; StringRef Message; MDNode *MD; @@ -71,7 +72,7 @@ class GenericRSMetadataError : public ErrorInfo { class InvalidRSMetadataFormat : public ErrorInfo { public: - static char ID; + LLVM_ABI static char ID; StringRef ElementName; InvalidRSMetadataFormat(StringRef ElementName) : ElementName(ElementName) {} @@ -87,7 +88,7 @@ class InvalidRSMetadataFormat : public ErrorInfo { class InvalidRSMetadataValue : public ErrorInfo { 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..f3a85bf290eb2 100644 --- a/llvm/include/llvm/Frontend/Offloading/PropertySet.h +++ b/llvm/include/llvm/Frontend/Offloading/PropertySet.h @@ -9,6 +9,7 @@ /// provides helper functions to translate PropertySetRegistry from/to JSON. //===----------------------------------------------------------------------===// +#include "llvm/Support/Compiler.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Error.h" @@ -26,8 +27,8 @@ using PropertyValue = std::variant; using PropertySet = std::map; using PropertySetRegistry = std::map; -void writePropertiesToJSON(const PropertySetRegistry &P, raw_ostream &O); -Expected readPropertiesFromJSON(MemoryBufferRef Buf); +LLVM_ABI void writePropertiesToJSON(const PropertySetRegistry &P, raw_ostream &O); +LLVM_ABI Expected 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..4fd456ea1afaf 100644 --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -2614,7 +2614,7 @@ class IRBuilderBase { return CreateShuffleVector(V, PoisonValue::get(V->getType()), Mask, Name); } - Value *CreateVectorInterleave(ArrayRef Ops, const Twine &Name = ""); + LLVM_ABI Value *CreateVectorInterleave(ArrayRef Ops, const Twine &Name = ""); Value *CreateExtractValue(Value *Agg, ArrayRef 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 { 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..06a7ae0490a3c 100644 --- a/llvm/include/llvm/Transforms/Utils/SplitModuleByCategory.h +++ b/llvm/include/llvm/Transforms/Utils/SplitModuleByCategory.h @@ -11,6 +11,7 @@ #ifndef LLVM_TRANSFORM_UTILS_SPLIT_MODULE_BY_CATEGORY_H #define LLVM_TRANSFORM_UTILS_SPLIT_MODULE_BY_CATEGORY_H +#include "llvm/Support/Compiler.h" #include "llvm/ADT/STLFunctionalExtras.h" #include @@ -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 M, function_ref(const Function &F)> EntryPointCategorizer, function_ref Part)> Callback); From 5b4e00c0008c837dbfb17e2783a441485c326e59 Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Mon, 4 Aug 2025 09:24:30 -0700 Subject: [PATCH 2/3] annotate private symbols for export for unit tests --- llvm/lib/Transforms/Vectorize/VPlan.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h index 8dfb982a7d2f9..531523a2a0388 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,7 +1293,7 @@ class VPIRInstruction : public VPRecipeBase { void execute(VPTransformState &State) override; /// Return the cost of this VPIRInstruction. - InstructionCost computeCost(ElementCount VF, + LLVM_ABI_FOR_TEST InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override; Instruction &getInstruction() const { return I; } @@ -1332,7 +1332,7 @@ 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) { From ac3ef66b0175f00f03963d47a06a9f426d1633bf Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Tue, 5 Aug 2025 09:39:40 -0700 Subject: [PATCH 3/3] clang-format --- llvm/include/llvm/Analysis/DXILResource.h | 4 ++-- llvm/include/llvm/Frontend/HLSL/HLSLBinding.h | 2 +- llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h | 2 +- llvm/include/llvm/Frontend/Offloading/PropertySet.h | 8 +++++--- llvm/include/llvm/IR/IRBuilder.h | 3 ++- .../include/llvm/Transforms/Utils/SplitModuleByCategory.h | 2 +- llvm/lib/Transforms/Vectorize/VPlan.h | 7 ++++--- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/llvm/include/llvm/Analysis/DXILResource.h b/llvm/include/llvm/Analysis/DXILResource.h index fbfde79b2309c..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; } - std::optional - findAvailableBinding(dxil::ResourceClass RC, uint32_t Space, int32_t Size) { + std::optional findAvailableBinding(dxil::ResourceClass RC, + uint32_t Space, int32_t Size) { return Bindings.findAvailableBinding(RC, Space, Size); } diff --git a/llvm/include/llvm/Frontend/HLSL/HLSLBinding.h b/llvm/include/llvm/Frontend/HLSL/HLSLBinding.h index ebad727ea7203..f4f46b35cf83d 100644 --- a/llvm/include/llvm/Frontend/HLSL/HLSLBinding.h +++ b/llvm/include/llvm/Frontend/HLSL/HLSLBinding.h @@ -13,9 +13,9 @@ #ifndef LLVM_FRONTEND_HLSL_HLSLBINDING_H #define LLVM_FRONTEND_HLSL_HLSLBINDING_H -#include "llvm/Support/Compiler.h" #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" diff --git a/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h b/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h index 520dbea786333..c6d7c32c4ad95 100644 --- a/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h +++ b/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h @@ -14,11 +14,11 @@ #ifndef LLVM_FRONTEND_HLSL_ROOTSIGNATUREMETADATA_H #define LLVM_FRONTEND_HLSL_ROOTSIGNATUREMETADATA_H -#include "llvm/Support/Compiler.h" #include "llvm/ADT/StringRef.h" #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; diff --git a/llvm/include/llvm/Frontend/Offloading/PropertySet.h b/llvm/include/llvm/Frontend/Offloading/PropertySet.h index f3a85bf290eb2..fbc1cf0f09211 100644 --- a/llvm/include/llvm/Frontend/Offloading/PropertySet.h +++ b/llvm/include/llvm/Frontend/Offloading/PropertySet.h @@ -9,8 +9,8 @@ /// provides helper functions to translate PropertySetRegistry from/to JSON. //===----------------------------------------------------------------------===// -#include "llvm/Support/Compiler.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include @@ -27,8 +27,10 @@ using PropertyValue = std::variant; using PropertySet = std::map; using PropertySetRegistry = std::map; -LLVM_ABI void writePropertiesToJSON(const PropertySetRegistry &P, raw_ostream &O); -LLVM_ABI Expected readPropertiesFromJSON(MemoryBufferRef Buf); +LLVM_ABI void writePropertiesToJSON(const PropertySetRegistry &P, + raw_ostream &O); +LLVM_ABI Expected +readPropertiesFromJSON(MemoryBufferRef Buf); } // namespace offloading } // namespace llvm diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h index 4fd456ea1afaf..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); } - LLVM_ABI Value *CreateVectorInterleave(ArrayRef Ops, const Twine &Name = ""); + LLVM_ABI Value *CreateVectorInterleave(ArrayRef Ops, + const Twine &Name = ""); Value *CreateExtractValue(Value *Agg, ArrayRef Idxs, const Twine &Name = "") { diff --git a/llvm/include/llvm/Transforms/Utils/SplitModuleByCategory.h b/llvm/include/llvm/Transforms/Utils/SplitModuleByCategory.h index 06a7ae0490a3c..cfcd1611e27fe 100644 --- a/llvm/include/llvm/Transforms/Utils/SplitModuleByCategory.h +++ b/llvm/include/llvm/Transforms/Utils/SplitModuleByCategory.h @@ -11,8 +11,8 @@ #ifndef LLVM_TRANSFORM_UTILS_SPLIT_MODULE_BY_CATEGORY_H #define LLVM_TRANSFORM_UTILS_SPLIT_MODULE_BY_CATEGORY_H -#include "llvm/Support/Compiler.h" #include "llvm/ADT/STLFunctionalExtras.h" +#include "llvm/Support/Compiler.h" #include #include diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h index 531523a2a0388..46dd11425aa2c 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.h +++ b/llvm/lib/Transforms/Vectorize/VPlan.h @@ -1293,8 +1293,8 @@ class VPIRInstruction : public VPRecipeBase { void execute(VPTransformState &State) override; /// Return the cost of this VPIRInstruction. - LLVM_ABI_FOR_TEST 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 LLVM_ABI_FOR_TEST 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) {