-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[llvm] annotate interfaces in llvm/IR for DLL export #141650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
You can test this locally with the following command:git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- llvm/include/llvm/IR/AbstractCallSite.h llvm/include/llvm/IR/Analysis.h llvm/include/llvm/IR/Argument.h llvm/include/llvm/IR/AssemblyAnnotationWriter.h llvm/include/llvm/IR/Assumptions.h llvm/include/llvm/IR/Attributes.h llvm/include/llvm/IR/AutoUpgrade.h llvm/include/llvm/IR/BasicBlock.h llvm/include/llvm/IR/BuiltinGCs.h llvm/include/llvm/IR/CmpPredicate.h llvm/include/llvm/IR/Comdat.h llvm/include/llvm/IR/Constant.h llvm/include/llvm/IR/ConstantFPRange.h llvm/include/llvm/IR/ConstantFold.h llvm/include/llvm/IR/ConstantFolder.h llvm/include/llvm/IR/ConstantRange.h llvm/include/llvm/IR/ConstantRangeList.h llvm/include/llvm/IR/Constants.h llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DataLayout.h llvm/include/llvm/IR/DebugInfo.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/include/llvm/IR/DebugLoc.h llvm/include/llvm/IR/DebugProgramInstruction.h llvm/include/llvm/IR/DerivedTypes.h llvm/include/llvm/IR/DiagnosticHandler.h llvm/include/llvm/IR/DiagnosticInfo.h llvm/include/llvm/IR/DiagnosticPrinter.h llvm/include/llvm/IR/Dominators.h llvm/include/llvm/IR/DroppedVariableStats.h llvm/include/llvm/IR/DroppedVariableStatsIR.h llvm/include/llvm/IR/EHPersonalities.h llvm/include/llvm/IR/FMF.h llvm/include/llvm/IR/FPEnv.h llvm/include/llvm/IR/Function.h llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h llvm/include/llvm/IR/GlobalAlias.h llvm/include/llvm/IR/GlobalIFunc.h llvm/include/llvm/IR/GlobalObject.h llvm/include/llvm/IR/GlobalValue.h llvm/include/llvm/IR/GlobalVariable.h llvm/include/llvm/IR/IRBuilder.h llvm/include/llvm/IR/IRBuilderFolder.h llvm/include/llvm/IR/IRPrintingPasses.h llvm/include/llvm/IR/InlineAsm.h llvm/include/llvm/IR/InstrTypes.h llvm/include/llvm/IR/Instruction.h llvm/include/llvm/IR/Instructions.h llvm/include/llvm/IR/IntrinsicInst.h llvm/include/llvm/IR/Intrinsics.h llvm/include/llvm/IR/LLVMContext.h llvm/include/llvm/IR/LLVMRemarkStreamer.h llvm/include/llvm/IR/LegacyPassManager.h llvm/include/llvm/IR/LegacyPassManagers.h llvm/include/llvm/IR/LegacyPassNameParser.h llvm/include/llvm/IR/MDBuilder.h llvm/include/llvm/IR/Mangler.h llvm/include/llvm/IR/MemoryModelRelaxationAnnotations.h llvm/include/llvm/IR/Metadata.h llvm/include/llvm/IR/Module.h llvm/include/llvm/IR/ModuleSlotTracker.h llvm/include/llvm/IR/ModuleSummaryIndex.h llvm/include/llvm/IR/NoFolder.h llvm/include/llvm/IR/Operator.h llvm/include/llvm/IR/OptBisect.h llvm/include/llvm/IR/PassInstrumentation.h llvm/include/llvm/IR/PassManager.h llvm/include/llvm/IR/PassManagerImpl.h llvm/include/llvm/IR/PassTimingInfo.h llvm/include/llvm/IR/ProfDataUtils.h llvm/include/llvm/IR/ProfileSummary.h llvm/include/llvm/IR/PseudoProbe.h llvm/include/llvm/IR/ReplaceConstant.h llvm/include/llvm/IR/RuntimeLibcalls.h llvm/include/llvm/IR/StructuralHash.h llvm/include/llvm/IR/SymbolTableListTraits.h llvm/include/llvm/IR/Type.h llvm/include/llvm/IR/TypedPointerType.h llvm/include/llvm/IR/Use.h llvm/include/llvm/IR/User.h llvm/include/llvm/IR/VFABIDemangler.h llvm/include/llvm/IR/Value.h llvm/include/llvm/IR/ValueHandle.h llvm/include/llvm/IR/ValueSymbolTable.h llvm/include/llvm/IR/VectorBuilder.h llvm/include/llvm/IR/VectorTypeUtils.h llvm/include/llvm/IR/Verifier.h llvm/include/llvm/IRPrinter/IRPrintingPasses.h llvm/include/llvm/IRReader/IRReader.h llvm/lib/IR/BasicBlock.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/DebugProgramInstruction.cpp llvm/lib/IR/Dominators.cpp llvm/lib/IR/Function.cpp llvm/lib/IR/IRPrintingPasses.cpp llvm/lib/IR/Instruction.cpp llvm/lib/IR/Instructions.cpp llvm/lib/IR/LegacyPassManager.cpp llvm/lib/IR/Module.cpp llvm/lib/IR/PassManager.cpp llvm/lib/IRPrinter/IRPrintingPasses.cpp llvm/unittests/IR/DebugInfoTest.cpp llvm/unittests/IR/InstructionsTest.cpp llvm/unittests/IR/MetadataTest.cpp llvm/unittests/IR/ValueTest.cpp View the diff from clang-format here.diff --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h
index 1480458e9..f305133e2 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -227,24 +227,24 @@ public:
/// nullptr if the function does not have a module.
///
/// Note: this is undefined behavior if the block does not have a parent.
- LLVM_ABI const Module *getModule() const;
- Module *getModule() {
- return const_cast<Module *>(
- static_cast<const BasicBlock *>(this)->getModule());
- }
+ LLVM_ABI const Module *getModule() const;
+ Module *getModule() {
+ return const_cast<Module *>(
+ static_cast<const BasicBlock *>(this)->getModule());
+ }
/// Get the data layout of the module this basic block belongs to.
///
/// Requires the basic block to have a parent module.
- LLVM_ABI const DataLayout &getDataLayout() const;
-
- /// Returns the terminator instruction if the block is well formed or
- /// null if the block is not well formed.
- const Instruction *getTerminator() const LLVM_READONLY {
- if (InstList.empty() || !InstList.back().isTerminator())
- return nullptr;
- return &InstList.back();
- }
+ LLVM_ABI const DataLayout &getDataLayout() const;
+
+ /// Returns the terminator instruction if the block is well formed or
+ /// null if the block is not well formed.
+ const Instruction *getTerminator() const LLVM_READONLY {
+ if (InstList.empty() || !InstList.back().isTerminator())
+ return nullptr;
+ return &InstList.back();
+ }
Instruction *getTerminator() {
return const_cast<Instruction *>(
static_cast<const BasicBlock *>(this)->getTerminator());
|
e6db935
to
4b70c6a
Compare
The git-clang-format generated fixit is incorrect: it wants to indent some declarations that should not be indented. I confirmed that running clang-format on the entire file does not produce these fixits. |
507c2df
to
7f3ea16
Compare
@llvm/pr-subscribers-debuginfo @llvm/pr-subscribers-llvm-ir Author: Andrew Rogers (andrurogerz) ChangesPurposeThis patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates the BackgroundThis effort is tracked in #109483. Additional context is provided in this discourse, and documentation for The bulk of these changes were generated automatically using the Interface Definition Scanner (IDS) tool, followed formatting with The following manual adjustments were also applied after running IDS on Linux:
ValidationLocal builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations:
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:
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]
|
@compnerd @vgvassilev here's one more, anyone else that should have a look at llvm/IR changes? The code_formatter failure is wrong; the suggestions should not be applied. |
What version of |
@boomanaiden154 thanks for having a look at this. I do not understand why it wants to make this indentation change and wasn't able to tweak the existing formatting to make it happy. And, just to be totally clear, |
The |
Even with the updated I found that if I |
That's probably the best move. I didn't realize that you said |
I filed #141861 to track the issue and made a simple repro. After determining the root cause, I can see that this issue might be considered expected behavior even though it produces incorrect results in this case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % clang-format!
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
, andllvm/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, and documentation for
LLVM_ABI
and related annotations is found in the LLVM repo here.The bulk of these changes were generated automatically using the Interface Definition Scanner (IDS) tool, followed formatting with
git clang-format
.The following manual adjustments were also applied after running IDS on Linux:
#include "llvm/Support/Compiler.h"
to files where it was not auto-added by IDS due to no pre-existing block of include statements.LLVM_ABI_FRIEND
to friend member functions declared withLLVM_ABI
LLVM_TEMPLATE_ABI
andLLVM_EXPORT_TEMPLATE
to exported instantiated templatesLLVM_ABI
to a subset of private class methods and fields that require exportLLVM_ABI
to a small number of symbols that require export but are not declared in headersLLVM_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: