[llvm] [llvm] annotate interfaces in llvm/IR for DLL export (PR #141650)
via llvm-commits
llvm-commits at lists.llvm.org
Wed May 28 11:30:35 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
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 the `llvm/IR`, `llvm/IRPrinter`, and `llvm/IRReader` libraries. These annotations currently have no meaningful impact on the LLVM build; however, they are a prerequisite to support an LLVM Windows DLL (shared library) build.
## 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).
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 on Linux:
- Add `#include "llvm/Support/Compiler.h"` to files where it was not auto-added by IDS due to no pre-existing block of include statements.
- Add `LLVM_ABI_FRIEND` to friend member functions declared with `LLVM_ABI`
- Add `LLVM_TEMPLATE_ABI` and `LLVM_EXPORT_TEMPLATE` to exported instantiated templates
- Add `LLVM_ABI` to a subset of private class methods and fields that require export
- Add `LLVM_ABI` to a small number of symbols that require export but are not declared in headers
- Reorder `LLVM_ABI` with `[[deprecated]]` and `[[nodiscard]]` attributes.
## Validation
Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations:
- Windows with MSVC
- Windows with Clang
- Linux with GCC
- Linux with Clang
- Darwin with Clang
---
Patch is 787.82 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/141650.diff
105 Files Affected:
- (modified) llvm/include/llvm/IR/AbstractCallSite.h (+5-3)
- (modified) llvm/include/llvm/IR/Analysis.h (+5-4)
- (modified) llvm/include/llvm/IR/Argument.h (+45-44)
- (modified) llvm/include/llvm/IR/AssemblyAnnotationWriter.h (+3-1)
- (modified) llvm/include/llvm/IR/Assumptions.h (+12-9)
- (modified) llvm/include/llvm/IR/Attributes.h (+283-268)
- (modified) llvm/include/llvm/IR/AutoUpgrade.h (+24-20)
- (modified) llvm/include/llvm/IR/BasicBlock.h (+87-78)
- (modified) llvm/include/llvm/IR/BuiltinGCs.h (+5-3)
- (modified) llvm/include/llvm/IR/CmpPredicate.h (+7-6)
- (modified) llvm/include/llvm/IR/Comdat.h (+5-4)
- (modified) llvm/include/llvm/IR/Constant.h (+40-38)
- (modified) llvm/include/llvm/IR/ConstantFPRange.h (+30-27)
- (modified) llvm/include/llvm/IR/ConstantFold.h (+30-23)
- (modified) llvm/include/llvm/IR/ConstantFolder.h (+2-1)
- (modified) llvm/include/llvm/IR/ConstantRange.h (+126-115)
- (modified) llvm/include/llvm/IR/ConstantRangeList.h (+8-7)
- (modified) llvm/include/llvm/IR/Constants.h (+165-158)
- (modified) llvm/include/llvm/IR/DIBuilder.h (+216-207)
- (modified) llvm/include/llvm/IR/DataLayout.h (+37-31)
- (modified) llvm/include/llvm/IR/DebugInfo.h (+52-47)
- (modified) llvm/include/llvm/IR/DebugInfoMetadata.h (+259-237)
- (modified) llvm/include/llvm/IR/DebugLoc.h (+19-18)
- (modified) llvm/include/llvm/IR/DebugProgramInstruction.h (+113-103)
- (modified) llvm/include/llvm/IR/DerivedTypes.h (+59-56)
- (modified) llvm/include/llvm/IR/DiagnosticHandler.h (+2-1)
- (modified) llvm/include/llvm/IR/DiagnosticInfo.h (+58-46)
- (modified) llvm/include/llvm/IR/DiagnosticPrinter.h (+2-1)
- (modified) llvm/include/llvm/IR/Dominators.h (+60-55)
- (modified) llvm/include/llvm/IR/DroppedVariableStats.h (+14-13)
- (modified) llvm/include/llvm/IR/DroppedVariableStatsIR.h (+2-1)
- (modified) llvm/include/llvm/IR/EHPersonalities.h (+6-5)
- (modified) llvm/include/llvm/IR/FMF.h (+3-1)
- (modified) llvm/include/llvm/IR/FPEnv.h (+8-5)
- (modified) llvm/include/llvm/IR/Function.h (+6-5)
- (modified) llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h (+7-5)
- (modified) llvm/include/llvm/IR/GlobalAlias.h (+17-16)
- (modified) llvm/include/llvm/IR/GlobalIFunc.h (+9-7)
- (modified) llvm/include/llvm/IR/GlobalObject.h (+15-14)
- (modified) llvm/include/llvm/IR/GlobalValue.h (+29-28)
- (modified) llvm/include/llvm/IR/GlobalVariable.h (+25-20)
- (modified) llvm/include/llvm/IR/IRBuilder.h (+177-154)
- (modified) llvm/include/llvm/IR/IRBuilderFolder.h (+2-1)
- (modified) llvm/include/llvm/IR/IRPrintingPasses.h (+8-7)
- (modified) llvm/include/llvm/IR/InlineAsm.h (+13-10)
- (modified) llvm/include/llvm/IR/InstrTypes.h (+144-135)
- (modified) llvm/include/llvm/IR/Instruction.h (+140-133)
- (modified) llvm/include/llvm/IR/Instructions.h (+282-243)
- (modified) llvm/include/llvm/IR/IntrinsicInst.h (+75-71)
- (modified) llvm/include/llvm/IR/Intrinsics.h (+35-26)
- (modified) llvm/include/llvm/IR/LLVMContext.h (+61-55)
- (modified) llvm/include/llvm/IR/LLVMRemarkStreamer.h (+10-10)
- (modified) llvm/include/llvm/IR/LegacyPassManager.h (+5-4)
- (modified) llvm/include/llvm/IR/LegacyPassManagers.h (+8-8)
- (modified) llvm/include/llvm/IR/LegacyPassNameParser.h (+3-2)
- (modified) llvm/include/llvm/IR/MDBuilder.h (+52-44)
- (modified) llvm/include/llvm/IR/Mangler.h (+20-14)
- (modified) llvm/include/llvm/IR/MemoryModelRelaxationAnnotations.h (+19-18)
- (modified) llvm/include/llvm/IR/Metadata.h (+105-99)
- (modified) llvm/include/llvm/IR/Module.h (+7-6)
- (modified) llvm/include/llvm/IR/ModuleSlotTracker.h (+3-2)
- (modified) llvm/include/llvm/IR/ModuleSummaryIndex.h (+24-20)
- (modified) llvm/include/llvm/IR/NoFolder.h (+2-1)
- (modified) llvm/include/llvm/IR/Operator.h (+14-12)
- (modified) llvm/include/llvm/IR/OptBisect.h (+3-2)
- (modified) llvm/include/llvm/IR/PassInstrumentation.h (+5-4)
- (modified) llvm/include/llvm/IR/PassManager.h (+17-14)
- (modified) llvm/include/llvm/IR/PassManagerImpl.h (+2-1)
- (modified) llvm/include/llvm/IR/PassTimingInfo.h (+8-7)
- (modified) llvm/include/llvm/IR/ProfDataUtils.h (+28-25)
- (modified) llvm/include/llvm/IR/ProfileSummary.h (+6-5)
- (modified) llvm/include/llvm/IR/PseudoProbe.h (+3-2)
- (modified) llvm/include/llvm/IR/ReplaceConstant.h (+5-4)
- (modified) llvm/include/llvm/IR/RuntimeLibcalls.h (+2-1)
- (modified) llvm/include/llvm/IR/StructuralHash.h (+7-5)
- (modified) llvm/include/llvm/IR/SymbolTableListTraits.h (+6-5)
- (modified) llvm/include/llvm/IR/Type.h (+60-58)
- (modified) llvm/include/llvm/IR/TypedPointerType.h (+4-2)
- (modified) llvm/include/llvm/IR/Use.h (+6-6)
- (modified) llvm/include/llvm/IR/User.h (+13-11)
- (modified) llvm/include/llvm/IR/VFABIDemangler.h (+12-9)
- (modified) llvm/include/llvm/IR/Value.h (+72-68)
- (modified) llvm/include/llvm/IR/ValueHandle.h (+7-6)
- (modified) llvm/include/llvm/IR/ValueSymbolTable.h (+6-5)
- (modified) llvm/include/llvm/IR/VectorBuilder.h (+10-9)
- (modified) llvm/include/llvm/IR/VectorTypeUtils.h (+5-4)
- (modified) llvm/include/llvm/IR/Verifier.h (+11-10)
- (modified) llvm/include/llvm/IRPrinter/IRPrintingPasses.h (+9-8)
- (modified) llvm/include/llvm/IRReader/IRReader.h (+13-10)
- (modified) llvm/lib/IR/BasicBlock.cpp (+4-3)
- (modified) llvm/lib/IR/DebugInfoMetadata.cpp (+2-1)
- (modified) llvm/lib/IR/DebugProgramInstruction.cpp (+5-4)
- (modified) llvm/lib/IR/Dominators.cpp (+27-14)
- (modified) llvm/lib/IR/Function.cpp (+2-2)
- (modified) llvm/lib/IR/IRPrintingPasses.cpp (+2-1)
- (modified) llvm/lib/IR/Instruction.cpp (+2-1)
- (modified) llvm/lib/IR/Instructions.cpp (+8-7)
- (modified) llvm/lib/IR/LegacyPassManager.cpp (+2-1)
- (modified) llvm/lib/IR/Module.cpp (+6-5)
- (modified) llvm/lib/IR/PassManager.cpp (+11-8)
- (modified) llvm/lib/IRPrinter/IRPrintingPasses.cpp (+2-1)
- (modified) llvm/unittests/IR/DebugInfoTest.cpp (+2-1)
- (modified) llvm/unittests/IR/InstructionsTest.cpp (+3-2)
- (modified) llvm/unittests/IR/MetadataTest.cpp (+2-1)
- (modified) llvm/unittests/IR/ValueTest.cpp (+2-1)
``````````diff
diff --git a/llvm/include/llvm/IR/AbstractCallSite.h b/llvm/include/llvm/IR/AbstractCallSite.h
index 50afe016f0d63..9e24ae7d1b431 100644
--- a/llvm/include/llvm/IR/AbstractCallSite.h
+++ b/llvm/include/llvm/IR/AbstractCallSite.h
@@ -18,6 +18,7 @@
#include "llvm/IR/Function.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Value.h"
+#include "llvm/Support/Compiler.h"
#include <cassert>
namespace llvm {
@@ -95,15 +96,16 @@ class AbstractCallSite {
/// If the use is not a callee use of a call or invoke instruction, the
/// callback metadata is used to determine the argument <-> parameter mapping
/// as well as the callee of the abstract call site.
- AbstractCallSite(const Use *U);
+ LLVM_ABI AbstractCallSite(const Use *U);
/// Add operand uses of \p CB that represent callback uses into
/// \p CallbackUses.
///
/// All uses added to \p CallbackUses can be used to create abstract call
/// sites for which AbstractCallSite::isCallbackCall() will return true.
- static void getCallbackUses(const CallBase &CB,
- SmallVectorImpl<const Use *> &CallbackUses);
+ LLVM_ABI static void
+ getCallbackUses(const CallBase &CB,
+ SmallVectorImpl<const Use *> &CallbackUses);
/// Conversion operator to conveniently check for a valid/initialized ACS.
explicit operator bool() const { return CB != nullptr; }
diff --git a/llvm/include/llvm/IR/Analysis.h b/llvm/include/llvm/IR/Analysis.h
index dd43f5ee5f706..8ab70dd9ed594 100644
--- a/llvm/include/llvm/IR/Analysis.h
+++ b/llvm/include/llvm/IR/Analysis.h
@@ -13,6 +13,7 @@
#define LLVM_IR_ANALYSIS_H
#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/Support/Compiler.h"
namespace llvm {
@@ -56,8 +57,8 @@ template <typename IRUnitT> class AllAnalysesOn {
template <typename IRUnitT> AnalysisSetKey AllAnalysesOn<IRUnitT>::SetKey;
-extern template class AllAnalysesOn<Module>;
-extern template class AllAnalysesOn<Function>;
+extern template class LLVM_TEMPLATE_ABI AllAnalysesOn<Module>;
+extern template class LLVM_TEMPLATE_ABI AllAnalysesOn<Function>;
/// Represents analyses that only rely on functions' control flow.
///
@@ -74,7 +75,7 @@ class CFGAnalyses {
static AnalysisSetKey *ID() { return &SetKey; }
private:
- static AnalysisSetKey SetKey;
+ LLVM_ABI static AnalysisSetKey SetKey;
};
/// A set of analyses that are preserved following a run of a transformation
@@ -310,7 +311,7 @@ class PreservedAnalyses {
private:
/// A special key used to indicate all analyses.
- static AnalysisSetKey AllAnalysesKey;
+ LLVM_ABI static AnalysisSetKey AllAnalysesKey;
/// The IDs of analyses and analysis sets that are preserved.
SmallPtrSet<void *, 2> PreservedIDs;
diff --git a/llvm/include/llvm/IR/Argument.h b/llvm/include/llvm/IR/Argument.h
index 5be58d7eca060..60854b17094bf 100644
--- a/llvm/include/llvm/IR/Argument.h
+++ b/llvm/include/llvm/IR/Argument.h
@@ -16,6 +16,7 @@
#include "llvm/ADT/Twine.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Value.h"
+#include "llvm/Support/Compiler.h"
#include <optional>
namespace llvm {
@@ -37,8 +38,8 @@ class Argument final : public Value {
public:
/// Argument constructor.
- explicit Argument(Type *Ty, const Twine &Name = "", Function *F = nullptr,
- unsigned ArgNo = 0);
+ LLVM_ABI explicit Argument(Type *Ty, const Twine &Name = "",
+ Function *F = nullptr, unsigned ArgNo = 0);
inline const Function *getParent() const { return Parent; }
inline Function *getParent() { return Parent; }
@@ -56,133 +57,133 @@ class Argument final : public Value {
/// addrspace(0).
/// If AllowUndefOrPoison is true, respect the semantics of nonnull attribute
/// and return true even if the argument can be undef or poison.
- bool hasNonNullAttr(bool AllowUndefOrPoison = true) const;
+ LLVM_ABI bool hasNonNullAttr(bool AllowUndefOrPoison = true) const;
/// If this argument has the dereferenceable attribute, return the number of
/// bytes known to be dereferenceable. Otherwise, zero is returned.
- uint64_t getDereferenceableBytes() const;
+ LLVM_ABI uint64_t getDereferenceableBytes() const;
/// If this argument has the dereferenceable_or_null attribute, return the
/// number of bytes known to be dereferenceable. Otherwise, zero is returned.
- uint64_t getDereferenceableOrNullBytes() const;
+ LLVM_ABI uint64_t getDereferenceableOrNullBytes() const;
/// If this argument has nofpclass attribute, return the mask representing
/// disallowed floating-point values. Otherwise, fcNone is returned.
- FPClassTest getNoFPClass() const;
+ LLVM_ABI FPClassTest getNoFPClass() const;
/// If this argument has a range attribute, return the value range of the
/// argument. Otherwise, std::nullopt is returned.
- std::optional<ConstantRange> getRange() const;
+ LLVM_ABI std::optional<ConstantRange> getRange() const;
/// Return true if this argument has the byval attribute.
- bool hasByValAttr() const;
+ LLVM_ABI bool hasByValAttr() const;
/// Return true if this argument has the byref attribute.
- bool hasByRefAttr() const;
+ LLVM_ABI bool hasByRefAttr() const;
/// Return true if this argument has the swiftself attribute.
- bool hasSwiftSelfAttr() const;
+ LLVM_ABI bool hasSwiftSelfAttr() const;
/// Return true if this argument has the swifterror attribute.
- bool hasSwiftErrorAttr() const;
+ LLVM_ABI bool hasSwiftErrorAttr() const;
/// Return true if this argument has the byval, inalloca, or preallocated
/// attribute. These attributes represent arguments being passed by value,
/// with an associated copy between the caller and callee
- bool hasPassPointeeByValueCopyAttr() const;
+ LLVM_ABI bool hasPassPointeeByValueCopyAttr() const;
/// If this argument satisfies has hasPassPointeeByValueAttr, return the
/// in-memory ABI size copied to the stack for the call. Otherwise, return 0.
- uint64_t getPassPointeeByValueCopySize(const DataLayout &DL) const;
+ LLVM_ABI uint64_t getPassPointeeByValueCopySize(const DataLayout &DL) const;
/// Return true if this argument has the byval, sret, inalloca, preallocated,
/// or byref attribute. These attributes represent arguments being passed by
/// value (which may or may not involve a stack copy)
- bool hasPointeeInMemoryValueAttr() const;
+ LLVM_ABI bool hasPointeeInMemoryValueAttr() const;
/// If hasPointeeInMemoryValueAttr returns true, the in-memory ABI type is
/// returned. Otherwise, nullptr.
- Type *getPointeeInMemoryValueType() const;
+ LLVM_ABI Type *getPointeeInMemoryValueType() const;
/// If this is a byval or inalloca argument, return its alignment.
/// FIXME: Remove this function once transition to Align is over.
/// Use getParamAlign() instead.
- LLVM_DEPRECATED("Use getParamAlign() instead", "getParamAlign")
- uint64_t getParamAlignment() const;
+ LLVM_ABI LLVM_DEPRECATED("Use getParamAlign() instead",
+ "getParamAlign") uint64_t getParamAlignment() const;
/// If this is a byval or inalloca argument, return its alignment.
- MaybeAlign getParamAlign() const;
+ LLVM_ABI MaybeAlign getParamAlign() const;
- MaybeAlign getParamStackAlign() const;
+ LLVM_ABI MaybeAlign getParamStackAlign() const;
/// If this is a byval argument, return its type.
- Type *getParamByValType() const;
+ LLVM_ABI Type *getParamByValType() const;
/// If this is an sret argument, return its type.
- Type *getParamStructRetType() const;
+ LLVM_ABI Type *getParamStructRetType() const;
/// If this is a byref argument, return its type.
- Type *getParamByRefType() const;
+ LLVM_ABI Type *getParamByRefType() const;
/// If this is an inalloca argument, return its type.
- Type *getParamInAllocaType() const;
+ LLVM_ABI Type *getParamInAllocaType() const;
/// Return true if this argument has the nest attribute.
- bool hasNestAttr() const;
+ LLVM_ABI bool hasNestAttr() const;
/// Return true if this argument has the noalias attribute.
- bool hasNoAliasAttr() const;
+ LLVM_ABI bool hasNoAliasAttr() const;
/// Return true if this argument has the nocapture attribute.
- bool hasNoCaptureAttr() const;
+ LLVM_ABI bool hasNoCaptureAttr() const;
/// Return true if this argument has the nofree attribute.
- bool hasNoFreeAttr() const;
+ LLVM_ABI bool hasNoFreeAttr() const;
/// Return true if this argument has the sret attribute.
- bool hasStructRetAttr() const;
+ LLVM_ABI bool hasStructRetAttr() const;
/// Return true if this argument has the inreg attribute.
- bool hasInRegAttr() const;
+ LLVM_ABI bool hasInRegAttr() const;
/// Return true if this argument has the returned attribute.
- bool hasReturnedAttr() const;
+ LLVM_ABI bool hasReturnedAttr() const;
/// Return true if this argument has the readonly or readnone attribute.
- bool onlyReadsMemory() const;
+ LLVM_ABI bool onlyReadsMemory() const;
/// Return true if this argument has the inalloca attribute.
- bool hasInAllocaAttr() const;
+ LLVM_ABI bool hasInAllocaAttr() const;
/// Return true if this argument has the preallocated attribute.
- bool hasPreallocatedAttr() const;
+ LLVM_ABI bool hasPreallocatedAttr() const;
/// Return true if this argument has the zext attribute.
- bool hasZExtAttr() const;
+ LLVM_ABI bool hasZExtAttr() const;
/// Return true if this argument has the sext attribute.
- bool hasSExtAttr() const;
+ LLVM_ABI bool hasSExtAttr() const;
/// Add attributes to an argument.
- void addAttrs(AttrBuilder &B);
+ LLVM_ABI void addAttrs(AttrBuilder &B);
- void addAttr(Attribute::AttrKind Kind);
+ LLVM_ABI void addAttr(Attribute::AttrKind Kind);
- void addAttr(Attribute Attr);
+ LLVM_ABI void addAttr(Attribute Attr);
/// Remove attributes from an argument.
- void removeAttr(Attribute::AttrKind Kind);
+ LLVM_ABI void removeAttr(Attribute::AttrKind Kind);
- void removeAttrs(const AttributeMask &AM);
+ LLVM_ABI void removeAttrs(const AttributeMask &AM);
/// Check if an argument has a given attribute.
- bool hasAttribute(Attribute::AttrKind Kind) const;
+ LLVM_ABI bool hasAttribute(Attribute::AttrKind Kind) const;
- bool hasAttribute(StringRef Kind) const;
+ LLVM_ABI bool hasAttribute(StringRef Kind) const;
- Attribute getAttribute(Attribute::AttrKind Kind) const;
+ LLVM_ABI Attribute getAttribute(Attribute::AttrKind Kind) const;
- AttributeSet getAttributes() const;
+ LLVM_ABI AttributeSet getAttributes() const;
/// Method for support type inquiry through isa, cast, and dyn_cast.
static bool classof(const Value *V) {
diff --git a/llvm/include/llvm/IR/AssemblyAnnotationWriter.h b/llvm/include/llvm/IR/AssemblyAnnotationWriter.h
index 3fd3c57a67963..d68bcbf85b2b7 100644
--- a/llvm/include/llvm/IR/AssemblyAnnotationWriter.h
+++ b/llvm/include/llvm/IR/AssemblyAnnotationWriter.h
@@ -16,6 +16,8 @@
#ifndef LLVM_IR_ASSEMBLYANNOTATIONWRITER_H
#define LLVM_IR_ASSEMBLYANNOTATIONWRITER_H
+#include "llvm/Support/Compiler.h"
+
namespace llvm {
class Function;
@@ -24,7 +26,7 @@ class Instruction;
class Value;
class formatted_raw_ostream;
-class AssemblyAnnotationWriter {
+class LLVM_ABI AssemblyAnnotationWriter {
public:
virtual ~AssemblyAnnotationWriter();
diff --git a/llvm/include/llvm/IR/Assumptions.h b/llvm/include/llvm/IR/Assumptions.h
index 2d2ecfbde6e6b..f1663f3d6d2bd 100644
--- a/llvm/include/llvm/IR/Assumptions.h
+++ b/llvm/include/llvm/IR/Assumptions.h
@@ -18,6 +18,7 @@
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
+#include "llvm/Support/Compiler.h"
namespace llvm {
@@ -29,7 +30,7 @@ constexpr StringRef AssumptionAttrKey = "llvm.assume";
/// A set of known assumption strings that are accepted without warning and
/// which can be recommended as typo correction.
-extern StringSet<> KnownAssumptionStrings;
+LLVM_ABI extern StringSet<> KnownAssumptionStrings;
/// Helper that allows to insert a new assumption string in the known assumption
/// set by creating a (static) object.
@@ -49,25 +50,27 @@ struct KnownAssumptionString {
};
/// Return true if \p F has the assumption \p AssumptionStr attached.
-bool hasAssumption(const Function &F,
- const KnownAssumptionString &AssumptionStr);
+LLVM_ABI bool hasAssumption(const Function &F,
+ const KnownAssumptionString &AssumptionStr);
/// Return true if \p CB or the callee has the assumption \p AssumptionStr
/// attached.
-bool hasAssumption(const CallBase &CB,
- const KnownAssumptionString &AssumptionStr);
+LLVM_ABI bool hasAssumption(const CallBase &CB,
+ const KnownAssumptionString &AssumptionStr);
/// Return the set of all assumptions for the function \p F.
-DenseSet<StringRef> getAssumptions(const Function &F);
+LLVM_ABI DenseSet<StringRef> getAssumptions(const Function &F);
/// Return the set of all assumptions for the call \p CB.
-DenseSet<StringRef> getAssumptions(const CallBase &CB);
+LLVM_ABI DenseSet<StringRef> getAssumptions(const CallBase &CB);
/// Appends the set of assumptions \p Assumptions to \F.
-bool addAssumptions(Function &F, const DenseSet<StringRef> &Assumptions);
+LLVM_ABI bool addAssumptions(Function &F,
+ const DenseSet<StringRef> &Assumptions);
/// Appends the set of assumptions \p Assumptions to \CB.
-bool addAssumptions(CallBase &CB, const DenseSet<StringRef> &Assumptions);
+LLVM_ABI bool addAssumptions(CallBase &CB,
+ const DenseSet<StringRef> &Assumptions);
} // namespace llvm
diff --git a/llvm/include/llvm/IR/Attributes.h b/llvm/include/llvm/IR/Attributes.h
index 0e8e31715acd7..c648170e708f5 100644
--- a/llvm/include/llvm/IR/Attributes.h
+++ b/llvm/include/llvm/IR/Attributes.h
@@ -22,6 +22,7 @@
#include "llvm/Config/llvm-config.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/CodeGen.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/ModRef.h"
#include "llvm/Support/PointerLikeTypeTraits.h"
#include <cassert>
@@ -114,14 +115,14 @@ class Attribute {
Kind <= LastConstantRangeListAttr;
}
- static bool canUseAsFnAttr(AttrKind Kind);
- static bool canUseAsParamAttr(AttrKind Kind);
- static bool canUseAsRetAttr(AttrKind Kind);
+ LLVM_ABI static bool canUseAsFnAttr(AttrKind Kind);
+ LLVM_ABI static bool canUseAsParamAttr(AttrKind Kind);
+ LLVM_ABI static bool canUseAsRetAttr(AttrKind Kind);
- static bool intersectMustPreserve(AttrKind Kind);
- static bool intersectWithAnd(AttrKind Kind);
- static bool intersectWithMin(AttrKind Kind);
- static bool intersectWithCustom(AttrKind Kind);
+ LLVM_ABI static bool intersectMustPreserve(AttrKind Kind);
+ LLVM_ABI static bool intersectWithAnd(AttrKind Kind);
+ LLVM_ABI static bool intersectWithMin(AttrKind Kind);
+ LLVM_ABI static bool intersectWithCustom(AttrKind Kind);
private:
AttributeImpl *pImpl = nullptr;
@@ -136,37 +137,47 @@ class Attribute {
//===--------------------------------------------------------------------===//
/// Return a uniquified Attribute object.
- static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val = 0);
- static Attribute get(LLVMContext &Context, StringRef Kind,
- StringRef Val = StringRef());
- static Attribute get(LLVMContext &Context, AttrKind Kind, Type *Ty);
- static Attribute get(LLVMContext &Context, AttrKind Kind,
- const ConstantRange &CR);
- static Attribute get(LLVMContext &Context, AttrKind Kind,
- ArrayRef<ConstantRange> Val);
+ LLVM_ABI static Attribute get(LLVMContext &Context, AttrKind Kind,
+ uint64_t Val = 0);
+ LLVM_ABI static Attribute get(LLVMContext &Context, StringRef Kind,
+ StringRef Val = StringRef());
+ LLVM_ABI static Attribute get(LLVMContext &Context, AttrKind Kind, Type *Ty);
+ LLVM_ABI static Attribute get(LLVMContext &Context, AttrKind Kind,
+ const ConstantRange &CR);
+ LLVM_ABI static Attribute get(LLVMContext &Context, AttrKind Kind,
+ ArrayRef<ConstantRange> Val);
/// Return a uniquified Attribute object that has the specific
/// alignment set.
- static Attribute getWithAlignment(LLVMContext &Context, Align Alignment);
- static Attribute getWithStackAlignment(LLVMContext &Context, Align Alignment);
- static Attribute getWithDereferenceableBytes(LLVMContext &Context,
- uint64_t Bytes);
- static Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context,
- uint64_t Bytes);
- static Attribute getWithAllocSizeArgs(
- LLVMContext &Context, unsigned ElemSizeArg,
- const std::optional<unsigned> &NumElemsArg);
- static Attribute getWithVScaleRangeArgs(LLVMContext &Context,
- unsigned MinValue, unsigned MaxValue);
- static Attribute getWithByValType(LLVMContext &Context, Type *Ty);
- static Attribute getWithStructRetType(LLVMContext &Context, Type *Ty);
- static Attribute getWithByRefType(LLVMContext &Context, Type *Ty);
- static Attribute getWithPreallocatedType(LLVMContext &Context, Type *Ty);
- static Attribute getWithInAllocaType(LLVMContext &Context, Type *Ty);
- static Attribute getWithUWTableKind(LLVMContext &Context, UWTableKind Kind);
- static Attribute getWithMemoryEffects(LLVMContext &Context, MemoryEffects ME);
- static Attribute getWithNoFPClass(LLVMContext &Context, FPClassTest Mask);
- static Attribute getWithCaptureInfo(LLVMContext &Context, CaptureInfo CI);
+ LLVM_ABI static Attribute getWithAlignment(LLVMContext &Context,
+ Align Alignment);
+ LLVM_ABI static Attribute getWithStackAlignment(LLVMContext &Context,
+ Align Alignment);
+ LLVM_ABI static Attribute getWithDereferenceableBytes(LLVMContext &Context,
+ uint64_t Bytes);
+ LLVM_ABI static Attribute
+ getWithDereferenceableOrNullBytes(LLVMContext &Context, uint64_t Bytes);
+ LLVM_ABI static Attribute
+ getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg,
+ const std::optional<unsigned> &NumElemsArg);
+ LLVM_ABI static Attribute getWithVScaleRangeArgs(LLVMContext &Context,
+ unsigned MinValue,
+ unsigned MaxValue);
+ LLVM_ABI static Attribute getWithByValType(LLVMContext &Context, Type *Ty);
+ LLVM_ABI static Attribute getWithStructRetType(LLVMContext &Context,
+ Type *Ty);
+ LLVM_ABI static Attribute getWithByRefType(LLVMContext &Context, Type *Ty);
+ LLVM_ABI static Attribute getWithPreallocatedType(LLVMContext &Context,
+ Type *Ty);
+ LLVM_ABI static Attribute getWithInAllocaType(LLVMContext &Context, Type *Ty);
+ LLVM_ABI static Attribute getWithUWTableKind(LLVMContext &Context,
+ UWTableKind Kind);
+ LLVM_ABI static Attribute getWithMemoryEffects(LLVMContext &Context,
+ MemoryEffects ME);
+ LLVM_ABI static Attribute getWithNoFPClass(LLVMContext &Context,
+ FPClassTest Mask);
+ LLVM_ABI static Attribute getWithCaptureInfo(LLVMContext &Context,
+ CaptureInfo CI);
/// For a typed attribute, return the equivalent attribute with the type
/// changed to \p ReplacementTy.
@@ -175,45 +186,45 @@ class Attribute {
return get(Context, getKindAsEnum(), ReplacementTy);
}
- static Attribute::AttrKind getAttrKindFromName(StringRef AttrName);
+ LLVM_ABI static Attribute::AttrKind getAttrKindFromName(StringRef AttrName);
- static StringRef getNameFromAttrKind(Attribute::AttrKind AttrKind);
+ LLVM_ABI static StringRef getNameFromAttrKind(Attribute::AttrKind AttrKind);
/// Return true if the provided string matches the IR name of an attribute.
...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/141650
More information about the llvm-commits
mailing list