diff options
105 files changed, 3510 insertions, 3139 deletions
diff --git a/llvm/include/llvm/IR/AbstractCallSite.h b/llvm/include/llvm/IR/AbstractCallSite.h index 50afe01..9e24ae7 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 @@ public: /// 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 dd43f5e..8ab70dd 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 @@ private: 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 @@ public: 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 @@ public: 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 5be58d7..60854b17 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 @@ public: /// 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 3fd3c57..d68bcbf 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 2d2ecfb..f1663f3 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 @@ private: }; /// 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 0e8e317..c648170 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 @@ public: 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 @@ public: //===--------------------------------------------------------------------===// /// 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 @@ public: 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. /// example: "noalias" return true but not "NoAlias" - static bool isExistingAttribute(StringRef Name); + LLVM_ABI static bool isExistingAttribute(StringRef Name); //===--------------------------------------------------------------------===// // Attribute Accessors //===--------------------------------------------------------------------===// /// Return true if the attribute is an Attribute::AttrKind type. - bool isEnumAttribute() const; + LLVM_ABI bool isEnumAttribute() const; /// Return true if the attribute is an integer attribute. - bool isIntAttribute() const; + LLVM_ABI bool isIntAttribute() const; /// Return true if the attribute is a string (target-dependent) /// attribute. - bool isStringAttribute() const; + LLVM_ABI bool isStringAttribute() const; /// Return true if the attribute is a type attribute. - bool isTypeAttribute() const; + LLVM_ABI bool isTypeAttribute() const; /// Return true if the attribute is a ConstantRange attribute. - bool isConstantRangeAttribute() const; + LLVM_ABI bool isConstantRangeAttribute() const; /// Return true if the attribute is a ConstantRangeList attribute. - bool isConstantRangeListAttribute() const; + LLVM_ABI bool isConstantRangeListAttribute() const; /// Return true if the attribute is any kind of attribute. bool isValid() const { return pImpl; } /// Return true if the attribute is present. - bool hasAttribute(AttrKind Val) const; + LLVM_ABI bool hasAttribute(AttrKind Val) const; /// Return true if the target-dependent attribute is present. - bool hasAttribute(StringRef Val) const; + LLVM_ABI bool hasAttribute(StringRef Val) const; /// Returns true if the attribute's kind can be represented as an enum (Enum, /// Integer, Type, ConstantRange, or ConstantRangeList attribute). @@ -221,101 +232,102 @@ public: /// Return the attribute's kind as an enum (Attribute::AttrKind). This /// requires the attribute be representable as an enum (see: `hasKindAsEnum`). - Attribute::AttrKind getKindAsEnum() const; + LLVM_ABI Attribute::AttrKind getKindAsEnum() const; /// Return the attribute's value as an integer. This requires that the /// attribute be an integer attribute. - uint64_t getValueAsInt() const; + LLVM_ABI uint64_t getValueAsInt() const; /// Return the attribute's value as a boolean. This requires that the /// attribute be a string attribute. - bool getValueAsBool() const; + LLVM_ABI bool getValueAsBool() const; /// Return the attribute's kind as a string. This requires the /// attribute to be a string attribute. - StringRef getKindAsString() const; + LLVM_ABI StringRef getKindAsString() const; /// Return the attribute's value as a string. This requires the /// attribute to be a string attribute. - StringRef getValueAsString() const; + LLVM_ABI StringRef getValueAsString() const; /// Return the attribute's value as a Type. This requires the attribute to be /// a type attribute. - Type *getValueAsType() const; + LLVM_ABI Type *getValueAsType() const; /// Return the attribute's value as a ConstantRange. This requires the /// attribute to be a ConstantRange attribute. - const ConstantRange &getValueAsConstantRange() const; + LLVM_ABI const ConstantRange &getValueAsConstantRange() const; /// Return the attribute's value as a ConstantRange array. This requires the /// attribute to be a ConstantRangeList attribute. - ArrayRef<ConstantRange> getValueAsConstantRangeList() const; + LLVM_ABI ArrayRef<ConstantRange> getValueAsConstantRangeList() const; /// Returns the alignment field of an attribute as a byte alignment /// value. - MaybeAlign getAlignment() const; + LLVM_ABI MaybeAlign getAlignment() const; /// Returns the stack alignment field of an attribute as a byte /// alignment value. - MaybeAlign getStackAlignment() const; + LLVM_ABI MaybeAlign getStackAlignment() const; /// Returns the number of dereferenceable bytes from the /// dereferenceable attribute. - uint64_t getDereferenceableBytes() const; + LLVM_ABI uint64_t getDereferenceableBytes() const; /// Returns the number of dereferenceable_or_null bytes from the /// dereferenceable_or_null attribute. - uint64_t getDereferenceableOrNullBytes() const; + LLVM_ABI uint64_t getDereferenceableOrNullBytes() const; /// Returns the argument numbers for the allocsize attribute. - std::pair<unsigned, std::optional<unsigned>> getAllocSizeArgs() const; + LLVM_ABI std::pair<unsigned, std::optional<unsigned>> + getAllocSizeArgs() const; /// Returns the minimum value for the vscale_range attribute. - unsigned getVScaleRangeMin() const; + LLVM_ABI unsigned getVScaleRangeMin() const; /// Returns the maximum value for the vscale_range attribute or std::nullopt /// when unknown. - std::optional<unsigned> getVScaleRangeMax() const; + LLVM_ABI std::optional<unsigned> getVScaleRangeMax() const; // Returns the unwind table kind. - UWTableKind getUWTableKind() const; + LLVM_ABI UWTableKind getUWTableKind() const; // Returns the allocator function kind. - AllocFnKind getAllocKind() const; + LLVM_ABI AllocFnKind getAllocKind() const; /// Returns memory effects. - MemoryEffects getMemoryEffects() const; + LLVM_ABI MemoryEffects getMemoryEffects() const; /// Returns information from captures attribute. - CaptureInfo getCaptureInfo() const; + LLVM_ABI CaptureInfo getCaptureInfo() const; /// Return the FPClassTest for nofpclass - FPClassTest getNoFPClass() const; + LLVM_ABI FPClassTest getNoFPClass() const; /// Returns the value of the range attribute. - const ConstantRange &getRange() const; + LLVM_ABI const ConstantRange &getRange() const; /// Returns the value of the initializes attribute. - ArrayRef<ConstantRange> getInitializes() const; + LLVM_ABI ArrayRef<ConstantRange> getInitializes() const; /// The Attribute is converted to a string of equivalent mnemonic. This /// is, presumably, for writing out the mnemonics for the assembly writer. - std::string getAsString(bool InAttrGrp = false) const; + LLVM_ABI std::string getAsString(bool InAttrGrp = false) const; /// Return true if this attribute belongs to the LLVMContext. - bool hasParentContext(LLVMContext &C) const; + LLVM_ABI bool hasParentContext(LLVMContext &C) const; /// Equality and non-equality operators. bool operator==(Attribute A) const { return pImpl == A.pImpl; } bool operator!=(Attribute A) const { return pImpl != A.pImpl; } /// Used to sort attribute by kind. - int cmpKind(Attribute A) const; + LLVM_ABI int cmpKind(Attribute A) const; /// Less-than operator. Useful for sorting the attributes list. - bool operator<(Attribute A) const; + LLVM_ABI bool operator<(Attribute A) const; - void Profile(FoldingSetNodeID &ID) const; + LLVM_ABI void Profile(FoldingSetNodeID &ID) const; /// Return a raw pointer that uniquely identifies this attribute. void *getRawPointer() const { @@ -364,94 +376,94 @@ public: AttributeSet(const AttributeSet &) = default; ~AttributeSet() = default; - static AttributeSet get(LLVMContext &C, const AttrBuilder &B); - static AttributeSet get(LLVMContext &C, ArrayRef<Attribute> Attrs); + LLVM_ABI static AttributeSet get(LLVMContext &C, const AttrBuilder &B); + LLVM_ABI static AttributeSet get(LLVMContext &C, ArrayRef<Attribute> Attrs); bool operator==(const AttributeSet &O) const { return SetNode == O.SetNode; } bool operator!=(const AttributeSet &O) const { return !(*this == O); } /// Add an argument attribute. Returns a new set because attribute sets are /// immutable. - [[nodiscard]] AttributeSet addAttribute(LLVMContext &C, - Attribute::AttrKind Kind) const; + [[nodiscard]] LLVM_ABI AttributeSet + addAttribute(LLVMContext &C, Attribute::AttrKind Kind) const; /// Add a target-dependent attribute. Returns a new set because attribute sets /// are immutable. - [[nodiscard]] AttributeSet addAttribute(LLVMContext &C, StringRef Kind, - StringRef Value = StringRef()) const; + [[nodiscard]] LLVM_ABI AttributeSet addAttribute( + LLVMContext &C, StringRef Kind, StringRef Value = StringRef()) const; /// Add attributes to the attribute set. Returns a new set because attribute /// sets are immutable. - [[nodiscard]] AttributeSet addAttributes(LLVMContext &C, - AttributeSet AS) const; + [[nodiscard]] LLVM_ABI AttributeSet addAttributes(LLVMContext &C, + AttributeSet AS) const; /// Remove the specified attribute from this set. Returns a new set because /// attribute sets are immutable. - [[nodiscard]] AttributeSet removeAttribute(LLVMContext &C, - Attribute::AttrKind Kind) const; + [[nodiscard]] LLVM_ABI AttributeSet + removeAttribute(LLVMContext &C, Attribute::AttrKind Kind) const; /// Remove the specified attribute from this set. Returns a new set because /// attribute sets are immutable. - [[nodiscard]] AttributeSet removeAttribute(LLVMContext &C, - StringRef Kind) const; + [[nodiscard]] LLVM_ABI AttributeSet removeAttribute(LLVMContext &C, + StringRef Kind) const; /// Remove the specified attributes from this set. Returns a new set because /// attribute sets are immutable. - [[nodiscard]] AttributeSet + [[nodiscard]] LLVM_ABI AttributeSet removeAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const; /// Try to intersect this AttributeSet with Other. Returns std::nullopt if /// the two lists are inherently incompatible (imply different behavior, not /// just analysis). - [[nodiscard]] std::optional<AttributeSet> + [[nodiscard]] LLVM_ABI std::optional<AttributeSet> intersectWith(LLVMContext &C, AttributeSet Other) const; /// Return the number of attributes in this set. - unsigned getNumAttributes() const; + LLVM_ABI unsigned getNumAttributes() const; /// Return true if attributes exists in this set. bool hasAttributes() const { return SetNode != nullptr; } /// Return true if the attribute exists in this set. - bool hasAttribute(Attribute::AttrKind Kind) const; + LLVM_ABI bool hasAttribute(Attribute::AttrKind Kind) const; /// Return true if the attribute exists in this set. - bool hasAttribute(StringRef Kind) const; + LLVM_ABI bool hasAttribute(StringRef Kind) const; /// Return the attribute object. - Attribute getAttribute(Attribute::AttrKind Kind) const; + LLVM_ABI Attribute getAttribute(Attribute::AttrKind Kind) const; /// Return the target-dependent attribute object. - Attribute getAttribute(StringRef Kind) const; - - MaybeAlign getAlignment() const; - MaybeAlign getStackAlignment() const; - uint64_t getDereferenceableBytes() const; - uint64_t getDereferenceableOrNullBytes() const; - Type *getByValType() const; - Type *getStructRetType() const; - Type *getByRefType() const; - Type *getPreallocatedType() const; - Type *getInAllocaType() const; - Type *getElementType() const; - std::optional<std::pair<unsigned, std::optional<unsigned>>> getAllocSizeArgs() - const; - unsigned getVScaleRangeMin() const; - std::optional<unsigned> getVScaleRangeMax() const; - UWTableKind getUWTableKind() const; - AllocFnKind getAllocKind() const; - MemoryEffects getMemoryEffects() const; - CaptureInfo getCaptureInfo() const; - FPClassTest getNoFPClass() const; - std::string getAsString(bool InAttrGrp = false) const; + LLVM_ABI Attribute getAttribute(StringRef Kind) const; + + LLVM_ABI MaybeAlign getAlignment() const; + LLVM_ABI MaybeAlign getStackAlignment() const; + LLVM_ABI uint64_t getDereferenceableBytes() const; + LLVM_ABI uint64_t getDereferenceableOrNullBytes() const; + LLVM_ABI Type *getByValType() const; + LLVM_ABI Type *getStructRetType() const; + LLVM_ABI Type *getByRefType() const; + LLVM_ABI Type *getPreallocatedType() const; + LLVM_ABI Type *getInAllocaType() const; + LLVM_ABI Type *getElementType() const; + LLVM_ABI std::optional<std::pair<unsigned, std::optional<unsigned>>> + getAllocSizeArgs() const; + LLVM_ABI unsigned getVScaleRangeMin() const; + LLVM_ABI std::optional<unsigned> getVScaleRangeMax() const; + LLVM_ABI UWTableKind getUWTableKind() const; + LLVM_ABI AllocFnKind getAllocKind() const; + LLVM_ABI MemoryEffects getMemoryEffects() const; + LLVM_ABI CaptureInfo getCaptureInfo() const; + LLVM_ABI FPClassTest getNoFPClass() const; + LLVM_ABI std::string getAsString(bool InAttrGrp = false) const; /// Return true if this attribute set belongs to the LLVMContext. - bool hasParentContext(LLVMContext &C) const; + LLVM_ABI bool hasParentContext(LLVMContext &C) const; using iterator = const Attribute *; - iterator begin() const; - iterator end() const; + LLVM_ABI iterator begin() const; + LLVM_ABI iterator end() const; #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) void dump() const; #endif @@ -510,16 +522,16 @@ private: public: /// Create an AttributeList with the specified parameters in it. - static AttributeList get(LLVMContext &C, - ArrayRef<std::pair<unsigned, Attribute>> Attrs); - static AttributeList get(LLVMContext &C, - ArrayRef<std::pair<unsigned, AttributeSet>> Attrs); + LLVM_ABI static AttributeList + get(LLVMContext &C, ArrayRef<std::pair<unsigned, Attribute>> Attrs); + LLVM_ABI static AttributeList + get(LLVMContext &C, ArrayRef<std::pair<unsigned, AttributeSet>> Attrs); /// Create an AttributeList from attribute sets for a function, its /// return value, and all of its arguments. - static AttributeList get(LLVMContext &C, AttributeSet FnAttrs, - AttributeSet RetAttrs, - ArrayRef<AttributeSet> ArgAttrs); + LLVM_ABI static AttributeList get(LLVMContext &C, AttributeSet FnAttrs, + AttributeSet RetAttrs, + ArrayRef<AttributeSet> ArgAttrs); private: explicit AttributeList(AttributeListImpl *LI) : pImpl(LI) {} @@ -537,42 +549,42 @@ public: //===--------------------------------------------------------------------===// /// Return an AttributeList with the specified parameters in it. - static AttributeList get(LLVMContext &C, ArrayRef<AttributeList> Attrs); - static AttributeList get(LLVMContext &C, unsigned Index, - ArrayRef<Attribute::AttrKind> Kinds); - static AttributeList get(LLVMContext &C, unsigned Index, - ArrayRef<Attribute::AttrKind> Kinds, - ArrayRef<uint64_t> Values); - static AttributeList get(LLVMContext &C, unsigned Index, - ArrayRef<StringRef> Kind); - static AttributeList get(LLVMContext &C, unsigned Index, - AttributeSet Attrs); - static AttributeList get(LLVMContext &C, unsigned Index, - const AttrBuilder &B); + LLVM_ABI static AttributeList get(LLVMContext &C, + ArrayRef<AttributeList> Attrs); + LLVM_ABI static AttributeList get(LLVMContext &C, unsigned Index, + ArrayRef<Attribute::AttrKind> Kinds); + LLVM_ABI static AttributeList get(LLVMContext &C, unsigned Index, + ArrayRef<Attribute::AttrKind> Kinds, + ArrayRef<uint64_t> Values); + LLVM_ABI static AttributeList get(LLVMContext &C, unsigned Index, + ArrayRef<StringRef> Kind); + LLVM_ABI static AttributeList get(LLVMContext &C, unsigned Index, + AttributeSet Attrs); + LLVM_ABI static AttributeList get(LLVMContext &C, unsigned Index, + const AttrBuilder &B); // TODO: remove non-AtIndex versions of these methods. /// Add an attribute to the attribute set at the given index. /// Returns a new list because attribute lists are immutable. - [[nodiscard]] AttributeList - addAttributeAtIndex(LLVMContext &C, unsigned Index, - Attribute::AttrKind Kind) const; + [[nodiscard]] LLVM_ABI AttributeList addAttributeAtIndex( + LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const; /// Add an attribute to the attribute set at the given index. /// Returns a new list because attribute lists are immutable. - [[nodiscard]] AttributeList + [[nodiscard]] LLVM_ABI AttributeList addAttributeAtIndex(LLVMContext &C, unsigned Index, StringRef Kind, StringRef Value = StringRef()) const; /// Add an attribute to the attribute set at the given index. /// Returns a new list because attribute lists are immutable. - [[nodiscard]] AttributeList - addAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute A) const; + [[nodiscard]] LLVM_ABI AttributeList addAttributeAtIndex(LLVMContext &C, + unsigned Index, + Attribute A) const; /// Add attributes to the attribute set at the given index. /// Returns a new list because attribute lists are immutable. - [[nodiscard]] AttributeList addAttributesAtIndex(LLVMContext &C, - unsigned Index, - const AttrBuilder &B) const; + [[nodiscard]] LLVM_ABI AttributeList addAttributesAtIndex( + LLVMContext &C, unsigned Index, const AttrBuilder &B) const; /// Add a function attribute to the list. Returns a new list because /// attribute lists are immutable. @@ -642,9 +654,8 @@ public: /// Add an attribute to the attribute list at the given arg indices. Returns a /// new list because attribute lists are immutable. - [[nodiscard]] AttributeList addParamAttribute(LLVMContext &C, - ArrayRef<unsigned> ArgNos, - Attribute A) const; + [[nodiscard]] LLVM_ABI AttributeList addParamAttribute( + LLVMContext &C, ArrayRef<unsigned> ArgNos, Attribute A) const; /// Add an argument attribute to the list. Returns a new list because /// attribute lists are immutable. @@ -655,13 +666,12 @@ public: /// Remove the specified attribute at the specified index from this /// attribute list. Returns a new list because attribute lists are immutable. - [[nodiscard]] AttributeList - removeAttributeAtIndex(LLVMContext &C, unsigned Index, - Attribute::AttrKind Kind) const; + [[nodiscard]] LLVM_ABI AttributeList removeAttributeAtIndex( + LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const; /// Remove the specified attribute at the specified index from this /// attribute list. Returns a new list because attribute lists are immutable. - [[nodiscard]] AttributeList + [[nodiscard]] LLVM_ABI AttributeList removeAttributeAtIndex(LLVMContext &C, unsigned Index, StringRef Kind) const; [[nodiscard]] AttributeList removeAttribute(LLVMContext &C, unsigned Index, StringRef Kind) const { @@ -670,14 +680,13 @@ public: /// Remove the specified attributes at the specified index from this /// attribute list. Returns a new list because attribute lists are immutable. - [[nodiscard]] AttributeList - removeAttributesAtIndex(LLVMContext &C, unsigned Index, - const AttributeMask &AttrsToRemove) const; + [[nodiscard]] LLVM_ABI AttributeList removeAttributesAtIndex( + LLVMContext &C, unsigned Index, const AttributeMask &AttrsToRemove) const; /// Remove all attributes at the specified index from this /// attribute list. Returns a new list because attribute lists are immutable. - [[nodiscard]] AttributeList removeAttributesAtIndex(LLVMContext &C, - unsigned Index) const; + [[nodiscard]] LLVM_ABI AttributeList + removeAttributesAtIndex(LLVMContext &C, unsigned Index) const; /// Remove the specified attribute at the function index from this /// attribute list. Returns a new list because attribute lists are immutable. @@ -772,37 +781,35 @@ public: /// \brief Add the dereferenceable attribute to the attribute set at the given /// index. Returns a new list because attribute lists are immutable. - [[nodiscard]] AttributeList addDereferenceableRetAttr(LLVMContext &C, - uint64_t Bytes) const; + [[nodiscard]] LLVM_ABI AttributeList + addDereferenceableRetAttr(LLVMContext &C, uint64_t Bytes) const; /// \brief Add the dereferenceable attribute to the attribute set at the given /// arg index. Returns a new list because attribute lists are immutable. - [[nodiscard]] AttributeList addDereferenceableParamAttr(LLVMContext &C, - unsigned ArgNo, - uint64_t Bytes) const; + [[nodiscard]] LLVM_ABI AttributeList addDereferenceableParamAttr( + LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const; /// Add the dereferenceable_or_null attribute to the attribute set at /// the given arg index. Returns a new list because attribute lists are /// immutable. - [[nodiscard]] AttributeList - addDereferenceableOrNullParamAttr(LLVMContext &C, unsigned ArgNo, - uint64_t Bytes) const; + [[nodiscard]] LLVM_ABI AttributeList addDereferenceableOrNullParamAttr( + LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const; /// Add the range attribute to the attribute set at the return value index. /// Returns a new list because attribute lists are immutable. - [[nodiscard]] AttributeList addRangeRetAttr(LLVMContext &C, - const ConstantRange &CR) const; + [[nodiscard]] LLVM_ABI AttributeList + addRangeRetAttr(LLVMContext &C, const ConstantRange &CR) const; /// Add the allocsize attribute to the attribute set at the given arg index. /// Returns a new list because attribute lists are immutable. - [[nodiscard]] AttributeList + [[nodiscard]] LLVM_ABI AttributeList addAllocSizeParamAttr(LLVMContext &C, unsigned ArgNo, unsigned ElemSizeArg, const std::optional<unsigned> &NumElemsArg) const; /// Try to intersect this AttributeList with Other. Returns std::nullopt if /// the two lists are inherently incompatible (imply different behavior, not /// just analysis). - [[nodiscard]] std::optional<AttributeList> + [[nodiscard]] LLVM_ABI std::optional<AttributeList> intersectWith(LLVMContext &C, AttributeList Other) const; //===--------------------------------------------------------------------===// @@ -810,26 +817,27 @@ public: //===--------------------------------------------------------------------===// /// The attributes for the specified index are returned. - AttributeSet getAttributes(unsigned Index) const; + LLVM_ABI AttributeSet getAttributes(unsigned Index) const; /// The attributes for the argument or parameter at the given index are /// returned. - AttributeSet getParamAttrs(unsigned ArgNo) const; + LLVM_ABI AttributeSet getParamAttrs(unsigned ArgNo) const; /// The attributes for the ret value are returned. - AttributeSet getRetAttrs() const; + LLVM_ABI AttributeSet getRetAttrs() const; /// The function attributes are returned. - AttributeSet getFnAttrs() const; + LLVM_ABI AttributeSet getFnAttrs() const; /// Return true if the attribute exists at the given index. - bool hasAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const; + LLVM_ABI bool hasAttributeAtIndex(unsigned Index, + Attribute::AttrKind Kind) const; /// Return true if the attribute exists at the given index. - bool hasAttributeAtIndex(unsigned Index, StringRef Kind) const; + LLVM_ABI bool hasAttributeAtIndex(unsigned Index, StringRef Kind) const; /// Return true if attribute exists at the given index. - bool hasAttributesAtIndex(unsigned Index) const; + LLVM_ABI bool hasAttributesAtIndex(unsigned Index) const; /// Return true if the attribute exists for the given argument bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const { @@ -860,10 +868,10 @@ public: bool hasRetAttrs() const { return hasAttributesAtIndex(ReturnIndex); } /// Return true if the attribute exists for the function. - bool hasFnAttr(Attribute::AttrKind Kind) const; + LLVM_ABI bool hasFnAttr(Attribute::AttrKind Kind) const; /// Return true if the attribute exists for the function. - bool hasFnAttr(StringRef Kind) const; + LLVM_ABI bool hasFnAttr(StringRef Kind) const; /// Return true the attributes exist for the function. bool hasFnAttrs() const { return hasAttributesAtIndex(FunctionIndex); } @@ -871,14 +879,15 @@ public: /// Return true if the specified attribute is set for at least one /// parameter or for the return value. If Index is not nullptr, the index /// of a parameter with the specified attribute is provided. - bool hasAttrSomewhere(Attribute::AttrKind Kind, - unsigned *Index = nullptr) const; + LLVM_ABI bool hasAttrSomewhere(Attribute::AttrKind Kind, + unsigned *Index = nullptr) const; /// Return the attribute object that exists at the given index. - Attribute getAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const; + LLVM_ABI Attribute getAttributeAtIndex(unsigned Index, + Attribute::AttrKind Kind) const; /// Return the attribute object that exists at the given index. - Attribute getAttributeAtIndex(unsigned Index, StringRef Kind) const; + LLVM_ABI Attribute getAttributeAtIndex(unsigned Index, StringRef Kind) const; /// Return the attribute object that exists at the arg index. Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const { @@ -906,75 +915,76 @@ public: } /// Return the alignment of the return value. - MaybeAlign getRetAlignment() const; + LLVM_ABI MaybeAlign getRetAlignment() const; /// Return the alignment for the specified function parameter. - MaybeAlign getParamAlignment(unsigned ArgNo) const; + LLVM_ABI MaybeAlign getParamAlignment(unsigned ArgNo) const; /// Return the stack alignment for the specified function parameter. - MaybeAlign getParamStackAlignment(unsigned ArgNo) const; + LLVM_ABI MaybeAlign getParamStackAlignment(unsigned ArgNo) const; /// Return the byval type for the specified function parameter. - Type *getParamByValType(unsigned ArgNo) const; + LLVM_ABI Type *getParamByValType(unsigned ArgNo) const; /// Return the sret type for the specified function parameter. - Type *getParamStructRetType(unsigned ArgNo) const; + LLVM_ABI Type *getParamStructRetType(unsigned ArgNo) const; /// Return the byref type for the specified function parameter. - Type *getParamByRefType(unsigned ArgNo) const; + LLVM_ABI Type *getParamByRefType(unsigned ArgNo) const; /// Return the preallocated type for the specified function parameter. - Type *getParamPreallocatedType(unsigned ArgNo) const; + LLVM_ABI Type *getParamPreallocatedType(unsigned ArgNo) const; /// Return the inalloca type for the specified function parameter. - Type *getParamInAllocaType(unsigned ArgNo) const; + LLVM_ABI Type *getParamInAllocaType(unsigned ArgNo) const; /// Return the elementtype type for the specified function parameter. - Type *getParamElementType(unsigned ArgNo) const; + LLVM_ABI Type *getParamElementType(unsigned ArgNo) const; /// Get the stack alignment of the function. - MaybeAlign getFnStackAlignment() const; + LLVM_ABI MaybeAlign getFnStackAlignment() const; /// Get the stack alignment of the return value. - MaybeAlign getRetStackAlignment() const; + LLVM_ABI MaybeAlign getRetStackAlignment() const; /// Get the number of dereferenceable bytes (or zero if unknown) of the return /// value. - uint64_t getRetDereferenceableBytes() const; + LLVM_ABI uint64_t getRetDereferenceableBytes() const; /// Get the number of dereferenceable bytes (or zero if unknown) of an arg. - uint64_t getParamDereferenceableBytes(unsigned Index) const; + LLVM_ABI uint64_t getParamDereferenceableBytes(unsigned Index) const; /// Get the number of dereferenceable_or_null bytes (or zero if unknown) of /// the return value. - uint64_t getRetDereferenceableOrNullBytes() const; + LLVM_ABI uint64_t getRetDereferenceableOrNullBytes() const; /// Get the number of dereferenceable_or_null bytes (or zero if unknown) of an /// arg. - uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const; + LLVM_ABI uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const; /// Get range (or std::nullopt if unknown) of an arg. - std::optional<ConstantRange> getParamRange(unsigned ArgNo) const; + LLVM_ABI std::optional<ConstantRange> getParamRange(unsigned ArgNo) const; /// Get the disallowed floating-point classes of the return value. - FPClassTest getRetNoFPClass() const; + LLVM_ABI FPClassTest getRetNoFPClass() const; /// Get the disallowed floating-point classes of the argument value. - FPClassTest getParamNoFPClass(unsigned ArgNo) const; + LLVM_ABI FPClassTest getParamNoFPClass(unsigned ArgNo) const; /// Get the unwind table kind requested for the function. - UWTableKind getUWTableKind() const; + LLVM_ABI UWTableKind getUWTableKind() const; - AllocFnKind getAllocKind() const; + LLVM_ABI AllocFnKind getAllocKind() const; /// Returns memory effects of the function. - MemoryEffects getMemoryEffects() const; + LLVM_ABI MemoryEffects getMemoryEffects() const; /// Return the attributes at the index as a string. - std::string getAsString(unsigned Index, bool InAttrGrp = false) const; + LLVM_ABI std::string getAsString(unsigned Index, + bool InAttrGrp = false) const; /// Return true if this attribute list belongs to the LLVMContext. - bool hasParentContext(LLVMContext &C) const; + LLVM_ABI bool hasParentContext(LLVMContext &C) const; //===--------------------------------------------------------------------===// // AttributeList Introspection @@ -982,10 +992,10 @@ public: using iterator = const AttributeSet *; - iterator begin() const; - iterator end() const; + LLVM_ABI iterator begin() const; + LLVM_ABI iterator end() const; - unsigned getNumAttrSets() const; + LLVM_ABI unsigned getNumAttrSets() const; // Implementation of indexes(). Produces iterators that wrap an index. Mostly // to hide the awkwardness of unsigned wrapping when iterating over valid @@ -1026,9 +1036,9 @@ public: /// Return true if there are no attributes. bool isEmpty() const { return pImpl == nullptr; } - void print(raw_ostream &O) const; + LLVM_ABI void print(raw_ostream &O) const; - void dump() const; + LLVM_ABI void dump() const; }; //===----------------------------------------------------------------------===// @@ -1076,24 +1086,24 @@ public: addAttribute(A); } - AttrBuilder(LLVMContext &Ctx, AttributeSet AS); + LLVM_ABI AttrBuilder(LLVMContext &Ctx, AttributeSet AS); - void clear(); + LLVM_ABI void clear(); /// Add an attribute to the builder. - AttrBuilder &addAttribute(Attribute::AttrKind Val); + LLVM_ABI AttrBuilder &addAttribute(Attribute::AttrKind Val); /// Add the Attribute object to the builder. - AttrBuilder &addAttribute(Attribute A); + LLVM_ABI AttrBuilder &addAttribute(Attribute A); /// Add the target-dependent attribute to the builder. - AttrBuilder &addAttribute(StringRef A, StringRef V = StringRef()); + LLVM_ABI AttrBuilder &addAttribute(StringRef A, StringRef V = StringRef()); /// Remove an attribute from the builder. - AttrBuilder &removeAttribute(Attribute::AttrKind Val); + LLVM_ABI AttrBuilder &removeAttribute(Attribute::AttrKind Val); /// Remove the target-dependent attribute from the builder. - AttrBuilder &removeAttribute(StringRef A); + LLVM_ABI AttrBuilder &removeAttribute(StringRef A); /// Remove the target-dependent attribute from the builder. AttrBuilder &removeAttribute(Attribute A) { @@ -1105,40 +1115,41 @@ public: /// Add the attributes from the builder. Attributes in the passed builder /// overwrite attributes in this builder if they have the same key. - AttrBuilder &merge(const AttrBuilder &B); + LLVM_ABI AttrBuilder &merge(const AttrBuilder &B); /// Remove the attributes from the builder. - AttrBuilder &remove(const AttributeMask &AM); + LLVM_ABI AttrBuilder &remove(const AttributeMask &AM); /// Return true if the builder has any attribute that's in the /// specified builder. - bool overlaps(const AttributeMask &AM) const; + LLVM_ABI bool overlaps(const AttributeMask &AM) const; /// Return true if the builder has the specified attribute. - bool contains(Attribute::AttrKind A) const; + LLVM_ABI bool contains(Attribute::AttrKind A) const; /// Return true if the builder has the specified target-dependent /// attribute. - bool contains(StringRef A) const; + LLVM_ABI bool contains(StringRef A) const; /// Return true if the builder has IR-level attributes. bool hasAttributes() const { return !Attrs.empty(); } /// Return Attribute with the given Kind. The returned attribute will be /// invalid if the Kind is not present in the builder. - Attribute getAttribute(Attribute::AttrKind Kind) const; + LLVM_ABI Attribute getAttribute(Attribute::AttrKind Kind) const; /// Return Attribute with the given Kind. The returned attribute will be /// invalid if the Kind is not present in the builder. - Attribute getAttribute(StringRef Kind) const; + LLVM_ABI Attribute getAttribute(StringRef Kind) const; /// Retrieve the range if the attribute exists (std::nullopt is returned /// otherwise). - std::optional<ConstantRange> getRange() const; + LLVM_ABI std::optional<ConstantRange> getRange() const; /// Return raw (possibly packed/encoded) value of integer attribute or /// std::nullopt if not set. - std::optional<uint64_t> getRawIntAttr(Attribute::AttrKind Kind) const; + LLVM_ABI std::optional<uint64_t> + getRawIntAttr(Attribute::AttrKind Kind) const; /// Retrieve the alignment attribute, if it exists. MaybeAlign getAlignment() const { @@ -1170,7 +1181,7 @@ public: } /// Retrieve type for the given type attribute. - Type *getTypeAttr(Attribute::AttrKind Kind) const; + LLVM_ABI Type *getTypeAttr(Attribute::AttrKind Kind) const; /// Retrieve the byval type. Type *getByValType() const { return getTypeAttr(Attribute::ByVal); } @@ -1191,15 +1202,15 @@ public: /// Retrieve the allocsize args, or std::nullopt if the attribute does not /// exist. - std::optional<std::pair<unsigned, std::optional<unsigned>>> getAllocSizeArgs() - const; + LLVM_ABI std::optional<std::pair<unsigned, std::optional<unsigned>>> + getAllocSizeArgs() const; /// Add integer attribute with raw value (packed/encoded if necessary). - AttrBuilder &addRawIntAttr(Attribute::AttrKind Kind, uint64_t Value); + LLVM_ABI AttrBuilder &addRawIntAttr(Attribute::AttrKind Kind, uint64_t Value); /// This turns an alignment into the form used internally in Attribute. /// This call has no effect if Align is not set. - AttrBuilder &addAlignmentAttr(MaybeAlign Align); + LLVM_ABI AttrBuilder &addAlignmentAttr(MaybeAlign Align); /// This turns an int alignment (which must be a power of 2) into the /// form used internally in Attribute. @@ -1211,7 +1222,7 @@ public: /// This turns a stack alignment into the form used internally in Attribute. /// This call has no effect if Align is not set. - AttrBuilder &addStackAlignmentAttr(MaybeAlign Align); + LLVM_ABI AttrBuilder &addStackAlignmentAttr(MaybeAlign Align); /// This turns an int stack alignment (which must be a power of 2) into /// the form used internally in Attribute. @@ -1223,84 +1234,86 @@ public: /// This turns the number of dereferenceable bytes into the form used /// internally in Attribute. - AttrBuilder &addDereferenceableAttr(uint64_t Bytes); + LLVM_ABI AttrBuilder &addDereferenceableAttr(uint64_t Bytes); /// This turns the number of dereferenceable_or_null bytes into the /// form used internally in Attribute. - AttrBuilder &addDereferenceableOrNullAttr(uint64_t Bytes); + LLVM_ABI AttrBuilder &addDereferenceableOrNullAttr(uint64_t Bytes); /// This turns one (or two) ints into the form used internally in Attribute. - AttrBuilder &addAllocSizeAttr(unsigned ElemSizeArg, - const std::optional<unsigned> &NumElemsArg); + LLVM_ABI AttrBuilder & + addAllocSizeAttr(unsigned ElemSizeArg, + const std::optional<unsigned> &NumElemsArg); /// This turns two ints into the form used internally in Attribute. - AttrBuilder &addVScaleRangeAttr(unsigned MinValue, - std::optional<unsigned> MaxValue); + LLVM_ABI AttrBuilder &addVScaleRangeAttr(unsigned MinValue, + std::optional<unsigned> MaxValue); /// Add a type attribute with the given type. - AttrBuilder &addTypeAttr(Attribute::AttrKind Kind, Type *Ty); + LLVM_ABI AttrBuilder &addTypeAttr(Attribute::AttrKind Kind, Type *Ty); /// This turns a byval type into the form used internally in Attribute. - AttrBuilder &addByValAttr(Type *Ty); + LLVM_ABI AttrBuilder &addByValAttr(Type *Ty); /// This turns a sret type into the form used internally in Attribute. - AttrBuilder &addStructRetAttr(Type *Ty); + LLVM_ABI AttrBuilder &addStructRetAttr(Type *Ty); /// This turns a byref type into the form used internally in Attribute. - AttrBuilder &addByRefAttr(Type *Ty); + LLVM_ABI AttrBuilder &addByRefAttr(Type *Ty); /// This turns a preallocated type into the form used internally in Attribute. - AttrBuilder &addPreallocatedAttr(Type *Ty); + LLVM_ABI AttrBuilder &addPreallocatedAttr(Type *Ty); /// This turns an inalloca type into the form used internally in Attribute. - AttrBuilder &addInAllocaAttr(Type *Ty); + LLVM_ABI AttrBuilder &addInAllocaAttr(Type *Ty); /// Add an allocsize attribute, using the representation returned by /// Attribute.getIntValue(). - AttrBuilder &addAllocSizeAttrFromRawRepr(uint64_t RawAllocSizeRepr); + LLVM_ABI AttrBuilder &addAllocSizeAttrFromRawRepr(uint64_t RawAllocSizeRepr); /// Add a vscale_range attribute, using the representation returned by /// Attribute.getIntValue(). - AttrBuilder &addVScaleRangeAttrFromRawRepr(uint64_t RawVScaleRangeRepr); + LLVM_ABI AttrBuilder & + addVScaleRangeAttrFromRawRepr(uint64_t RawVScaleRangeRepr); /// This turns the unwind table kind into the form used internally in /// Attribute. - AttrBuilder &addUWTableAttr(UWTableKind Kind); + LLVM_ABI AttrBuilder &addUWTableAttr(UWTableKind Kind); // This turns the allocator kind into the form used internally in Attribute. - AttrBuilder &addAllocKindAttr(AllocFnKind Kind); + LLVM_ABI AttrBuilder &addAllocKindAttr(AllocFnKind Kind); /// Add memory effect attribute. - AttrBuilder &addMemoryAttr(MemoryEffects ME); + LLVM_ABI AttrBuilder &addMemoryAttr(MemoryEffects ME); /// Add captures attribute. - AttrBuilder &addCapturesAttr(CaptureInfo CI); + LLVM_ABI AttrBuilder &addCapturesAttr(CaptureInfo CI); // Add nofpclass attribute - AttrBuilder &addNoFPClassAttr(FPClassTest NoFPClassMask); + LLVM_ABI AttrBuilder &addNoFPClassAttr(FPClassTest NoFPClassMask); /// Add a ConstantRange attribute with the given range. - AttrBuilder &addConstantRangeAttr(Attribute::AttrKind Kind, - const ConstantRange &CR); + LLVM_ABI AttrBuilder &addConstantRangeAttr(Attribute::AttrKind Kind, + const ConstantRange &CR); /// Add range attribute. - AttrBuilder &addRangeAttr(const ConstantRange &CR); + LLVM_ABI AttrBuilder &addRangeAttr(const ConstantRange &CR); /// Add a ConstantRangeList attribute with the given ranges. - AttrBuilder &addConstantRangeListAttr(Attribute::AttrKind Kind, - ArrayRef<ConstantRange> Val); + LLVM_ABI AttrBuilder &addConstantRangeListAttr(Attribute::AttrKind Kind, + ArrayRef<ConstantRange> Val); /// Add initializes attribute. - AttrBuilder &addInitializesAttr(const ConstantRangeList &CRL); + LLVM_ABI AttrBuilder &addInitializesAttr(const ConstantRangeList &CRL); /// Add 0 or more parameter attributes which are equivalent to metadata /// attached to \p I. e.g. !align -> align. This assumes the argument type is /// the same as the original instruction and the attribute is compatible. - AttrBuilder &addFromEquivalentMetadata(const Instruction &I); + LLVM_ABI AttrBuilder &addFromEquivalentMetadata(const Instruction &I); ArrayRef<Attribute> attrs() const { return Attrs; } - bool operator==(const AttrBuilder &B) const; + LLVM_ABI bool operator==(const AttrBuilder &B) const; bool operator!=(const AttrBuilder &B) const { return !(*this == B); } }; @@ -1314,7 +1327,7 @@ enum AttributeSafetyKind : uint8_t { /// Returns true if this is a type legal for the 'nofpclass' attribute. This /// follows the same type rules as FPMathOperator. -bool isNoFPClassCompatibleType(Type *Ty); +LLVM_ABI bool isNoFPClassCompatibleType(Type *Ty); /// Which attributes cannot be applied to a type. The argument \p AS /// is used as a hint for the attributes whose compatibility is being @@ -1325,20 +1338,20 @@ bool isNoFPClassCompatibleType(Type *Ty); /// attributes that are known to be safely droppable are contained in /// the mask; only attributes that might be unsafe to drop (e.g., /// ABI-related attributes) are in the mask; or both. -AttributeMask typeIncompatible(Type *Ty, AttributeSet AS, - AttributeSafetyKind ASK = ASK_ALL); +LLVM_ABI AttributeMask typeIncompatible(Type *Ty, AttributeSet AS, + AttributeSafetyKind ASK = ASK_ALL); /// Get param/return attributes which imply immediate undefined behavior if an /// invalid value is passed. For example, this includes noundef (where undef /// implies UB), but not nonnull (where null implies poison). It also does not /// include attributes like nocapture, which constrain the function /// implementation rather than the passed value. -AttributeMask getUBImplyingAttributes(); +LLVM_ABI AttributeMask getUBImplyingAttributes(); /// \returns Return true if the two functions have compatible target-independent /// attributes for inlining purposes. -bool areInlineCompatible(const Function &Caller, const Function &Callee); - +LLVM_ABI bool areInlineCompatible(const Function &Caller, + const Function &Callee); /// Checks if there are any incompatible function attributes between /// \p A and \p B. @@ -1346,19 +1359,21 @@ bool areInlineCompatible(const Function &Caller, const Function &Callee); /// \param [in] A - The first function to be compared with. /// \param [in] B - The second function to be compared with. /// \returns true if the functions have compatible attributes. -bool areOutlineCompatible(const Function &A, const Function &B); +LLVM_ABI bool areOutlineCompatible(const Function &A, const Function &B); /// Merge caller's and callee's attributes. -void mergeAttributesForInlining(Function &Caller, const Function &Callee); +LLVM_ABI void mergeAttributesForInlining(Function &Caller, + const Function &Callee); /// Merges the functions attributes from \p ToMerge into function \p Base. /// /// \param [in,out] Base - The function being merged into. /// \param [in] ToMerge - The function to merge attributes from. -void mergeAttributesForOutlining(Function &Base, const Function &ToMerge); +LLVM_ABI void mergeAttributesForOutlining(Function &Base, + const Function &ToMerge); /// Update min-legal-vector-width if it is in Attribute and less than Width. -void updateMinLegalVectorWidthAttr(Function &Fn, uint64_t Width); +LLVM_ABI void updateMinLegalVectorWidthAttr(Function &Fn, uint64_t Width); } // end namespace AttributeFuncs diff --git a/llvm/include/llvm/IR/AutoUpgrade.h b/llvm/include/llvm/IR/AutoUpgrade.h index 8c09356..31096e8 100644 --- a/llvm/include/llvm/IR/AutoUpgrade.h +++ b/llvm/include/llvm/IR/AutoUpgrade.h @@ -14,6 +14,7 @@ #define LLVM_IR_AUTOUPGRADE_H #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Compiler.h" #include <vector> namespace llvm { @@ -36,62 +37,64 @@ namespace llvm { /// for upgrading, and returns true if it requires upgrading. It may return /// null in NewFn if the all calls to the original intrinsic function /// should be transformed to non-function-call instructions. - bool UpgradeIntrinsicFunction(Function *F, Function *&NewFn, - bool CanUpgradeDebugIntrinsicsToRecords = true); + LLVM_ABI bool + UpgradeIntrinsicFunction(Function *F, Function *&NewFn, + bool CanUpgradeDebugIntrinsicsToRecords = true); /// This is the complement to the above, replacing a specific call to an /// intrinsic function with a call to the specified new function. - void UpgradeIntrinsicCall(CallBase *CB, Function *NewFn); + LLVM_ABI void UpgradeIntrinsicCall(CallBase *CB, Function *NewFn); // This upgrades the comment for objc retain release markers in inline asm // calls - void UpgradeInlineAsmString(std::string *AsmStr); + LLVM_ABI void UpgradeInlineAsmString(std::string *AsmStr); /// This is an auto-upgrade hook for any old intrinsic function syntaxes /// which need to have both the function updated as well as all calls updated /// to the new function. This should only be run in a post-processing fashion /// so that it can update all calls to the old function. - void UpgradeCallsToIntrinsic(Function* F); + LLVM_ABI void UpgradeCallsToIntrinsic(Function *F); /// This checks for global variables which should be upgraded. If it requires /// upgrading, returns a pointer to the upgraded variable. - GlobalVariable *UpgradeGlobalVariable(GlobalVariable *GV); + LLVM_ABI GlobalVariable *UpgradeGlobalVariable(GlobalVariable *GV); /// This checks for module flags which should be upgraded. It returns true if /// module is modified. - bool UpgradeModuleFlags(Module &M); + LLVM_ABI bool UpgradeModuleFlags(Module &M); /// Convert legacy nvvm.annotations metadata to appropriate function /// attributes. - void UpgradeNVVMAnnotations(Module &M); + LLVM_ABI void UpgradeNVVMAnnotations(Module &M); /// Convert calls to ARC runtime functions to intrinsic calls and upgrade the /// old retain release marker to new module flag format. - void UpgradeARCRuntime(Module &M); + LLVM_ABI void UpgradeARCRuntime(Module &M); - void UpgradeSectionAttributes(Module &M); + LLVM_ABI void UpgradeSectionAttributes(Module &M); /// Correct any IR that is relying on old function attribute behavior. - void UpgradeFunctionAttributes(Function &F); + LLVM_ABI void UpgradeFunctionAttributes(Function &F); /// If the given TBAA tag uses the scalar TBAA format, create a new node /// corresponding to the upgrade to the struct-path aware TBAA format. /// Otherwise return the \p TBAANode itself. - MDNode *UpgradeTBAANode(MDNode &TBAANode); + LLVM_ABI MDNode *UpgradeTBAANode(MDNode &TBAANode); /// This is an auto-upgrade for bitcast between pointers with different /// address spaces: the instruction is replaced by a pair ptrtoint+inttoptr. - Instruction *UpgradeBitCastInst(unsigned Opc, Value *V, Type *DestTy, - Instruction *&Temp); + LLVM_ABI Instruction *UpgradeBitCastInst(unsigned Opc, Value *V, Type *DestTy, + Instruction *&Temp); /// This is an auto-upgrade for bitcast constant expression between pointers /// with different address spaces: the instruction is replaced by a pair /// ptrtoint+inttoptr. - Constant *UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy); + LLVM_ABI Constant *UpgradeBitCastExpr(unsigned Opc, Constant *C, + Type *DestTy); /// Check the debug info version number, if it is out-dated, drop the debug /// info. Return true if module is modified. - bool UpgradeDebugInfo(Module &M); + LLVM_ABI bool UpgradeDebugInfo(Module &M); /// Check whether a string looks like an old loop attachment tag. inline bool mayBeOldLoopAttachmentTag(StringRef Name) { @@ -99,17 +102,18 @@ namespace llvm { } /// Upgrade the loop attachment metadata node. - MDNode *upgradeInstructionLoopAttachment(MDNode &N); + LLVM_ABI MDNode *upgradeInstructionLoopAttachment(MDNode &N); /// Upgrade the datalayout string by adding a section for address space /// pointers. - std::string UpgradeDataLayoutString(StringRef DL, StringRef Triple); + LLVM_ABI std::string UpgradeDataLayoutString(StringRef DL, StringRef Triple); /// Upgrade attributes that changed format or kind. - void UpgradeAttributes(AttrBuilder &B); + LLVM_ABI void UpgradeAttributes(AttrBuilder &B); /// Upgrade operand bundles (without knowing about their user instruction). - void UpgradeOperandBundles(std::vector<OperandBundleDef> &OperandBundles); + LLVM_ABI void + UpgradeOperandBundles(std::vector<OperandBundleDef> &OperandBundles); } // End llvm namespace diff --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h index 6e62b88..b5ad0de 100644 --- a/llvm/include/llvm/IR/BasicBlock.h +++ b/llvm/include/llvm/IR/BasicBlock.h @@ -24,6 +24,7 @@ #include "llvm/IR/Instruction.h" #include "llvm/IR/SymbolTableListTraits.h" #include "llvm/IR/Value.h" +#include "llvm/Support/Compiler.h" #include <cassert> #include <cstddef> #include <iterator> @@ -81,25 +82,25 @@ private: public: /// Attach a DbgMarker to the given instruction. Enables the storage of any /// debug-info at this position in the program. - DbgMarker *createMarker(Instruction *I); - DbgMarker *createMarker(InstListType::iterator It); + LLVM_ABI DbgMarker *createMarker(Instruction *I); + LLVM_ABI DbgMarker *createMarker(InstListType::iterator It); /// Convert variable location debugging information stored in dbg.value /// intrinsics into DbgMarkers / DbgRecords. Deletes all dbg.values in /// the process and sets IsNewDbgInfoFormat = true. Only takes effect if /// the UseNewDbgInfoFormat LLVM command line option is given. - void convertToNewDbgValues(); + LLVM_ABI void convertToNewDbgValues(); /// Convert variable location debugging information stored in DbgMarkers and /// DbgRecords into the dbg.value intrinsic representation. Sets /// IsNewDbgInfoFormat = false. - void convertFromNewDbgValues(); + LLVM_ABI void convertFromNewDbgValues(); /// Ensure the block is in "old" dbg.value format (\p NewFlag == false) or /// in the new format (\p NewFlag == true), converting to the desired format /// if necessary. - void setIsNewDbgInfoFormat(bool NewFlag); - void setNewDbgInfoFormatFlag(bool NewFlag); + LLVM_ABI void setIsNewDbgInfoFormat(bool NewFlag); + LLVM_ABI void setNewDbgInfoFormatFlag(bool NewFlag); unsigned getNumber() const { assert(getParent() && "only basic blocks in functions have valid numbers"); @@ -110,48 +111,50 @@ public: /// instruction of this block. These are equivalent to dbg.value intrinsics /// that exist at the end of a basic block with no terminator (a transient /// state that occurs regularly). - void setTrailingDbgRecords(DbgMarker *M); + LLVM_ABI void setTrailingDbgRecords(DbgMarker *M); /// Fetch the collection of DbgRecords that "trail" after the last instruction /// of this block, see \ref setTrailingDbgRecords. If there are none, returns /// nullptr. - DbgMarker *getTrailingDbgRecords(); + LLVM_ABI DbgMarker *getTrailingDbgRecords(); /// Delete any trailing DbgRecords at the end of this block, see /// \ref setTrailingDbgRecords. - void deleteTrailingDbgRecords(); + LLVM_ABI void deleteTrailingDbgRecords(); - void dumpDbgValues() const; + LLVM_ABI void dumpDbgValues() const; /// Return the DbgMarker for the position given by \p It, so that DbgRecords /// can be inserted there. This will either be nullptr if not present, a /// DbgMarker, or TrailingDbgRecords if It is end(). - DbgMarker *getMarker(InstListType::iterator It); + LLVM_ABI DbgMarker *getMarker(InstListType::iterator It); /// Return the DbgMarker for the position that comes after \p I. \see /// BasicBlock::getMarker, this can be nullptr, a DbgMarker, or /// TrailingDbgRecords if there is no next instruction. - DbgMarker *getNextMarker(Instruction *I); + LLVM_ABI DbgMarker *getNextMarker(Instruction *I); /// Insert a DbgRecord into a block at the position given by \p I. - void insertDbgRecordAfter(DbgRecord *DR, Instruction *I); + LLVM_ABI void insertDbgRecordAfter(DbgRecord *DR, Instruction *I); /// Insert a DbgRecord into a block at the position given by \p Here. - void insertDbgRecordBefore(DbgRecord *DR, InstListType::iterator Here); + LLVM_ABI void insertDbgRecordBefore(DbgRecord *DR, + InstListType::iterator Here); /// Eject any debug-info trailing at the end of a block. DbgRecords can /// transiently be located "off the end" of a block if the blocks terminator /// is temporarily removed. Once a terminator is re-inserted this method will /// move such DbgRecords back to the right place (ahead of the terminator). - void flushTerminatorDbgRecords(); + LLVM_ABI void flushTerminatorDbgRecords(); /// In rare circumstances instructions can be speculatively removed from /// blocks, and then be re-inserted back into that position later. When this /// happens in RemoveDIs debug-info mode, some special patching-up needs to /// occur: inserting into the middle of a sequence of dbg.value intrinsics /// does not have an equivalent with DbgRecords. - void reinsertInstInDbgRecords(Instruction *I, - std::optional<DbgRecord::self_iterator> Pos); + LLVM_ABI void + reinsertInstInDbgRecords(Instruction *I, + std::optional<DbgRecord::self_iterator> Pos); private: void setParent(Function *parent); @@ -161,17 +164,17 @@ private: /// If the function parameter is specified, the basic block is automatically /// inserted at either the end of the function (if InsertBefore is null), or /// before the specified basic block. - explicit BasicBlock(LLVMContext &C, const Twine &Name = "", - Function *Parent = nullptr, - BasicBlock *InsertBefore = nullptr); + LLVM_ABI explicit BasicBlock(LLVMContext &C, const Twine &Name = "", + Function *Parent = nullptr, + BasicBlock *InsertBefore = nullptr); public: BasicBlock(const BasicBlock &) = delete; BasicBlock &operator=(const BasicBlock &) = delete; - ~BasicBlock(); + LLVM_ABI ~BasicBlock(); /// Get the context in which this basic block lives. - LLVMContext &getContext() const; + LLVM_ABI LLVMContext &getContext() const; /// Instruction iterators... using iterator = InstListType::iterator; @@ -224,7 +227,7 @@ public: /// nullptr if the function does not have a module. /// /// Note: this is undefined behavior if the block does not have a parent. - const Module *getModule() const; + LLVM_ABI const Module *getModule() const; Module *getModule() { return const_cast<Module *>( static_cast<const BasicBlock *>(this)->getModule()); @@ -233,10 +236,10 @@ public: /// Get the data layout of the module this basic block belongs to. /// /// Requires the basic block to have a parent module. - const DataLayout &getDataLayout() const; + 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. + /// 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; @@ -250,7 +253,7 @@ public: /// Returns the call instruction calling \@llvm.experimental.deoptimize /// prior to the terminating return instruction of this basic block, if such /// a call is present. Otherwise, returns null. - const CallInst *getTerminatingDeoptimizeCall() const; + LLVM_ABI const CallInst *getTerminatingDeoptimizeCall() const; CallInst *getTerminatingDeoptimizeCall() { return const_cast<CallInst *>( static_cast<const BasicBlock *>(this)->getTerminatingDeoptimizeCall()); @@ -260,7 +263,7 @@ public: /// that is present either in current basic block or in block that is a unique /// successor to current block, if such call is present. Otherwise, returns /// null. - const CallInst *getPostdominatingDeoptimizeCall() const; + LLVM_ABI const CallInst *getPostdominatingDeoptimizeCall() const; CallInst *getPostdominatingDeoptimizeCall() { return const_cast<CallInst *>(static_cast<const BasicBlock *>(this) ->getPostdominatingDeoptimizeCall()); @@ -269,7 +272,7 @@ public: /// Returns the call instruction marked 'musttail' prior to the terminating /// return instruction of this basic block, if such a call is present. /// Otherwise, returns null. - const CallInst *getTerminatingMustTailCall() const; + LLVM_ABI const CallInst *getTerminatingMustTailCall() const; CallInst *getTerminatingMustTailCall() { return const_cast<CallInst *>( static_cast<const BasicBlock *>(this)->getTerminatingMustTailCall()); @@ -284,11 +287,11 @@ public: /// /// Deprecated in favour of getFirstNonPHIIt, which returns an iterator that /// preserves some debugging information. - LLVM_DEPRECATED("Use iterators as instruction positions", "getFirstNonPHIIt") - const Instruction *getFirstNonPHI() const; - LLVM_DEPRECATED("Use iterators as instruction positions instead", - "getFirstNonPHIIt") - Instruction *getFirstNonPHI(); + LLVM_ABI LLVM_DEPRECATED("Use iterators as instruction positions", + "getFirstNonPHIIt") const + Instruction *getFirstNonPHI() const; + LLVM_ABI LLVM_DEPRECATED("Use iterators as instruction positions instead", + "getFirstNonPHIIt") Instruction *getFirstNonPHI(); /// Returns an iterator to the first instruction in this block that is not a /// PHINode instruction. @@ -299,7 +302,7 @@ public: /// /// Avoid unwrapping the iterator to an Instruction* before inserting here, /// as important debug-info is preserved in the iterator. - InstListType::const_iterator getFirstNonPHIIt() const; + LLVM_ABI InstListType::const_iterator getFirstNonPHIIt() const; InstListType::iterator getFirstNonPHIIt() { BasicBlock::iterator It = static_cast<const BasicBlock *>(this)->getFirstNonPHIIt().getNonConst(); @@ -310,7 +313,7 @@ public: /// Returns a pointer to the first instruction in this block that is not a /// PHINode or a debug intrinsic, or any pseudo operation if \c SkipPseudoOp /// is true. - InstListType::const_iterator + LLVM_ABI InstListType::const_iterator getFirstNonPHIOrDbg(bool SkipPseudoOp = true) const; InstListType::iterator getFirstNonPHIOrDbg(bool SkipPseudoOp = true) { return static_cast<const BasicBlock *>(this) @@ -321,7 +324,7 @@ public: /// Returns a pointer to the first instruction in this block that is not a /// PHINode, a debug intrinsic, or a lifetime intrinsic, or any pseudo /// operation if \c SkipPseudoOp is true. - InstListType::const_iterator + LLVM_ABI InstListType::const_iterator getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp = true) const; InstListType::iterator getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp = true) { @@ -334,7 +337,7 @@ public: /// suitable for inserting a non-PHI instruction. /// /// In particular, it skips all PHIs and LandingPad instructions. - const_iterator getFirstInsertionPt() const; + LLVM_ABI const_iterator getFirstInsertionPt() const; iterator getFirstInsertionPt() { return static_cast<const BasicBlock *>(this) ->getFirstInsertionPt() @@ -343,7 +346,7 @@ public: /// Returns an iterator to the first instruction in this block that is /// not a PHINode, a debug intrinsic, a static alloca or any pseudo operation. - const_iterator getFirstNonPHIOrDbgOrAlloca() const; + LLVM_ABI const_iterator getFirstNonPHIOrDbgOrAlloca() const; iterator getFirstNonPHIOrDbgOrAlloca() { return static_cast<const BasicBlock *>(this) ->getFirstNonPHIOrDbgOrAlloca() @@ -353,7 +356,7 @@ public: /// Returns the first potential AsynchEH faulty instruction /// currently it checks for loads/stores (which may dereference a null /// pointer) and calls/invokes (which may propagate exceptions) - const Instruction *getFirstMayFaultInst() const; + LLVM_ABI const Instruction *getFirstMayFaultInst() const; Instruction *getFirstMayFaultInst() { return const_cast<Instruction *>( static_cast<const BasicBlock *>(this)->getFirstMayFaultInst()); @@ -362,6 +365,7 @@ public: /// Return a const iterator range over the instructions in the block, skipping /// any debug instructions. Skip any pseudo operations as well if \c /// SkipPseudoOp is true. + LLVM_ABI iterator_range<filter_iterator<BasicBlock::const_iterator, std::function<bool(const Instruction &)>>> instructionsWithoutDebug(bool SkipPseudoOp = true) const; @@ -369,33 +373,34 @@ public: /// Return an iterator range over the instructions in the block, skipping any /// debug instructions. Skip and any pseudo operations as well if \c /// SkipPseudoOp is true. - iterator_range< + LLVM_ABI iterator_range< filter_iterator<BasicBlock::iterator, std::function<bool(Instruction &)>>> instructionsWithoutDebug(bool SkipPseudoOp = true); /// Return the size of the basic block ignoring debug instructions + LLVM_ABI filter_iterator<BasicBlock::const_iterator, std::function<bool(const Instruction &)>>::difference_type sizeWithoutDebug() const; /// Unlink 'this' from the containing function, but do not delete it. - void removeFromParent(); + LLVM_ABI void removeFromParent(); /// Unlink 'this' from the containing function and delete it. /// // \returns an iterator pointing to the element after the erased one. - SymbolTableList<BasicBlock>::iterator eraseFromParent(); + LLVM_ABI SymbolTableList<BasicBlock>::iterator eraseFromParent(); /// Unlink this basic block from its current function and insert it into /// the function that \p MovePos lives in, right before \p MovePos. inline void moveBefore(BasicBlock *MovePos) { moveBefore(MovePos->getIterator()); } - void moveBefore(SymbolTableList<BasicBlock>::iterator MovePos); + LLVM_ABI void moveBefore(SymbolTableList<BasicBlock>::iterator MovePos); /// Unlink this basic block from its current function and insert it /// right after \p MovePos in the function \p MovePos lives in. - void moveAfter(BasicBlock *MovePos); + LLVM_ABI void moveAfter(BasicBlock *MovePos); /// Insert unlinked basic block into a function. /// @@ -403,11 +408,12 @@ public: /// provided, inserts before that basic block, otherwise inserts at the end. /// /// \pre \a getParent() is \c nullptr. - void insertInto(Function *Parent, BasicBlock *InsertBefore = nullptr); + LLVM_ABI void insertInto(Function *Parent, + BasicBlock *InsertBefore = nullptr); /// Return the predecessor of this block if it has a single predecessor /// block. Otherwise return a null pointer. - const BasicBlock *getSinglePredecessor() const; + LLVM_ABI const BasicBlock *getSinglePredecessor() const; BasicBlock *getSinglePredecessor() { return const_cast<BasicBlock *>( static_cast<const BasicBlock *>(this)->getSinglePredecessor()); @@ -419,23 +425,23 @@ public: /// Note that unique predecessor doesn't mean single edge, there can be /// multiple edges from the unique predecessor to this block (for example a /// switch statement with multiple cases having the same destination). - const BasicBlock *getUniquePredecessor() const; + LLVM_ABI const BasicBlock *getUniquePredecessor() const; BasicBlock *getUniquePredecessor() { return const_cast<BasicBlock *>( static_cast<const BasicBlock *>(this)->getUniquePredecessor()); } /// Return true if this block has exactly N predecessors. - bool hasNPredecessors(unsigned N) const; + LLVM_ABI bool hasNPredecessors(unsigned N) const; /// Return true if this block has N predecessors or more. - bool hasNPredecessorsOrMore(unsigned N) const; + LLVM_ABI bool hasNPredecessorsOrMore(unsigned N) const; /// Return the successor of this block if it has a single successor. /// Otherwise return a null pointer. /// /// This method is analogous to getSinglePredecessor above. - const BasicBlock *getSingleSuccessor() const; + LLVM_ABI const BasicBlock *getSingleSuccessor() const; BasicBlock *getSingleSuccessor() { return const_cast<BasicBlock *>( static_cast<const BasicBlock *>(this)->getSingleSuccessor()); @@ -445,7 +451,7 @@ public: /// Otherwise return a null pointer. /// /// This method is analogous to getUniquePredecessor above. - const BasicBlock *getUniqueSuccessor() const; + LLVM_ABI const BasicBlock *getUniqueSuccessor() const; BasicBlock *getUniqueSuccessor() { return const_cast<BasicBlock *>( static_cast<const BasicBlock *>(this)->getUniqueSuccessor()); @@ -453,9 +459,9 @@ public: /// Print the basic block to an output stream with an optional /// AssemblyAnnotationWriter. - void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW = nullptr, - bool ShouldPreserveUseListOrder = false, - bool IsForDebug = false) const; + LLVM_ABI void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW = nullptr, + bool ShouldPreserveUseListOrder = false, + bool IsForDebug = false) const; //===--------------------------------------------------------------------===// /// Instruction iterator methods @@ -532,7 +538,7 @@ public: iterator_range<const_phi_iterator> phis() const { return const_cast<BasicBlock *>(this)->phis(); } - iterator_range<phi_iterator> phis(); + LLVM_ABI iterator_range<phi_iterator> phis(); private: /// Return the underlying instruction list container. @@ -586,7 +592,7 @@ private: public: /// Returns a pointer to the symbol table if one exists. - ValueSymbolTable *getValueSymbolTable(); + LLVM_ABI ValueSymbolTable *getValueSymbolTable(); /// Methods for support type inquiry through isa, cast, and dyn_cast. static bool classof(const Value *V) { @@ -601,7 +607,7 @@ public: /// counts go to zero. Then everything is delete'd for real. Note that no /// operations are valid on an object that has "dropped all references", /// except operator delete. - void dropAllReferences(); + LLVM_ABI void dropAllReferences(); /// Update PHI nodes in this BasicBlock before removal of predecessor \p Pred. /// Note that this function does not actually remove the predecessor. @@ -609,9 +615,10 @@ public: /// If \p KeepOneInputPHIs is true then don't remove PHIs that are left with /// zero or one incoming values, and don't simplify PHIs with all incoming /// values the same. - void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs = false); + LLVM_ABI void removePredecessor(BasicBlock *Pred, + bool KeepOneInputPHIs = false); - bool canSplitPredecessors() const; + LLVM_ABI bool canSplitPredecessors() const; /// Split the basic block into two basic blocks at the specified instruction. /// @@ -631,8 +638,8 @@ public: /// /// Also note that this doesn't preserve any passes. To split blocks while /// keeping loop information consistent, use the SplitBlock utility function. - BasicBlock *splitBasicBlock(iterator I, const Twine &BBName = "", - bool Before = false); + LLVM_ABI BasicBlock *splitBasicBlock(iterator I, const Twine &BBName = "", + bool Before = false); BasicBlock *splitBasicBlock(Instruction *I, const Twine &BBName = "", bool Before = false) { return splitBasicBlock(I->getIterator(), BBName, Before); @@ -655,7 +662,8 @@ public: /// Also note that this doesn't preserve any passes. To split blocks while /// keeping loop information consistent, use the SplitBlockBefore utility /// function. - BasicBlock *splitBasicBlockBefore(iterator I, const Twine &BBName = ""); + LLVM_ABI BasicBlock *splitBasicBlockBefore(iterator I, + const Twine &BBName = ""); BasicBlock *splitBasicBlockBefore(Instruction *I, const Twine &BBName = "") { return splitBasicBlockBefore(I->getIterator(), BBName); } @@ -678,13 +686,14 @@ public: /// Transfer a range of instructions that belong to \p FromBB from \p /// FromBeginIt to \p FromEndIt, to this basic block at \p ToIt. - void splice(BasicBlock::iterator ToIt, BasicBlock *FromBB, - BasicBlock::iterator FromBeginIt, BasicBlock::iterator FromEndIt); + LLVM_ABI void splice(BasicBlock::iterator ToIt, BasicBlock *FromBB, + BasicBlock::iterator FromBeginIt, + BasicBlock::iterator FromEndIt); /// Erases a range of instructions from \p FromIt to (not including) \p ToIt. /// \Returns \p ToIt. - BasicBlock::iterator erase(BasicBlock::iterator FromIt, - BasicBlock::iterator ToIt); + LLVM_ABI BasicBlock::iterator erase(BasicBlock::iterator FromIt, + BasicBlock::iterator ToIt); /// Returns true if there are any uses of this basic block other than /// direct branches, switches, etc. to it. @@ -694,15 +703,15 @@ public: /// Update all phi nodes in this basic block to refer to basic block \p New /// instead of basic block \p Old. - void replacePhiUsesWith(BasicBlock *Old, BasicBlock *New); + LLVM_ABI void replacePhiUsesWith(BasicBlock *Old, BasicBlock *New); /// Update all phi nodes in this basic block's successors to refer to basic /// block \p New instead of basic block \p Old. - void replaceSuccessorsPhiUsesWith(BasicBlock *Old, BasicBlock *New); + LLVM_ABI void replaceSuccessorsPhiUsesWith(BasicBlock *Old, BasicBlock *New); /// Update all phi nodes in this basic block's successors to refer to basic /// block \p New instead of to it. - void replaceSuccessorsPhiUsesWith(BasicBlock *New); + LLVM_ABI void replaceSuccessorsPhiUsesWith(BasicBlock *New); /// Return true if this basic block is an exception handling block. bool isEHPad() const { return getFirstNonPHIIt()->isEHPad(); } @@ -711,23 +720,23 @@ public: /// /// Being a ``landing pad'' means that the basic block is the destination of /// the 'unwind' edge of an invoke instruction. - bool isLandingPad() const; + LLVM_ABI bool isLandingPad() const; /// Return the landingpad instruction associated with the landing pad. - const LandingPadInst *getLandingPadInst() const; + LLVM_ABI const LandingPadInst *getLandingPadInst() const; LandingPadInst *getLandingPadInst() { return const_cast<LandingPadInst *>( static_cast<const BasicBlock *>(this)->getLandingPadInst()); } /// Return true if it is legal to hoist instructions into this block. - bool isLegalToHoistInto() const; + LLVM_ABI bool isLegalToHoistInto() const; /// Return true if this is the entry block of the containing function. /// This method can only be used on blocks that have a parent function. - bool isEntryBlock() const; + LLVM_ABI bool isEntryBlock() const; - std::optional<uint64_t> getIrrLoopHeaderWeight() const; + LLVM_ABI std::optional<uint64_t> getIrrLoopHeaderWeight() const; /// Returns true if the Order field of child Instructions is valid. bool isInstrOrderValid() const { @@ -741,7 +750,7 @@ public: } /// Renumber instructions and mark the ordering as valid. - void renumberInstructions(); + LLVM_ABI void renumberInstructions(); /// Asserts that instruction order numbers are marked invalid, or that they /// are in ascending order. This is constant time if the ordering is invalid, @@ -759,7 +768,7 @@ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef) /// Advance \p It while it points to a debug instruction and return the result. /// This assumes that \p It is not at the end of a block. -BasicBlock::iterator skipDebugIntrinsics(BasicBlock::iterator It); +LLVM_ABI BasicBlock::iterator skipDebugIntrinsics(BasicBlock::iterator It); #ifdef NDEBUG /// In release builds, this is a no-op. For !NDEBUG builds, the checks are diff --git a/llvm/include/llvm/IR/BuiltinGCs.h b/llvm/include/llvm/IR/BuiltinGCs.h index 16aff01..aeb16ef 100644 --- a/llvm/include/llvm/IR/BuiltinGCs.h +++ b/llvm/include/llvm/IR/BuiltinGCs.h @@ -14,19 +14,21 @@ #ifndef LLVM_IR_BUILTINGCS_H #define LLVM_IR_BUILTINGCS_H +#include "llvm/Support/Compiler.h" + namespace llvm { /// FIXME: Collector instances are not useful on their own. These no longer /// serve any purpose except to link in the plugins. /// Ensure the definition of the builtin GCs gets linked in -void linkAllBuiltinGCs(); +LLVM_ABI void linkAllBuiltinGCs(); /// Creates an ocaml-compatible metadata printer. -void linkOcamlGCPrinter(); +LLVM_ABI void linkOcamlGCPrinter(); /// Creates an erlang-compatible metadata printer. -void linkErlangGCPrinter(); +LLVM_ABI void linkErlangGCPrinter(); } // namespace llvm diff --git a/llvm/include/llvm/IR/CmpPredicate.h b/llvm/include/llvm/IR/CmpPredicate.h index fca27a7..96b8542 100644 --- a/llvm/include/llvm/IR/CmpPredicate.h +++ b/llvm/include/llvm/IR/CmpPredicate.h @@ -14,6 +14,7 @@ #define LLVM_IR_CMPPREDICATE_H #include "llvm/IR/InstrTypes.h" +#include "llvm/Support/Compiler.h" namespace llvm { /// An abstraction over a floating-point predicate, and a pack of an integer @@ -54,14 +55,14 @@ public: /// samesign ult + slt -> slt /// ult + ult -> ult /// ult + slt -> std::nullopt - static std::optional<CmpPredicate> getMatching(CmpPredicate A, - CmpPredicate B); + LLVM_ABI static std::optional<CmpPredicate> getMatching(CmpPredicate A, + CmpPredicate B); /// Attempts to return a signed CmpInst::Predicate from the CmpPredicate. If /// the CmpPredicate has samesign, return ICmpInst::getSignedPredicate, /// dropping samesign information. Otherwise, return the predicate, dropping /// samesign information. - CmpInst::Predicate getPreferredSignedPredicate() const; + LLVM_ABI CmpInst::Predicate getPreferredSignedPredicate() const; /// An operator== on the underlying Predicate. bool operator==(CmpInst::Predicate P) const { return Pred == P; } @@ -74,13 +75,13 @@ public: /// Do a ICmpInst::getCmpPredicate() or CmpInst::getPredicate(), as /// appropriate. - static CmpPredicate get(const CmpInst *Cmp); + LLVM_ABI static CmpPredicate get(const CmpInst *Cmp); /// Get the swapped predicate of a CmpPredicate. - static CmpPredicate getSwapped(CmpPredicate P); + LLVM_ABI static CmpPredicate getSwapped(CmpPredicate P); /// Get the swapped predicate of a CmpInst. - static CmpPredicate getSwapped(const CmpInst *Cmp); + LLVM_ABI static CmpPredicate getSwapped(const CmpInst *Cmp); }; } // namespace llvm diff --git a/llvm/include/llvm/IR/Comdat.h b/llvm/include/llvm/IR/Comdat.h index 1701802..3865d0c 100644 --- a/llvm/include/llvm/IR/Comdat.h +++ b/llvm/include/llvm/IR/Comdat.h @@ -18,6 +18,7 @@ #include "llvm-c/Types.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/CBindingWrapping.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -41,13 +42,13 @@ public: }; Comdat(const Comdat &) = delete; - Comdat(Comdat &&C); + LLVM_ABI Comdat(Comdat &&C); SelectionKind getSelectionKind() const { return SK; } void setSelectionKind(SelectionKind Val) { SK = Val; } - StringRef getName() const; - void print(raw_ostream &OS, bool IsForDebug = false) const; - void dump() const; + LLVM_ABI StringRef getName() const; + LLVM_ABI void print(raw_ostream &OS, bool IsForDebug = false) const; + LLVM_ABI void dump() const; const SmallPtrSetImpl<GlobalObject *> &getUsers() const { return Users; } private: diff --git a/llvm/include/llvm/IR/Constant.h b/llvm/include/llvm/IR/Constant.h index 0aefb5e..0be1fc1 100644 --- a/llvm/include/llvm/IR/Constant.h +++ b/llvm/include/llvm/IR/Constant.h @@ -16,6 +16,7 @@ #include "llvm/IR/User.h" #include "llvm/IR/Value.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -51,84 +52,84 @@ public: Constant(const Constant &) = delete; /// Return true if this is the value that would be returned by getNullValue. - bool isNullValue() const; + LLVM_ABI bool isNullValue() const; /// Returns true if the value is one. - bool isOneValue() const; + LLVM_ABI bool isOneValue() const; /// Return true if the value is not the one value, or, /// for vectors, does not contain one value elements. - bool isNotOneValue() const; + LLVM_ABI bool isNotOneValue() const; /// Return true if this is the value that would be returned by /// getAllOnesValue. - bool isAllOnesValue() const; + LLVM_ABI bool isAllOnesValue() const; /// Return true if the value is what would be returned by /// getZeroValueForNegation. - bool isNegativeZeroValue() const; + LLVM_ABI bool isNegativeZeroValue() const; /// Return true if the value is negative zero or null value. - bool isZeroValue() const; + LLVM_ABI bool isZeroValue() const; /// Return true if the value is not the smallest signed value, or, /// for vectors, does not contain smallest signed value elements. - bool isNotMinSignedValue() const; + LLVM_ABI bool isNotMinSignedValue() const; /// Return true if the value is the smallest signed value. - bool isMinSignedValue() const; + LLVM_ABI bool isMinSignedValue() const; /// Return true if this is a finite and non-zero floating-point scalar /// constant or a fixed width vector constant with all finite and non-zero /// elements. - bool isFiniteNonZeroFP() const; + LLVM_ABI bool isFiniteNonZeroFP() const; /// Return true if this is a normal (as opposed to denormal, infinity, nan, /// or zero) floating-point scalar constant or a vector constant with all /// normal elements. See APFloat::isNormal. - bool isNormalFP() const; + LLVM_ABI bool isNormalFP() const; /// Return true if this scalar has an exact multiplicative inverse or this /// vector has an exact multiplicative inverse for each element in the vector. - bool hasExactInverseFP() const; + LLVM_ABI bool hasExactInverseFP() const; /// Return true if this is a floating-point NaN constant or a vector /// floating-point constant with all NaN elements. - bool isNaN() const; + LLVM_ABI bool isNaN() const; /// Return true if this constant and a constant 'Y' are element-wise equal. /// This is identical to just comparing the pointers, with the exception that /// for vectors, if only one of the constants has an `undef` element in some /// lane, the constants still match. - bool isElementWiseEqual(Value *Y) const; + LLVM_ABI bool isElementWiseEqual(Value *Y) const; /// Return true if this is a vector constant that includes any undef or /// poison elements. Since it is impossible to inspect a scalable vector /// element- wise at compile time, this function returns true only if the /// entire vector is undef or poison. - bool containsUndefOrPoisonElement() const; + LLVM_ABI bool containsUndefOrPoisonElement() const; /// Return true if this is a vector constant that includes any poison /// elements. - bool containsPoisonElement() const; + LLVM_ABI bool containsPoisonElement() const; /// Return true if this is a vector constant that includes any strictly undef /// (not poison) elements. - bool containsUndefElement() const; + LLVM_ABI bool containsUndefElement() const; /// Return true if this is a fixed width vector constant that includes /// any constant expressions. - bool containsConstantExpression() const; + LLVM_ABI bool containsConstantExpression() const; /// Return true if the value can vary between threads. - bool isThreadDependent() const; + LLVM_ABI bool isThreadDependent() const; /// Return true if the value is dependent on a dllimport variable. - bool isDLLImportDependent() const; + LLVM_ABI bool isDLLImportDependent() const; /// Return true if the constant has users other than constant expressions and /// other dangling things. - bool isConstantUsed() const; + LLVM_ABI bool isConstantUsed() const; /// This method classifies the entry according to whether or not it may /// generate a relocation entry (either static or dynamic). This must be @@ -136,28 +137,28 @@ public: /// so. /// /// FIXME: This really should not be in IR. - bool needsRelocation() const; - bool needsDynamicRelocation() const; + LLVM_ABI bool needsRelocation() const; + LLVM_ABI bool needsDynamicRelocation() const; /// For aggregates (struct/array/vector) return the constant that corresponds /// to the specified element if possible, or null if not. This can return null /// if the element index is a ConstantExpr, if 'this' is a constant expr or /// if the constant does not fit into an uint64_t. - Constant *getAggregateElement(unsigned Elt) const; - Constant *getAggregateElement(Constant *Elt) const; + LLVM_ABI Constant *getAggregateElement(unsigned Elt) const; + LLVM_ABI Constant *getAggregateElement(Constant *Elt) const; /// If all elements of the vector constant have the same value, return that /// value. Otherwise, return nullptr. Ignore poison elements by setting /// AllowPoison to true. - Constant *getSplatValue(bool AllowPoison = false) const; + LLVM_ABI Constant *getSplatValue(bool AllowPoison = false) const; /// If C is a constant integer then return its value, otherwise C must be a /// vector of constant integers, all equal, and the common value is returned. - const APInt &getUniqueInteger() const; + LLVM_ABI const APInt &getUniqueInteger() const; /// Convert constant to an approximate constant range. For vectors, the /// range is the union over the element ranges. Poison elements are ignored. - ConstantRange toConstantRange() const; + LLVM_ABI ConstantRange toConstantRange() const; /// Called if some element of this constant is no longer valid. /// At this point only other constants may be on the use_list for this @@ -166,7 +167,7 @@ public: /// available cached constants. Implementations should implement /// destroyConstantImpl to remove constants from any pools/maps they are /// contained it. - void destroyConstant(); + LLVM_ABI void destroyConstant(); //// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { @@ -184,36 +185,36 @@ public: /// use Value::replaceAllUsesWith, which automatically dispatches to this /// method as needed. /// - void handleOperandChange(Value *, Value *); + LLVM_ABI void handleOperandChange(Value *, Value *); - static Constant *getNullValue(Type* Ty); + LLVM_ABI static Constant *getNullValue(Type *Ty); /// @returns the value for an integer or vector of integer constant of the /// given type that has all its bits set to true. /// Get the all ones value - static Constant *getAllOnesValue(Type* Ty); + LLVM_ABI static Constant *getAllOnesValue(Type *Ty); /// Return the value for an integer or pointer constant, or a vector thereof, /// with the given scalar value. - static Constant *getIntegerValue(Type *Ty, const APInt &V); + LLVM_ABI static Constant *getIntegerValue(Type *Ty, const APInt &V); /// If there are any dead constant users dangling off of this constant, remove /// them. This method is useful for clients that want to check to see if a /// global is unused, but don't want to deal with potentially dead constants /// hanging off of the globals. - void removeDeadConstantUsers() const; + LLVM_ABI void removeDeadConstantUsers() const; /// Return true if the constant has exactly one live use. /// /// This returns the same result as calling Value::hasOneUse after /// Constant::removeDeadConstantUsers, but doesn't remove dead constants. - bool hasOneLiveUse() const; + LLVM_ABI bool hasOneLiveUse() const; /// Return true if the constant has no live uses. /// /// This returns the same result as calling Value::use_empty after /// Constant::removeDeadConstantUsers, but doesn't remove dead constants. - bool hasZeroLiveUses() const; + LLVM_ABI bool hasZeroLiveUses() const; const Constant *stripPointerCasts() const { return cast<Constant>(Value::stripPointerCasts()); @@ -226,17 +227,18 @@ public: /// Try to replace undefined constant C or undefined elements in C with /// Replacement. If no changes are made, the constant C is returned. - static Constant *replaceUndefsWith(Constant *C, Constant *Replacement); + LLVM_ABI static Constant *replaceUndefsWith(Constant *C, + Constant *Replacement); /// Merges undefs of a Constant with another Constant, along with the /// undefs already present. Other doesn't have to be the same type as C, but /// both must either be scalars or vectors with the same element count. If no /// changes are made, the constant C is returned. - static Constant *mergeUndefsWith(Constant *C, Constant *Other); + LLVM_ABI static Constant *mergeUndefsWith(Constant *C, Constant *Other); /// Return true if a constant is ConstantData or a ConstantAggregate or /// ConstantExpr that contain only ConstantData. - bool isManifestConstant() const; + LLVM_ABI bool isManifestConstant() const; private: enum PossibleRelocationsTy { diff --git a/llvm/include/llvm/IR/ConstantFPRange.h b/llvm/include/llvm/IR/ConstantFPRange.h index e240671..930c6f9 100644 --- a/llvm/include/llvm/IR/ConstantFPRange.h +++ b/llvm/include/llvm/IR/ConstantFPRange.h @@ -25,6 +25,7 @@ #include "llvm/ADT/APFloat.h" #include "llvm/IR/Instructions.h" +#include "llvm/Support/Compiler.h" #include <optional> namespace llvm { @@ -52,17 +53,17 @@ class [[nodiscard]] ConstantFPRange { void makeFull(); /// Initialize a full or empty set for the specified semantics. - explicit ConstantFPRange(const fltSemantics &Sem, bool IsFullSet); + LLVM_ABI explicit ConstantFPRange(const fltSemantics &Sem, bool IsFullSet); public: /// Initialize a range to hold the single specified value. - explicit ConstantFPRange(const APFloat &Value); + LLVM_ABI explicit ConstantFPRange(const APFloat &Value); /// Initialize a range of values explicitly. /// Note: If \p LowerVal is greater than \p UpperVal, please use the canonical /// form [Inf, -Inf]. - ConstantFPRange(APFloat LowerVal, APFloat UpperVal, bool MayBeQNaN, - bool MayBeSNaN); + LLVM_ABI ConstantFPRange(APFloat LowerVal, APFloat UpperVal, bool MayBeQNaN, + bool MayBeSNaN); /// Create empty constant range with the given semantics. static ConstantFPRange getEmpty(const fltSemantics &Sem) { @@ -75,10 +76,10 @@ public: } /// Helper for (-inf, inf) to represent all finite values. - static ConstantFPRange getFinite(const fltSemantics &Sem); + LLVM_ABI static ConstantFPRange getFinite(const fltSemantics &Sem); /// Helper for [-inf, inf] to represent all non-NaN values. - static ConstantFPRange getNonNaN(const fltSemantics &Sem); + LLVM_ABI static ConstantFPRange getNonNaN(const fltSemantics &Sem); /// Create a range which doesn't contain NaNs. static ConstantFPRange getNonNaN(APFloat LowerVal, APFloat UpperVal) { @@ -93,8 +94,8 @@ public: } /// Create a range which only contains NaNs. - static ConstantFPRange getNaNOnly(const fltSemantics &Sem, bool MayBeQNaN, - bool MayBeSNaN); + LLVM_ABI static ConstantFPRange getNaNOnly(const fltSemantics &Sem, + bool MayBeQNaN, bool MayBeSNaN); /// Produce the smallest range such that all values that may satisfy the given /// predicate with any value contained within Other is contained in the @@ -104,8 +105,8 @@ public: /// a proper superset of the above. /// /// Example: Pred = ole and Other = float [2, 5] returns Result = [-inf, 5] - static ConstantFPRange makeAllowedFCmpRegion(FCmpInst::Predicate Pred, - const ConstantFPRange &Other); + LLVM_ABI static ConstantFPRange + makeAllowedFCmpRegion(FCmpInst::Predicate Pred, const ConstantFPRange &Other); /// Produce the largest range such that all values in the returned range /// satisfy the given predicate with all values contained within Other. @@ -115,8 +116,9 @@ public: /// will be a proper subset of the above. /// /// Example: Pred = ole and Other = float [2, 5] returns [-inf, 2] - static ConstantFPRange makeSatisfyingFCmpRegion(FCmpInst::Predicate Pred, - const ConstantFPRange &Other); + LLVM_ABI static ConstantFPRange + makeSatisfyingFCmpRegion(FCmpInst::Predicate Pred, + const ConstantFPRange &Other); /// Produce the exact range such that all values in the returned range satisfy /// the given predicate with any value contained within Other. Formally, this @@ -125,12 +127,13 @@ public: /// Example: Pred = olt and Other = float 3 returns [-inf, 3) /// If the exact answer is not representable as a ConstantFPRange, returns /// std::nullopt. - static std::optional<ConstantFPRange> + LLVM_ABI static std::optional<ConstantFPRange> makeExactFCmpRegion(FCmpInst::Predicate Pred, const APFloat &Other); /// Does the predicate \p Pred hold between ranges this and \p Other? /// NOTE: false does not mean that inverse predicate holds! - bool fcmp(FCmpInst::Predicate Pred, const ConstantFPRange &Other) const; + LLVM_ABI bool fcmp(FCmpInst::Predicate Pred, + const ConstantFPRange &Other) const; /// Return the lower value for this range. const APFloat &getLower() const { return Lower; } @@ -141,27 +144,27 @@ public: bool containsNaN() const { return MayBeQNaN || MayBeSNaN; } bool containsQNaN() const { return MayBeQNaN; } bool containsSNaN() const { return MayBeSNaN; } - bool isNaNOnly() const; + LLVM_ABI bool isNaNOnly() const; /// Get the semantics of this ConstantFPRange. const fltSemantics &getSemantics() const { return Lower.getSemantics(); } /// Return true if this set contains all of the elements possible /// for this data-type. - bool isFullSet() const; + LLVM_ABI bool isFullSet() const; /// Return true if this set contains no members. - bool isEmptySet() const; + LLVM_ABI bool isEmptySet() const; /// Return true if the specified value is in the set. - bool contains(const APFloat &Val) const; + LLVM_ABI bool contains(const APFloat &Val) const; /// Return true if the other range is a subset of this one. - bool contains(const ConstantFPRange &CR) const; + LLVM_ABI bool contains(const ConstantFPRange &CR) const; /// If this set contains a single element, return it, otherwise return null. /// If \p ExcludesNaN is true, return the non-NaN single element. - const APFloat *getSingleElement(bool ExcludesNaN = false) const; + LLVM_ABI const APFloat *getSingleElement(bool ExcludesNaN = false) const; /// Return true if this set contains exactly one member. /// If \p ExcludesNaN is true, return true if this set contains exactly one @@ -173,30 +176,30 @@ public: /// Return true if the sign bit of all values in this range is 1. /// Return false if the sign bit of all values in this range is 0. /// Otherwise, return std::nullopt. - std::optional<bool> getSignBit() const; + LLVM_ABI std::optional<bool> getSignBit() const; /// Return true if this range is equal to another range. - bool operator==(const ConstantFPRange &CR) const; + LLVM_ABI bool operator==(const ConstantFPRange &CR) const; /// Return true if this range is not equal to another range. bool operator!=(const ConstantFPRange &CR) const { return !operator==(CR); } /// Return the FPClassTest which will return true for the value. - FPClassTest classify() const; + LLVM_ABI FPClassTest classify() const; /// Print out the bounds to a stream. - void print(raw_ostream &OS) const; + LLVM_ABI void print(raw_ostream &OS) const; /// Allow printing from a debugger easily. - void dump() const; + LLVM_ABI void dump() const; /// Return the range that results from the intersection of this range with /// another range. - ConstantFPRange intersectWith(const ConstantFPRange &CR) const; + LLVM_ABI ConstantFPRange intersectWith(const ConstantFPRange &CR) const; /// Return the smallest range that results from the union of this range /// with another range. The resultant range is guaranteed to include the /// elements of both sets, but may contain more. - ConstantFPRange unionWith(const ConstantFPRange &CR) const; + LLVM_ABI ConstantFPRange unionWith(const ConstantFPRange &CR) const; }; inline raw_ostream &operator<<(raw_ostream &OS, const ConstantFPRange &CR) { diff --git a/llvm/include/llvm/IR/ConstantFold.h b/llvm/include/llvm/IR/ConstantFold.h index 42043d3..f9f2b35 100644 --- a/llvm/include/llvm/IR/ConstantFold.h +++ b/llvm/include/llvm/IR/ConstantFold.h @@ -22,6 +22,7 @@ #define LLVM_IR_CONSTANTFOLD_H #include "llvm/IR/InstrTypes.h" +#include "llvm/Support/Compiler.h" #include <optional> namespace llvm { @@ -31,30 +32,36 @@ namespace llvm { class Type; // Constant fold various types of instruction... - Constant *ConstantFoldCastInstruction( - unsigned opcode, ///< The opcode of the cast - Constant *V, ///< The source constant - Type *DestTy ///< The destination type + LLVM_ABI Constant * + ConstantFoldCastInstruction(unsigned opcode, ///< The opcode of the cast + Constant *V, ///< The source constant + Type *DestTy ///< The destination type ); - Constant *ConstantFoldSelectInstruction(Constant *Cond, - Constant *V1, Constant *V2); - Constant *ConstantFoldExtractElementInstruction(Constant *Val, Constant *Idx); - Constant *ConstantFoldInsertElementInstruction(Constant *Val, Constant *Elt, - Constant *Idx); - Constant *ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2, - ArrayRef<int> Mask); - Constant *ConstantFoldExtractValueInstruction(Constant *Agg, - ArrayRef<unsigned> Idxs); - Constant *ConstantFoldInsertValueInstruction(Constant *Agg, Constant *Val, - ArrayRef<unsigned> Idxs); - Constant *ConstantFoldUnaryInstruction(unsigned Opcode, Constant *V); - Constant *ConstantFoldBinaryInstruction(unsigned Opcode, Constant *V1, - Constant *V2); - Constant *ConstantFoldCompareInstruction(CmpInst::Predicate Predicate, - Constant *C1, Constant *C2); - Constant *ConstantFoldGetElementPtr(Type *Ty, Constant *C, - std::optional<ConstantRange> InRange, - ArrayRef<Value *> Idxs); + LLVM_ABI Constant *ConstantFoldSelectInstruction(Constant *Cond, Constant *V1, + Constant *V2); + LLVM_ABI Constant *ConstantFoldExtractElementInstruction(Constant *Val, + Constant *Idx); + LLVM_ABI Constant *ConstantFoldInsertElementInstruction(Constant *Val, + Constant *Elt, + Constant *Idx); + LLVM_ABI Constant *ConstantFoldShuffleVectorInstruction(Constant *V1, + Constant *V2, + ArrayRef<int> Mask); + LLVM_ABI Constant * + ConstantFoldExtractValueInstruction(Constant *Agg, ArrayRef<unsigned> Idxs); + LLVM_ABI Constant * + ConstantFoldInsertValueInstruction(Constant *Agg, Constant *Val, + ArrayRef<unsigned> Idxs); + LLVM_ABI Constant *ConstantFoldUnaryInstruction(unsigned Opcode, Constant *V); + LLVM_ABI Constant *ConstantFoldBinaryInstruction(unsigned Opcode, + Constant *V1, Constant *V2); + LLVM_ABI Constant * + ConstantFoldCompareInstruction(CmpInst::Predicate Predicate, Constant *C1, + Constant *C2); + LLVM_ABI Constant * + ConstantFoldGetElementPtr(Type *Ty, Constant *C, + std::optional<ConstantRange> InRange, + ArrayRef<Value *> Idxs); } // End llvm namespace #endif diff --git a/llvm/include/llvm/IR/ConstantFolder.h b/llvm/include/llvm/IR/ConstantFolder.h index a1d9a8f..26b7242 100644 --- a/llvm/include/llvm/IR/ConstantFolder.h +++ b/llvm/include/llvm/IR/ConstantFolder.h @@ -23,11 +23,12 @@ #include "llvm/IR/IRBuilderFolder.h" #include "llvm/IR/Instruction.h" #include "llvm/IR/Operator.h" +#include "llvm/Support/Compiler.h" namespace llvm { /// ConstantFolder - Create constants with minimum, target independent, folding. -class ConstantFolder final : public IRBuilderFolder { +class LLVM_ABI ConstantFolder final : public IRBuilderFolder { LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION(); public: diff --git a/llvm/include/llvm/IR/ConstantRange.h b/llvm/include/llvm/IR/ConstantRange.h index 3561513..9a6a9db 100644 --- a/llvm/include/llvm/IR/ConstantRange.h +++ b/llvm/include/llvm/IR/ConstantRange.h @@ -59,15 +59,15 @@ class [[nodiscard]] ConstantRange { public: /// Initialize a full or empty set for the specified bit width. - explicit ConstantRange(uint32_t BitWidth, bool isFullSet); + LLVM_ABI explicit ConstantRange(uint32_t BitWidth, bool isFullSet); /// Initialize a range to hold the single specified value. - ConstantRange(APInt Value); + LLVM_ABI ConstantRange(APInt Value); /// Initialize a range of values explicitly. This will assert out if /// Lower==Upper and Lower != Min or Max value for its type. It will also /// assert out if the two APInt's are not the same bit width. - ConstantRange(APInt Lower, APInt Upper); + LLVM_ABI ConstantRange(APInt Lower, APInt Upper); /// Create empty constant range with the given bit width. static ConstantRange getEmpty(uint32_t BitWidth) { @@ -90,11 +90,12 @@ public: /// Initialize a range based on a known bits constraint. The IsSigned flag /// indicates whether the constant range should not wrap in the signed or /// unsigned domain. - static ConstantRange fromKnownBits(const KnownBits &Known, bool IsSigned); + LLVM_ABI static ConstantRange fromKnownBits(const KnownBits &Known, + bool IsSigned); /// Split the ConstantRange into positive and negative components, ignoring /// zero values. - std::pair<ConstantRange, ConstantRange> splitPosNeg() const; + LLVM_ABI std::pair<ConstantRange, ConstantRange> splitPosNeg() const; /// Produce the smallest range such that all values that may satisfy the given /// predicate with any value contained within Other is contained in the @@ -104,8 +105,8 @@ public: /// proper superset of the above. /// /// Example: Pred = ult and Other = i8 [2, 5) returns Result = [0, 4) - static ConstantRange makeAllowedICmpRegion(CmpInst::Predicate Pred, - const ConstantRange &Other); + LLVM_ABI static ConstantRange + makeAllowedICmpRegion(CmpInst::Predicate Pred, const ConstantRange &Other); /// Produce the largest range such that all values in the returned range /// satisfy the given predicate with all values contained within Other. @@ -115,8 +116,8 @@ public: /// will be a proper subset of the above. /// /// Example: Pred = ult and Other = i8 [2, 5) returns [0, 2) - static ConstantRange makeSatisfyingICmpRegion(CmpInst::Predicate Pred, - const ConstantRange &Other); + LLVM_ABI static ConstantRange + makeSatisfyingICmpRegion(CmpInst::Predicate Pred, const ConstantRange &Other); /// Produce the exact range such that all values in the returned range satisfy /// the given predicate with any value contained within Other. Formally, this @@ -125,22 +126,22 @@ public: /// { x : icmp op x y is true}'. /// /// Example: Pred = ult and Other = i8 3 returns [0, 3) - static ConstantRange makeExactICmpRegion(CmpInst::Predicate Pred, - const APInt &Other); + LLVM_ABI static ConstantRange makeExactICmpRegion(CmpInst::Predicate Pred, + const APInt &Other); /// Does the predicate \p Pred hold between ranges this and \p Other? /// NOTE: false does not mean that inverse predicate holds! - bool icmp(CmpInst::Predicate Pred, const ConstantRange &Other) const; + LLVM_ABI bool icmp(CmpInst::Predicate Pred, const ConstantRange &Other) const; /// Return true iff CR1 ult CR2 is equivalent to CR1 slt CR2. /// Does not depend on strictness/direction of the predicate. - static bool + LLVM_ABI static bool areInsensitiveToSignednessOfICmpPredicate(const ConstantRange &CR1, const ConstantRange &CR2); /// Return true iff CR1 ult CR2 is equivalent to CR1 sge CR2. /// Does not depend on strictness/direction of the predicate. - static bool + LLVM_ABI static bool areInsensitiveToSignednessOfInvertedICmpPredicate(const ConstantRange &CR1, const ConstantRange &CR2); @@ -149,7 +150,7 @@ public: /// return a predicate equivalent to \p Pred, with flipped signedness /// (i.e. unsigned instead of signed or vice versa), and maybe inverted, /// otherwise returns CmpInst::Predicate::BAD_ICMP_PREDICATE. - static CmpInst::Predicate + LLVM_ABI static CmpInst::Predicate getEquivalentPredWithFlippedSignedness(CmpInst::Predicate Pred, const ConstantRange &CR1, const ConstantRange &CR2); @@ -170,38 +171,39 @@ public: /// MGNR(Add, [i8 -1, 6), OBO::NoSignedWrap) == [INT_MIN+1, INT_MAX-4) /// MGNR(Sub, [i8 1, 2), OBO::NoSignedWrap) == [-127, 128) /// MGNR(Sub, [i8 1, 2), OBO::NoUnsignedWrap) == [1, 0) - static ConstantRange makeGuaranteedNoWrapRegion(Instruction::BinaryOps BinOp, - const ConstantRange &Other, - unsigned NoWrapKind); + LLVM_ABI static ConstantRange + makeGuaranteedNoWrapRegion(Instruction::BinaryOps BinOp, + const ConstantRange &Other, unsigned NoWrapKind); /// Produce the range that contains X if and only if "X BinOp Other" does /// not wrap. - static ConstantRange makeExactNoWrapRegion(Instruction::BinaryOps BinOp, - const APInt &Other, - unsigned NoWrapKind); + LLVM_ABI static ConstantRange + makeExactNoWrapRegion(Instruction::BinaryOps BinOp, const APInt &Other, + unsigned NoWrapKind); /// Initialize a range containing all values X that satisfy `(X & Mask) /// != C`. Note that the range returned may contain values where `(X & Mask) /// == C` holds, making it less precise, but still conservative. - static ConstantRange makeMaskNotEqualRange(const APInt &Mask, const APInt &C); + LLVM_ABI static ConstantRange makeMaskNotEqualRange(const APInt &Mask, + const APInt &C); /// Returns true if ConstantRange calculations are supported for intrinsic /// with \p IntrinsicID. - static bool isIntrinsicSupported(Intrinsic::ID IntrinsicID); + LLVM_ABI static bool isIntrinsicSupported(Intrinsic::ID IntrinsicID); /// Compute range of intrinsic result for the given operand ranges. - static ConstantRange intrinsic(Intrinsic::ID IntrinsicID, - ArrayRef<ConstantRange> Ops); + LLVM_ABI static ConstantRange intrinsic(Intrinsic::ID IntrinsicID, + ArrayRef<ConstantRange> Ops); /// Set up \p Pred and \p RHS such that /// ConstantRange::makeExactICmpRegion(Pred, RHS) == *this. Return true if /// successful. - bool getEquivalentICmp(CmpInst::Predicate &Pred, APInt &RHS) const; + LLVM_ABI bool getEquivalentICmp(CmpInst::Predicate &Pred, APInt &RHS) const; /// Set up \p Pred, \p RHS and \p Offset such that (V + Offset) Pred RHS /// is true iff V is in the range. Prefers using Offset == 0 if possible. - void - getEquivalentICmp(CmpInst::Predicate &Pred, APInt &RHS, APInt &Offset) const; + LLVM_ABI void getEquivalentICmp(CmpInst::Predicate &Pred, APInt &RHS, + APInt &Offset) const; /// Return the lower value for this range. const APInt &getLower() const { return Lower; } @@ -214,42 +216,42 @@ public: /// Return true if this set contains all of the elements possible /// for this data-type. - bool isFullSet() const; + LLVM_ABI bool isFullSet() const; /// Return true if this set contains no members. - bool isEmptySet() const; + LLVM_ABI bool isEmptySet() const; /// Return true if this set wraps around the unsigned domain. Special cases: /// * Empty set: Not wrapped. /// * Full set: Not wrapped. /// * [X, 0) == [X, Max]: Not wrapped. - bool isWrappedSet() const; + LLVM_ABI bool isWrappedSet() const; /// Return true if the exclusive upper bound wraps around the unsigned /// domain. Special cases: /// * Empty set: Not wrapped. /// * Full set: Not wrapped. /// * [X, 0): Wrapped. - bool isUpperWrapped() const; + LLVM_ABI bool isUpperWrapped() const; /// Return true if this set wraps around the signed domain. Special cases: /// * Empty set: Not wrapped. /// * Full set: Not wrapped. /// * [X, SignedMin) == [X, SignedMax]: Not wrapped. - bool isSignWrappedSet() const; + LLVM_ABI bool isSignWrappedSet() const; /// Return true if the (exclusive) upper bound wraps around the signed /// domain. Special cases: /// * Empty set: Not wrapped. /// * Full set: Not wrapped. /// * [X, SignedMin): Wrapped. - bool isUpperSignWrapped() const; + LLVM_ABI bool isUpperSignWrapped() const; /// Return true if the specified value is in the set. - bool contains(const APInt &Val) const; + LLVM_ABI bool contains(const APInt &Val) const; /// Return true if the other range is a subset of this one. - bool contains(const ConstantRange &CR) const; + LLVM_ABI bool contains(const ConstantRange &CR) const; /// If this set contains a single element, return it, otherwise return null. const APInt *getSingleElement() const { @@ -270,31 +272,31 @@ public: bool isSingleElement() const { return getSingleElement() != nullptr; } /// Compare set size of this range with the range CR. - bool isSizeStrictlySmallerThan(const ConstantRange &CR) const; + LLVM_ABI bool isSizeStrictlySmallerThan(const ConstantRange &CR) const; /// Compare set size of this range with Value. - bool isSizeLargerThan(uint64_t MaxSize) const; + LLVM_ABI bool isSizeLargerThan(uint64_t MaxSize) const; /// Return true if all values in this range are negative. - bool isAllNegative() const; + LLVM_ABI bool isAllNegative() const; /// Return true if all values in this range are non-negative. - bool isAllNonNegative() const; + LLVM_ABI bool isAllNonNegative() const; /// Return true if all values in this range are positive. - bool isAllPositive() const; + LLVM_ABI bool isAllPositive() const; /// Return the largest unsigned value contained in the ConstantRange. - APInt getUnsignedMax() const; + LLVM_ABI APInt getUnsignedMax() const; /// Return the smallest unsigned value contained in the ConstantRange. - APInt getUnsignedMin() const; + LLVM_ABI APInt getUnsignedMin() const; /// Return the largest signed value contained in the ConstantRange. - APInt getSignedMax() const; + LLVM_ABI APInt getSignedMax() const; /// Return the smallest signed value contained in the ConstantRange. - APInt getSignedMin() const; + LLVM_ABI APInt getSignedMin() const; /// Return true if this range is equal to another range. bool operator==(const ConstantRange &CR) const { @@ -306,18 +308,18 @@ public: /// Compute the maximal number of active bits needed to represent every value /// in this range. - unsigned getActiveBits() const; + LLVM_ABI unsigned getActiveBits() const; /// Compute the maximal number of bits needed to represent every value /// in this signed range. - unsigned getMinSignedBits() const; + LLVM_ABI unsigned getMinSignedBits() const; /// Subtract the specified constant from the endpoints of this constant range. - ConstantRange subtract(const APInt &CI) const; + LLVM_ABI ConstantRange subtract(const APInt &CI) const; /// Subtract the specified range from this range (aka relative complement of /// the sets). - ConstantRange difference(const ConstantRange &CR) const; + LLVM_ABI ConstantRange difference(const ConstantRange &CR) const; /// If represented precisely, the result of some range operations may consist /// of multiple disjoint ranges. As only a single range may be returned, any @@ -333,25 +335,26 @@ public: /// Return the range that results from the intersection of this range with /// another range. If the intersection is disjoint, such that two results /// are possible, the preferred range is determined by the PreferredRangeType. - ConstantRange intersectWith(const ConstantRange &CR, - PreferredRangeType Type = Smallest) const; + LLVM_ABI ConstantRange intersectWith( + const ConstantRange &CR, PreferredRangeType Type = Smallest) const; /// Return the range that results from the union of this range /// with another range. The resultant range is guaranteed to include the /// elements of both sets, but may contain more. For example, [3, 9) union /// [12,15) is [3, 15), which includes 9, 10, and 11, which were not included /// in either set before. - ConstantRange unionWith(const ConstantRange &CR, - PreferredRangeType Type = Smallest) const; + LLVM_ABI ConstantRange unionWith(const ConstantRange &CR, + PreferredRangeType Type = Smallest) const; /// Intersect the two ranges and return the result if it can be represented /// exactly, otherwise return std::nullopt. - std::optional<ConstantRange> + LLVM_ABI std::optional<ConstantRange> exactIntersectWith(const ConstantRange &CR) const; /// Union the two ranges and return the result if it can be represented /// exactly, otherwise return std::nullopt. - std::optional<ConstantRange> exactUnionWith(const ConstantRange &CR) const; + LLVM_ABI std::optional<ConstantRange> + exactUnionWith(const ConstantRange &CR) const; /// Return a new range representing the possible values resulting /// from an application of the specified cast operator to this range. \p @@ -359,212 +362,215 @@ public: /// change bitwidth, it must be the same as the source bitwidth. For casts /// which do change bitwidth, the bitwidth must be consistent with the /// requested cast and source bitwidth. - ConstantRange castOp(Instruction::CastOps CastOp, - uint32_t BitWidth) const; + LLVM_ABI ConstantRange castOp(Instruction::CastOps CastOp, + uint32_t BitWidth) const; /// Return a new range in the specified integer type, which must /// be strictly larger than the current type. The returned range will /// correspond to the possible range of values if the source range had been /// zero extended to BitWidth. - ConstantRange zeroExtend(uint32_t BitWidth) const; + LLVM_ABI ConstantRange zeroExtend(uint32_t BitWidth) const; /// Return a new range in the specified integer type, which must /// be strictly larger than the current type. The returned range will /// correspond to the possible range of values if the source range had been /// sign extended to BitWidth. - ConstantRange signExtend(uint32_t BitWidth) const; + LLVM_ABI ConstantRange signExtend(uint32_t BitWidth) const; /// Return a new range in the specified integer type, which must be /// strictly smaller than the current type. The returned range will /// correspond to the possible range of values if the source range had been /// truncated to the specified type. - ConstantRange truncate(uint32_t BitWidth) const; + LLVM_ABI ConstantRange truncate(uint32_t BitWidth) const; /// Make this range have the bit width given by \p BitWidth. The /// value is zero extended, truncated, or left alone to make it that width. - ConstantRange zextOrTrunc(uint32_t BitWidth) const; + LLVM_ABI ConstantRange zextOrTrunc(uint32_t BitWidth) const; /// Make this range have the bit width given by \p BitWidth. The /// value is sign extended, truncated, or left alone to make it that width. - ConstantRange sextOrTrunc(uint32_t BitWidth) const; + LLVM_ABI ConstantRange sextOrTrunc(uint32_t BitWidth) const; /// Return a new range representing the possible values resulting /// from an application of the specified binary operator to an left hand side /// of this range and a right hand side of \p Other. - ConstantRange binaryOp(Instruction::BinaryOps BinOp, - const ConstantRange &Other) const; + LLVM_ABI ConstantRange binaryOp(Instruction::BinaryOps BinOp, + const ConstantRange &Other) const; /// Return a new range representing the possible values resulting /// from an application of the specified overflowing binary operator to a /// left hand side of this range and a right hand side of \p Other given /// the provided knowledge about lack of wrapping \p NoWrapKind. - ConstantRange overflowingBinaryOp(Instruction::BinaryOps BinOp, - const ConstantRange &Other, - unsigned NoWrapKind) const; + LLVM_ABI ConstantRange overflowingBinaryOp(Instruction::BinaryOps BinOp, + const ConstantRange &Other, + unsigned NoWrapKind) const; /// Return a new range representing the possible values resulting /// from an addition of a value in this range and a value in \p Other. - ConstantRange add(const ConstantRange &Other) const; + LLVM_ABI ConstantRange add(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting /// from an addition with wrap type \p NoWrapKind of a value in this /// range and a value in \p Other. /// If the result range is disjoint, the preferred range is determined by the /// \p PreferredRangeType. - ConstantRange addWithNoWrap(const ConstantRange &Other, unsigned NoWrapKind, - PreferredRangeType RangeType = Smallest) const; + LLVM_ABI ConstantRange + addWithNoWrap(const ConstantRange &Other, unsigned NoWrapKind, + PreferredRangeType RangeType = Smallest) const; /// Return a new range representing the possible values resulting /// from a subtraction of a value in this range and a value in \p Other. - ConstantRange sub(const ConstantRange &Other) const; + LLVM_ABI ConstantRange sub(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting /// from an subtraction with wrap type \p NoWrapKind of a value in this /// range and a value in \p Other. /// If the result range is disjoint, the preferred range is determined by the /// \p PreferredRangeType. - ConstantRange subWithNoWrap(const ConstantRange &Other, unsigned NoWrapKind, - PreferredRangeType RangeType = Smallest) const; + LLVM_ABI ConstantRange + subWithNoWrap(const ConstantRange &Other, unsigned NoWrapKind, + PreferredRangeType RangeType = Smallest) const; /// Return a new range representing the possible values resulting /// from a multiplication of a value in this range and a value in \p Other, /// treating both this and \p Other as unsigned ranges. - ConstantRange multiply(const ConstantRange &Other) const; + LLVM_ABI ConstantRange multiply(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting /// from a multiplication with wrap type \p NoWrapKind of a value in this /// range and a value in \p Other. /// If the result range is disjoint, the preferred range is determined by the /// \p PreferredRangeType. - ConstantRange + LLVM_ABI ConstantRange multiplyWithNoWrap(const ConstantRange &Other, unsigned NoWrapKind, PreferredRangeType RangeType = Smallest) const; /// Return range of possible values for a signed multiplication of this and /// \p Other. However, if overflow is possible always return a full range /// rather than trying to determine a more precise result. - ConstantRange smul_fast(const ConstantRange &Other) const; + LLVM_ABI ConstantRange smul_fast(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting /// from a signed maximum of a value in this range and a value in \p Other. - ConstantRange smax(const ConstantRange &Other) const; + LLVM_ABI ConstantRange smax(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting /// from an unsigned maximum of a value in this range and a value in \p Other. - ConstantRange umax(const ConstantRange &Other) const; + LLVM_ABI ConstantRange umax(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting /// from a signed minimum of a value in this range and a value in \p Other. - ConstantRange smin(const ConstantRange &Other) const; + LLVM_ABI ConstantRange smin(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting /// from an unsigned minimum of a value in this range and a value in \p Other. - ConstantRange umin(const ConstantRange &Other) const; + LLVM_ABI ConstantRange umin(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting /// from an unsigned division of a value in this range and a value in /// \p Other. - ConstantRange udiv(const ConstantRange &Other) const; + LLVM_ABI ConstantRange udiv(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting /// from a signed division of a value in this range and a value in /// \p Other. Division by zero and division of SignedMin by -1 are considered /// undefined behavior, in line with IR, and do not contribute towards the /// result. - ConstantRange sdiv(const ConstantRange &Other) const; + LLVM_ABI ConstantRange sdiv(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting /// from an unsigned remainder operation of a value in this range and a /// value in \p Other. - ConstantRange urem(const ConstantRange &Other) const; + LLVM_ABI ConstantRange urem(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting /// from a signed remainder operation of a value in this range and a /// value in \p Other. - ConstantRange srem(const ConstantRange &Other) const; + LLVM_ABI ConstantRange srem(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting from /// a binary-xor of a value in this range by an all-one value, /// aka bitwise complement operation. - ConstantRange binaryNot() const; + LLVM_ABI ConstantRange binaryNot() const; /// Return a new range representing the possible values resulting /// from a binary-and of a value in this range by a value in \p Other. - ConstantRange binaryAnd(const ConstantRange &Other) const; + LLVM_ABI ConstantRange binaryAnd(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting /// from a binary-or of a value in this range by a value in \p Other. - ConstantRange binaryOr(const ConstantRange &Other) const; + LLVM_ABI ConstantRange binaryOr(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting /// from a binary-xor of a value in this range by a value in \p Other. - ConstantRange binaryXor(const ConstantRange &Other) const; + LLVM_ABI ConstantRange binaryXor(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting /// from a left shift of a value in this range by a value in \p Other. /// TODO: This isn't fully implemented yet. - ConstantRange shl(const ConstantRange &Other) const; + LLVM_ABI ConstantRange shl(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting /// from a left shift with wrap type \p NoWrapKind of a value in this /// range and a value in \p Other. /// If the result range is disjoint, the preferred range is determined by the /// \p PreferredRangeType. - ConstantRange shlWithNoWrap(const ConstantRange &Other, unsigned NoWrapKind, - PreferredRangeType RangeType = Smallest) const; + LLVM_ABI ConstantRange + shlWithNoWrap(const ConstantRange &Other, unsigned NoWrapKind, + PreferredRangeType RangeType = Smallest) const; /// Return a new range representing the possible values resulting from a /// logical right shift of a value in this range and a value in \p Other. - ConstantRange lshr(const ConstantRange &Other) const; + LLVM_ABI ConstantRange lshr(const ConstantRange &Other) const; /// Return a new range representing the possible values resulting from a /// arithmetic right shift of a value in this range and a value in \p Other. - ConstantRange ashr(const ConstantRange &Other) const; + LLVM_ABI ConstantRange ashr(const ConstantRange &Other) const; /// Perform an unsigned saturating addition of two constant ranges. - ConstantRange uadd_sat(const ConstantRange &Other) const; + LLVM_ABI ConstantRange uadd_sat(const ConstantRange &Other) const; /// Perform a signed saturating addition of two constant ranges. - ConstantRange sadd_sat(const ConstantRange &Other) const; + LLVM_ABI ConstantRange sadd_sat(const ConstantRange &Other) const; /// Perform an unsigned saturating subtraction of two constant ranges. - ConstantRange usub_sat(const ConstantRange &Other) const; + LLVM_ABI ConstantRange usub_sat(const ConstantRange &Other) const; /// Perform a signed saturating subtraction of two constant ranges. - ConstantRange ssub_sat(const ConstantRange &Other) const; + LLVM_ABI ConstantRange ssub_sat(const ConstantRange &Other) const; /// Perform an unsigned saturating multiplication of two constant ranges. - ConstantRange umul_sat(const ConstantRange &Other) const; + LLVM_ABI ConstantRange umul_sat(const ConstantRange &Other) const; /// Perform a signed saturating multiplication of two constant ranges. - ConstantRange smul_sat(const ConstantRange &Other) const; + LLVM_ABI ConstantRange smul_sat(const ConstantRange &Other) const; /// Perform an unsigned saturating left shift of this constant range by a /// value in \p Other. - ConstantRange ushl_sat(const ConstantRange &Other) const; + LLVM_ABI ConstantRange ushl_sat(const ConstantRange &Other) const; /// Perform a signed saturating left shift of this constant range by a /// value in \p Other. - ConstantRange sshl_sat(const ConstantRange &Other) const; + LLVM_ABI ConstantRange sshl_sat(const ConstantRange &Other) const; /// Return a new range that is the logical not of the current set. - ConstantRange inverse() const; + LLVM_ABI ConstantRange inverse() const; /// Calculate absolute value range. If the original range contains signed /// min, then the resulting range will contain signed min if and only if /// \p IntMinIsPoison is false. - ConstantRange abs(bool IntMinIsPoison = false) const; + LLVM_ABI ConstantRange abs(bool IntMinIsPoison = false) const; /// Calculate ctlz range. If \p ZeroIsPoison is set, the range is computed /// ignoring a possible zero value contained in the input range. - ConstantRange ctlz(bool ZeroIsPoison = false) const; + LLVM_ABI ConstantRange ctlz(bool ZeroIsPoison = false) const; /// Calculate cttz range. If \p ZeroIsPoison is set, the range is computed /// ignoring a possible zero value contained in the input range. - ConstantRange cttz(bool ZeroIsPoison = false) const; + LLVM_ABI ConstantRange cttz(bool ZeroIsPoison = false) const; /// Calculate ctpop range. - ConstantRange ctpop() const; + LLVM_ABI ConstantRange ctpop() const; /// Represents whether an operation on the given constant range is known to /// always or never overflow. @@ -580,28 +586,33 @@ public: }; /// Return whether unsigned add of the two ranges always/never overflows. - OverflowResult unsignedAddMayOverflow(const ConstantRange &Other) const; + LLVM_ABI OverflowResult + unsignedAddMayOverflow(const ConstantRange &Other) const; /// Return whether signed add of the two ranges always/never overflows. - OverflowResult signedAddMayOverflow(const ConstantRange &Other) const; + LLVM_ABI OverflowResult + signedAddMayOverflow(const ConstantRange &Other) const; /// Return whether unsigned sub of the two ranges always/never overflows. - OverflowResult unsignedSubMayOverflow(const ConstantRange &Other) const; + LLVM_ABI OverflowResult + unsignedSubMayOverflow(const ConstantRange &Other) const; /// Return whether signed sub of the two ranges always/never overflows. - OverflowResult signedSubMayOverflow(const ConstantRange &Other) const; + LLVM_ABI OverflowResult + signedSubMayOverflow(const ConstantRange &Other) const; /// Return whether unsigned mul of the two ranges always/never overflows. - OverflowResult unsignedMulMayOverflow(const ConstantRange &Other) const; + LLVM_ABI OverflowResult + unsignedMulMayOverflow(const ConstantRange &Other) const; /// Return known bits for values in this range. - KnownBits toKnownBits() const; + LLVM_ABI KnownBits toKnownBits() const; /// Print out the bounds to a stream. - void print(raw_ostream &OS) const; + LLVM_ABI void print(raw_ostream &OS) const; /// Allow printing from a debugger easily. - void dump() const; + LLVM_ABI void dump() const; }; inline raw_ostream &operator<<(raw_ostream &OS, const ConstantRange &CR) { @@ -612,7 +623,7 @@ inline raw_ostream &operator<<(raw_ostream &OS, const ConstantRange &CR) { /// Parse out a conservative ConstantRange from !range metadata. /// /// E.g. if RangeMD is !{i32 0, i32 10, i32 15, i32 20} then return [0, 20). -ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD); +LLVM_ABI ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD); } // end namespace llvm diff --git a/llvm/include/llvm/IR/ConstantRangeList.h b/llvm/include/llvm/IR/ConstantRangeList.h index b12c913..104018b 100644 --- a/llvm/include/llvm/IR/ConstantRangeList.h +++ b/llvm/include/llvm/IR/ConstantRangeList.h @@ -18,6 +18,7 @@ #include "llvm/ADT/APInt.h" #include "llvm/IR/ConstantRange.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include <cstddef> #include <cstdint> @@ -41,8 +42,8 @@ public: } // Return true if the ranges are non-overlapping and increasing. - static bool isOrderedRanges(ArrayRef<ConstantRange> RangesRef); - static std::optional<ConstantRangeList> + LLVM_ABI static bool isOrderedRanges(ArrayRef<ConstantRange> RangesRef); + LLVM_ABI static std::optional<ConstantRangeList> getConstantRangeList(ArrayRef<ConstantRange> RangesRef); ArrayRef<ConstantRange> rangesRef() const { return Ranges; } @@ -67,21 +68,21 @@ public: size_t size() const { return Ranges.size(); } /// Insert a new range to Ranges and keep the list ordered. - void insert(const ConstantRange &NewRange); + LLVM_ABI void insert(const ConstantRange &NewRange); void insert(int64_t Lower, int64_t Upper) { insert(ConstantRange(APInt(64, Lower, /*isSigned=*/true), APInt(64, Upper, /*isSigned=*/true))); } - void subtract(const ConstantRange &SubRange); + LLVM_ABI void subtract(const ConstantRange &SubRange); /// Return the range list that results from the union of this /// ConstantRangeList with another ConstantRangeList, "CRL". - ConstantRangeList unionWith(const ConstantRangeList &CRL) const; + LLVM_ABI ConstantRangeList unionWith(const ConstantRangeList &CRL) const; /// Return the range list that results from the intersection of this /// ConstantRangeList with another ConstantRangeList, "CRL". - ConstantRangeList intersectWith(const ConstantRangeList &CRL) const; + LLVM_ABI ConstantRangeList intersectWith(const ConstantRangeList &CRL) const; /// Return true if this range list is equal to another range list. bool operator==(const ConstantRangeList &CRL) const { @@ -92,7 +93,7 @@ public: } /// Print out the ranges to a stream. - void print(raw_ostream &OS) const; + LLVM_ABI void print(raw_ostream &OS) const; #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) void dump() const; diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h index 6a01e82..9c9fc88 100644 --- a/llvm/include/llvm/IR/Constants.h +++ b/llvm/include/llvm/IR/Constants.h @@ -103,16 +103,16 @@ class ConstantInt final : public ConstantData { public: ConstantInt(const ConstantInt &) = delete; - static ConstantInt *getTrue(LLVMContext &Context); - static ConstantInt *getFalse(LLVMContext &Context); - static ConstantInt *getBool(LLVMContext &Context, bool V); - static Constant *getTrue(Type *Ty); - static Constant *getFalse(Type *Ty); - static Constant *getBool(Type *Ty, bool V); + LLVM_ABI static ConstantInt *getTrue(LLVMContext &Context); + LLVM_ABI static ConstantInt *getFalse(LLVMContext &Context); + LLVM_ABI static ConstantInt *getBool(LLVMContext &Context, bool V); + LLVM_ABI static Constant *getTrue(Type *Ty); + LLVM_ABI static Constant *getFalse(Type *Ty); + LLVM_ABI static Constant *getBool(Type *Ty, bool V); /// If Ty is a vector type, return a Constant with a splat of the given /// value. Otherwise return a ConstantInt for the given value. - static Constant *get(Type *Ty, uint64_t V, bool IsSigned = false); + LLVM_ABI static Constant *get(Type *Ty, uint64_t V, bool IsSigned = false); /// Return a ConstantInt with the specified integer value for the specified /// type. If the type is wider than 64 bits, the value will be zero-extended @@ -120,7 +120,8 @@ public: /// be interpreted as a 64-bit signed integer and sign-extended to fit /// the type. /// Get a ConstantInt for a specific value. - static ConstantInt *get(IntegerType *Ty, uint64_t V, bool IsSigned = false); + LLVM_ABI static ConstantInt *get(IntegerType *Ty, uint64_t V, + bool IsSigned = false); /// Return a ConstantInt with the specified value for the specified type. The /// value V will be canonicalized to a an unsigned APInt. Accessing it with @@ -136,15 +137,16 @@ public: /// Return a ConstantInt with the specified value and an implied Type. The /// type is the integer type that corresponds to the bit width of the value. - static ConstantInt *get(LLVMContext &Context, const APInt &V); + LLVM_ABI static ConstantInt *get(LLVMContext &Context, const APInt &V); /// Return a ConstantInt constructed from the string strStart with the given /// radix. - static ConstantInt *get(IntegerType *Ty, StringRef Str, uint8_t Radix); + LLVM_ABI static ConstantInt *get(IntegerType *Ty, StringRef Str, + uint8_t Radix); /// If Ty is a vector type, return a Constant with a splat of the given /// value. Otherwise return a ConstantInt for the given value. - static Constant *get(Type *Ty, const APInt &V); + LLVM_ABI static Constant *get(Type *Ty, const APInt &V); /// Return the constant as an APInt value reference. This allows clients to /// obtain a full-precision copy of the value. @@ -201,8 +203,8 @@ public: /// to the appropriate unsigned type before calling the method. /// @returns true if V is a valid value for type Ty /// Determine if the value is in range for the given type. - static bool isValueValidForType(Type *Ty, uint64_t V); - static bool isValueValidForType(Type *Ty, int64_t V); + LLVM_ABI static bool isValueValidForType(Type *Ty, uint64_t V); + LLVM_ABI static bool isValueValidForType(Type *Ty, int64_t V); bool isNegative() const { return Val.isNegative(); } @@ -295,26 +297,26 @@ public: /// for the specified value in the specified type. This should only be used /// for simple constant values like 2.0/1.0 etc, that are known-valid both as /// host double and as the target format. - static Constant *get(Type *Ty, double V); + LLVM_ABI static Constant *get(Type *Ty, double V); /// If Ty is a vector type, return a Constant with a splat of the given /// value. Otherwise return a ConstantFP for the given value. - static Constant *get(Type *Ty, const APFloat &V); - - static Constant *get(Type *Ty, StringRef Str); - static ConstantFP *get(LLVMContext &Context, const APFloat &V); - static Constant *getNaN(Type *Ty, bool Negative = false, - uint64_t Payload = 0); - static Constant *getQNaN(Type *Ty, bool Negative = false, - APInt *Payload = nullptr); - static Constant *getSNaN(Type *Ty, bool Negative = false, - APInt *Payload = nullptr); - static Constant *getZero(Type *Ty, bool Negative = false); + LLVM_ABI static Constant *get(Type *Ty, const APFloat &V); + + LLVM_ABI static Constant *get(Type *Ty, StringRef Str); + LLVM_ABI static ConstantFP *get(LLVMContext &Context, const APFloat &V); + LLVM_ABI static Constant *getNaN(Type *Ty, bool Negative = false, + uint64_t Payload = 0); + LLVM_ABI static Constant *getQNaN(Type *Ty, bool Negative = false, + APInt *Payload = nullptr); + LLVM_ABI static Constant *getSNaN(Type *Ty, bool Negative = false, + APInt *Payload = nullptr); + LLVM_ABI static Constant *getZero(Type *Ty, bool Negative = false); static Constant *getNegativeZero(Type *Ty) { return getZero(Ty, true); } - static Constant *getInfinity(Type *Ty, bool Negative = false); + LLVM_ABI static Constant *getInfinity(Type *Ty, bool Negative = false); /// Return true if Ty is big enough to represent V. - static bool isValueValidForType(Type *Ty, const APFloat &V); + LLVM_ABI static bool isValueValidForType(Type *Ty, const APFloat &V); inline const APFloat &getValueAPF() const { return Val; } inline const APFloat &getValue() const { return Val; } @@ -336,7 +338,7 @@ public: /// two floating point values. The version with a double operand is retained /// because it's so convenient to write isExactlyValue(2.0), but please use /// it only for simple constants. - bool isExactlyValue(const APFloat &V) const; + LLVM_ABI bool isExactlyValue(const APFloat &V) const; bool isExactlyValue(double V) const { bool ignored; @@ -365,25 +367,25 @@ class ConstantAggregateZero final : public ConstantData { public: ConstantAggregateZero(const ConstantAggregateZero &) = delete; - static ConstantAggregateZero *get(Type *Ty); + LLVM_ABI static ConstantAggregateZero *get(Type *Ty); /// If this CAZ has array or vector type, return a zero with the right element /// type. - Constant *getSequentialElement() const; + LLVM_ABI Constant *getSequentialElement() const; /// If this CAZ has struct type, return a zero with the right element type for /// the specified element. - Constant *getStructElement(unsigned Elt) const; + LLVM_ABI Constant *getStructElement(unsigned Elt) const; /// Return a zero of the right value for the specified GEP index if we can, /// otherwise return null (e.g. if C is a ConstantExpr). - Constant *getElementValue(Constant *C) const; + LLVM_ABI Constant *getElementValue(Constant *C) const; /// Return a zero of the right value for the specified GEP index. - Constant *getElementValue(unsigned Idx) const; + LLVM_ABI Constant *getElementValue(unsigned Idx) const; /// Return the number of elements in the array, vector, or struct. - ElementCount getElementCount() const; + LLVM_ABI ElementCount getElementCount() const; /// Methods for support type inquiry through isa, cast, and dyn_cast: /// @@ -405,8 +407,8 @@ public: /// use operands. class ConstantAggregate : public Constant { protected: - ConstantAggregate(Type *T, ValueTy VT, ArrayRef<Constant *> V, - AllocInfo AllocInfo); + LLVM_ABI ConstantAggregate(Type *T, ValueTy VT, ArrayRef<Constant *> V, + AllocInfo AllocInfo); public: /// Transparently provide more efficient getOperand methods. @@ -439,7 +441,7 @@ class ConstantArray final : public ConstantAggregate { public: // ConstantArray accessors - static Constant *get(ArrayType *T, ArrayRef<Constant *> V); + LLVM_ABI static Constant *get(ArrayType *T, ArrayRef<Constant *> V); private: static Constant *getImpl(ArrayType *T, ArrayRef<Constant *> V); @@ -471,7 +473,7 @@ class ConstantStruct final : public ConstantAggregate { public: // ConstantStruct accessors - static Constant *get(StructType *T, ArrayRef<Constant *> V); + LLVM_ABI static Constant *get(StructType *T, ArrayRef<Constant *> V); template <typename... Csts> static std::enable_if_t<are_base_of<Constant, Csts...>::value, Constant *> @@ -491,12 +493,12 @@ public: /// Return an anonymous struct type to use for a constant with the specified /// set of elements. The list must not be empty. - static StructType *getTypeForElements(ArrayRef<Constant *> V, - bool Packed = false); + LLVM_ABI static StructType *getTypeForElements(ArrayRef<Constant *> V, + bool Packed = false); /// This version of the method allows an empty list. - static StructType *getTypeForElements(LLVMContext &Ctx, - ArrayRef<Constant *> V, - bool Packed = false); + LLVM_ABI static StructType *getTypeForElements(LLVMContext &Ctx, + ArrayRef<Constant *> V, + bool Packed = false); /// Specialization - reduce amount of casting. inline StructType *getType() const { @@ -523,7 +525,7 @@ class ConstantVector final : public ConstantAggregate { public: // ConstantVector accessors - static Constant *get(ArrayRef<Constant *> V); + LLVM_ABI static Constant *get(ArrayRef<Constant *> V); private: static Constant *getImpl(ArrayRef<Constant *> V); @@ -531,7 +533,7 @@ private: public: /// Return a ConstantVector with the specified constant in each element. /// Note that this might not return an instance of ConstantVector - static Constant *getSplat(ElementCount EC, Constant *Elt); + LLVM_ABI static Constant *getSplat(ElementCount EC, Constant *Elt); /// Specialize the getType() method to always return a FixedVectorType, /// which reduces the amount of casting needed in parts of the compiler. @@ -542,7 +544,7 @@ public: /// If all elements of the vector constant have the same value, return that /// value. Otherwise, return nullptr. Ignore poison elements by setting /// AllowPoison to true. - Constant *getSplatValue(bool AllowPoison = false) const; + LLVM_ABI Constant *getSplatValue(bool AllowPoison = false) const; /// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { @@ -565,7 +567,7 @@ public: ConstantPointerNull(const ConstantPointerNull &) = delete; /// Static factory methods - Return objects of the specified value - static ConstantPointerNull *get(PointerType *T); + LLVM_ABI static ConstantPointerNull *get(PointerType *T); /// Specialize the getType() method to always return an PointerType, /// which reduces the amount of casting needed in parts of the compiler. @@ -608,7 +610,7 @@ protected: explicit ConstantDataSequential(Type *ty, ValueTy VT, const char *Data) : ConstantData(ty, VT), DataElements(Data) {} - static Constant *getImpl(StringRef Bytes, Type *Ty); + LLVM_ABI static Constant *getImpl(StringRef Bytes, Type *Ty); public: ConstantDataSequential(const ConstantDataSequential &) = delete; @@ -617,49 +619,49 @@ public: /// array of the specified element type. /// ConstantDataArray only works with normal float and int types that are /// stored densely in memory, not with things like i42 or x86_f80. - static bool isElementTypeCompatible(Type *Ty); + LLVM_ABI static bool isElementTypeCompatible(Type *Ty); /// If this is a sequential container of integers (of any size), return the /// specified element in the low bits of a uint64_t. - uint64_t getElementAsInteger(uint64_t i) const; + LLVM_ABI uint64_t getElementAsInteger(uint64_t i) const; /// If this is a sequential container of integers (of any size), return the /// specified element as an APInt. - APInt getElementAsAPInt(uint64_t i) const; + LLVM_ABI APInt getElementAsAPInt(uint64_t i) const; /// If this is a sequential container of floating point type, return the /// specified element as an APFloat. - APFloat getElementAsAPFloat(uint64_t i) const; + LLVM_ABI APFloat getElementAsAPFloat(uint64_t i) const; /// If this is an sequential container of floats, return the specified element /// as a float. - float getElementAsFloat(uint64_t i) const; + LLVM_ABI float getElementAsFloat(uint64_t i) const; /// If this is an sequential container of doubles, return the specified /// element as a double. - double getElementAsDouble(uint64_t i) const; + LLVM_ABI double getElementAsDouble(uint64_t i) const; /// Return a Constant for a specified index's element. /// Note that this has to compute a new constant to return, so it isn't as /// efficient as getElementAsInteger/Float/Double. - Constant *getElementAsConstant(uint64_t i) const; + LLVM_ABI Constant *getElementAsConstant(uint64_t i) const; /// Return the element type of the array/vector. - Type *getElementType() const; + LLVM_ABI Type *getElementType() const; /// Return the number of elements in the array or vector. - uint64_t getNumElements() const; + LLVM_ABI uint64_t getNumElements() const; /// Return the size (in bytes) of each element in the array/vector. /// The size of the elements is known to be a multiple of one byte. - uint64_t getElementByteSize() const; + LLVM_ABI uint64_t getElementByteSize() const; /// This method returns true if this is an array of \p CharSize integers. - bool isString(unsigned CharSize = 8) const; + LLVM_ABI bool isString(unsigned CharSize = 8) const; /// This method returns true if the array "isString", ends with a null byte, /// and does not contains any other null bytes. - bool isCString() const; + LLVM_ABI bool isCString() const; /// If this array is isString(), then this method returns the array as a /// StringRef. Otherwise, it asserts out. @@ -679,7 +681,7 @@ public: /// Return the raw, underlying, bytes of this data. Note that this is an /// extremely tricky thing to work with, as it exposes the host endianness of /// the data elements. - StringRef getRawDataValues() const; + LLVM_ABI StringRef getRawDataValues() const; /// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { @@ -741,17 +743,17 @@ public: /// number of bits of the type contained in the passed in ArrayRef. /// (i.e. half or bfloat for 16bits, float for 32bits, double for 64bits) Note /// that this can return a ConstantAggregateZero object. - static Constant *getFP(Type *ElementType, ArrayRef<uint16_t> Elts); - static Constant *getFP(Type *ElementType, ArrayRef<uint32_t> Elts); - static Constant *getFP(Type *ElementType, ArrayRef<uint64_t> Elts); + LLVM_ABI static Constant *getFP(Type *ElementType, ArrayRef<uint16_t> Elts); + LLVM_ABI static Constant *getFP(Type *ElementType, ArrayRef<uint32_t> Elts); + LLVM_ABI static Constant *getFP(Type *ElementType, ArrayRef<uint64_t> Elts); /// This method constructs a CDS and initializes it with a text string. /// The default behavior (AddNull==true) causes a null terminator to /// be placed at the end of the array (increasing the length of the string by /// one more than the StringRef would normally indicate. Pass AddNull=false /// to disable this behavior. - static Constant *getString(LLVMContext &Context, StringRef Initializer, - bool AddNull = true); + LLVM_ABI static Constant * + getString(LLVMContext &Context, StringRef Initializer, bool AddNull = true); /// Specialize the getType() method to always return an ArrayType, /// which reduces the amount of casting needed in parts of the compiler. @@ -788,12 +790,12 @@ public: /// get() constructors - Return a constant with vector type with an element /// count and element type matching the ArrayRef passed in. Note that this /// can return a ConstantAggregateZero object. - static Constant *get(LLVMContext &Context, ArrayRef<uint8_t> Elts); - static Constant *get(LLVMContext &Context, ArrayRef<uint16_t> Elts); - static Constant *get(LLVMContext &Context, ArrayRef<uint32_t> Elts); - static Constant *get(LLVMContext &Context, ArrayRef<uint64_t> Elts); - static Constant *get(LLVMContext &Context, ArrayRef<float> Elts); - static Constant *get(LLVMContext &Context, ArrayRef<double> Elts); + LLVM_ABI static Constant *get(LLVMContext &Context, ArrayRef<uint8_t> Elts); + LLVM_ABI static Constant *get(LLVMContext &Context, ArrayRef<uint16_t> Elts); + LLVM_ABI static Constant *get(LLVMContext &Context, ArrayRef<uint32_t> Elts); + LLVM_ABI static Constant *get(LLVMContext &Context, ArrayRef<uint64_t> Elts); + LLVM_ABI static Constant *get(LLVMContext &Context, ArrayRef<float> Elts); + LLVM_ABI static Constant *get(LLVMContext &Context, ArrayRef<double> Elts); /// getRaw() constructor - Return a constant with vector type with an element /// count and element type matching the NumElements and ElementTy parameters @@ -813,22 +815,22 @@ public: /// number of bits of the type contained in the passed in ArrayRef. /// (i.e. half or bfloat for 16bits, float for 32bits, double for 64bits) Note /// that this can return a ConstantAggregateZero object. - static Constant *getFP(Type *ElementType, ArrayRef<uint16_t> Elts); - static Constant *getFP(Type *ElementType, ArrayRef<uint32_t> Elts); - static Constant *getFP(Type *ElementType, ArrayRef<uint64_t> Elts); + LLVM_ABI static Constant *getFP(Type *ElementType, ArrayRef<uint16_t> Elts); + LLVM_ABI static Constant *getFP(Type *ElementType, ArrayRef<uint32_t> Elts); + LLVM_ABI static Constant *getFP(Type *ElementType, ArrayRef<uint64_t> Elts); /// Return a ConstantVector with the specified constant in each element. /// The specified constant has to be a of a compatible type (i8/i16/ /// i32/i64/half/bfloat/float/double) and must be a ConstantFP or ConstantInt. - static Constant *getSplat(unsigned NumElts, Constant *Elt); + LLVM_ABI static Constant *getSplat(unsigned NumElts, Constant *Elt); /// Returns true if this is a splat constant, meaning that all elements have /// the same value. - bool isSplat() const; + LLVM_ABI bool isSplat() const; /// If this is a splat constant, meaning that all of the elements have the /// same value, return that value. Otherwise return NULL. - Constant *getSplatValue() const; + LLVM_ABI Constant *getSplatValue() const; /// Specialize the getType() method to always return a FixedVectorType, /// which reduces the amount of casting needed in parts of the compiler. @@ -857,7 +859,7 @@ public: ConstantTokenNone(const ConstantTokenNone &) = delete; /// Return the ConstantTokenNone. - static ConstantTokenNone *get(LLVMContext &Context); + LLVM_ABI static ConstantTokenNone *get(LLVMContext &Context); /// Methods to support type inquiry through isa, cast, and dyn_cast. static bool classof(const Value *V) { @@ -878,7 +880,7 @@ public: ConstantTargetNone(const ConstantTargetNone &) = delete; /// Static factory methods - Return objects of the specified value. - static ConstantTargetNone *get(TargetExtType *T); + LLVM_ABI static ConstantTargetNone *get(TargetExtType *T); /// Specialize the getType() method to always return an TargetExtType, /// which reduces the amount of casting needed in parts of the compiler. @@ -910,21 +912,21 @@ public: void operator delete(void *Ptr) { User::operator delete(Ptr); } /// Return a BlockAddress for the specified function and basic block. - static BlockAddress *get(Function *F, BasicBlock *BB); + LLVM_ABI static BlockAddress *get(Function *F, BasicBlock *BB); /// Return a BlockAddress for the specified basic block. The basic /// block must be embedded into a function. - static BlockAddress *get(BasicBlock *BB); + LLVM_ABI static BlockAddress *get(BasicBlock *BB); /// Return a BlockAddress for the specified basic block, which may not be /// part of a function. The specified type must match the type of the function /// the block will be inserted into. - static BlockAddress *get(Type *Ty, BasicBlock *BB); + LLVM_ABI static BlockAddress *get(Type *Ty, BasicBlock *BB); /// Lookup an existing \c BlockAddress constant for the given BasicBlock. /// /// \returns 0 if \c !BB->hasAddressTaken(), otherwise the \c BlockAddress. - static BlockAddress *lookup(const BasicBlock *BB); + LLVM_ABI static BlockAddress *lookup(const BasicBlock *BB); /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -963,7 +965,7 @@ public: void operator delete(void *Ptr) { User::operator delete(Ptr); } /// Return a DSOLocalEquivalent for the specified global value. - static DSOLocalEquivalent *get(GlobalValue *GV); + LLVM_ABI static DSOLocalEquivalent *get(GlobalValue *GV); /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -1000,7 +1002,7 @@ class NoCFIValue final : public Constant { public: /// Return a NoCFIValue for the specified function. - static NoCFIValue *get(GlobalValue *GV); + LLVM_ABI static NoCFIValue *get(GlobalValue *GV); /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -1043,12 +1045,12 @@ class ConstantPtrAuth final : public Constant { public: /// Return a pointer signed with the specified parameters. - static ConstantPtrAuth *get(Constant *Ptr, ConstantInt *Key, - ConstantInt *Disc, Constant *AddrDisc); + LLVM_ABI static ConstantPtrAuth *get(Constant *Ptr, ConstantInt *Key, + ConstantInt *Disc, Constant *AddrDisc); /// Produce a new ptrauth expression signing the given value using /// the same schema as is stored in one. - ConstantPtrAuth *getWithSameSchema(Constant *Pointer) const; + LLVM_ABI ConstantPtrAuth *getWithSameSchema(Constant *Pointer) const; /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); @@ -1087,13 +1089,14 @@ public: /// These discriminators can't be used in real pointer-auth values; they /// can only be used in "prototype" values that indicate how some real /// schema is supposed to be produced. - bool hasSpecialAddressDiscriminator(uint64_t Value) const; + LLVM_ABI bool hasSpecialAddressDiscriminator(uint64_t Value) const; /// Check whether an authentication operation with key \p Key and (possibly /// blended) discriminator \p Discriminator is known to be compatible with /// this ptrauth signed pointer. - bool isKnownCompatibleWith(const Value *Key, const Value *Discriminator, - const DataLayout &DL) const; + LLVM_ABI bool isKnownCompatibleWith(const Value *Key, + const Value *Discriminator, + const DataLayout &DL) const; /// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { @@ -1138,30 +1141,31 @@ public: /// getAlignOf constant expr - computes the alignment of a type in a target /// independent way (Note: the return type is an i64). - static Constant *getAlignOf(Type *Ty); + LLVM_ABI static Constant *getAlignOf(Type *Ty); /// getSizeOf constant expr - computes the (alloc) size of a type (in /// address-units, not bits) in a target independent way (Note: the return /// type is an i64). /// - static Constant *getSizeOf(Type *Ty); - - static Constant *getNeg(Constant *C, bool HasNSW = false); - static Constant *getNot(Constant *C); - static Constant *getAdd(Constant *C1, Constant *C2, bool HasNUW = false, - bool HasNSW = false); - static Constant *getSub(Constant *C1, Constant *C2, bool HasNUW = false, - bool HasNSW = false); - static Constant *getXor(Constant *C1, Constant *C2); - static Constant *getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced = false); - static Constant *getPtrToInt(Constant *C, Type *Ty, - bool OnlyIfReduced = false); - static Constant *getIntToPtr(Constant *C, Type *Ty, - bool OnlyIfReduced = false); - static Constant *getBitCast(Constant *C, Type *Ty, - bool OnlyIfReduced = false); - static Constant *getAddrSpaceCast(Constant *C, Type *Ty, - bool OnlyIfReduced = false); + LLVM_ABI static Constant *getSizeOf(Type *Ty); + + LLVM_ABI static Constant *getNeg(Constant *C, bool HasNSW = false); + LLVM_ABI static Constant *getNot(Constant *C); + LLVM_ABI static Constant *getAdd(Constant *C1, Constant *C2, + bool HasNUW = false, bool HasNSW = false); + LLVM_ABI static Constant *getSub(Constant *C1, Constant *C2, + bool HasNUW = false, bool HasNSW = false); + LLVM_ABI static Constant *getXor(Constant *C1, Constant *C2); + LLVM_ABI static Constant *getTrunc(Constant *C, Type *Ty, + bool OnlyIfReduced = false); + LLVM_ABI static Constant *getPtrToInt(Constant *C, Type *Ty, + bool OnlyIfReduced = false); + LLVM_ABI static Constant *getIntToPtr(Constant *C, Type *Ty, + bool OnlyIfReduced = false); + LLVM_ABI static Constant *getBitCast(Constant *C, Type *Ty, + bool OnlyIfReduced = false); + LLVM_ABI static Constant *getAddrSpaceCast(Constant *C, Type *Ty, + bool OnlyIfReduced = false); static Constant *getNSWNeg(Constant *C) { return getNeg(C, /*HasNSW=*/true); } @@ -1185,7 +1189,7 @@ public: /// function returns a new scalar/fixed width vector obtained from logBase2 /// of C. Undef vector elements are set to zero. /// Return a null pointer otherwise. - static Constant *getExactLogBase2(Constant *C); + LLVM_ABI static Constant *getExactLogBase2(Constant *C); /// Return the identity constant for a binary opcode. /// If the binop is not commutative, callers can acquire the operand 1 @@ -1194,17 +1198,18 @@ public: /// is a fadd/fsub operation and we don't care about signed zeros, then /// setting NSZ to true returns the identity +0.0 instead of -0.0. Return /// nullptr if the operator does not have an identity constant. - static Constant *getBinOpIdentity(unsigned Opcode, Type *Ty, - bool AllowRHSConstant = false, - bool NSZ = false); + LLVM_ABI static Constant *getBinOpIdentity(unsigned Opcode, Type *Ty, + bool AllowRHSConstant = false, + bool NSZ = false); - static Constant *getIntrinsicIdentity(Intrinsic::ID, Type *Ty); + LLVM_ABI static Constant *getIntrinsicIdentity(Intrinsic::ID, Type *Ty); /// Return the identity constant for a binary or intrinsic Instruction. /// The identity constant C is defined as X op C = X and C op X = X where C /// and X are the first two operands, and the operation is commutative. - static Constant *getIdentity(Instruction *I, Type *Ty, - bool AllowRHSConstant = false, bool NSZ = false); + LLVM_ABI static Constant *getIdentity(Instruction *I, Type *Ty, + bool AllowRHSConstant = false, + bool NSZ = false); /// Return the absorbing element for the given binary /// operation, i.e. a constant C such that X op C = C and C op X = C for @@ -1212,8 +1217,8 @@ public: /// If AllowLHSConstant is true, the LHS operand is a constant C that must be /// defined as C op X = C. It returns null if the operator doesn't have /// an absorbing element. - static Constant *getBinOpAbsorber(unsigned Opcode, Type *Ty, - bool AllowLHSConstant = false); + LLVM_ABI static Constant *getBinOpAbsorber(unsigned Opcode, Type *Ty, + bool AllowLHSConstant = false); /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); @@ -1224,38 +1229,39 @@ public: /// \param C The constant to be converted /// \param Ty The type to which the constant is converted /// \param OnlyIfReduced see \a getWithOperands() docs. - static Constant *getCast(unsigned ops, Constant *C, Type *Ty, - bool OnlyIfReduced = false); + LLVM_ABI static Constant *getCast(unsigned ops, Constant *C, Type *Ty, + bool OnlyIfReduced = false); // Create a Trunc or BitCast cast constant expression - static Constant * + LLVM_ABI static Constant * getTruncOrBitCast(Constant *C, ///< The constant to trunc or bitcast Type *Ty ///< The type to trunc or bitcast C to ); /// Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant /// expression. - static Constant * + LLVM_ABI static Constant * getPointerCast(Constant *C, ///< The pointer value to be casted (operand 0) Type *Ty ///< The type to which cast should be made ); /// Create a BitCast or AddrSpaceCast for a pointer type depending on /// the address space. - static Constant *getPointerBitCastOrAddrSpaceCast( + LLVM_ABI static Constant *getPointerBitCastOrAddrSpaceCast( Constant *C, ///< The constant to addrspacecast or bitcast Type *Ty ///< The type to bitcast or addrspacecast C to ); /// Return true if this is a convert constant expression - bool isCast() const; + LLVM_ABI bool isCast() const; /// get - Return a binary or shift operator constant expression, /// folding if possible. /// /// \param OnlyIfReducedTy see \a getWithOperands() docs. - static Constant *get(unsigned Opcode, Constant *C1, Constant *C2, - unsigned Flags = 0, Type *OnlyIfReducedTy = nullptr); + LLVM_ABI static Constant *get(unsigned Opcode, Constant *C1, Constant *C2, + unsigned Flags = 0, + Type *OnlyIfReducedTy = nullptr); /// Getelementptr form. Value* is only accepted for convenience; /// all elements must be Constants. @@ -1282,7 +1288,7 @@ public: return getGetElementPtr(Ty, C, cast<Value>(Idx), NW, InRange, OnlyIfReducedTy); } - static Constant * + LLVM_ABI static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef<Value *> IdxList, GEPNoWrapFlags NW = GEPNoWrapFlags::none(), std::optional<ConstantRange> InRange = std::nullopt, @@ -1306,29 +1312,30 @@ public: return getGetElementPtr(Ty, C, IdxList, GEPNoWrapFlags::inBounds()); } - static Constant *getExtractElement(Constant *Vec, Constant *Idx, - Type *OnlyIfReducedTy = nullptr); - static Constant *getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, - Type *OnlyIfReducedTy = nullptr); - static Constant *getShuffleVector(Constant *V1, Constant *V2, - ArrayRef<int> Mask, - Type *OnlyIfReducedTy = nullptr); + LLVM_ABI static Constant *getExtractElement(Constant *Vec, Constant *Idx, + Type *OnlyIfReducedTy = nullptr); + LLVM_ABI static Constant *getInsertElement(Constant *Vec, Constant *Elt, + Constant *Idx, + Type *OnlyIfReducedTy = nullptr); + LLVM_ABI static Constant *getShuffleVector(Constant *V1, Constant *V2, + ArrayRef<int> Mask, + Type *OnlyIfReducedTy = nullptr); /// Return the opcode at the root of this constant expression unsigned getOpcode() const { return getSubclassDataFromValue(); } /// Assert that this is a shufflevector and return the mask. See class /// ShuffleVectorInst for a description of the mask representation. - ArrayRef<int> getShuffleMask() const; + LLVM_ABI ArrayRef<int> getShuffleMask() const; /// Assert that this is a shufflevector and return the mask. /// /// TODO: This is a temporary hack until we update the bitcode format for /// shufflevector. - Constant *getShuffleMaskForBitcode() const; + LLVM_ABI Constant *getShuffleMaskForBitcode() const; /// Return a string representation for an opcode. - const char *getOpcodeName() const; + LLVM_ABI const char *getOpcodeName() const; /// This returns the current constant expression with the operands replaced /// with the specified values. The specified array must have the same number @@ -1346,9 +1353,9 @@ public: /// If \c OnlyIfReduced is \c true, nullptr will be returned unless something /// gets constant-folded, the type changes, or the expression is otherwise /// canonicalized. This parameter should almost always be \c false. - Constant *getWithOperands(ArrayRef<Constant *> Ops, Type *Ty, - bool OnlyIfReduced = false, - Type *SrcTy = nullptr) const; + LLVM_ABI Constant *getWithOperands(ArrayRef<Constant *> Ops, Type *Ty, + bool OnlyIfReduced = false, + Type *SrcTy = nullptr) const; /// Returns an Instruction which implements the same operation as this /// ConstantExpr. It is not inserted into any basic block. @@ -1357,21 +1364,21 @@ public: /// which would take a ConstantExpr parameter, but that would have spread /// implementation details of ConstantExpr outside of Constants.cpp, which /// would make it harder to remove ConstantExprs altogether. - Instruction *getAsInstruction() const; + LLVM_ABI Instruction *getAsInstruction() const; /// Whether creating a constant expression for this binary operator is /// desirable. - static bool isDesirableBinOp(unsigned Opcode); + LLVM_ABI static bool isDesirableBinOp(unsigned Opcode); /// Whether creating a constant expression for this binary operator is /// supported. - static bool isSupportedBinOp(unsigned Opcode); + LLVM_ABI static bool isSupportedBinOp(unsigned Opcode); /// Whether creating a constant expression for this cast is desirable. - static bool isDesirableCastOp(unsigned Opcode); + LLVM_ABI static bool isDesirableCastOp(unsigned Opcode); /// Whether creating a constant expression for this cast is supported. - static bool isSupportedCastOp(unsigned Opcode); + LLVM_ABI static bool isSupportedCastOp(unsigned Opcode); /// Whether creating a constant expression for this getelementptr type is /// supported. @@ -1422,25 +1429,25 @@ public: UndefValue(const UndefValue &) = delete; /// Static factory methods - Return an 'undef' object of the specified type. - static UndefValue *get(Type *T); + LLVM_ABI static UndefValue *get(Type *T); /// If this Undef has array or vector type, return a undef with the right /// element type. - UndefValue *getSequentialElement() const; + LLVM_ABI UndefValue *getSequentialElement() const; /// If this undef has struct type, return a undef with the right element type /// for the specified element. - UndefValue *getStructElement(unsigned Elt) const; + LLVM_ABI UndefValue *getStructElement(unsigned Elt) const; /// Return an undef of the right value for the specified GEP index if we can, /// otherwise return null (e.g. if C is a ConstantExpr). - UndefValue *getElementValue(Constant *C) const; + LLVM_ABI UndefValue *getElementValue(Constant *C) const; /// Return an undef of the right value for the specified GEP index. - UndefValue *getElementValue(unsigned Idx) const; + LLVM_ABI UndefValue *getElementValue(unsigned Idx) const; /// Return the number of elements in the array, vector, or struct. - unsigned getNumElements() const; + LLVM_ABI unsigned getNumElements() const; /// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { @@ -1467,22 +1474,22 @@ public: PoisonValue(const PoisonValue &) = delete; /// Static factory methods - Return an 'poison' object of the specified type. - static PoisonValue *get(Type *T); + LLVM_ABI static PoisonValue *get(Type *T); /// If this poison has array or vector type, return a poison with the right /// element type. - PoisonValue *getSequentialElement() const; + LLVM_ABI PoisonValue *getSequentialElement() const; /// If this poison has struct type, return a poison with the right element /// type for the specified element. - PoisonValue *getStructElement(unsigned Elt) const; + LLVM_ABI PoisonValue *getStructElement(unsigned Elt) const; /// Return an poison of the right value for the specified GEP index if we can, /// otherwise return null (e.g. if C is a ConstantExpr). - PoisonValue *getElementValue(Constant *C) const; + LLVM_ABI PoisonValue *getElementValue(Constant *C) const; /// Return an poison of the right value for the specified GEP index. - PoisonValue *getElementValue(unsigned Idx) const; + LLVM_ABI PoisonValue *getElementValue(unsigned Idx) const; /// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h index 4ce71bd..ebfe41d 100644 --- a/llvm/include/llvm/IR/DIBuilder.h +++ b/llvm/include/llvm/IR/DIBuilder.h @@ -24,6 +24,7 @@ #include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/TrackingMDRef.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" #include <algorithm> #include <cstdint> #include <optional> @@ -109,17 +110,17 @@ namespace llvm { /// in order to resolve cycles during \a finalize(). /// /// If \p CU is given a value other than nullptr, then set \p CUNode to CU. - explicit DIBuilder(Module &M, bool AllowUnresolved = true, - DICompileUnit *CU = nullptr); + LLVM_ABI explicit DIBuilder(Module &M, bool AllowUnresolved = true, + DICompileUnit *CU = nullptr); DIBuilder(const DIBuilder &) = delete; DIBuilder &operator=(const DIBuilder &) = delete; /// Construct any deferred debug info descriptors. - void finalize(); + LLVM_ABI void finalize(); /// Finalize a specific subprogram - no new variables may be added to this /// subprogram afterwards. - void finalizeSubprogram(DISubprogram *SP); + LLVM_ABI void finalizeSubprogram(DISubprogram *SP); /// A CompileUnit provides an anchor for all debugging /// information generated during this instance of compilation. @@ -148,7 +149,7 @@ namespace llvm { /// \param SysRoot The clang system root (value of -isysroot). /// \param SDK The SDK name. On Darwin, this is the last component /// of the sysroot. - DICompileUnit * + LLVM_ABI DICompileUnit * createCompileUnit(unsigned Lang, DIFile *File, StringRef Producer, bool isOptimized, StringRef Flags, unsigned RV, StringRef SplitName = StringRef(), @@ -167,7 +168,7 @@ namespace llvm { /// \param Checksum Optional checksum kind (e.g. CSK_MD5, CSK_SHA1, etc.) /// and value. /// \param Source Optional source text. - DIFile *createFile( + LLVM_ABI DIFile *createFile( StringRef Filename, StringRef Directory, std::optional<DIFile::ChecksumInfo<StringRef>> Checksum = std::nullopt, std::optional<StringRef> Source = std::nullopt); @@ -178,8 +179,9 @@ namespace llvm { /// \param MacroType DW_MACINFO_define or DW_MACINFO_undef. /// \param Name Macro name. /// \param Value Macro value. - DIMacro *createMacro(DIMacroFile *Parent, unsigned Line, unsigned MacroType, - StringRef Name, StringRef Value = StringRef()); + LLVM_ABI DIMacro *createMacro(DIMacroFile *Parent, unsigned Line, + unsigned MacroType, StringRef Name, + StringRef Value = StringRef()); /// Create debugging information temporary entry for a macro file. /// List of macro node direct children will be calculated by DIBuilder, @@ -187,19 +189,20 @@ namespace llvm { /// \param Parent Macro file parent (could be nullptr). /// \param Line Source line number where the macro file is included. /// \param File File descriptor containing the name of the macro file. - DIMacroFile *createTempMacroFile(DIMacroFile *Parent, unsigned Line, - DIFile *File); + LLVM_ABI DIMacroFile *createTempMacroFile(DIMacroFile *Parent, + unsigned Line, DIFile *File); /// Create a single enumerator value. - DIEnumerator *createEnumerator(StringRef Name, const APSInt &Value); - DIEnumerator *createEnumerator(StringRef Name, uint64_t Val, - bool IsUnsigned = false); + LLVM_ABI DIEnumerator *createEnumerator(StringRef Name, + const APSInt &Value); + LLVM_ABI DIEnumerator *createEnumerator(StringRef Name, uint64_t Val, + bool IsUnsigned = false); /// Create a DWARF unspecified type. - DIBasicType *createUnspecifiedType(StringRef Name); + LLVM_ABI DIBasicType *createUnspecifiedType(StringRef Name); /// Create C++11 nullptr type. - DIBasicType *createNullPtrType(); + LLVM_ABI DIBasicType *createNullPtrType(); /// Create debugging information entry for a basic /// type. @@ -210,10 +213,10 @@ namespace llvm { /// \param NumExtraInhabitants The number of extra inhabitants of the type. /// An extra inhabitant is a bit pattern that does not represent a valid /// value for instances of a given type. This is used by the Swift language. - DIBasicType *createBasicType(StringRef Name, uint64_t SizeInBits, - unsigned Encoding, - DINode::DIFlags Flags = DINode::FlagZero, - uint32_t NumExtraInhabitants = 0); + LLVM_ABI DIBasicType * + createBasicType(StringRef Name, uint64_t SizeInBits, unsigned Encoding, + DINode::DIFlags Flags = DINode::FlagZero, + uint32_t NumExtraInhabitants = 0); /// Create debugging information entry for a binary fixed-point type. /// \param Name Type name. @@ -221,7 +224,7 @@ namespace llvm { /// dwarf::DW_ATE_signed_fixed or DW_ATE_unsigned_fixed. /// \param Flags Optional DWARF attributes, e.g., DW_AT_endianity. /// \param Factor Binary scale factor. - DIFixedPointType * + LLVM_ABI DIFixedPointType * createBinaryFixedPointType(StringRef Name, uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding, DINode::DIFlags Flags, int Factor); @@ -232,7 +235,7 @@ namespace llvm { /// dwarf::DW_ATE_signed_fixed or DW_ATE_unsigned_fixed. /// \param Flags Optional DWARF attributes, e.g., DW_AT_endianity. /// \param Factor Decimal scale factor. - DIFixedPointType * + LLVM_ABI DIFixedPointType * createDecimalFixedPointType(StringRef Name, uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding, DINode::DIFlags Flags, int Factor); @@ -245,7 +248,7 @@ namespace llvm { /// \param Flags Optional DWARF attributes, e.g., DW_AT_endianity. /// \param Numerator Numerator of scale factor. /// \param Denominator Denominator of scale factor. - DIFixedPointType * + LLVM_ABI DIFixedPointType * createRationalFixedPointType(StringRef Name, uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding, DINode::DIFlags Flags, APInt Numerator, @@ -255,30 +258,32 @@ namespace llvm { /// type. /// \param Name Type name. /// \param SizeInBits Size of the type. - DIStringType *createStringType(StringRef Name, uint64_t SizeInBits); + LLVM_ABI DIStringType *createStringType(StringRef Name, + uint64_t SizeInBits); /// Create debugging information entry for Fortran /// assumed length string type. /// \param Name Type name. /// \param StringLength String length expressed as DIVariable *. /// \param StrLocationExp Optional memory location of the string. - DIStringType *createStringType(StringRef Name, DIVariable *StringLength, - DIExpression *StrLocationExp = nullptr); + LLVM_ABI DIStringType * + createStringType(StringRef Name, DIVariable *StringLength, + DIExpression *StrLocationExp = nullptr); /// Create debugging information entry for Fortran /// assumed length string type. /// \param Name Type name. /// \param StringLengthExp String length expressed in DIExpression form. /// \param StrLocationExp Optional memory location of the string. - DIStringType *createStringType(StringRef Name, - DIExpression *StringLengthExp, - DIExpression *StrLocationExp = nullptr); + LLVM_ABI DIStringType * + createStringType(StringRef Name, DIExpression *StringLengthExp, + DIExpression *StrLocationExp = nullptr); /// Create debugging information entry for a qualified /// type, e.g. 'const int'. /// \param Tag Tag identifing type, e.g. dwarf::TAG_volatile_type /// \param FromTy Base Type. - DIDerivedType *createQualifiedType(unsigned Tag, DIType *FromTy); + LLVM_ABI DIDerivedType *createQualifiedType(unsigned Tag, DIType *FromTy); /// Create debugging information entry for a pointer. /// \param PointeeTy Type pointed by this pointer. @@ -287,32 +292,32 @@ namespace llvm { /// \param DWARFAddressSpace DWARF address space. (optional) /// \param Name Pointer type name. (optional) /// \param Annotations Member annotations. - DIDerivedType * + LLVM_ABI DIDerivedType * createPointerType(DIType *PointeeTy, uint64_t SizeInBits, uint32_t AlignInBits = 0, std::optional<unsigned> DWARFAddressSpace = std::nullopt, StringRef Name = "", DINodeArray Annotations = nullptr); /// Create a __ptrauth qualifier. - DIDerivedType *createPtrAuthQualifiedType(DIType *FromTy, unsigned Key, - bool IsAddressDiscriminated, - unsigned ExtraDiscriminator, - bool IsaPointer, - bool authenticatesNullValues); + LLVM_ABI DIDerivedType * + createPtrAuthQualifiedType(DIType *FromTy, unsigned Key, + bool IsAddressDiscriminated, + unsigned ExtraDiscriminator, bool IsaPointer, + bool authenticatesNullValues); /// Create debugging information entry for a pointer to member. /// \param PointeeTy Type pointed to by this pointer. /// \param SizeInBits Size. /// \param AlignInBits Alignment. (optional) /// \param Class Type for which this pointer points to members of. - DIDerivedType * + LLVM_ABI DIDerivedType * createMemberPointerType(DIType *PointeeTy, DIType *Class, uint64_t SizeInBits, uint32_t AlignInBits = 0, DINode::DIFlags Flags = DINode::FlagZero); /// Create debugging information entry for a c++ /// style reference or rvalue reference type. - DIDerivedType *createReferenceType( + LLVM_ABI DIDerivedType *createReferenceType( unsigned Tag, DIType *RTy, uint64_t SizeInBits = 0, uint32_t AlignInBits = 0, std::optional<unsigned> DWARFAddressSpace = std::nullopt); @@ -326,11 +331,11 @@ namespace llvm { /// \param AlignInBits Alignment. (optional) /// \param Flags Flags to describe inheritance attribute, e.g. private /// \param Annotations Annotations. (optional) - DIDerivedType *createTypedef(DIType *Ty, StringRef Name, DIFile *File, - unsigned LineNo, DIScope *Context, - uint32_t AlignInBits = 0, - DINode::DIFlags Flags = DINode::FlagZero, - DINodeArray Annotations = nullptr); + LLVM_ABI DIDerivedType * + createTypedef(DIType *Ty, StringRef Name, DIFile *File, unsigned LineNo, + DIScope *Context, uint32_t AlignInBits = 0, + DINode::DIFlags Flags = DINode::FlagZero, + DINodeArray Annotations = nullptr); /// Create debugging information entry for a template alias. /// \param Ty Original type. @@ -343,15 +348,15 @@ namespace llvm { /// \param Flags Flags to describe inheritance attribute (optional), /// e.g. private. /// \param Annotations Annotations. (optional) - DIDerivedType *createTemplateAlias(DIType *Ty, StringRef Name, DIFile *File, - unsigned LineNo, DIScope *Context, - DINodeArray TParams, - uint32_t AlignInBits = 0, - DINode::DIFlags Flags = DINode::FlagZero, - DINodeArray Annotations = nullptr); + LLVM_ABI DIDerivedType * + createTemplateAlias(DIType *Ty, StringRef Name, DIFile *File, + unsigned LineNo, DIScope *Context, DINodeArray TParams, + uint32_t AlignInBits = 0, + DINode::DIFlags Flags = DINode::FlagZero, + DINodeArray Annotations = nullptr); /// Create debugging information entry for a 'friend'. - DIDerivedType *createFriend(DIType *Ty, DIType *FriendTy); + LLVM_ABI DIDerivedType *createFriend(DIType *Ty, DIType *FriendTy); /// Create debugging information entry to establish /// inheritance relationship between two types. @@ -361,9 +366,10 @@ namespace llvm { /// \param VBPtrOffset Virtual base pointer offset. /// \param Flags Flags to describe inheritance attribute, /// e.g. private - DIDerivedType *createInheritance(DIType *Ty, DIType *BaseTy, - uint64_t BaseOffset, uint32_t VBPtrOffset, - DINode::DIFlags Flags); + LLVM_ABI DIDerivedType *createInheritance(DIType *Ty, DIType *BaseTy, + uint64_t BaseOffset, + uint32_t VBPtrOffset, + DINode::DIFlags Flags); /// Create debugging information entry for a member. /// \param Scope Member scope. @@ -376,12 +382,11 @@ namespace llvm { /// \param Flags Flags to encode member attribute, e.g. private /// \param Ty Parent type. /// \param Annotations Member annotations. - DIDerivedType *createMemberType(DIScope *Scope, StringRef Name, - DIFile *File, unsigned LineNo, - uint64_t SizeInBits, uint32_t AlignInBits, - uint64_t OffsetInBits, - DINode::DIFlags Flags, DIType *Ty, - DINodeArray Annotations = nullptr); + LLVM_ABI DIDerivedType * + createMemberType(DIScope *Scope, StringRef Name, DIFile *File, + unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, + uint64_t OffsetInBits, DINode::DIFlags Flags, DIType *Ty, + DINodeArray Annotations = nullptr); /// Create debugging information entry for a variant. A variant /// normally should be a member of a variant part. @@ -398,13 +403,10 @@ namespace llvm { /// ConstantDataArray if the variant applies /// for multiple discriminants. /// \param Ty Parent type. - DIDerivedType *createVariantMemberType(DIScope *Scope, StringRef Name, - DIFile *File, unsigned LineNo, - uint64_t SizeInBits, - uint32_t AlignInBits, - uint64_t OffsetInBits, - Constant *Discriminant, - DINode::DIFlags Flags, DIType *Ty); + LLVM_ABI DIDerivedType *createVariantMemberType( + DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, + uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, + Constant *Discriminant, DINode::DIFlags Flags, DIType *Ty); /// Create debugging information entry for a variant. A variant /// created this way "inlines" multiple members into the enclosing @@ -416,8 +418,10 @@ namespace llvm { /// ConstantDataArray if the variant applies /// for multiple discriminants. /// \param Ty Parent type. - DIDerivedType *createVariantMemberType(DIScope *Scope, DINodeArray Elements, - Constant *Discriminant, DIType *Ty); + LLVM_ABI DIDerivedType *createVariantMemberType(DIScope *Scope, + DINodeArray Elements, + Constant *Discriminant, + DIType *Ty); /// Create debugging information entry for a bit field member. /// \param Scope Member scope. @@ -430,13 +434,11 @@ namespace llvm { /// \param Flags Flags to encode member attribute. /// \param Ty Parent type. /// \param Annotations Member annotations. - DIDerivedType *createBitFieldMemberType(DIScope *Scope, StringRef Name, - DIFile *File, unsigned LineNo, - uint64_t SizeInBits, - uint64_t OffsetInBits, - uint64_t StorageOffsetInBits, - DINode::DIFlags Flags, DIType *Ty, - DINodeArray Annotations = nullptr); + LLVM_ABI DIDerivedType *createBitFieldMemberType( + DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, + uint64_t SizeInBits, uint64_t OffsetInBits, + uint64_t StorageOffsetInBits, DINode::DIFlags Flags, DIType *Ty, + DINodeArray Annotations = nullptr); /// Create debugging information entry for a /// C++ static data member. @@ -449,11 +451,12 @@ namespace llvm { /// \param Val Const initializer of the member. /// \param Tag DWARF tag of the static member. /// \param AlignInBits Member alignment. - DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name, - DIFile *File, unsigned LineNo, - DIType *Ty, DINode::DIFlags Flags, - Constant *Val, unsigned Tag, - uint32_t AlignInBits = 0); + LLVM_ABI DIDerivedType *createStaticMemberType(DIScope *Scope, + StringRef Name, DIFile *File, + unsigned LineNo, DIType *Ty, + DINode::DIFlags Flags, + Constant *Val, unsigned Tag, + uint32_t AlignInBits = 0); /// Create debugging information entry for Objective-C /// instance variable. @@ -466,10 +469,12 @@ namespace llvm { /// \param Flags Flags to encode member attribute, e.g. private /// \param Ty Parent type. /// \param PropertyNode Property associated with this ivar. - DIDerivedType *createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo, - uint64_t SizeInBits, uint32_t AlignInBits, - uint64_t OffsetInBits, DINode::DIFlags Flags, - DIType *Ty, MDNode *PropertyNode); + LLVM_ABI DIDerivedType *createObjCIVar(StringRef Name, DIFile *File, + unsigned LineNo, uint64_t SizeInBits, + uint32_t AlignInBits, + uint64_t OffsetInBits, + DINode::DIFlags Flags, DIType *Ty, + MDNode *PropertyNode); /// Create debugging information entry for Objective-C /// property. @@ -480,11 +485,10 @@ namespace llvm { /// \param SetterName Name of the Objective C property setter selector. /// \param PropertyAttributes Objective C property attributes. /// \param Ty Type. - DIObjCProperty *createObjCProperty(StringRef Name, DIFile *File, - unsigned LineNumber, - StringRef GetterName, - StringRef SetterName, - unsigned PropertyAttributes, DIType *Ty); + LLVM_ABI DIObjCProperty * + createObjCProperty(StringRef Name, DIFile *File, unsigned LineNumber, + StringRef GetterName, StringRef SetterName, + unsigned PropertyAttributes, DIType *Ty); /// Create debugging information entry for a class. /// \param Scope Scope in which this class is defined. @@ -503,7 +507,7 @@ namespace llvm { /// for more info. /// \param TemplateParms Template type parameters. /// \param UniqueIdentifier A unique identifier for the class. - DICompositeType *createClassType( + LLVM_ABI DICompositeType *createClassType( DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements, @@ -526,7 +530,7 @@ namespace llvm { /// \param NumExtraInhabitants The number of extra inhabitants of the type. /// An extra inhabitant is a bit pattern that does not represent a valid /// value for instances of a given type. This is used by the Swift language. - DICompositeType *createStructType( + LLVM_ABI DICompositeType *createStructType( DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang = 0, @@ -544,13 +548,12 @@ namespace llvm { /// \param Elements Union elements. /// \param RunTimeLang Optional parameter, Objective-C runtime version. /// \param UniqueIdentifier A unique identifier for the union. - DICompositeType *createUnionType(DIScope *Scope, StringRef Name, - DIFile *File, unsigned LineNumber, - uint64_t SizeInBits, uint32_t AlignInBits, - DINode::DIFlags Flags, - DINodeArray Elements, - unsigned RunTimeLang = 0, - StringRef UniqueIdentifier = ""); + LLVM_ABI DICompositeType * + createUnionType(DIScope *Scope, StringRef Name, DIFile *File, + unsigned LineNumber, uint64_t SizeInBits, + uint32_t AlignInBits, DINode::DIFlags Flags, + DINodeArray Elements, unsigned RunTimeLang = 0, + StringRef UniqueIdentifier = ""); /// Create debugging information entry for a variant part. A /// variant part normally has a discriminator (though this is not @@ -565,13 +568,12 @@ namespace llvm { /// \param Discriminator Discriminant member /// \param Elements Variant elements. /// \param UniqueIdentifier A unique identifier for the union. - DICompositeType *createVariantPart(DIScope *Scope, StringRef Name, - DIFile *File, unsigned LineNumber, - uint64_t SizeInBits, uint32_t AlignInBits, - DINode::DIFlags Flags, - DIDerivedType *Discriminator, - DINodeArray Elements, - StringRef UniqueIdentifier = ""); + LLVM_ABI DICompositeType * + createVariantPart(DIScope *Scope, StringRef Name, DIFile *File, + unsigned LineNumber, uint64_t SizeInBits, + uint32_t AlignInBits, DINode::DIFlags Flags, + DIDerivedType *Discriminator, DINodeArray Elements, + StringRef UniqueIdentifier = ""); /// Create debugging information for template /// type parameter. @@ -579,10 +581,9 @@ namespace llvm { /// \param Name Type parameter name. /// \param Ty Parameter type. /// \param IsDefault Parameter is default or not - DITemplateTypeParameter *createTemplateTypeParameter(DIScope *Scope, - StringRef Name, - DIType *Ty, - bool IsDefault); + LLVM_ABI DITemplateTypeParameter * + createTemplateTypeParameter(DIScope *Scope, StringRef Name, DIType *Ty, + bool IsDefault); /// Create debugging information for template /// value parameter. @@ -591,7 +592,7 @@ namespace llvm { /// \param Ty Parameter type. /// \param IsDefault Parameter is default or not /// \param Val Constant parameter value. - DITemplateValueParameter * + LLVM_ABI DITemplateValueParameter * createTemplateValueParameter(DIScope *Scope, StringRef Name, DIType *Ty, bool IsDefault, Constant *Val); @@ -601,7 +602,7 @@ namespace llvm { /// \param Ty Parameter type. /// \param Val The fully qualified name of the template. /// \param IsDefault Parameter is default or not. - DITemplateValueParameter * + LLVM_ABI DITemplateValueParameter * createTemplateTemplateParameter(DIScope *Scope, StringRef Name, DIType *Ty, StringRef Val, bool IsDefault = false); @@ -610,10 +611,9 @@ namespace llvm { /// \param Name Value parameter name. /// \param Ty Parameter type. /// \param Val An array of types in the pack. - DITemplateValueParameter *createTemplateParameterPack(DIScope *Scope, - StringRef Name, - DIType *Ty, - DINodeArray Val); + LLVM_ABI DITemplateValueParameter * + createTemplateParameterPack(DIScope *Scope, StringRef Name, DIType *Ty, + DINodeArray Val); /// Create debugging information entry for an array. /// \param Size Array size. @@ -632,7 +632,7 @@ namespace llvm { /// \param Rank The rank attribute of a descriptor-based /// Fortran array, either a DIExpression* or /// a DIVariable*. - DICompositeType *createArrayType( + LLVM_ABI DICompositeType *createArrayType( uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts, PointerUnion<DIExpression *, DIVariable *> DataLocation = nullptr, PointerUnion<DIExpression *, DIVariable *> Associated = nullptr, @@ -661,7 +661,7 @@ namespace llvm { /// Fortran array, either a DIExpression* or /// a DIVariable*. /// \param BitStride The bit size of an element of the array. - DICompositeType *createArrayType( + LLVM_ABI DICompositeType *createArrayType( DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts, PointerUnion<DIExpression *, DIVariable *> DataLocation = nullptr, @@ -675,8 +675,9 @@ namespace llvm { /// \param AlignInBits Alignment. /// \param Ty Element type. /// \param Subscripts Subscripts. - DICompositeType *createVectorType(uint64_t Size, uint32_t AlignInBits, - DIType *Ty, DINodeArray Subscripts); + LLVM_ABI DICompositeType *createVectorType(uint64_t Size, + uint32_t AlignInBits, DIType *Ty, + DINodeArray Subscripts); /// Create debugging information entry for an /// enumeration. @@ -692,7 +693,7 @@ namespace llvm { /// \param UniqueIdentifier A unique identifier for the enum. /// \param IsScoped Boolean flag indicate if this is C++11/ObjC 'enum /// class'. - DICompositeType *createEnumerationType( + LLVM_ABI DICompositeType *createEnumerationType( DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements, DIType *UnderlyingType, unsigned RunTimeLang = 0, @@ -706,9 +707,10 @@ namespace llvm { /// \param SizeInBits Set size. /// \param AlignInBits Set alignment. /// \param Ty Base type of the set. - DIDerivedType *createSetType(DIScope *Scope, StringRef Name, DIFile *File, - unsigned LineNo, uint64_t SizeInBits, - uint32_t AlignInBits, DIType *Ty); + LLVM_ABI DIDerivedType *createSetType(DIScope *Scope, StringRef Name, + DIFile *File, unsigned LineNo, + uint64_t SizeInBits, + uint32_t AlignInBits, DIType *Ty); /// Create subroutine type. /// \param ParameterTypes An array of subroutine parameter types. This @@ -716,20 +718,20 @@ namespace llvm { /// \param Flags E.g.: LValueReference. /// These flags are used to emit dwarf attributes. /// \param CC Calling convention, e.g. dwarf::DW_CC_normal - DISubroutineType * + LLVM_ABI DISubroutineType * createSubroutineType(DITypeRefArray ParameterTypes, DINode::DIFlags Flags = DINode::FlagZero, unsigned CC = 0); /// Create a distinct clone of \p SP with FlagArtificial set. - static DISubprogram *createArtificialSubprogram(DISubprogram *SP); + LLVM_ABI static DISubprogram *createArtificialSubprogram(DISubprogram *SP); /// Create a uniqued clone of \p Ty with FlagArtificial set. - static DIType *createArtificialType(DIType *Ty); + LLVM_ABI static DIType *createArtificialType(DIType *Ty); /// Create a uniqued clone of \p Ty with FlagObjectPointer set. /// If \p Implicit is true, also set FlagArtificial. - static DIType *createObjectPointerType(DIType *Ty, bool Implicit); + LLVM_ABI static DIType *createObjectPointerType(DIType *Ty, bool Implicit); /// Create a type describing a subrange of another type. /// \param Scope Scope in which this set is defined. @@ -744,7 +746,7 @@ namespace llvm { /// \param UpperBound Upper bound. /// \param Stride Stride, if any. /// \param Bias Bias, if any. - DISubrangeType * + LLVM_ABI DISubrangeType * createSubrangeType(StringRef Name, DIFile *File, unsigned LineNo, DIScope *Scope, uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags, DIType *Ty, @@ -752,7 +754,7 @@ namespace llvm { Metadata *Stride, Metadata *Bias); /// Create a permanent forward-declared type. - DICompositeType * + LLVM_ABI DICompositeType * createForwardDecl(unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line, unsigned RuntimeLang = 0, uint64_t SizeInBits = 0, uint32_t AlignInBits = 0, @@ -760,7 +762,7 @@ namespace llvm { std::optional<uint32_t> EnumKind = std::nullopt); /// Create a temporary forward-declared type. - DICompositeType *createReplaceableCompositeType( + LLVM_ABI DICompositeType *createReplaceableCompositeType( unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line, unsigned RuntimeLang = 0, uint64_t SizeInBits = 0, uint32_t AlignInBits = 0, DINode::DIFlags Flags = DINode::FlagFwdDecl, @@ -769,29 +771,32 @@ namespace llvm { /// Retain DIScope* in a module even if it is not referenced /// through debug info anchors. - void retainType(DIScope *T); + LLVM_ABI void retainType(DIScope *T); /// Create unspecified parameter type /// for a subroutine type. - DIBasicType *createUnspecifiedParameter(); + LLVM_ABI DIBasicType *createUnspecifiedParameter(); /// Get a DINodeArray, create one if required. - DINodeArray getOrCreateArray(ArrayRef<Metadata *> Elements); + LLVM_ABI DINodeArray getOrCreateArray(ArrayRef<Metadata *> Elements); /// Get a DIMacroNodeArray, create one if required. - DIMacroNodeArray getOrCreateMacroArray(ArrayRef<Metadata *> Elements); + LLVM_ABI DIMacroNodeArray + getOrCreateMacroArray(ArrayRef<Metadata *> Elements); /// Get a DITypeRefArray, create one if required. - DITypeRefArray getOrCreateTypeArray(ArrayRef<Metadata *> Elements); + LLVM_ABI DITypeRefArray getOrCreateTypeArray(ArrayRef<Metadata *> Elements); /// Create a descriptor for a value range. This /// implicitly uniques the values returned. - DISubrange *getOrCreateSubrange(int64_t Lo, int64_t Count); - DISubrange *getOrCreateSubrange(int64_t Lo, Metadata *CountNode); - DISubrange *getOrCreateSubrange(Metadata *Count, Metadata *LowerBound, - Metadata *UpperBound, Metadata *Stride); - - DIGenericSubrange * + LLVM_ABI DISubrange *getOrCreateSubrange(int64_t Lo, int64_t Count); + LLVM_ABI DISubrange *getOrCreateSubrange(int64_t Lo, Metadata *CountNode); + LLVM_ABI DISubrange *getOrCreateSubrange(Metadata *Count, + Metadata *LowerBound, + Metadata *UpperBound, + Metadata *Stride); + + LLVM_ABI DIGenericSubrange * getOrCreateGenericSubrange(DIGenericSubrange::BoundType Count, DIGenericSubrange::BoundType LowerBound, DIGenericSubrange::BoundType UpperBound, @@ -811,7 +816,7 @@ namespace llvm { /// \param Decl Reference to the corresponding declaration. /// \param AlignInBits Variable alignment(or 0 if no alignment attr was /// specified) - DIGlobalVariableExpression *createGlobalVariableExpression( + LLVM_ABI DIGlobalVariableExpression *createGlobalVariableExpression( DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DIType *Ty, bool IsLocalToUnit, bool isDefined = true, DIExpression *Expr = nullptr, MDNode *Decl = nullptr, @@ -820,7 +825,7 @@ namespace llvm { /// Identical to createGlobalVariable /// except that the resulting DbgNode is temporary and meant to be RAUWed. - DIGlobalVariable *createTempGlobalVariableFwdDecl( + LLVM_ABI DIGlobalVariable *createTempGlobalVariableFwdDecl( DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DIType *Ty, bool IsLocalToUnit, MDNode *Decl = nullptr, MDTuple *TemplateParams = nullptr, uint32_t AlignInBits = 0); @@ -833,7 +838,7 @@ namespace llvm { /// /// If \c AlwaysPreserve, this variable will be referenced from its /// containing subprogram, and will survive some optimizations. - DILocalVariable * + LLVM_ABI DILocalVariable * createAutoVariable(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, DIType *Ty, bool AlwaysPreserve = false, DINode::DIFlags Flags = DINode::FlagZero, @@ -843,9 +848,8 @@ namespace llvm { /// /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually /// leads to a \a DISubprogram. - DILabel * - createLabel(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, - bool AlwaysPreserve = false); + LLVM_ABI DILabel *createLabel(DIScope *Scope, StringRef Name, DIFile *File, + unsigned LineNo, bool AlwaysPreserve = false); /// Create a new descriptor for a parameter variable. /// @@ -858,7 +862,7 @@ namespace llvm { /// /// If \c AlwaysPreserve, this variable will be referenced from its /// containing subprogram, and will survive some optimizations. - DILocalVariable * + LLVM_ABI DILocalVariable * createParameterVariable(DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File, unsigned LineNo, DIType *Ty, bool AlwaysPreserve = false, @@ -868,7 +872,7 @@ namespace llvm { /// Create a new descriptor for the specified /// variable which has a complex address expression for its address. /// \param Addr An array of complex address operations. - DIExpression *createExpression(ArrayRef<uint64_t> Addr = {}); + LLVM_ABI DIExpression *createExpression(ArrayRef<uint64_t> Addr = {}); /// Create an expression for a variable that does not have an address, but /// does have a constant value. @@ -894,20 +898,18 @@ namespace llvm { /// \param Annotations Attribute Annotations. /// \param TargetFuncName The name of the target function if this is /// a trampoline. - DISubprogram * - createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName, - DIFile *File, unsigned LineNo, DISubroutineType *Ty, - unsigned ScopeLine, DINode::DIFlags Flags = DINode::FlagZero, - DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero, - DITemplateParameterArray TParams = nullptr, - DISubprogram *Decl = nullptr, - DITypeArray ThrownTypes = nullptr, - DINodeArray Annotations = nullptr, - StringRef TargetFuncName = ""); + LLVM_ABI DISubprogram *createFunction( + DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, + unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine, + DINode::DIFlags Flags = DINode::FlagZero, + DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero, + DITemplateParameterArray TParams = nullptr, + DISubprogram *Decl = nullptr, DITypeArray ThrownTypes = nullptr, + DINodeArray Annotations = nullptr, StringRef TargetFuncName = ""); /// Identical to createFunction, /// except that the resulting DbgNode is meant to be RAUWed. - DISubprogram *createTempFunctionFwdDecl( + LLVM_ABI DISubprogram *createTempFunctionFwdDecl( DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine, DINode::DIFlags Flags = DINode::FlagZero, @@ -934,7 +936,7 @@ namespace llvm { /// \param SPFlags Additional flags specific to subprograms. /// \param TParams Function template parameters. /// \param ThrownTypes Exception types this function may throw. - DISubprogram * + LLVM_ABI DISubprogram * createMethod(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, unsigned VTableIndex = 0, int ThisAdjustment = 0, @@ -950,17 +952,18 @@ namespace llvm { /// \param Name The name of this common block. /// \param File The file this common block is defined. /// \param LineNo Line number. - DICommonBlock *createCommonBlock(DIScope *Scope, DIGlobalVariable *decl, - StringRef Name, DIFile *File, - unsigned LineNo); + LLVM_ABI DICommonBlock *createCommonBlock(DIScope *Scope, + DIGlobalVariable *decl, + StringRef Name, DIFile *File, + unsigned LineNo); /// This creates new descriptor for a namespace with the specified /// parent scope. /// \param Scope Namespace scope /// \param Name Name of this namespace /// \param ExportSymbols True for C++ inline namespaces. - DINamespace *createNameSpace(DIScope *Scope, StringRef Name, - bool ExportSymbols); + LLVM_ABI DINamespace *createNameSpace(DIScope *Scope, StringRef Name, + bool ExportSymbols); /// This creates new descriptor for a module with the specified /// parent scope. @@ -979,10 +982,12 @@ namespace llvm { /// when set to true, only Scope and Name are required /// as this entry is just a hint for the debugger to find /// the corresponding definition in the global scope. - DIModule *createModule(DIScope *Scope, StringRef Name, - StringRef ConfigurationMacros, StringRef IncludePath, - StringRef APINotesFile = {}, DIFile *File = nullptr, - unsigned LineNo = 0, bool IsDecl = false); + LLVM_ABI DIModule *createModule(DIScope *Scope, StringRef Name, + StringRef ConfigurationMacros, + StringRef IncludePath, + StringRef APINotesFile = {}, + DIFile *File = nullptr, unsigned LineNo = 0, + bool IsDecl = false); /// This creates a descriptor for a lexical block with a new file /// attached. This merely extends the existing @@ -990,8 +995,9 @@ namespace llvm { /// \param Scope Lexical block. /// \param File Source file. /// \param Discriminator DWARF path discriminator value. - DILexicalBlockFile *createLexicalBlockFile(DIScope *Scope, DIFile *File, - unsigned Discriminator = 0); + LLVM_ABI DILexicalBlockFile * + createLexicalBlockFile(DIScope *Scope, DIFile *File, + unsigned Discriminator = 0); /// This creates a descriptor for a lexical block with the /// specified parent context. @@ -999,8 +1005,8 @@ namespace llvm { /// \param File Source file. /// \param Line Line number. /// \param Col Column number. - DILexicalBlock *createLexicalBlock(DIScope *Scope, DIFile *File, - unsigned Line, unsigned Col); + LLVM_ABI DILexicalBlock *createLexicalBlock(DIScope *Scope, DIFile *File, + unsigned Line, unsigned Col); /// Create a descriptor for an imported module. /// \param Context The scope this module is imported into @@ -1008,9 +1014,9 @@ namespace llvm { /// \param File File where the declaration is located. /// \param Line Line number of the declaration. /// \param Elements Renamed elements. - DIImportedEntity *createImportedModule(DIScope *Context, DINamespace *NS, - DIFile *File, unsigned Line, - DINodeArray Elements = nullptr); + LLVM_ABI DIImportedEntity * + createImportedModule(DIScope *Context, DINamespace *NS, DIFile *File, + unsigned Line, DINodeArray Elements = nullptr); /// Create a descriptor for an imported module. /// \param Context The scope this module is imported into. @@ -1018,10 +1024,9 @@ namespace llvm { /// \param File File where the declaration is located. /// \param Line Line number of the declaration. /// \param Elements Renamed elements. - DIImportedEntity *createImportedModule(DIScope *Context, - DIImportedEntity *NS, DIFile *File, - unsigned Line, - DINodeArray Elements = nullptr); + LLVM_ABI DIImportedEntity * + createImportedModule(DIScope *Context, DIImportedEntity *NS, DIFile *File, + unsigned Line, DINodeArray Elements = nullptr); /// Create a descriptor for an imported module. /// \param Context The scope this module is imported into. @@ -1029,9 +1034,9 @@ namespace llvm { /// \param File File where the declaration is located. /// \param Line Line number of the declaration. /// \param Elements Renamed elements. - DIImportedEntity *createImportedModule(DIScope *Context, DIModule *M, - DIFile *File, unsigned Line, - DINodeArray Elements = nullptr); + LLVM_ABI DIImportedEntity * + createImportedModule(DIScope *Context, DIModule *M, DIFile *File, + unsigned Line, DINodeArray Elements = nullptr); /// Create a descriptor for an imported function. /// \param Context The scope this module is imported into. @@ -1040,10 +1045,10 @@ namespace llvm { /// \param File File where the declaration is located. /// \param Line Line number of the declaration. /// \param Elements Renamed elements. - DIImportedEntity *createImportedDeclaration(DIScope *Context, DINode *Decl, - DIFile *File, unsigned Line, - StringRef Name = "", - DINodeArray Elements = nullptr); + LLVM_ABI DIImportedEntity * + createImportedDeclaration(DIScope *Context, DINode *Decl, DIFile *File, + unsigned Line, StringRef Name = "", + DINodeArray Elements = nullptr); /// Insert a new llvm.dbg.declare intrinsic call. /// \param Storage llvm::Value of the variable @@ -1051,9 +1056,10 @@ namespace llvm { /// \param Expr A complex location expression. /// \param DL Debug info location. /// \param InsertAtEnd Location for the new intrinsic. - DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo, - DIExpression *Expr, const DILocation *DL, - BasicBlock *InsertAtEnd); + LLVM_ABI DbgInstPtr insertDeclare(llvm::Value *Storage, + DILocalVariable *VarInfo, + DIExpression *Expr, const DILocation *DL, + BasicBlock *InsertAtEnd); /// Insert a new llvm.dbg.assign intrinsic call. /// \param LinkedInstr Instruction with a DIAssignID to link with the new @@ -1069,10 +1075,11 @@ namespace llvm { /// \param DL Debug info location, usually: (line: 0, /// column: 0, scope: var-decl-scope). See /// getDebugValueLoc. - DbgInstPtr insertDbgAssign(Instruction *LinkedInstr, Value *Val, - DILocalVariable *SrcVar, DIExpression *ValExpr, - Value *Addr, DIExpression *AddrExpr, - const DILocation *DL); + LLVM_ABI DbgInstPtr insertDbgAssign(Instruction *LinkedInstr, Value *Val, + DILocalVariable *SrcVar, + DIExpression *ValExpr, Value *Addr, + DIExpression *AddrExpr, + const DILocation *DL); /// Insert a new llvm.dbg.declare intrinsic call. /// \param Storage llvm::Value of the variable @@ -1080,16 +1087,17 @@ namespace llvm { /// \param Expr A complex location expression. /// \param DL Debug info location. /// \param InsertPt Location for the new intrinsic. - DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo, - DIExpression *Expr, const DILocation *DL, - InsertPosition InsertPt); + LLVM_ABI DbgInstPtr insertDeclare(llvm::Value *Storage, + DILocalVariable *VarInfo, + DIExpression *Expr, const DILocation *DL, + InsertPosition InsertPt); /// Insert a new llvm.dbg.label intrinsic call. /// \param LabelInfo Label's debug info descriptor. /// \param DL Debug info location. /// \param InsertBefore Location for the new intrinsic. - DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL, - InsertPosition InsertPt); + LLVM_ABI DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL, + InsertPosition InsertPt); /// Insert a new llvm.dbg.value intrinsic call. /// \param Val llvm::Value of the variable @@ -1097,25 +1105,26 @@ namespace llvm { /// \param Expr A complex location expression. /// \param DL Debug info location. /// \param InsertPt Location for the new intrinsic. - DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val, - DILocalVariable *VarInfo, - DIExpression *Expr, const DILocation *DL, - InsertPosition InsertPt); + LLVM_ABI DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val, + DILocalVariable *VarInfo, + DIExpression *Expr, + const DILocation *DL, + InsertPosition InsertPt); /// Replace the vtable holder in the given type. /// /// If this creates a self reference, it may orphan some unresolved cycles /// in the operands of \c T, so \a DIBuilder needs to track that. - void replaceVTableHolder(DICompositeType *&T, - DIType *VTableHolder); + LLVM_ABI void replaceVTableHolder(DICompositeType *&T, + DIType *VTableHolder); /// Replace arrays on a composite type. /// /// If \c T is resolved, but the arrays aren't -- which can happen if \c T /// has a self-reference -- \a DIBuilder needs to track the array to /// resolve cycles. - void replaceArrays(DICompositeType *&T, DINodeArray Elements, - DINodeArray TParams = DINodeArray()); + LLVM_ABI void replaceArrays(DICompositeType *&T, DINodeArray Elements, + DINodeArray TParams = DINodeArray()); /// Replace a temporary node. /// diff --git a/llvm/include/llvm/IR/DataLayout.h b/llvm/include/llvm/IR/DataLayout.h index e399a2f..2992484 100644 --- a/llvm/include/llvm/IR/DataLayout.h +++ b/llvm/include/llvm/IR/DataLayout.h @@ -68,7 +68,7 @@ public: Align ABIAlign; Align PrefAlign; - bool operator==(const PrimitiveSpec &Other) const; + LLVM_ABI bool operator==(const PrimitiveSpec &Other) const; }; /// Pointer type specification. @@ -83,7 +83,7 @@ public: /// Additionally, they may also be non-integral (i.e. containing additional /// metadata such as bounds information/permissions). bool IsNonIntegral; - bool operator==(const PointerSpec &Other) const; + LLVM_ABI bool operator==(const PointerSpec &Other) const; }; enum class FunctionPtrAlignType { @@ -144,7 +144,7 @@ private: /// Searches for a pointer specification that matches the given address space. /// Returns the default address space specification if not found. - const PointerSpec &getPointerSpec(uint32_t AddrSpace) const; + LLVM_ABI const PointerSpec &getPointerSpec(uint32_t AddrSpace) const; /// Sets or updates the specification for pointer in the given address space. void setPointerSpec(uint32_t AddrSpace, uint32_t BitWidth, Align ABIAlign, @@ -152,7 +152,7 @@ private: bool IsNonIntegral); /// Internal helper to get alignment for integer of given bitwidth. - Align getIntegerAlignment(uint32_t BitWidth, bool abi_or_pref) const; + LLVM_ABI Align getIntegerAlignment(uint32_t BitWidth, bool abi_or_pref) const; /// Internal helper method that returns requested alignment for type. Align getAlignment(Type *Ty, bool abi_or_pref) const; @@ -175,24 +175,24 @@ private: public: /// Constructs a DataLayout with default values. - DataLayout(); + LLVM_ABI DataLayout(); /// Constructs a DataLayout from a specification string. /// WARNING: Aborts execution if the string is malformed. Use parse() instead. - explicit DataLayout(StringRef LayoutString); + LLVM_ABI explicit DataLayout(StringRef LayoutString); DataLayout(const DataLayout &DL) { *this = DL; } - ~DataLayout(); // Not virtual, do not subclass this class + LLVM_ABI ~DataLayout(); // Not virtual, do not subclass this class - DataLayout &operator=(const DataLayout &Other); + LLVM_ABI DataLayout &operator=(const DataLayout &Other); - bool operator==(const DataLayout &Other) const; + LLVM_ABI bool operator==(const DataLayout &Other) const; bool operator!=(const DataLayout &Other) const { return !(*this == Other); } /// Parse a data layout string and return the layout. Return an error /// description on failure. - static Expected<DataLayout> parse(StringRef LayoutString); + LLVM_ABI static Expected<DataLayout> parse(StringRef LayoutString); /// Layout endianness... bool isLittleEndian() const { return !BigEndian; } @@ -303,7 +303,7 @@ public: llvm_unreachable("invalid mangling mode"); } - static const char *getManglingComponent(const Triple &T); + LLVM_ABI static const char *getManglingComponent(const Triple &T); /// Returns true if the specified type fits in a native integer type /// supported by the CPU. @@ -318,12 +318,12 @@ public: } /// Layout pointer alignment - Align getPointerABIAlignment(unsigned AS) const; + LLVM_ABI Align getPointerABIAlignment(unsigned AS) const; /// Return target's alignment for stack-based pointers /// FIXME: The defaults need to be removed once all of /// the backends/clients are updated. - Align getPointerPrefAlignment(unsigned AS = 0) const; + LLVM_ABI Align getPointerPrefAlignment(unsigned AS = 0) const; /// The pointer representation size in bytes, rounded up to a whole number of /// bytes. The difference between this function and getAddressSize() is that @@ -333,7 +333,7 @@ public: /// \sa DataLayout::getAddressSizeInBits /// FIXME: The defaults need to be removed once all of /// the backends/clients are updated. - unsigned getPointerSize(unsigned AS = 0) const; + LLVM_ABI unsigned getPointerSize(unsigned AS = 0) const; /// The index size in bytes used for address calculation, rounded up to a /// whole number of bytes. This not only defines the size used in @@ -344,7 +344,7 @@ public: /// getPointerSize() returns 16, but getIndexSize() returns 8. /// To help with code understanding, the alias getAddressSize() can be used /// instead of getIndexSize() to clarify that an address width is needed. - unsigned getIndexSize(unsigned AS) const; + LLVM_ABI unsigned getIndexSize(unsigned AS) const; /// The integral size of a pointer in a given address space in bytes, which /// is defined to be the same as getIndexSize(). This exists as a separate @@ -413,13 +413,13 @@ public: /// If this function is called with a vector of pointers, then the type size /// of the pointer is returned. This should only be called with a pointer or /// vector of pointers. - unsigned getPointerTypeSizeInBits(Type *) const; + LLVM_ABI unsigned getPointerTypeSizeInBits(Type *) const; /// The size in bits of the index used in GEP calculation for this type. /// The function should be called with pointer or vector of pointers type. /// This is defined to return the same value as getAddressSizeInBits(), /// but separate functions exist for code clarity. - unsigned getIndexTypeSizeInBits(Type *Ty) const; + LLVM_ABI unsigned getIndexTypeSizeInBits(Type *Ty) const; /// The size in bits of an address for this type. /// This is defined to return the same value as getIndexTypeSizeInBits(), @@ -519,7 +519,7 @@ public: } /// Returns the minimum ABI-required alignment for the specified type. - Align getABITypeAlign(Type *Ty) const; + LLVM_ABI Align getABITypeAlign(Type *Ty) const; /// Helper function to return `Alignment` if it's set or the result of /// `getABITypeAlign(Ty)`, in any case the result is a valid alignment. @@ -538,19 +538,21 @@ public: /// type. /// /// This is always at least as good as the ABI alignment. - Align getPrefTypeAlign(Type *Ty) const; + LLVM_ABI Align getPrefTypeAlign(Type *Ty) const; /// Returns an integer type with size at least as big as that of a /// pointer in the given address space. - IntegerType *getIntPtrType(LLVMContext &C, unsigned AddressSpace = 0) const; + LLVM_ABI IntegerType *getIntPtrType(LLVMContext &C, + unsigned AddressSpace = 0) const; /// Returns an integer (vector of integer) type with size at least as /// big as that of a pointer of the given pointer (vector of pointer) type. - Type *getIntPtrType(Type *) const; + LLVM_ABI Type *getIntPtrType(Type *) const; /// Returns the smallest integer type with size at least as big as /// Width bits. - Type *getSmallestLegalIntType(LLVMContext &C, unsigned Width = 0) const; + LLVM_ABI Type *getSmallestLegalIntType(LLVMContext &C, + unsigned Width = 0) const; /// Returns the largest legal integer type, or null if none are set. Type *getLargestLegalIntType(LLVMContext &C) const { @@ -560,12 +562,13 @@ public: /// Returns the size of largest legal integer type size, or 0 if none /// are set. - unsigned getLargestLegalIntTypeSizeInBits() const; + LLVM_ABI unsigned getLargestLegalIntTypeSizeInBits() const; /// Returns the type of a GEP index in \p AddressSpace. /// If it was not specified explicitly, it will be the integer type of the /// pointer width - IntPtrType. - IntegerType *getIndexType(LLVMContext &C, unsigned AddressSpace) const; + LLVM_ABI IntegerType *getIndexType(LLVMContext &C, + unsigned AddressSpace) const; /// Returns the type of an address in \p AddressSpace IntegerType *getAddressType(LLVMContext &C, unsigned AddressSpace) const { return getIndexType(C, AddressSpace); @@ -574,7 +577,7 @@ public: /// Returns the type of a GEP index. /// If it was not specified explicitly, it will be the integer type of the /// pointer width - IntPtrType. - Type *getIndexType(Type *PtrTy) const; + LLVM_ABI Type *getIndexType(Type *PtrTy) const; /// Returns the type of an address in \p AddressSpace Type *getAddressType(Type *PtrTy) const { return getIndexType(PtrTy); } @@ -583,28 +586,31 @@ public: /// /// Note that this takes the element type, not the pointer type. /// This is used to implement getelementptr. - int64_t getIndexedOffsetInType(Type *ElemTy, ArrayRef<Value *> Indices) const; + LLVM_ABI int64_t getIndexedOffsetInType(Type *ElemTy, + ArrayRef<Value *> Indices) const; /// Get GEP indices to access Offset inside ElemTy. ElemTy is updated to be /// the result element type and Offset to be the residual offset. - SmallVector<APInt> getGEPIndicesForOffset(Type *&ElemTy, APInt &Offset) const; + LLVM_ABI SmallVector<APInt> getGEPIndicesForOffset(Type *&ElemTy, + APInt &Offset) const; /// Get single GEP index to access Offset inside ElemTy. Returns std::nullopt /// if index cannot be computed, e.g. because the type is not an aggregate. /// ElemTy is updated to be the result element type and Offset to be the /// residual offset. - std::optional<APInt> getGEPIndexForOffset(Type *&ElemTy, APInt &Offset) const; + LLVM_ABI std::optional<APInt> getGEPIndexForOffset(Type *&ElemTy, + APInt &Offset) const; /// Returns a StructLayout object, indicating the alignment of the /// struct, its size, and the offsets of its fields. /// /// Note that this information is lazily cached. - const StructLayout *getStructLayout(StructType *Ty) const; + LLVM_ABI const StructLayout *getStructLayout(StructType *Ty) const; /// Returns the preferred alignment of the specified global. /// /// This includes an explicitly requested alignment (if the global has one). - Align getPreferredAlign(const GlobalVariable *GV) const; + LLVM_ABI Align getPreferredAlign(const GlobalVariable *GV) const; }; inline DataLayout *unwrap(LLVMTargetDataRef P) { @@ -638,7 +644,7 @@ public: /// Given a valid byte offset into the structure, returns the structure /// index that contains it. - unsigned getElementContainingOffset(uint64_t FixedOffset) const; + LLVM_ABI unsigned getElementContainingOffset(uint64_t FixedOffset) const; MutableArrayRef<TypeSize> getMemberOffsets() { return getTrailingObjects(NumElements); diff --git a/llvm/include/llvm/IR/DebugInfo.h b/llvm/include/llvm/IR/DebugInfo.h index c47738a..77cee87 100644 --- a/llvm/include/llvm/IR/DebugInfo.h +++ b/llvm/include/llvm/IR/DebugInfo.h @@ -27,6 +27,7 @@ #include "llvm/IR/DataLayout.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/PassManager.h" +#include "llvm/Support/Compiler.h" #include <optional> namespace llvm { @@ -40,37 +41,37 @@ class Module; /// Finds dbg.declare intrinsics declaring local variables as living in the /// memory that 'V' points to. -TinyPtrVector<DbgDeclareInst *> findDbgDeclares(Value *V); +LLVM_ABI TinyPtrVector<DbgDeclareInst *> findDbgDeclares(Value *V); /// As above, for DVRDeclares. -TinyPtrVector<DbgVariableRecord *> findDVRDeclares(Value *V); +LLVM_ABI TinyPtrVector<DbgVariableRecord *> findDVRDeclares(Value *V); /// As above, for DVRValues. -TinyPtrVector<DbgVariableRecord *> findDVRValues(Value *V); +LLVM_ABI TinyPtrVector<DbgVariableRecord *> findDVRValues(Value *V); /// Finds the llvm.dbg.value intrinsics describing a value. -void findDbgValues( +LLVM_ABI void findDbgValues( SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V, SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords = nullptr); /// Finds the debug info intrinsics describing a value. -void findDbgUsers( +LLVM_ABI void findDbgUsers( SmallVectorImpl<DbgVariableIntrinsic *> &DbgInsts, Value *V, SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords = nullptr); /// Find subprogram that is enclosing this scope. -DISubprogram *getDISubprogram(const MDNode *Scope); +LLVM_ABI DISubprogram *getDISubprogram(const MDNode *Scope); /// Produce a DebugLoc to use for each dbg.declare that is promoted to a /// dbg.value. -DebugLoc getDebugValueLoc(DbgVariableIntrinsic *DII); -DebugLoc getDebugValueLoc(DbgVariableRecord *DVR); +LLVM_ABI DebugLoc getDebugValueLoc(DbgVariableIntrinsic *DII); +LLVM_ABI DebugLoc getDebugValueLoc(DbgVariableRecord *DVR); /// Strip debug info in the module if it exists. /// /// To do this, we remove all calls to the debugger intrinsics and any named /// metadata for debugging. We also remove debug locations for instructions. /// Return true if module is modified. -bool StripDebugInfo(Module &M); -bool stripDebugInfo(Function &F); +LLVM_ABI bool StripDebugInfo(Module &M); +LLVM_ABI bool stripDebugInfo(Function &F); /// Downgrade the debug info in a module to contain only line table information. /// @@ -82,17 +83,18 @@ bool stripDebugInfo(Function &F); /// 4) Create a new CU debug info, and similarly for every metadata node /// that's reachable from the CU debug info. /// All debug type metadata nodes are unreachable and garbage collected. -bool stripNonLineTableDebugInfo(Module &M); +LLVM_ABI bool stripNonLineTableDebugInfo(Module &M); /// Update the debug locations contained within the MD_loop metadata attached /// to the instruction \p I, if one exists. \p Updater is applied to Metadata /// operand in the MD_loop metadata: the returned value is included in the /// updated loop metadata node if it is non-null. -void updateLoopMetadataDebugLocations( - Instruction &I, function_ref<Metadata *(Metadata *)> Updater); +LLVM_ABI void +updateLoopMetadataDebugLocations(Instruction &I, + function_ref<Metadata *(Metadata *)> Updater); /// Return Debug Info Metadata Version by checking module flags. -unsigned getDebugMetadataVersionFromModule(const Module &M); +LLVM_ABI unsigned getDebugMetadataVersionFromModule(const Module &M); /// Utility to find all debug info in a module. /// @@ -105,23 +107,23 @@ unsigned getDebugMetadataVersionFromModule(const Module &M); class DebugInfoFinder { public: /// Process entire module and collect debug info anchors. - void processModule(const Module &M); + LLVM_ABI void processModule(const Module &M); /// Process a single instruction and collect debug info anchors. - void processInstruction(const Module &M, const Instruction &I); + LLVM_ABI void processInstruction(const Module &M, const Instruction &I); /// Process a DILocalVariable. - void processVariable(DILocalVariable *DVI); + LLVM_ABI void processVariable(DILocalVariable *DVI); /// Process debug info location. - void processLocation(const Module &M, const DILocation *Loc); + LLVM_ABI void processLocation(const Module &M, const DILocation *Loc); /// Process a DbgRecord (e.g, treat a DbgVariableRecord like a /// DbgVariableIntrinsic). - void processDbgRecord(const Module &M, const DbgRecord &DR); + LLVM_ABI void processDbgRecord(const Module &M, const DbgRecord &DR); /// Process subprogram. - void processSubprogram(DISubprogram *SP); + LLVM_ABI void processSubprogram(DISubprogram *SP); /// Clear all lists. - void reset(); + LLVM_ABI void reset(); private: void processCompileUnit(DICompileUnit *CU); @@ -190,7 +192,7 @@ using AssignmentInstRange = /// as an attachment. /// Iterators invalidated by adding or removing DIAssignID metadata to/from any /// instruction (including by deleting or cloning instructions). -AssignmentInstRange getAssignmentInsts(DIAssignID *ID); +LLVM_ABI AssignmentInstRange getAssignmentInsts(DIAssignID *ID); /// Return a range of instructions (typically just one) that perform the /// assignment that \p DAI encodes. /// Iterators invalidated by adding or removing DIAssignID metadata to/from any @@ -226,7 +228,7 @@ public: using AssignmentMarkerRange = iterator_range<DbgAssignIt>; /// Return a range of dbg.assign intrinsics which use \ID as an operand. /// Iterators invalidated by deleting an intrinsic contained in this range. -AssignmentMarkerRange getAssignmentMarkers(DIAssignID *ID); +LLVM_ABI AssignmentMarkerRange getAssignmentMarkers(DIAssignID *ID); /// Return a range of dbg.assign intrinsics for which \p Inst performs the /// assignment they encode. /// Iterators invalidated by deleting an intrinsic contained in this range. @@ -245,13 +247,13 @@ getDVRAssignmentMarkers(const Instruction *Inst) { } /// Delete the llvm.dbg.assign intrinsics linked to \p Inst. -void deleteAssignmentMarkers(const Instruction *Inst); +LLVM_ABI void deleteAssignmentMarkers(const Instruction *Inst); /// Replace all uses (and attachments) of \p Old with \p New. -void RAUW(DIAssignID *Old, DIAssignID *New); +LLVM_ABI void RAUW(DIAssignID *Old, DIAssignID *New); /// Remove all Assignment Tracking related intrinsics and metadata from \p F. -void deleteAll(Function *F); +LLVM_ABI void deleteAll(Function *F); /// Calculate the fragment of the variable in \p DAI covered /// from (Dest + SliceOffsetInBits) to @@ -262,18 +264,21 @@ void deleteAll(Function *F); /// variable size) in DAI. /// /// Result contains a zero-sized fragment if there's no intersect. -bool calculateFragmentIntersect( - const DataLayout &DL, const Value *Dest, uint64_t SliceOffsetInBits, - uint64_t SliceSizeInBits, const DbgAssignIntrinsic *DbgAssign, - std::optional<DIExpression::FragmentInfo> &Result); -bool calculateFragmentIntersect( - const DataLayout &DL, const Value *Dest, uint64_t SliceOffsetInBits, - uint64_t SliceSizeInBits, const DbgVariableRecord *DVRAssign, - std::optional<DIExpression::FragmentInfo> &Result); +LLVM_ABI bool +calculateFragmentIntersect(const DataLayout &DL, const Value *Dest, + uint64_t SliceOffsetInBits, uint64_t SliceSizeInBits, + const DbgAssignIntrinsic *DbgAssign, + std::optional<DIExpression::FragmentInfo> &Result); +LLVM_ABI bool +calculateFragmentIntersect(const DataLayout &DL, const Value *Dest, + uint64_t SliceOffsetInBits, uint64_t SliceSizeInBits, + const DbgVariableRecord *DVRAssign, + std::optional<DIExpression::FragmentInfo> &Result); /// Replace DIAssignID uses and attachments with IDs from \p Map. /// If an ID is unmapped a new ID is generated and added to \p Map. -void remapAssignID(DenseMap<DIAssignID *, DIAssignID *> &Map, Instruction &I); +LLVM_ABI void remapAssignID(DenseMap<DIAssignID *, DIAssignID *> &Map, + Instruction &I); /// Helper struct for trackAssignments, below. We don't use the similar /// DebugVariable class because trackAssignments doesn't (yet?) understand @@ -330,9 +335,9 @@ using StorageToVarsMap = /// Track assignments to \p Vars between \p Start and \p End. -void trackAssignments(Function::iterator Start, Function::iterator End, - const StorageToVarsMap &Vars, const DataLayout &DL, - bool DebugPrints = false); +LLVM_ABI void trackAssignments(Function::iterator Start, Function::iterator End, + const StorageToVarsMap &Vars, + const DataLayout &DL, bool DebugPrints = false); /// Describes properties of a store that has a static size and offset into a /// some base storage. Used by the getAssignmentInfo functions. @@ -350,12 +355,12 @@ struct AssignmentInfo { SizeInBits == DL.getTypeSizeInBits(Base->getAllocatedType())) {} }; -std::optional<AssignmentInfo> getAssignmentInfo(const DataLayout &DL, - const MemIntrinsic *I); -std::optional<AssignmentInfo> getAssignmentInfo(const DataLayout &DL, - const StoreInst *SI); -std::optional<AssignmentInfo> getAssignmentInfo(const DataLayout &DL, - const AllocaInst *AI); +LLVM_ABI std::optional<AssignmentInfo> getAssignmentInfo(const DataLayout &DL, + const MemIntrinsic *I); +LLVM_ABI std::optional<AssignmentInfo> getAssignmentInfo(const DataLayout &DL, + const StoreInst *SI); +LLVM_ABI std::optional<AssignmentInfo> getAssignmentInfo(const DataLayout &DL, + const AllocaInst *AI); } // end namespace at @@ -371,12 +376,12 @@ class AssignmentTrackingPass : public PassInfoMixin<AssignmentTrackingPass> { bool runOnFunction(Function &F); public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); - PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); + LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); }; /// Return true if assignment tracking is enabled for module \p M. -bool isAssignmentTrackingEnabled(const Module &M); +LLVM_ABI bool isAssignmentTrackingEnabled(const Module &M); } // end namespace llvm diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index 8531424..02f0a9f 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -26,6 +26,7 @@ #include "llvm/IR/PseudoProbe.h" #include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Discriminator.h" #include <cassert> #include <climits> @@ -68,7 +69,7 @@ enum Tag : uint16_t; class DbgVariableIntrinsic; class DbgVariableRecord; -extern cl::opt<bool> EnableFSDiscriminator; +LLVM_ABI extern cl::opt<bool> EnableFSDiscriminator; class DITypeRefArray { const MDTuple *N = nullptr; @@ -165,7 +166,7 @@ protected: void setTag(unsigned Tag) { SubclassData16 = Tag; } public: - dwarf::Tag getTag() const; + LLVM_ABI dwarf::Tag getTag() const; /// Debug info flags. /// @@ -181,15 +182,15 @@ public: LLVM_MARK_AS_BITMASK_ENUM(FlagLargest) }; - static DIFlags getFlag(StringRef Flag); - static StringRef getFlagString(DIFlags Flag); + LLVM_ABI static DIFlags getFlag(StringRef Flag); + LLVM_ABI static StringRef getFlagString(DIFlags Flag); /// Split up a flags bitfield. /// /// Split \c Flags into \c SplitFlags, a vector of its components. Returns /// any remaining (unrecognized) bits. - static DIFlags splitFlags(DIFlags Flags, - SmallVectorImpl<DIFlags> &SplitFlags); + LLVM_ABI static DIFlags splitFlags(DIFlags Flags, + SmallVectorImpl<DIFlags> &SplitFlags); static bool classof(const Metadata *MD) { switch (MD->getMetadataID()) { @@ -257,9 +258,11 @@ class GenericDINode : public DINode { DwarfOps, Storage, ShouldCreate); } - static GenericDINode *getImpl(LLVMContext &Context, unsigned Tag, - MDString *Header, ArrayRef<Metadata *> DwarfOps, - StorageType Storage, bool ShouldCreate = true); + LLVM_ABI static GenericDINode *getImpl(LLVMContext &Context, unsigned Tag, + MDString *Header, + ArrayRef<Metadata *> DwarfOps, + StorageType Storage, + bool ShouldCreate = true); TempGenericDINode cloneImpl() const { return getTemporary(getContext(), getTag(), getHeader(), @@ -281,7 +284,7 @@ public: /// Return a (temporary) clone of this. TempGenericDINode clone() const { return cloneImpl(); } - dwarf::Tag getTag() const; + LLVM_ABI dwarf::Tag getTag() const; StringRef getHeader() const { return getStringOperand(0); } MDString *getRawHeader() const { return getOperandAs<MDString>(0); } @@ -317,8 +320,8 @@ class DIAssignID : public MDNode { ~DIAssignID() { dropAllReferences(); } - static DIAssignID *getImpl(LLVMContext &Context, StorageType Storage, - bool ShouldCreate = true); + LLVM_ABI static DIAssignID *getImpl(LLVMContext &Context, StorageType Storage, + bool ShouldCreate = true); TempDIAssignID cloneImpl() const { return getTemporary(getContext()); } @@ -352,18 +355,19 @@ class DISubrange : public DINode { ~DISubrange() = default; - static DISubrange *getImpl(LLVMContext &Context, int64_t Count, - int64_t LowerBound, StorageType Storage, - bool ShouldCreate = true); + LLVM_ABI static DISubrange *getImpl(LLVMContext &Context, int64_t Count, + int64_t LowerBound, StorageType Storage, + bool ShouldCreate = true); - static DISubrange *getImpl(LLVMContext &Context, Metadata *CountNode, - int64_t LowerBound, StorageType Storage, - bool ShouldCreate = true); + LLVM_ABI static DISubrange *getImpl(LLVMContext &Context, Metadata *CountNode, + int64_t LowerBound, StorageType Storage, + bool ShouldCreate = true); - static DISubrange *getImpl(LLVMContext &Context, Metadata *CountNode, - Metadata *LowerBound, Metadata *UpperBound, - Metadata *Stride, StorageType Storage, - bool ShouldCreate = true); + LLVM_ABI static DISubrange *getImpl(LLVMContext &Context, Metadata *CountNode, + Metadata *LowerBound, + Metadata *UpperBound, Metadata *Stride, + StorageType Storage, + bool ShouldCreate = true); TempDISubrange cloneImpl() const { return getTemporary(getContext(), getRawCountNode(), getRawLowerBound(), @@ -394,13 +398,13 @@ public: typedef PointerUnion<ConstantInt *, DIVariable *, DIExpression *> BoundType; - BoundType getCount() const; + LLVM_ABI BoundType getCount() const; - BoundType getLowerBound() const; + LLVM_ABI BoundType getLowerBound() const; - BoundType getUpperBound() const; + LLVM_ABI BoundType getUpperBound() const; - BoundType getStride() const; + LLVM_ABI BoundType getStride() const; static bool classof(const Metadata *MD) { return MD->getMetadataID() == DISubrangeKind; @@ -416,10 +420,10 @@ class DIGenericSubrange : public DINode { ~DIGenericSubrange() = default; - static DIGenericSubrange *getImpl(LLVMContext &Context, Metadata *CountNode, - Metadata *LowerBound, Metadata *UpperBound, - Metadata *Stride, StorageType Storage, - bool ShouldCreate = true); + LLVM_ABI static DIGenericSubrange * + getImpl(LLVMContext &Context, Metadata *CountNode, Metadata *LowerBound, + Metadata *UpperBound, Metadata *Stride, StorageType Storage, + bool ShouldCreate = true); TempDIGenericSubrange cloneImpl() const { return getTemporary(getContext(), getRawCountNode(), getRawLowerBound(), @@ -441,10 +445,10 @@ public: using BoundType = PointerUnion<DIVariable *, DIExpression *>; - BoundType getCount() const; - BoundType getLowerBound() const; - BoundType getUpperBound() const; - BoundType getStride() const; + LLVM_ABI BoundType getCount() const; + LLVM_ABI BoundType getLowerBound() const; + LLVM_ABI BoundType getUpperBound() const; + LLVM_ABI BoundType getStride() const; static bool classof(const Metadata *MD) { return MD->getMetadataID() == DIGenericSubrangeKind; @@ -460,8 +464,8 @@ class DIEnumerator : public DINode { friend class MDNode; APInt Value; - DIEnumerator(LLVMContext &C, StorageType Storage, const APInt &Value, - bool IsUnsigned, ArrayRef<Metadata *> Ops); + LLVM_ABI DIEnumerator(LLVMContext &C, StorageType Storage, const APInt &Value, + bool IsUnsigned, ArrayRef<Metadata *> Ops); DIEnumerator(LLVMContext &C, StorageType Storage, int64_t Value, bool IsUnsigned, ArrayRef<Metadata *> Ops) : DIEnumerator(C, Storage, APInt(64, Value, !IsUnsigned), IsUnsigned, @@ -474,9 +478,10 @@ class DIEnumerator : public DINode { return getImpl(Context, Value, IsUnsigned, getCanonicalMDString(Context, Name), Storage, ShouldCreate); } - static DIEnumerator *getImpl(LLVMContext &Context, const APInt &Value, - bool IsUnsigned, MDString *Name, - StorageType Storage, bool ShouldCreate = true); + LLVM_ABI static DIEnumerator *getImpl(LLVMContext &Context, + const APInt &Value, bool IsUnsigned, + MDString *Name, StorageType Storage, + bool ShouldCreate = true); TempDIEnumerator cloneImpl() const { return getTemporary(getContext(), getValue(), isUnsigned(), getName()); @@ -529,8 +534,8 @@ public: inline StringRef getDirectory() const; inline std::optional<StringRef> getSource() const; - StringRef getName() const; - DIScope *getScope() const; + LLVM_ABI StringRef getName() const; + LLVM_ABI DIScope *getScope() const; /// Return the raw underlying file. /// @@ -630,11 +635,11 @@ private: Source ? MDString::get(Context, *Source) : nullptr, Storage, ShouldCreate); } - static DIFile *getImpl(LLVMContext &Context, MDString *Filename, - MDString *Directory, - std::optional<ChecksumInfo<MDString *>> CS, - MDString *Source, StorageType Storage, - bool ShouldCreate = true); + LLVM_ABI static DIFile *getImpl(LLVMContext &Context, MDString *Filename, + MDString *Directory, + std::optional<ChecksumInfo<MDString *>> CS, + MDString *Source, StorageType Storage, + bool ShouldCreate = true); TempDIFile cloneImpl() const { return getTemporary(getContext(), getFilename(), getDirectory(), @@ -675,8 +680,9 @@ public: } MDString *getRawSource() const { return Source; } - static StringRef getChecksumKindAsString(ChecksumKind CSKind); - static std::optional<ChecksumKind> getChecksumKind(StringRef CSKindStr); + LLVM_ABI static StringRef getChecksumKindAsString(ChecksumKind CSKind); + LLVM_ABI static std::optional<ChecksumKind> + getChecksumKind(StringRef CSKindStr); static bool classof(const Metadata *MD) { return MD->getMetadataID() == DIFileKind; @@ -754,7 +760,7 @@ public: unsigned getLine() const { return Line; } uint64_t getSizeInBits() const { return SizeInBits; } - uint32_t getAlignInBits() const; + LLVM_ABI uint32_t getAlignInBits() const; uint32_t getAlignInBytes() const { return getAlignInBits() / CHAR_BIT; } uint64_t getOffsetInBits() const { return OffsetInBits; } uint32_t getNumExtraInhabitants() const { return NumExtraInhabitants; } @@ -855,11 +861,12 @@ protected: SizeInBits, AlignInBits, Encoding, NumExtraInhabitants, Flags, Storage, ShouldCreate); } - static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag, - MDString *Name, uint64_t SizeInBits, - uint32_t AlignInBits, unsigned Encoding, - uint32_t NumExtraInhabitants, DIFlags Flags, - StorageType Storage, bool ShouldCreate = true); + LLVM_ABI static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag, + MDString *Name, uint64_t SizeInBits, + uint32_t AlignInBits, unsigned Encoding, + uint32_t NumExtraInhabitants, + DIFlags Flags, StorageType Storage, + bool ShouldCreate = true); TempDIBasicType cloneImpl() const { return getTemporary(getContext(), getTag(), getName(), getSizeInBits(), @@ -905,7 +912,7 @@ public: /// Return the signedness of this type, or std::nullopt if this type is /// neither signed nor unsigned. - std::optional<Signedness> getSignedness() const; + LLVM_ABI std::optional<Signedness> getSignedness() const; static bool classof(const Metadata *MD) { return MD->getMetadataID() == DIBasicTypeKind || @@ -963,7 +970,7 @@ class DIFixedPointType : public DIBasicType { SizeInBits, AlignInBits, Encoding, Flags, Kind, Factor, Numerator, Denominator, Storage, ShouldCreate); } - static DIFixedPointType * + LLVM_ABI static DIFixedPointType * getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding, DIFlags Flags, unsigned Kind, int Factor, APInt Numerator, @@ -986,8 +993,9 @@ public: LastFixedPointKind = FixedPointRational, }; - static std::optional<FixedPointKind> getFixedPointKind(StringRef Str); - static const char *fixedPointKindString(FixedPointKind); + LLVM_ABI static std::optional<FixedPointKind> + getFixedPointKind(StringRef Str); + LLVM_ABI static const char *fixedPointKindString(FixedPointKind); DEFINE_MDNODE_GET(DIFixedPointType, (unsigned Tag, MDString *Name, uint64_t SizeInBits, @@ -1010,7 +1018,7 @@ public: bool isDecimal() const { return Kind == FixedPointDecimal; } bool isRational() const { return Kind == FixedPointRational; } - bool isSigned() const; + LLVM_ABI bool isSigned() const; FixedPointKind getKind() const { return static_cast<FixedPointKind>(Kind); } @@ -1062,12 +1070,11 @@ class DIStringType : public DIType { StringLength, StrLenExp, StrLocationExp, SizeInBits, AlignInBits, Encoding, Storage, ShouldCreate); } - static DIStringType *getImpl(LLVMContext &Context, unsigned Tag, - MDString *Name, Metadata *StringLength, - Metadata *StrLenExp, Metadata *StrLocationExp, - uint64_t SizeInBits, uint32_t AlignInBits, - unsigned Encoding, StorageType Storage, - bool ShouldCreate = true); + LLVM_ABI static DIStringType * + getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, + Metadata *StringLength, Metadata *StrLenExp, Metadata *StrLocationExp, + uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding, + StorageType Storage, bool ShouldCreate = true); TempDIStringType cloneImpl() const { return getTemporary(getContext(), getTag(), getRawName(), @@ -1193,7 +1200,7 @@ private: DWARFAddressSpace, PtrAuthData, Flags, ExtraData, Annotations.get(), Storage, ShouldCreate); } - static DIDerivedType * + LLVM_ABI static DIDerivedType * getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, @@ -1247,7 +1254,7 @@ public: return DWARFAddressSpace; } - std::optional<PtrAuthData> getPtrAuthData() const; + LLVM_ABI std::optional<PtrAuthData> getPtrAuthData() const; /// Get extra data associated with this derived type. /// @@ -1274,19 +1281,19 @@ public: /// Get casted version of extra data. /// @{ - DIType *getClassType() const; + LLVM_ABI DIType *getClassType() const; DIObjCProperty *getObjCProperty() const { return dyn_cast_or_null<DIObjCProperty>(getExtraData()); } - uint32_t getVBPtrOffset() const; + LLVM_ABI uint32_t getVBPtrOffset() const; - Constant *getStorageOffsetInBits() const; + LLVM_ABI Constant *getStorageOffsetInBits() const; - Constant *getConstant() const; + LLVM_ABI Constant *getConstant() const; - Constant *getDiscriminantValue() const; + LLVM_ABI Constant *getDiscriminantValue() const; /// @} static bool classof(const Metadata *MD) { @@ -1331,13 +1338,12 @@ private: UpperBound, Stride, Bias, Storage, ShouldCreate); } - static DISubrangeType *getImpl(LLVMContext &Context, MDString *Name, - Metadata *File, unsigned Line, Metadata *Scope, - uint64_t SizeInBits, uint32_t AlignInBits, - DIFlags Flags, Metadata *BaseType, - Metadata *LowerBound, Metadata *UpperBound, - Metadata *Stride, Metadata *Bias, - StorageType Storage, bool ShouldCreate = true); + LLVM_ABI static DISubrangeType * + getImpl(LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line, + Metadata *Scope, uint64_t SizeInBits, uint32_t AlignInBits, + DIFlags Flags, Metadata *BaseType, Metadata *LowerBound, + Metadata *UpperBound, Metadata *Stride, Metadata *Bias, + StorageType Storage, bool ShouldCreate = true); TempDISubrangeType cloneImpl() const { return getTemporary(getContext(), getName(), getFile(), getLine(), @@ -1346,7 +1352,7 @@ private: getRawUpperBound(), getRawStride(), getRawBias()); } - BoundType convertRawToBound(Metadata *IN) const; + LLVM_ABI BoundType convertRawToBound(Metadata *IN) const; public: DEFINE_MDNODE_GET(DISubrangeType, @@ -1449,7 +1455,7 @@ class DICompositeType : public DIType { Associated, Allocated, Rank, Annotations.get(), Specification, NumExtraInhabitants, BitStride, Storage, ShouldCreate); } - static DICompositeType * + LLVM_ABI static DICompositeType * getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, @@ -1519,7 +1525,7 @@ public: /// a new node. /// /// Else, returns \c nullptr. - static DICompositeType * + LLVM_ABI static DICompositeType * getODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits, @@ -1530,8 +1536,8 @@ public: Metadata *Discriminator, Metadata *DataLocation, Metadata *Associated, Metadata *Allocated, Metadata *Rank, Metadata *Annotations, Metadata *BitStride); - static DICompositeType *getODRTypeIfExists(LLVMContext &Context, - MDString &Identifier); + LLVM_ABI static DICompositeType *getODRTypeIfExists(LLVMContext &Context, + MDString &Identifier); /// Build a DICompositeType with the given ODR identifier. /// @@ -1542,7 +1548,7 @@ public: /// /// If not \a LLVMContext::isODRUniquingDebugTypes(), this function returns /// nullptr. - static DICompositeType * + LLVM_ABI static DICompositeType * buildODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits, @@ -1675,10 +1681,10 @@ class DISubroutineType : public DIType { bool ShouldCreate = true) { return getImpl(Context, Flags, CC, TypeArray.get(), Storage, ShouldCreate); } - static DISubroutineType *getImpl(LLVMContext &Context, DIFlags Flags, - uint8_t CC, Metadata *TypeArray, - StorageType Storage, - bool ShouldCreate = true); + LLVM_ABI static DISubroutineType *getImpl(LLVMContext &Context, DIFlags Flags, + uint8_t CC, Metadata *TypeArray, + StorageType Storage, + bool ShouldCreate = true); TempDISubroutineType cloneImpl() const { return getTemporary(getContext(), getFlags(), getCC(), getTypeArray()); @@ -1735,10 +1741,12 @@ public: LastDebugNameTableKind = Apple }; - static std::optional<DebugEmissionKind> getEmissionKind(StringRef Str); - static const char *emissionKindString(DebugEmissionKind EK); - static std::optional<DebugNameTableKind> getNameTableKind(StringRef Str); - static const char *nameTableKindString(DebugNameTableKind PK); + LLVM_ABI static std::optional<DebugEmissionKind> + getEmissionKind(StringRef Str); + LLVM_ABI static const char *emissionKindString(DebugEmissionKind EK); + LLVM_ABI static std::optional<DebugNameTableKind> + getNameTableKind(StringRef Str); + LLVM_ABI static const char *nameTableKindString(DebugNameTableKind PK); private: unsigned SourceLanguage; @@ -1779,7 +1787,7 @@ private: getCanonicalMDString(Context, SysRoot), getCanonicalMDString(Context, SDK), Storage, ShouldCreate); } - static DICompileUnit * + LLVM_ABI static DICompileUnit * getImpl(LLVMContext &Context, unsigned SourceLanguage, Metadata *File, MDString *Producer, bool IsOptimized, MDString *Flags, unsigned RuntimeVersion, MDString *SplitDebugFilename, @@ -1932,11 +1940,11 @@ public: /// /// Return this if it's an \a DISubprogram; otherwise, look up the scope /// chain. - DISubprogram *getSubprogram() const; + LLVM_ABI DISubprogram *getSubprogram() const; /// Traverses the scope chain rooted at RootScope until it hits a Subprogram, /// recreating the chain with "NewSP" instead. - static DILocalScope * + LLVM_ABI static DILocalScope * cloneScopeForSubprogram(DILocalScope &RootScope, DISubprogram &NewSP, LLVMContext &Ctx, DenseMap<const MDNode *, MDNode *> &Cache); @@ -1945,7 +1953,7 @@ public: /// /// Return this if it's not a \a DILexicalBlockFIle; otherwise, look up the /// scope chain. - DILocalScope *getNonLexicalBlockFileScope() const; + LLVM_ABI DILocalScope *getNonLexicalBlockFileScope() const; static bool classof(const Metadata *MD) { return MD->getMetadataID() == DISubprogramKind || @@ -1979,21 +1987,21 @@ public: LLVM_MARK_AS_BITMASK_ENUM(SPFlagLargest) }; - static DISPFlags getFlag(StringRef Flag); - static StringRef getFlagString(DISPFlags Flag); + LLVM_ABI static DISPFlags getFlag(StringRef Flag); + LLVM_ABI static StringRef getFlagString(DISPFlags Flag); /// Split up a flags bitfield for easier printing. /// /// Split \c Flags into \c SplitFlags, a vector of its components. Returns /// any remaining (unrecognized) bits. - static DISPFlags splitFlags(DISPFlags Flags, - SmallVectorImpl<DISPFlags> &SplitFlags); + LLVM_ABI static DISPFlags splitFlags(DISPFlags Flags, + SmallVectorImpl<DISPFlags> &SplitFlags); // Helper for converting old bitfields to new flags word. - static DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition, - bool IsOptimized, - unsigned Virtuality = SPFlagNonvirtual, - bool IsMainSubprogram = false); + LLVM_ABI static DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition, + bool IsOptimized, + unsigned Virtuality = SPFlagNonvirtual, + bool IsMainSubprogram = false); private: DIFlags Flags; @@ -2022,7 +2030,7 @@ private: getCanonicalMDString(Context, TargetFuncName), Storage, ShouldCreate); } - static DISubprogram * + LLVM_ABI static DISubprogram * getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type, unsigned ScopeLine, Metadata *ContainingType, unsigned VirtualIndex, @@ -2219,7 +2227,7 @@ public: /// Check if this subprogram describes the given function. /// /// FIXME: Should this be looking through bitcasts? - bool describes(const Function *F) const; + LLVM_ABI bool describes(const Function *F) const; static bool classof(const Metadata *MD) { return MD->getMetadataID() == DISubprogramKind; @@ -2246,11 +2254,10 @@ class DILocation : public MDNode { ArrayRef<Metadata *> MDs, bool ImplicitCode); ~DILocation() { dropAllReferences(); } - static DILocation *getImpl(LLVMContext &Context, unsigned Line, - unsigned Column, Metadata *Scope, - Metadata *InlinedAt, bool ImplicitCode, - uint64_t AtomGroup, uint8_t AtomRank, - StorageType Storage, bool ShouldCreate = true); + LLVM_ABI static DILocation * + getImpl(LLVMContext &Context, unsigned Line, unsigned Column, Metadata *Scope, + Metadata *InlinedAt, bool ImplicitCode, uint64_t AtomGroup, + uint8_t AtomRank, StorageType Storage, bool ShouldCreate = true); static DILocation *getImpl(LLVMContext &Context, unsigned Line, unsigned Column, DILocalScope *Scope, DILocation *InlinedAt, bool ImplicitCode, @@ -2444,13 +2451,14 @@ public: /// use the scope of any location. /// /// \p LocA \p LocB: The locations to be merged. - static DILocation *getMergedLocation(DILocation *LocA, DILocation *LocB); + LLVM_ABI static DILocation *getMergedLocation(DILocation *LocA, + DILocation *LocB); /// Try to combine the vector of locations passed as input in a single one. /// This function applies getMergedLocation() repeatedly left-to-right. /// /// \p Locs: The locations to be merged. - static DILocation *getMergedLocations(ArrayRef<DILocation *> Locs); + LLVM_ABI static DILocation *getMergedLocations(ArrayRef<DILocation *> Locs); /// Return the masked discriminator value for an input discrimnator value D /// (i.e. zero out the (B+1)-th and above bits for D (B is 0-base). @@ -2499,12 +2507,12 @@ public: /// The return is std::nullopt if the values cannot be encoded in 32 bits - /// for example, values for BD or DF larger than 12 bits. Otherwise, the /// return is the encoded value. - static std::optional<unsigned> encodeDiscriminator(unsigned BD, unsigned DF, - unsigned CI); + LLVM_ABI static std::optional<unsigned> + encodeDiscriminator(unsigned BD, unsigned DF, unsigned CI); /// Raw decoder for values in an encoded discriminator D. - static void decodeDiscriminator(unsigned D, unsigned &BD, unsigned &DF, - unsigned &CI); + LLVM_ABI static void decodeDiscriminator(unsigned D, unsigned &BD, + unsigned &DF, unsigned &CI); /// Returns the duplication factor for a given encoded discriminator \p D, or /// 1 if no value or 0 is encoded. @@ -2538,8 +2546,8 @@ public: class DILexicalBlockBase : public DILocalScope { protected: - DILexicalBlockBase(LLVMContext &C, unsigned ID, StorageType Storage, - ArrayRef<Metadata *> Ops); + LLVM_ABI DILexicalBlockBase(LLVMContext &C, unsigned ID, StorageType Storage, + ArrayRef<Metadata *> Ops); ~DILexicalBlockBase() = default; public: @@ -2585,9 +2593,10 @@ class DILexicalBlock : public DILexicalBlockBase { ShouldCreate); } - static DILexicalBlock *getImpl(LLVMContext &Context, Metadata *Scope, - Metadata *File, unsigned Line, unsigned Column, - StorageType Storage, bool ShouldCreate = true); + LLVM_ABI static DILexicalBlock *getImpl(LLVMContext &Context, Metadata *Scope, + Metadata *File, unsigned Line, + unsigned Column, StorageType Storage, + bool ShouldCreate = true); TempDILexicalBlock cloneImpl() const { return getTemporary(getContext(), getScope(), getFile(), getLine(), @@ -2634,10 +2643,11 @@ class DILexicalBlockFile : public DILexicalBlockBase { ShouldCreate); } - static DILexicalBlockFile *getImpl(LLVMContext &Context, Metadata *Scope, - Metadata *File, unsigned Discriminator, - StorageType Storage, - bool ShouldCreate = true); + LLVM_ABI static DILexicalBlockFile *getImpl(LLVMContext &Context, + Metadata *Scope, Metadata *File, + unsigned Discriminator, + StorageType Storage, + bool ShouldCreate = true); TempDILexicalBlockFile cloneImpl() const { return getTemporary(getContext(), getScope(), getFile(), @@ -2755,9 +2765,10 @@ class DINamespace : public DIScope { return getImpl(Context, Scope, getCanonicalMDString(Context, Name), ExportSymbols, Storage, ShouldCreate); } - static DINamespace *getImpl(LLVMContext &Context, Metadata *Scope, - MDString *Name, bool ExportSymbols, - StorageType Storage, bool ShouldCreate = true); + LLVM_ABI static DINamespace *getImpl(LLVMContext &Context, Metadata *Scope, + MDString *Name, bool ExportSymbols, + StorageType Storage, + bool ShouldCreate = true); TempDINamespace cloneImpl() const { return getTemporary(getContext(), getScope(), getName(), @@ -2809,11 +2820,11 @@ class DIModule : public DIScope { getCanonicalMDString(Context, APINotesFile), LineNo, IsDecl, Storage, ShouldCreate); } - static DIModule *getImpl(LLVMContext &Context, Metadata *File, - Metadata *Scope, MDString *Name, - MDString *ConfigurationMacros, MDString *IncludePath, - MDString *APINotesFile, unsigned LineNo, bool IsDecl, - StorageType Storage, bool ShouldCreate = true); + LLVM_ABI static DIModule * + getImpl(LLVMContext &Context, Metadata *File, Metadata *Scope, MDString *Name, + MDString *ConfigurationMacros, MDString *IncludePath, + MDString *APINotesFile, unsigned LineNo, bool IsDecl, + StorageType Storage, bool ShouldCreate = true); TempDIModule cloneImpl() const { return getTemporary(getContext(), getFile(), getScope(), getName(), @@ -2901,10 +2912,9 @@ class DITemplateTypeParameter : public DITemplateParameter { return getImpl(Context, getCanonicalMDString(Context, Name), Type, IsDefault, Storage, ShouldCreate); } - static DITemplateTypeParameter *getImpl(LLVMContext &Context, MDString *Name, - Metadata *Type, bool IsDefault, - StorageType Storage, - bool ShouldCreate = true); + LLVM_ABI static DITemplateTypeParameter * + getImpl(LLVMContext &Context, MDString *Name, Metadata *Type, bool IsDefault, + StorageType Storage, bool ShouldCreate = true); TempDITemplateTypeParameter cloneImpl() const { return getTemporary(getContext(), getName(), getType(), isDefault()); @@ -2944,11 +2954,10 @@ class DITemplateValueParameter : public DITemplateParameter { return getImpl(Context, Tag, getCanonicalMDString(Context, Name), Type, IsDefault, Value, Storage, ShouldCreate); } - static DITemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag, - MDString *Name, Metadata *Type, - bool IsDefault, Metadata *Value, - StorageType Storage, - bool ShouldCreate = true); + LLVM_ABI static DITemplateValueParameter * + getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type, + bool IsDefault, Metadata *Value, StorageType Storage, + bool ShouldCreate = true); TempDITemplateValueParameter cloneImpl() const { return getTemporary(getContext(), getTag(), getName(), getType(), @@ -2981,8 +2990,9 @@ class DIVariable : public DINode { unsigned Line; protected: - DIVariable(LLVMContext &C, unsigned ID, StorageType Storage, signed Line, - ArrayRef<Metadata *> Ops, uint32_t AlignInBits = 0); + LLVM_ABI DIVariable(LLVMContext &C, unsigned ID, StorageType Storage, + signed Line, ArrayRef<Metadata *> Ops, + uint32_t AlignInBits = 0); ~DIVariable() = default; public: @@ -2994,7 +3004,7 @@ public: uint32_t getAlignInBits() const { return SubclassData32; } uint32_t getAlignInBytes() const { return getAlignInBits() / CHAR_BIT; } /// Determines the size of the variable's type. - std::optional<uint64_t> getSizeInBits() const; + LLVM_ABI std::optional<uint64_t> getSizeInBits() const; /// Return the signedness of this variable's type, or std::nullopt if this /// type is neither signed nor unsigned. @@ -3053,9 +3063,10 @@ class DIExpression : public MDNode { Elements(Elements.begin(), Elements.end()) {} ~DIExpression() = default; - static DIExpression *getImpl(LLVMContext &Context, - ArrayRef<uint64_t> Elements, StorageType Storage, - bool ShouldCreate = true); + LLVM_ABI static DIExpression *getImpl(LLVMContext &Context, + ArrayRef<uint64_t> Elements, + StorageType Storage, + bool ShouldCreate = true); TempDIExpression cloneImpl() const { return getTemporary(getContext(), getElements()); @@ -3078,7 +3089,7 @@ public: enum SignedOrUnsignedConstant { SignedConstant, UnsignedConstant }; /// Determine whether this represents a constant value, if so // return it's sign information. - std::optional<SignedOrUnsignedConstant> isConstant() const; + LLVM_ABI std::optional<SignedOrUnsignedConstant> isConstant() const; /// Return the number of unique location operands referred to (via /// DW_OP_LLVM_arg) in this expression; this is not necessarily the number of @@ -3088,7 +3099,7 @@ public: /// DW_OP_LLVM_arg 0, DW_OP_mul) /// This function would return 2, as there are two unique location operands /// (0 and 1). - uint64_t getNumLocationOperands() const; + LLVM_ABI uint64_t getNumLocationOperands() const; using element_iterator = ArrayRef<uint64_t>::iterator; @@ -3121,7 +3132,7 @@ public: /// Return the size of the operand. /// /// Return the number of elements in the operand (1 + args). - unsigned getSize() const; + LLVM_ABI unsigned getSize() const; /// Append the elements of this operand to \p V. void appendToVector(SmallVectorImpl<uint64_t> &V) const { @@ -3194,17 +3205,17 @@ public: } /// @} - bool isValid() const; + LLVM_ABI bool isValid() const; static bool classof(const Metadata *MD) { return MD->getMetadataID() == DIExpressionKind; } /// Return whether the first element a DW_OP_deref. - bool startsWithDeref() const; + LLVM_ABI bool startsWithDeref() const; /// Return whether there is exactly one operator and it is a DW_OP_deref; - bool isDeref() const; + LLVM_ABI bool isDeref() const; using FragmentInfo = DbgVariableFragmentInfo; @@ -3212,11 +3223,11 @@ public: /// aren't known to be zero/sign (depending on the type of Var) and which /// are within the size of this fragment (if it is one). If we can't deduce /// anything from the expression this will return the size of Var. - std::optional<uint64_t> getActiveBits(DIVariable *Var); + LLVM_ABI std::optional<uint64_t> getActiveBits(DIVariable *Var); /// Retrieve the details of this fragment expression. - static std::optional<FragmentInfo> getFragmentInfo(expr_op_iterator Start, - expr_op_iterator End); + LLVM_ABI static std::optional<FragmentInfo> + getFragmentInfo(expr_op_iterator Start, expr_op_iterator End); /// Retrieve the details of this fragment expression. std::optional<FragmentInfo> getFragmentInfo() const { @@ -3227,23 +3238,24 @@ public: bool isFragment() const { return getFragmentInfo().has_value(); } /// Return whether this is an implicit location description. - bool isImplicit() const; + LLVM_ABI bool isImplicit() const; /// Return whether the location is computed on the expression stack, meaning /// it cannot be a simple register location. - bool isComplex() const; + LLVM_ABI bool isComplex() const; /// Return whether the evaluated expression makes use of a single location at /// the start of the expression, i.e. if it contains only a single /// DW_OP_LLVM_arg op as its first operand, or if it contains none. - bool isSingleLocationExpression() const; + LLVM_ABI bool isSingleLocationExpression() const; /// Returns a reference to the elements contained in this expression, skipping /// past the leading `DW_OP_LLVM_arg, 0` if one is present. /// Similar to `convertToNonVariadicExpression`, but faster and cheaper - it /// does not check whether the expression is a single-location expression, and /// it returns elements rather than creating a new DIExpression. - std::optional<ArrayRef<uint64_t>> getSingleLocationExpressionElements() const; + LLVM_ABI std::optional<ArrayRef<uint64_t>> + getSingleLocationExpressionElements() const; /// Removes all elements from \p Expr that do not apply to an undef debug /// value, which includes every operator that computes the value/location on @@ -3251,12 +3263,13 @@ public: /// of this function always a single-location expression) while leaving /// everything that defines what the computed value applies to, i.e. the /// fragment information. - static const DIExpression *convertToUndefExpression(const DIExpression *Expr); + LLVM_ABI static const DIExpression * + convertToUndefExpression(const DIExpression *Expr); /// If \p Expr is a non-variadic expression (i.e. one that does not contain /// DW_OP_LLVM_arg), returns \p Expr converted to variadic form by adding a /// leading [DW_OP_LLVM_arg, 0] to the expression; otherwise returns \p Expr. - static const DIExpression * + LLVM_ABI static const DIExpression * convertToVariadicExpression(const DIExpression *Expr); /// If \p Expr is a valid single-location expression, i.e. it refers to only a @@ -3266,7 +3279,7 @@ public: /// See also `getSingleLocationExpressionElements` above, which skips /// checking `isSingleLocationExpression` and returns a list of elements /// rather than a DIExpression. - static std::optional<const DIExpression *> + LLVM_ABI static std::optional<const DIExpression *> convertToNonVariadicExpression(const DIExpression *Expr); /// Inserts the elements of \p Expr into \p Ops modified to a canonical form, @@ -3274,9 +3287,9 @@ public: /// implied derefence from the \p IsIndirect flag into the expression. This /// allows us to check equivalence between expressions with differing /// directness or variadicness. - static void canonicalizeExpressionOps(SmallVectorImpl<uint64_t> &Ops, - const DIExpression *Expr, - bool IsIndirect); + LLVM_ABI static void canonicalizeExpressionOps(SmallVectorImpl<uint64_t> &Ops, + const DIExpression *Expr, + bool IsIndirect); /// Determines whether two debug values should produce equivalent DWARF /// expressions, using their DIExpressions and directness, ignoring the @@ -3289,17 +3302,18 @@ public: /// whose second operand is an immediate value. /// \p SecondExpr and \p SecondIndirect have the same meaning as the prior /// arguments, but apply to the second debug value. - static bool isEqualExpression(const DIExpression *FirstExpr, - bool FirstIndirect, - const DIExpression *SecondExpr, - bool SecondIndirect); + LLVM_ABI static bool isEqualExpression(const DIExpression *FirstExpr, + bool FirstIndirect, + const DIExpression *SecondExpr, + bool SecondIndirect); /// Append \p Ops with operations to apply the \p Offset. - static void appendOffset(SmallVectorImpl<uint64_t> &Ops, int64_t Offset); + LLVM_ABI static void appendOffset(SmallVectorImpl<uint64_t> &Ops, + int64_t Offset); /// If this is a constant offset, extract it. If there is no expression, /// return true with an offset of zero. - bool extractIfOffset(int64_t &Offset) const; + LLVM_ABI bool extractIfOffset(int64_t &Offset) const; /// Assuming that the expression operates on an address, extract a constant /// offset and the successive ops. Return false if the expression contains @@ -3308,18 +3322,19 @@ public: /// /// We don't try very hard to interpret the expression because we assume that /// foldConstantMath has canonicalized the expression. - bool extractLeadingOffset(int64_t &OffsetInBytes, - SmallVectorImpl<uint64_t> &RemainingOps) const; + LLVM_ABI bool + extractLeadingOffset(int64_t &OffsetInBytes, + SmallVectorImpl<uint64_t> &RemainingOps) const; /// Returns true iff this DIExpression contains at least one instance of /// `DW_OP_LLVM_arg, n` for all n in [0, N). - bool hasAllLocationOps(unsigned N) const; + LLVM_ABI bool hasAllLocationOps(unsigned N) const; /// Checks if the last 4 elements of the expression are DW_OP_constu <DWARF /// Address Space> DW_OP_swap DW_OP_xderef and extracts the <DWARF Address /// Space>. - static const DIExpression *extractAddressClass(const DIExpression *Expr, - unsigned &AddrClass); + LLVM_ABI static const DIExpression * + extractAddressClass(const DIExpression *Expr, unsigned &AddrClass); /// Used for DIExpression::prepend. enum PrependOps : uint8_t { @@ -3332,36 +3347,38 @@ public: /// Prepend \p DIExpr with a deref and offset operation and optionally turn it /// into a stack value or/and an entry value. - static DIExpression *prepend(const DIExpression *Expr, uint8_t Flags, - int64_t Offset = 0); + LLVM_ABI static DIExpression *prepend(const DIExpression *Expr, uint8_t Flags, + int64_t Offset = 0); /// Prepend \p DIExpr with the given opcodes and optionally turn it into a /// stack value. - static DIExpression *prependOpcodes(const DIExpression *Expr, - SmallVectorImpl<uint64_t> &Ops, - bool StackValue = false, - bool EntryValue = false); + LLVM_ABI static DIExpression *prependOpcodes(const DIExpression *Expr, + SmallVectorImpl<uint64_t> &Ops, + bool StackValue = false, + bool EntryValue = false); /// Append the opcodes \p Ops to \p DIExpr. Unlike \ref appendToStack, the /// returned expression is a stack value only if \p DIExpr is a stack value. /// If \p DIExpr describes a fragment, the returned expression will describe /// the same fragment. - static DIExpression *append(const DIExpression *Expr, ArrayRef<uint64_t> Ops); + LLVM_ABI static DIExpression *append(const DIExpression *Expr, + ArrayRef<uint64_t> Ops); /// Convert \p DIExpr into a stack value if it isn't one already by appending /// DW_OP_deref if needed, and appending \p Ops to the resulting expression. /// If \p DIExpr describes a fragment, the returned expression will describe /// the same fragment. - static DIExpression *appendToStack(const DIExpression *Expr, - ArrayRef<uint64_t> Ops); + LLVM_ABI static DIExpression *appendToStack(const DIExpression *Expr, + ArrayRef<uint64_t> Ops); /// Create a copy of \p Expr by appending the given list of \p Ops to each /// instance of the operand `DW_OP_LLVM_arg, \p ArgNo`. This is used to /// modify a specific location used by \p Expr, such as when salvaging that /// location. - static DIExpression *appendOpsToArg(const DIExpression *Expr, - ArrayRef<uint64_t> Ops, unsigned ArgNo, - bool StackValue = false); + LLVM_ABI static DIExpression *appendOpsToArg(const DIExpression *Expr, + ArrayRef<uint64_t> Ops, + unsigned ArgNo, + bool StackValue = false); /// Create a copy of \p Expr with each instance of /// `DW_OP_LLVM_arg, \p OldArg` replaced with `DW_OP_LLVM_arg, \p NewArg`, @@ -3369,8 +3386,8 @@ public: /// for all Arg > \p OldArg. /// This is used when replacing one of the operands of a debug value list /// with another operand in the same list and deleting the old operand. - static DIExpression *replaceArg(const DIExpression *Expr, uint64_t OldArg, - uint64_t NewArg); + LLVM_ABI static DIExpression *replaceArg(const DIExpression *Expr, + uint64_t OldArg, uint64_t NewArg); /// Create a DIExpression to describe one part of an aggregate variable that /// is fragmented across multiple Values. The DW_OP_LLVM_fragment operation @@ -3383,7 +3400,7 @@ public: /// \return Creating a fragment expression may fail if \c Expr /// contains arithmetic operations that would be /// truncated. - static std::optional<DIExpression *> + LLVM_ABI static std::optional<DIExpression *> createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits); @@ -3433,7 +3450,7 @@ public: /// and offsets because different debug records store the information in /// different places (dbg_assign has two DIExpressions - one contains the /// fragment info for the entire intrinsic). - static bool calculateFragmentIntersect( + LLVM_ABI static bool calculateFragmentIntersect( const DataLayout &DL, const Value *SliceStart, uint64_t SliceOffsetInBits, uint64_t SliceSizeInBits, const Value *DbgPtr, int64_t DbgPtrOffsetInBits, int64_t DbgExtractOffsetInBits, DIExpression::FragmentInfo VarFrag, @@ -3443,12 +3460,14 @@ public: using ExtOps = std::array<uint64_t, 6>; /// Returns the ops for a zero- or sign-extension in a DIExpression. - static ExtOps getExtOps(unsigned FromSize, unsigned ToSize, bool Signed); + LLVM_ABI static ExtOps getExtOps(unsigned FromSize, unsigned ToSize, + bool Signed); /// Append a zero- or sign-extension to \p Expr. Converts the expression to a /// stack value if it isn't one already. - static DIExpression *appendExt(const DIExpression *Expr, unsigned FromSize, - unsigned ToSize, bool Signed); + LLVM_ABI static DIExpression *appendExt(const DIExpression *Expr, + unsigned FromSize, unsigned ToSize, + bool Signed); /// Check if fragments overlap between a pair of FragmentInfos. static bool fragmentsOverlap(const FragmentInfo &A, const FragmentInfo &B) { @@ -3472,18 +3491,18 @@ public: /// Check if the expression consists of exactly one entry value operand. /// (This is the only configuration of entry values that is supported.) - bool isEntryValue() const; + LLVM_ABI bool isEntryValue() const; /// Try to shorten an expression with an initial constant operand. /// Returns a new expression and constant on success, or the original /// expression and constant on failure. - std::pair<DIExpression *, const ConstantInt *> + LLVM_ABI std::pair<DIExpression *, const ConstantInt *> constantFold(const ConstantInt *CI); /// Try to shorten an expression with constant math operations that can be /// evaluated at compile time. Returns a new expression on success, or the old /// expression if there is nothing to be reduced. - DIExpression *foldConstantMath(); + LLVM_ABI DIExpression *foldConstantMath(); }; inline bool operator==(const DIExpression::FragmentInfo &A, @@ -3621,7 +3640,7 @@ class DIGlobalVariable : public DIVariable { cast_or_null<Metadata>(TemplateParams), AlignInBits, Annotations.get(), Storage, ShouldCreate); } - static DIGlobalVariable * + LLVM_ABI static DIGlobalVariable * getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition, @@ -3696,10 +3715,11 @@ class DICommonBlock : public DIScope { return getImpl(Context, Scope, Decl, getCanonicalMDString(Context, Name), File, LineNo, Storage, ShouldCreate); } - static DICommonBlock *getImpl(LLVMContext &Context, Metadata *Scope, - Metadata *Decl, MDString *Name, Metadata *File, - unsigned LineNo, StorageType Storage, - bool ShouldCreate = true); + LLVM_ABI static DICommonBlock *getImpl(LLVMContext &Context, Metadata *Scope, + Metadata *Decl, MDString *Name, + Metadata *File, unsigned LineNo, + StorageType Storage, + bool ShouldCreate = true); TempDICommonBlock cloneImpl() const { return getTemporary(getContext(), getScope(), getDecl(), getName(), @@ -3765,12 +3785,11 @@ class DILocalVariable : public DIVariable { Line, Type, Arg, Flags, AlignInBits, Annotations.get(), Storage, ShouldCreate); } - static DILocalVariable *getImpl(LLVMContext &Context, Metadata *Scope, - MDString *Name, Metadata *File, unsigned Line, - Metadata *Type, unsigned Arg, DIFlags Flags, - uint32_t AlignInBits, Metadata *Annotations, - StorageType Storage, - bool ShouldCreate = true); + LLVM_ABI static DILocalVariable * + getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, Metadata *File, + unsigned Line, Metadata *Type, unsigned Arg, DIFlags Flags, + uint32_t AlignInBits, Metadata *Annotations, StorageType Storage, + bool ShouldCreate = true); TempDILocalVariable cloneImpl() const { return getTemporary(getContext(), getScope(), getName(), getFile(), @@ -3844,9 +3863,10 @@ class DILabel : public DINode { return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File, Line, Storage, ShouldCreate); } - static DILabel *getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, - Metadata *File, unsigned Line, StorageType Storage, - bool ShouldCreate = true); + LLVM_ABI static DILabel *getImpl(LLVMContext &Context, Metadata *Scope, + MDString *Name, Metadata *File, + unsigned Line, StorageType Storage, + bool ShouldCreate = true); TempDILabel cloneImpl() const { return getTemporary(getContext(), getScope(), getName(), getFile(), @@ -3913,11 +3933,10 @@ class DIObjCProperty : public DINode { getCanonicalMDString(Context, SetterName), Attributes, Type, Storage, ShouldCreate); } - static DIObjCProperty *getImpl(LLVMContext &Context, MDString *Name, - Metadata *File, unsigned Line, - MDString *GetterName, MDString *SetterName, - unsigned Attributes, Metadata *Type, - StorageType Storage, bool ShouldCreate = true); + LLVM_ABI static DIObjCProperty * + getImpl(LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line, + MDString *GetterName, MDString *SetterName, unsigned Attributes, + Metadata *Type, StorageType Storage, bool ShouldCreate = true); TempDIObjCProperty cloneImpl() const { return getTemporary(getContext(), getName(), getFile(), getLine(), @@ -3995,7 +4014,7 @@ class DIImportedEntity : public DINode { getCanonicalMDString(Context, Name), Elements.get(), Storage, ShouldCreate); } - static DIImportedEntity * + LLVM_ABI static DIImportedEntity * getImpl(LLVMContext &Context, unsigned Tag, Metadata *Scope, Metadata *Entity, Metadata *File, unsigned Line, MDString *Name, Metadata *Elements, StorageType Storage, bool ShouldCreate = true); @@ -4049,7 +4068,7 @@ class DIGlobalVariableExpression : public MDNode { : MDNode(C, DIGlobalVariableExpressionKind, Storage, Ops) {} ~DIGlobalVariableExpression() = default; - static DIGlobalVariableExpression * + LLVM_ABI static DIGlobalVariableExpression * getImpl(LLVMContext &Context, Metadata *Variable, Metadata *Expression, StorageType Storage, bool ShouldCreate = true); @@ -4152,9 +4171,10 @@ class DIMacro : public DIMacroNode { return getImpl(Context, MIType, Line, getCanonicalMDString(Context, Name), getCanonicalMDString(Context, Value), Storage, ShouldCreate); } - static DIMacro *getImpl(LLVMContext &Context, unsigned MIType, unsigned Line, - MDString *Name, MDString *Value, StorageType Storage, - bool ShouldCreate = true); + LLVM_ABI static DIMacro *getImpl(LLVMContext &Context, unsigned MIType, + unsigned Line, MDString *Name, + MDString *Value, StorageType Storage, + bool ShouldCreate = true); TempDIMacro cloneImpl() const { return getTemporary(getContext(), getMacinfoType(), getLine(), getName(), @@ -4208,9 +4228,10 @@ class DIMacroFile : public DIMacroNode { Elements.get(), Storage, ShouldCreate); } - static DIMacroFile *getImpl(LLVMContext &Context, unsigned MIType, - unsigned Line, Metadata *File, Metadata *Elements, - StorageType Storage, bool ShouldCreate = true); + LLVM_ABI static DIMacroFile *getImpl(LLVMContext &Context, unsigned MIType, + unsigned Line, Metadata *File, + Metadata *Elements, StorageType Storage, + bool ShouldCreate = true); TempDIMacroFile cloneImpl() const { return getTemporary(getContext(), getMacinfoType(), getLine(), getFile(), @@ -4269,12 +4290,13 @@ class DIArgList : public Metadata, ReplaceableMetadataImpl { } ~DIArgList() { untrack(); } - void track(); - void untrack(); + LLVM_ABI void track(); + LLVM_ABI void untrack(); void dropAllReferences(bool Untrack); public: - static DIArgList *get(LLVMContext &Context, ArrayRef<ValueAsMetadata *> Args); + LLVM_ABI static DIArgList *get(LLVMContext &Context, + ArrayRef<ValueAsMetadata *> Args); ArrayRef<ValueAsMetadata *> getArgs() const { return Args; } @@ -4289,7 +4311,7 @@ public: return ReplaceableMetadataImpl::getAllDbgVariableRecordUsers(); } - void handleChangedOperand(void *Ref, Metadata *New); + LLVM_ABI void handleChangedOperand(void *Ref, Metadata *New); }; /// Identifies a unique instance of a variable. @@ -4312,11 +4334,11 @@ class DebugVariable { /// Fragment that will overlap all other fragments. Used as default when /// caller demands a fragment. - static const FragmentInfo DefaultFragment; + LLVM_ABI static const FragmentInfo DefaultFragment; public: - DebugVariable(const DbgVariableIntrinsic *DII); - DebugVariable(const DbgVariableRecord *DVR); + LLVM_ABI DebugVariable(const DbgVariableIntrinsic *DII); + LLVM_ABI DebugVariable(const DbgVariableRecord *DVR); DebugVariable(const DILocalVariable *Var, std::optional<FragmentInfo> FragmentInfo, @@ -4383,7 +4405,7 @@ template <> struct DenseMapInfo<DebugVariable> { /// information). class DebugVariableAggregate : public DebugVariable { public: - DebugVariableAggregate(const DbgVariableIntrinsic *DVI); + LLVM_ABI DebugVariableAggregate(const DbgVariableIntrinsic *DVI); DebugVariableAggregate(const DebugVariable &V) : DebugVariable(V.getVariable(), std::nullopt, V.getInlinedAt()) {} }; diff --git a/llvm/include/llvm/IR/DebugLoc.h b/llvm/include/llvm/IR/DebugLoc.h index ffb8ed4..c3d0fb8 100644 --- a/llvm/include/llvm/IR/DebugLoc.h +++ b/llvm/include/llvm/IR/DebugLoc.h @@ -16,6 +16,7 @@ #include "llvm/Config/llvm-config.h" #include "llvm/IR/TrackingMDRef.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" namespace llvm { @@ -66,7 +67,7 @@ namespace llvm { DILocAndCoverageTracking(const MDNode *Loc) : TrackingMDNodeRef(const_cast<MDNode *>(Loc)), Kind(DebugLocKind::Normal) {} - DILocAndCoverageTracking(const DILocation *Loc); + LLVM_ABI DILocAndCoverageTracking(const DILocation *Loc); // Explicit DebugLocKind, which always means a nullptr MDNode*. DILocAndCoverageTracking(DebugLocKind Kind) : TrackingMDNodeRef(nullptr), Kind(Kind) {} @@ -106,7 +107,7 @@ namespace llvm { DebugLoc() = default; /// Construct from an \a DILocation. - DebugLoc(const DILocation *L); + LLVM_ABI DebugLoc(const DILocation *L); /// Construct from an \a MDNode. /// @@ -114,7 +115,7 @@ namespace llvm { /// accessors will crash. However, construction from other nodes is /// supported in order to handle forward references when reading textual /// IR. - explicit DebugLoc(const MDNode *N); + LLVM_ABI explicit DebugLoc(const MDNode *N); #if LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING DebugLoc(DebugLocKind Kind) : Loc(Kind) {} @@ -145,7 +146,7 @@ namespace llvm { /// /// \pre !*this or \c isa<DILocation>(getAsMDNode()). /// @{ - DILocation *get() const; + LLVM_ABI DILocation *get() const; operator DILocation *() const { return get(); } DILocation *operator->() const { return get(); } DILocation &operator*() const { return *get(); } @@ -166,9 +167,9 @@ namespace llvm { /// Rebuild the entire inlined-at chain for this instruction so that the top of /// the chain now is inlined-at the new call site. /// \param InlinedAt The new outermost inlined-at in the chain. - static DebugLoc appendInlinedAt(const DebugLoc &DL, DILocation *InlinedAt, - LLVMContext &Ctx, - DenseMap<const MDNode *, MDNode *> &Cache); + LLVM_ABI static DebugLoc + appendInlinedAt(const DebugLoc &DL, DILocation *InlinedAt, LLVMContext &Ctx, + DenseMap<const MDNode *, MDNode *> &Cache); /// Return true if the source locations match, ignoring isImplicitCode and /// source atom info. @@ -180,19 +181,19 @@ namespace llvm { getInlinedAt() == Other.getInlinedAt(); } - unsigned getLine() const; - unsigned getCol() const; - MDNode *getScope() const; - DILocation *getInlinedAt() const; + LLVM_ABI unsigned getLine() const; + LLVM_ABI unsigned getCol() const; + LLVM_ABI MDNode *getScope() const; + LLVM_ABI DILocation *getInlinedAt() const; /// Get the fully inlined-at scope for a DebugLoc. /// /// Gets the inlined-at scope for a DebugLoc. - MDNode *getInlinedAtScope() const; + LLVM_ABI MDNode *getInlinedAtScope() const; /// Rebuild the entire inline-at chain by replacing the subprogram at the /// end of the chain with NewSP. - static DebugLoc + LLVM_ABI static DebugLoc replaceInlinedAtSubprogram(const DebugLoc &DL, DISubprogram &NewSP, LLVMContext &Ctx, DenseMap<const MDNode *, MDNode *> &Cache); @@ -204,22 +205,22 @@ namespace llvm { /// /// FIXME: Remove this. Users should use DILocation/DILocalScope API to /// find the subprogram, and then DILocation::get(). - DebugLoc getFnDebugLoc() const; + LLVM_ABI DebugLoc getFnDebugLoc() const; /// Return \c this as a bar \a MDNode. MDNode *getAsMDNode() const { return Loc; } /// Check if the DebugLoc corresponds to an implicit code. - bool isImplicitCode() const; - void setImplicitCode(bool ImplicitCode); + LLVM_ABI bool isImplicitCode() const; + LLVM_ABI void setImplicitCode(bool ImplicitCode); bool operator==(const DebugLoc &DL) const { return Loc == DL.Loc; } bool operator!=(const DebugLoc &DL) const { return Loc != DL.Loc; } - void dump() const; + LLVM_ABI void dump() const; /// prints source location /path/to/file.exe:line:col @[inlined at] - void print(raw_ostream &OS) const; + LLVM_ABI void print(raw_ostream &OS) const; }; } // end namespace llvm diff --git a/llvm/include/llvm/IR/DebugProgramInstruction.h b/llvm/include/llvm/IR/DebugProgramInstruction.h index 37db789..1436677 100644 --- a/llvm/include/llvm/IR/DebugProgramInstruction.h +++ b/llvm/include/llvm/IR/DebugProgramInstruction.h @@ -55,6 +55,7 @@ #include "llvm/IR/Instruction.h" #include "llvm/IR/SymbolTableListTraits.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -117,6 +118,10 @@ public: } }; +extern template class LLVM_TEMPLATE_ABI DbgRecordParamRef<DIExpression>; +extern template class LLVM_TEMPLATE_ABI DbgRecordParamRef<DILabel>; +extern template class LLVM_TEMPLATE_ABI DbgRecordParamRef<DILocalVariable>; + /// Base class for non-instruction debug metadata records that have positions /// within IR. Features various methods copied across from the Instruction /// class to aid ease-of-use. DbgRecords should always be linked into a @@ -149,20 +154,21 @@ public: /// Methods that dispatch to subclass implementations. These need to be /// manually updated when a new subclass is added. ///@{ - void deleteRecord(); - DbgRecord *clone() const; - void print(raw_ostream &O, bool IsForDebug = false) const; - void print(raw_ostream &O, ModuleSlotTracker &MST, bool IsForDebug) const; - bool isIdenticalToWhenDefined(const DbgRecord &R) const; + LLVM_ABI void deleteRecord(); + LLVM_ABI DbgRecord *clone() const; + LLVM_ABI void print(raw_ostream &O, bool IsForDebug = false) const; + LLVM_ABI void print(raw_ostream &O, ModuleSlotTracker &MST, + bool IsForDebug) const; + LLVM_ABI bool isIdenticalToWhenDefined(const DbgRecord &R) const; /// Convert this DbgRecord back into an appropriate llvm.dbg.* intrinsic. /// \p InsertBefore Optional position to insert this intrinsic. /// \returns A new llvm.dbg.* intrinsic representiung this DbgRecord. - DbgInfoIntrinsic *createDebugIntrinsic(Module *M, - Instruction *InsertBefore) const; + LLVM_ABI DbgInfoIntrinsic * + createDebugIntrinsic(Module *M, Instruction *InsertBefore) const; ///@} /// Same as isIdenticalToWhenDefined but checks DebugLoc too. - bool isEquivalentTo(const DbgRecord &R) const; + LLVM_ABI bool isEquivalentTo(const DbgRecord &R) const; Kind getRecordKind() const { return RecordKind; } @@ -171,44 +177,44 @@ public: DbgMarker *getMarker() { return Marker; } const DbgMarker *getMarker() const { return Marker; } - BasicBlock *getBlock(); - const BasicBlock *getBlock() const; + LLVM_ABI BasicBlock *getBlock(); + LLVM_ABI const BasicBlock *getBlock() const; - Function *getFunction(); - const Function *getFunction() const; + LLVM_ABI Function *getFunction(); + LLVM_ABI const Function *getFunction() const; - Module *getModule(); - const Module *getModule() const; + LLVM_ABI Module *getModule(); + LLVM_ABI const Module *getModule() const; - LLVMContext &getContext(); - const LLVMContext &getContext() const; + LLVM_ABI LLVMContext &getContext(); + LLVM_ABI const LLVMContext &getContext() const; - const Instruction *getInstruction() const; - const BasicBlock *getParent() const; - BasicBlock *getParent(); + LLVM_ABI const Instruction *getInstruction() const; + LLVM_ABI const BasicBlock *getParent() const; + LLVM_ABI BasicBlock *getParent(); - void removeFromParent(); - void eraseFromParent(); + LLVM_ABI void removeFromParent(); + LLVM_ABI void eraseFromParent(); DbgRecord *getNextNode() { return &*std::next(getIterator()); } DbgRecord *getPrevNode() { return &*std::prev(getIterator()); } // Some generic lambdas supporting intrinsic-based debug-info mean we need // to support both iterator and instruction position based insertion. - void insertBefore(DbgRecord *InsertBefore); - void insertAfter(DbgRecord *InsertAfter); - void moveBefore(DbgRecord *MoveBefore); - void moveAfter(DbgRecord *MoveAfter); + LLVM_ABI void insertBefore(DbgRecord *InsertBefore); + LLVM_ABI void insertAfter(DbgRecord *InsertAfter); + LLVM_ABI void moveBefore(DbgRecord *MoveBefore); + LLVM_ABI void moveAfter(DbgRecord *MoveAfter); - void insertBefore(self_iterator InsertBefore); - void insertAfter(self_iterator InsertAfter); - void moveBefore(self_iterator MoveBefore); - void moveAfter(self_iterator MoveAfter); + LLVM_ABI void insertBefore(self_iterator InsertBefore); + LLVM_ABI void insertAfter(self_iterator InsertAfter); + LLVM_ABI void moveBefore(self_iterator MoveBefore); + LLVM_ABI void moveAfter(self_iterator MoveAfter); DebugLoc getDebugLoc() const { return DbgLoc; } void setDebugLoc(DebugLoc Loc) { DbgLoc = std::move(Loc); } - void dump() const; + LLVM_ABI void dump() const; using self_iterator = simple_ilist<DbgRecord>::iterator; using const_self_iterator = simple_ilist<DbgRecord>::const_iterator; @@ -237,20 +243,21 @@ class DbgLabelRecord : public DbgRecord { DbgLabelRecord(MDNode *Label, MDNode *DL); public: - DbgLabelRecord(DILabel *Label, DebugLoc DL); + LLVM_ABI DbgLabelRecord(DILabel *Label, DebugLoc DL); /// For use during parsing; creates a DbgLabelRecord from as-of-yet unresolved /// MDNodes. Trying to access the resulting DbgLabelRecord's fields before /// they are resolved, or if they resolve to the wrong type, will result in a /// crash. - static DbgLabelRecord *createUnresolvedDbgLabelRecord(MDNode *Label, - MDNode *DL); + LLVM_ABI static DbgLabelRecord *createUnresolvedDbgLabelRecord(MDNode *Label, + MDNode *DL); - DbgLabelRecord *clone() const; - void print(raw_ostream &O, bool IsForDebug = false) const; - void print(raw_ostream &ROS, ModuleSlotTracker &MST, bool IsForDebug) const; - DbgLabelInst *createDebugIntrinsic(Module *M, - Instruction *InsertBefore) const; + LLVM_ABI DbgLabelRecord *clone() const; + LLVM_ABI void print(raw_ostream &O, bool IsForDebug = false) const; + LLVM_ABI void print(raw_ostream &ROS, ModuleSlotTracker &MST, + bool IsForDebug) const; + LLVM_ABI DbgLabelInst *createDebugIntrinsic(Module *M, + Instruction *InsertBefore) const; void setLabel(DILabel *NewLabel) { Label = NewLabel; } DILabel *getLabel() const { return Label.get(); } @@ -296,17 +303,17 @@ public: public: /// Create a new DbgVariableRecord representing the intrinsic \p DVI, for /// example the assignment represented by a dbg.value. - DbgVariableRecord(const DbgVariableIntrinsic *DVI); - DbgVariableRecord(const DbgVariableRecord &DVR); + LLVM_ABI DbgVariableRecord(const DbgVariableIntrinsic *DVI); + LLVM_ABI DbgVariableRecord(const DbgVariableRecord &DVR); /// Directly construct a new DbgVariableRecord representing a dbg.value /// intrinsic assigning \p Location to the DV / Expr / DI variable. - DbgVariableRecord(Metadata *Location, DILocalVariable *DV, DIExpression *Expr, - const DILocation *DI, - LocationType Type = LocationType::Value); - DbgVariableRecord(Metadata *Value, DILocalVariable *Variable, - DIExpression *Expression, DIAssignID *AssignID, - Metadata *Address, DIExpression *AddressExpression, - const DILocation *DI); + LLVM_ABI DbgVariableRecord(Metadata *Location, DILocalVariable *DV, + DIExpression *Expr, const DILocation *DI, + LocationType Type = LocationType::Value); + LLVM_ABI DbgVariableRecord(Metadata *Value, DILocalVariable *Variable, + DIExpression *Expression, DIAssignID *AssignID, + Metadata *Address, DIExpression *AddressExpression, + const DILocation *DI); private: /// Private constructor for creating new instances during parsing only. Only @@ -325,36 +332,35 @@ public: /// for all types of DbgVariableRecords for simplicity while parsing, but /// asserts if any necessary fields are empty or unused fields are not empty, /// i.e. if the #dbg_assign fields are used for a non-dbg-assign type. - static DbgVariableRecord * + LLVM_ABI static DbgVariableRecord * createUnresolvedDbgVariableRecord(LocationType Type, Metadata *Val, MDNode *Variable, MDNode *Expression, MDNode *AssignID, Metadata *Address, MDNode *AddressExpression, MDNode *DI); - static DbgVariableRecord * + LLVM_ABI static DbgVariableRecord * createDVRAssign(Value *Val, DILocalVariable *Variable, DIExpression *Expression, DIAssignID *AssignID, Value *Address, DIExpression *AddressExpression, const DILocation *DI); - static DbgVariableRecord * + LLVM_ABI static DbgVariableRecord * createLinkedDVRAssign(Instruction *LinkedInstr, Value *Val, DILocalVariable *Variable, DIExpression *Expression, Value *Address, DIExpression *AddressExpression, const DILocation *DI); - static DbgVariableRecord *createDbgVariableRecord(Value *Location, - DILocalVariable *DV, - DIExpression *Expr, - const DILocation *DI); - static DbgVariableRecord * + LLVM_ABI static DbgVariableRecord * + createDbgVariableRecord(Value *Location, DILocalVariable *DV, + DIExpression *Expr, const DILocation *DI); + LLVM_ABI static DbgVariableRecord * createDbgVariableRecord(Value *Location, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI, DbgVariableRecord &InsertBefore); - static DbgVariableRecord *createDVRDeclare(Value *Address, - DILocalVariable *DV, - DIExpression *Expr, - const DILocation *DI); - static DbgVariableRecord * + LLVM_ABI static DbgVariableRecord *createDVRDeclare(Value *Address, + DILocalVariable *DV, + DIExpression *Expr, + const DILocation *DI); + LLVM_ABI static DbgVariableRecord * createDVRDeclare(Value *Address, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI, DbgVariableRecord &InsertBefore); @@ -412,20 +418,20 @@ public: /// Get the locations corresponding to the variable referenced by the debug /// info intrinsic. Depending on the intrinsic, this could be the /// variable's value or its address. - iterator_range<location_op_iterator> location_ops() const; + LLVM_ABI iterator_range<location_op_iterator> location_ops() const; - Value *getVariableLocationOp(unsigned OpIdx) const; + LLVM_ABI Value *getVariableLocationOp(unsigned OpIdx) const; - void replaceVariableLocationOp(Value *OldValue, Value *NewValue, - bool AllowEmpty = false); - void replaceVariableLocationOp(unsigned OpIdx, Value *NewValue); + LLVM_ABI void replaceVariableLocationOp(Value *OldValue, Value *NewValue, + bool AllowEmpty = false); + LLVM_ABI void replaceVariableLocationOp(unsigned OpIdx, Value *NewValue); /// Adding a new location operand will always result in this intrinsic using /// an ArgList, and must always be accompanied by a new expression that uses /// the new operand. - void addVariableLocationOps(ArrayRef<Value *> NewValues, - DIExpression *NewExpr); + LLVM_ABI void addVariableLocationOps(ArrayRef<Value *> NewValues, + DIExpression *NewExpr); - unsigned getNumVariableLocationOps() const; + LLVM_ABI unsigned getNumVariableLocationOps() const; bool hasArgList() const { return isa<DIArgList>(getRawLocation()); } /// Returns true if this DbgVariableRecord has no empty MDNodes in its @@ -442,8 +448,8 @@ public: LocationType getType() const { return Type; } - void setKillLocation(); - bool isKillLocation() const; + LLVM_ABI void setKillLocation(); + LLVM_ABI bool isKillLocation() const; void setVariable(DILocalVariable *NewVar) { Variable = NewVar; } DILocalVariable *getVariable() const { return Variable.get(); }; @@ -474,7 +480,7 @@ public: resetDebugValue(0, NewLocation); } - std::optional<DbgVariableFragmentInfo> getFragment() const; + LLVM_ABI std::optional<DbgVariableFragmentInfo> getFragment() const; /// Get the FragmentInfo for the variable if it exists, otherwise return a /// FragmentInfo that covers the entire variable if the variable size is /// known, otherwise return a zero-sized fragment. @@ -487,7 +493,7 @@ public: } /// Get the size (in bits) of the variable, or fragment of the variable that /// is described. - std::optional<uint64_t> getFragmentSizeInBits() const; + LLVM_ABI std::optional<uint64_t> getFragmentSizeInBits() const; bool isEquivalentTo(const DbgVariableRecord &Other) const { return DbgLoc == Other.DbgLoc && isIdenticalToWhenDefined(Other); @@ -505,12 +511,12 @@ public: /// @{ bool isDbgAssign() const { return getType() == LocationType::Assign; } - Value *getAddress() const; + LLVM_ABI Value *getAddress() const; Metadata *getRawAddress() const { return isDbgAssign() ? DebugValues[1] : DebugValues[0]; } Metadata *getRawAssignID() const { return DebugValues[2]; } - DIAssignID *getAssignID() const; + LLVM_ABI DIAssignID *getAssignID() const; DIExpression *getAddressExpression() const { return AddressExpression.get(); } MDNode *getRawAddressExpression() const { return AddressExpression.getAsMDNode(); @@ -518,31 +524,32 @@ public: void setAddressExpression(DIExpression *NewExpr) { AddressExpression = NewExpr; } - void setAssignId(DIAssignID *New); + LLVM_ABI void setAssignId(DIAssignID *New); void setAddress(Value *V) { resetDebugValue(1, ValueAsMetadata::get(V)); } /// Kill the address component. - void setKillAddress(); + LLVM_ABI void setKillAddress(); /// Check whether this kills the address component. This doesn't take into /// account the position of the intrinsic, therefore a returned value of false /// does not guarentee the address is a valid location for the variable at the /// intrinsic's position in IR. - bool isKillAddress() const; + LLVM_ABI bool isKillAddress() const; /// @} - DbgVariableRecord *clone() const; + LLVM_ABI DbgVariableRecord *clone() const; /// Convert this DbgVariableRecord back into a dbg.value intrinsic. /// \p InsertBefore Optional position to insert this intrinsic. /// \returns A new dbg.value intrinsic representiung this DbgVariableRecord. - DbgVariableIntrinsic *createDebugIntrinsic(Module *M, - Instruction *InsertBefore) const; + LLVM_ABI DbgVariableIntrinsic * + createDebugIntrinsic(Module *M, Instruction *InsertBefore) const; /// Handle changes to the location of the Value(s) that we refer to happening /// "under our feet". - void handleChangedLocation(Metadata *NewLocation); + LLVM_ABI void handleChangedLocation(Metadata *NewLocation); - void print(raw_ostream &O, bool IsForDebug = false) const; - void print(raw_ostream &ROS, ModuleSlotTracker &MST, bool IsForDebug) const; + LLVM_ABI void print(raw_ostream &O, bool IsForDebug = false) const; + LLVM_ABI void print(raw_ostream &ROS, ModuleSlotTracker &MST, + bool IsForDebug) const; /// Support type inquiry through isa, cast, and dyn_cast. static bool classof(const DbgRecord *E) { @@ -594,42 +601,45 @@ public: simple_ilist<DbgRecord> StoredDbgRecords; bool empty() const { return StoredDbgRecords.empty(); } - const BasicBlock *getParent() const; - BasicBlock *getParent(); + LLVM_ABI const BasicBlock *getParent() const; + LLVM_ABI BasicBlock *getParent(); /// Handle the removal of a marker: the position of debug-info has gone away, /// but the stored debug records should not. Drop them onto the next /// instruction, or otherwise work out what to do with them. - void removeMarker(); - void dump() const; + LLVM_ABI void removeMarker(); + LLVM_ABI void dump() const; - void removeFromParent(); - void eraseFromParent(); + LLVM_ABI void removeFromParent(); + LLVM_ABI void eraseFromParent(); /// Implement operator<< on DbgMarker. - void print(raw_ostream &O, bool IsForDebug = false) const; - void print(raw_ostream &ROS, ModuleSlotTracker &MST, bool IsForDebug) const; + LLVM_ABI void print(raw_ostream &O, bool IsForDebug = false) const; + LLVM_ABI void print(raw_ostream &ROS, ModuleSlotTracker &MST, + bool IsForDebug) const; /// Produce a range over all the DbgRecords in this Marker. - iterator_range<simple_ilist<DbgRecord>::iterator> getDbgRecordRange(); - iterator_range<simple_ilist<DbgRecord>::const_iterator> + LLVM_ABI iterator_range<simple_ilist<DbgRecord>::iterator> + getDbgRecordRange(); + LLVM_ABI iterator_range<simple_ilist<DbgRecord>::const_iterator> getDbgRecordRange() const; /// Transfer any DbgRecords from \p Src into this DbgMarker. If \p /// InsertAtHead is true, place them before existing DbgRecords, otherwise /// afterwards. - void absorbDebugValues(DbgMarker &Src, bool InsertAtHead); + LLVM_ABI void absorbDebugValues(DbgMarker &Src, bool InsertAtHead); /// Transfer the DbgRecords in \p Range from \p Src into this DbgMarker. If /// \p InsertAtHead is true, place them before existing DbgRecords, otherwise // afterwards. - void absorbDebugValues(iterator_range<DbgRecord::self_iterator> Range, - DbgMarker &Src, bool InsertAtHead); + LLVM_ABI void + absorbDebugValues(iterator_range<DbgRecord::self_iterator> Range, + DbgMarker &Src, bool InsertAtHead); /// Insert a DbgRecord into this DbgMarker, at the end of the list. If /// \p InsertAtHead is true, at the start. - void insertDbgRecord(DbgRecord *New, bool InsertAtHead); + LLVM_ABI void insertDbgRecord(DbgRecord *New, bool InsertAtHead); /// Insert a DbgRecord prior to a DbgRecord contained within this marker. - void insertDbgRecord(DbgRecord *New, DbgRecord *InsertBefore); + LLVM_ABI void insertDbgRecord(DbgRecord *New, DbgRecord *InsertBefore); /// Insert a DbgRecord after a DbgRecord contained within this marker. - void insertDbgRecordAfter(DbgRecord *New, DbgRecord *InsertAfter); + LLVM_ABI void insertDbgRecordAfter(DbgRecord *New, DbgRecord *InsertAfter); /// Clone all DbgMarkers from \p From into this marker. There are numerous /// options to customise the source/destination, due to gnarliness, see class /// comment. @@ -638,16 +648,16 @@ public: /// \p InsertAtHead Place the cloned DbgRecords at the start of /// StoredDbgRecords /// \returns Range over all the newly cloned DbgRecords - iterator_range<simple_ilist<DbgRecord>::iterator> + LLVM_ABI iterator_range<simple_ilist<DbgRecord>::iterator> cloneDebugInfoFrom(DbgMarker *From, std::optional<simple_ilist<DbgRecord>::iterator> FromHere, bool InsertAtHead = false); /// Erase all DbgRecords in this DbgMarker. - void dropDbgRecords(); + LLVM_ABI void dropDbgRecords(); /// Erase a single DbgRecord from this marker. In an ideal future, we would /// never erase an assignment in this way, but it's the equivalent to /// erasing a debug intrinsic from a block. - void dropOneDbgRecord(DbgRecord *DR); + LLVM_ABI void dropOneDbgRecord(DbgRecord *DR); /// We generally act like all llvm Instructions have a range of DbgRecords /// attached to them, but in reality sometimes we don't allocate the DbgMarker @@ -656,7 +666,7 @@ public: /// static markers range instead. This will bite us if someone tries to insert /// a DbgRecord in that range, but they should be using the Official (TM) API /// for that. - static DbgMarker EmptyDbgMarker; + LLVM_ABI static DbgMarker EmptyDbgMarker; static iterator_range<simple_ilist<DbgRecord>::iterator> getEmptyDbgRecordRange() { return make_range(EmptyDbgMarker.StoredDbgRecords.end(), diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h index fba6f45..4d6bb1c 100644 --- a/llvm/include/llvm/IR/DerivedTypes.h +++ b/llvm/include/llvm/IR/DerivedTypes.h @@ -63,7 +63,7 @@ public: /// that instance will be returned. Otherwise a new one will be created. Only /// one instance with a given NumBits value is ever created. /// Get or create an IntegerType instance. - static IntegerType *get(LLVMContext &C, unsigned NumBits); + LLVM_ABI static IntegerType *get(LLVMContext &C, unsigned NumBits); /// Returns type twice as wide the input type. IntegerType *getExtendedType() const { @@ -88,7 +88,7 @@ public: /// For example, this is 0xFF for an 8 bit integer, 0xFFFF for i16, etc. /// @returns a bit mask with ones set for all the bits of this type. /// Get a bit mask for this type. - APInt getMask() const; + LLVM_ABI APInt getMask() const; /// Methods for support type inquiry through isa, cast, and dyn_cast. static bool classof(const Type *T) { @@ -110,17 +110,17 @@ public: FunctionType &operator=(const FunctionType &) = delete; /// This static method is the primary way of constructing a FunctionType. - static FunctionType *get(Type *Result, - ArrayRef<Type*> Params, bool isVarArg); + LLVM_ABI static FunctionType *get(Type *Result, ArrayRef<Type *> Params, + bool isVarArg); /// Create a FunctionType taking no parameters. - static FunctionType *get(Type *Result, bool isVarArg); + LLVM_ABI static FunctionType *get(Type *Result, bool isVarArg); /// Return true if the specified type is valid as a return type. - static bool isValidReturnType(Type *RetTy); + LLVM_ABI static bool isValidReturnType(Type *RetTy); /// Return true if the specified type is valid as an argument type. - static bool isValidArgumentType(Type *ArgTy); + LLVM_ABI static bool isValidArgumentType(Type *ArgTy); bool isVarArg() const { return getSubclassData()!=0; } Type *getReturnType() const { return ContainedTys[0]; } @@ -243,15 +243,17 @@ public: StructType &operator=(const StructType &) = delete; /// This creates an identified struct. - static StructType *create(LLVMContext &Context, StringRef Name); - static StructType *create(LLVMContext &Context); - - static StructType *create(ArrayRef<Type *> Elements, StringRef Name, - bool isPacked = false); - static StructType *create(ArrayRef<Type *> Elements); - static StructType *create(LLVMContext &Context, ArrayRef<Type *> Elements, - StringRef Name, bool isPacked = false); - static StructType *create(LLVMContext &Context, ArrayRef<Type *> Elements); + LLVM_ABI static StructType *create(LLVMContext &Context, StringRef Name); + LLVM_ABI static StructType *create(LLVMContext &Context); + + LLVM_ABI static StructType *create(ArrayRef<Type *> Elements, StringRef Name, + bool isPacked = false); + LLVM_ABI static StructType *create(ArrayRef<Type *> Elements); + LLVM_ABI static StructType *create(LLVMContext &Context, + ArrayRef<Type *> Elements, StringRef Name, + bool isPacked = false); + LLVM_ABI static StructType *create(LLVMContext &Context, + ArrayRef<Type *> Elements); template <class... Tys> static std::enable_if_t<are_base_of<Type, Tys...>::value, StructType *> create(StringRef Name, Type *elt1, Tys *... elts) { @@ -260,11 +262,11 @@ public: } /// This static method is the primary way to create a literal StructType. - static StructType *get(LLVMContext &Context, ArrayRef<Type*> Elements, - bool isPacked = false); + LLVM_ABI static StructType * + get(LLVMContext &Context, ArrayRef<Type *> Elements, bool isPacked = false); /// Create an empty structure type. - static StructType *get(LLVMContext &Context, bool isPacked = false); + LLVM_ABI static StructType *get(LLVMContext &Context, bool isPacked = false); /// This static method is a convenience method for creating structure types by /// specifying the elements as arguments. Note that this method always returns @@ -279,7 +281,7 @@ public: /// Return the type with the specified name, or null if there is none by that /// name. - static StructType *getTypeByName(LLVMContext &C, StringRef Name); + LLVM_ABI static StructType *getTypeByName(LLVMContext &C, StringRef Name); bool isPacked() const { return (getSubclassData() & SCDB_Packed) != 0; } @@ -292,21 +294,21 @@ public: bool isOpaque() const { return (getSubclassData() & SCDB_HasBody) == 0; } /// isSized - Return true if this is a sized type. - bool isSized(SmallPtrSetImpl<Type *> *Visited = nullptr) const; + LLVM_ABI bool isSized(SmallPtrSetImpl<Type *> *Visited = nullptr) const; /// Returns true if this struct contains a scalable vector. - bool isScalableTy(SmallPtrSetImpl<const Type *> &Visited) const; + LLVM_ABI bool isScalableTy(SmallPtrSetImpl<const Type *> &Visited) const; using Type::isScalableTy; /// Return true if this type is or contains a target extension type that /// disallows being used as a global. - bool + LLVM_ABI bool containsNonGlobalTargetExtType(SmallPtrSetImpl<const Type *> &Visited) const; using Type::containsNonGlobalTargetExtType; /// Return true if this type is or contains a target extension type that /// disallows being used as a local. - bool + LLVM_ABI bool containsNonLocalTargetExtType(SmallPtrSetImpl<const Type *> &Visited) const; using Type::containsNonLocalTargetExtType; @@ -316,11 +318,11 @@ public: /// when calling this function. /// {{<vscale x 2 x i32>, <vscale x 4 x i64>}, /// {<vscale x 2 x i32>, <vscale x 4 x i64>}} - bool containsHomogeneousScalableVectorTypes() const; + LLVM_ABI bool containsHomogeneousScalableVectorTypes() const; /// Return true if this struct is non-empty and all element types are the /// same. - bool containsHomogeneousTypes() const; + LLVM_ABI bool containsHomogeneousTypes() const; /// Return true if this is a named struct that has a non-empty name. bool hasName() const { return SymbolTableEntry != nullptr; } @@ -328,26 +330,27 @@ public: /// Return the name for this struct type if it has an identity. /// This may return an empty string for an unnamed struct type. Do not call /// this on an literal type. - StringRef getName() const; + LLVM_ABI StringRef getName() const; /// Change the name of this type to the specified name, or to a name with a /// suffix if there is a collision. Do not call this on an literal type. - void setName(StringRef Name); + LLVM_ABI void setName(StringRef Name); /// Specify a body for an opaque identified type, which must not make the type /// recursive. - void setBody(ArrayRef<Type*> Elements, bool isPacked = false); + LLVM_ABI void setBody(ArrayRef<Type *> Elements, bool isPacked = false); /// Specify a body for an opaque identified type or return an error if it /// would make the type recursive. - Error setBodyOrError(ArrayRef<Type *> Elements, bool isPacked = false); + LLVM_ABI Error setBodyOrError(ArrayRef<Type *> Elements, + bool isPacked = false); /// Return an error if the body for an opaque identified type would make it /// recursive. - Error checkBody(ArrayRef<Type *> Elements); + LLVM_ABI Error checkBody(ArrayRef<Type *> Elements); /// Return true if the specified type is valid as a element type. - static bool isValidElementType(Type *ElemTy); + LLVM_ABI static bool isValidElementType(Type *ElemTy); // Iterator access to the elements. using element_iterator = Type::subtype_iterator; @@ -359,7 +362,7 @@ public: } /// Return true if this is layout identical to the specified struct. - bool isLayoutIdentical(StructType *Other) const; + LLVM_ABI bool isLayoutIdentical(StructType *Other) const; /// Random access to the elements unsigned getNumElements() const { return NumContainedTys; } @@ -368,9 +371,9 @@ public: return ContainedTys[N]; } /// Given an index value into the type, return the type of the element. - Type *getTypeAtIndex(const Value *V) const; + LLVM_ABI Type *getTypeAtIndex(const Value *V) const; Type *getTypeAtIndex(unsigned N) const { return getElementType(N); } - bool indexValid(const Value *V) const; + LLVM_ABI bool indexValid(const Value *V) const; bool indexValid(unsigned Idx) const { return Idx < getNumElements(); } /// Methods for support type inquiry through isa, cast, and dyn_cast. @@ -408,10 +411,10 @@ public: Type *getElementType() const { return ContainedType; } /// This static method is the primary way to construct an ArrayType - static ArrayType *get(Type *ElementType, uint64_t NumElements); + LLVM_ABI static ArrayType *get(Type *ElementType, uint64_t NumElements); /// Return true if the specified type is valid as a element type. - static bool isValidElementType(Type *ElemTy); + LLVM_ABI static bool isValidElementType(Type *ElemTy); /// Methods for support type inquiry through isa, cast, and dyn_cast. static bool classof(const Type *T) { @@ -451,7 +454,7 @@ protected: /// vscale is a runtime-constant integer greater than 0. const unsigned ElementQuantity; - VectorType(Type *ElType, unsigned EQ, Type::TypeID TID); + LLVM_ABI VectorType(Type *ElType, unsigned EQ, Type::TypeID TID); public: VectorType(const VectorType &) = delete; @@ -460,7 +463,7 @@ public: Type *getElementType() const { return ContainedType; } /// This static method is the primary way to construct an VectorType. - static VectorType *get(Type *ElementType, ElementCount EC); + LLVM_ABI static VectorType *get(Type *ElementType, ElementCount EC); static VectorType *get(Type *ElementType, unsigned NumElements, bool Scalable) { @@ -572,7 +575,7 @@ public: } /// Return true if the specified type is valid as a element type. - static bool isValidElementType(Type *ElemTy); + LLVM_ABI static bool isValidElementType(Type *ElemTy); /// Return an ElementCount instance to represent the (possibly scalable) /// number of elements in the vector. @@ -592,7 +595,7 @@ protected: : VectorType(ElTy, NumElts, FixedVectorTyID) {} public: - static FixedVectorType *get(Type *ElementType, unsigned NumElts); + LLVM_ABI static FixedVectorType *get(Type *ElementType, unsigned NumElts); static FixedVectorType *get(Type *ElementType, const FixedVectorType *FVTy) { return get(ElementType, FVTy->getNumElements()); @@ -639,7 +642,8 @@ protected: : VectorType(ElTy, MinNumElts, ScalableVectorTyID) {} public: - static ScalableVectorType *get(Type *ElementType, unsigned MinNumElts); + LLVM_ABI static ScalableVectorType *get(Type *ElementType, + unsigned MinNumElts); static ScalableVectorType *get(Type *ElementType, const ScalableVectorType *SVTy) { @@ -704,10 +708,10 @@ public: /// address space. [[deprecated("PointerType::get with pointee type is pending removal. Use " "Context overload.")]] - static PointerType *get(Type *ElementType, unsigned AddressSpace); + LLVM_ABI static PointerType *get(Type *ElementType, unsigned AddressSpace); /// This constructs an opaque pointer to an object in a numbered address /// space. - static PointerType *get(LLVMContext &C, unsigned AddressSpace); + LLVM_ABI static PointerType *get(LLVMContext &C, unsigned AddressSpace); /// This constructs a pointer to an object of the specified type in the /// default address space (address space zero). @@ -727,10 +731,10 @@ public: } /// Return true if the specified type is valid as a element type. - static bool isValidElementType(Type *ElemTy); + LLVM_ABI static bool isValidElementType(Type *ElemTy); /// Return true if we can load or store from a pointer to this type. - static bool isLoadableOrStorableType(Type *ElemTy); + LLVM_ABI static bool isLoadableOrStorableType(Type *ElemTy); /// Return the address space of the Pointer type. inline unsigned getAddressSpace() const { return getSubclassData(); } @@ -788,22 +792,21 @@ public: /// Return a target extension type having the specified name and optional /// type and integer parameters. - static TargetExtType *get(LLVMContext &Context, StringRef Name, - ArrayRef<Type *> Types = {}, - ArrayRef<unsigned> Ints = {}); + LLVM_ABI static TargetExtType *get(LLVMContext &Context, StringRef Name, + ArrayRef<Type *> Types = {}, + ArrayRef<unsigned> Ints = {}); /// Return a target extension type having the specified name and optional /// type and integer parameters, or an appropriate Error if it fails the /// parameters check. - static Expected<TargetExtType *> getOrError(LLVMContext &Context, - StringRef Name, - ArrayRef<Type *> Types = {}, - ArrayRef<unsigned> Ints = {}); + LLVM_ABI static Expected<TargetExtType *> + getOrError(LLVMContext &Context, StringRef Name, ArrayRef<Type *> Types = {}, + ArrayRef<unsigned> Ints = {}); /// Check that a newly created target extension type has the expected number /// of type parameters and integer parameters, returning the type itself if OK /// or an appropriate Error if not. - static Expected<TargetExtType *> checkParams(TargetExtType *TTy); + LLVM_ABI static Expected<TargetExtType *> checkParams(TargetExtType *TTy); /// Return the name for this target extension type. Two distinct target /// extension types may have the same name if their type or integer parameters @@ -845,13 +848,13 @@ public: }; /// Returns true if the target extension type contains the given property. - bool hasProperty(Property Prop) const; + LLVM_ABI bool hasProperty(Property Prop) const; /// Returns an underlying layout type for the target extension type. This /// type can be used to query size and alignment information, if it is /// appropriate (although note that the layout type may also be void). It is /// not legal to bitcast between this type and the layout type, however. - Type *getLayoutType() const; + LLVM_ABI Type *getLayoutType() const; /// Methods for support type inquiry through isa, cast, and dyn_cast. static bool classof(const Type *T) { return T->getTypeID() == TargetExtTyID; } diff --git a/llvm/include/llvm/IR/DiagnosticHandler.h b/llvm/include/llvm/IR/DiagnosticHandler.h index 1f0544b..54880d8 100644 --- a/llvm/include/llvm/IR/DiagnosticHandler.h +++ b/llvm/include/llvm/IR/DiagnosticHandler.h @@ -13,6 +13,7 @@ #define LLVM_IR_DIAGNOSTICHANDLER_H #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Compiler.h" namespace llvm { class DiagnosticInfo; @@ -21,7 +22,7 @@ class DiagnosticInfo; /// The handleDiagnostics method must be overriden by the subclasses to handle /// diagnostic. The *RemarkEnabled methods can be overriden to control /// which remarks are enabled. -struct DiagnosticHandler { +struct LLVM_ABI DiagnosticHandler { void *DiagnosticContext = nullptr; bool HasErrors = false; DiagnosticHandler(void *DiagContext = nullptr) diff --git a/llvm/include/llvm/IR/DiagnosticInfo.h b/llvm/include/llvm/IR/DiagnosticInfo.h index 4ffd63f..862be04 100644 --- a/llvm/include/llvm/IR/DiagnosticInfo.h +++ b/llvm/include/llvm/IR/DiagnosticInfo.h @@ -21,6 +21,7 @@ #include "llvm/ADT/Twine.h" #include "llvm/IR/DebugLoc.h" #include "llvm/Support/CBindingWrapping.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/TypeSize.h" @@ -103,14 +104,14 @@ enum DiagnosticKind { /// The returned ID will be greater than or equal to DK_FirstPluginKind. /// Thus, the plugin identifiers will not conflict with the /// DiagnosticKind values. -int getNextAvailablePluginDiagnosticKind(); +LLVM_ABI int getNextAvailablePluginDiagnosticKind(); /// This is the base abstract class for diagnostic reporting in /// the backend. /// The print method must be overloaded by the subclasses to print a /// user-friendly message in the client of the backend (let us call it a /// frontend). -class DiagnosticInfo { +class LLVM_ABI DiagnosticInfo { private: /// Kind defines the kind of report this is about. const /* DiagnosticKind */ int Kind; @@ -138,7 +139,7 @@ public: using DiagnosticHandlerFunction = std::function<void(const DiagnosticInfo &)>; -class DiagnosticInfoGeneric : public DiagnosticInfo { +class LLVM_ABI DiagnosticInfoGeneric : public DiagnosticInfo { const Twine &MsgStr; const Instruction *Inst = nullptr; @@ -168,7 +169,7 @@ public: /// Diagnostic information for inline asm reporting. /// This is basically a message and an optional location. -class DiagnosticInfoInlineAsm : public DiagnosticInfo { +class LLVM_ABI DiagnosticInfoInlineAsm : public DiagnosticInfo { private: /// Optional line information. 0 if not set. uint64_t LocCookie = 0; @@ -209,7 +210,7 @@ public: /// Diagnostic information for debug metadata version reporting. /// This is basically a module and a version. -class DiagnosticInfoDebugMetadataVersion : public DiagnosticInfo { +class LLVM_ABI DiagnosticInfoDebugMetadataVersion : public DiagnosticInfo { private: /// The module that is concerned by this debug metadata version diagnostic. const Module &M; @@ -236,7 +237,8 @@ public: }; /// Diagnostic information for stripping invalid debug metadata. -class DiagnosticInfoIgnoringInvalidDebugMetadata : public DiagnosticInfo { +class LLVM_ABI DiagnosticInfoIgnoringInvalidDebugMetadata + : public DiagnosticInfo { private: /// The module that is concerned by this debug metadata version diagnostic. const Module &M; @@ -258,7 +260,7 @@ public: }; /// Diagnostic information for the sample profiler. -class DiagnosticInfoSampleProfile : public DiagnosticInfo { +class LLVM_ABI DiagnosticInfoSampleProfile : public DiagnosticInfo { public: DiagnosticInfoSampleProfile(StringRef FileName, unsigned LineNum, const Twine &Msg LLVM_LIFETIME_BOUND, @@ -298,7 +300,7 @@ private: }; /// Diagnostic information for the PGO profiler. -class DiagnosticInfoPGOProfile : public DiagnosticInfo { +class LLVM_ABI DiagnosticInfoPGOProfile : public DiagnosticInfo { public: DiagnosticInfoPGOProfile(const char *FileName, const Twine &Msg LLVM_LIFETIME_BOUND, @@ -330,20 +332,20 @@ class DiagnosticLocation { public: DiagnosticLocation() = default; - DiagnosticLocation(const DebugLoc &DL); - DiagnosticLocation(const DISubprogram *SP); + LLVM_ABI DiagnosticLocation(const DebugLoc &DL); + LLVM_ABI DiagnosticLocation(const DISubprogram *SP); bool isValid() const { return File; } /// Return the full path to the file. - std::string getAbsolutePath() const; + LLVM_ABI std::string getAbsolutePath() const; /// Return the file name relative to the compilation directory. - StringRef getRelativePath() const; + LLVM_ABI StringRef getRelativePath() const; unsigned getLine() const { return Line; } unsigned getColumn() const { return Column; } }; /// Common features for diagnostics with an associated location. -class DiagnosticInfoWithLocationBase : public DiagnosticInfo { +class LLVM_ABI DiagnosticInfoWithLocationBase : public DiagnosticInfo { void anchor() override; public: /// \p Fn is the function where the diagnostic is being emitted. \p Loc is @@ -381,7 +383,8 @@ private: DiagnosticLocation Loc; }; -class DiagnosticInfoGenericWithLoc : public DiagnosticInfoWithLocationBase { +class LLVM_ABI DiagnosticInfoGenericWithLoc + : public DiagnosticInfoWithLocationBase { private: /// Message to be reported. const Twine &MsgStr; @@ -406,7 +409,8 @@ public: } }; -class DiagnosticInfoRegAllocFailure : public DiagnosticInfoWithLocationBase { +class LLVM_ABI DiagnosticInfoRegAllocFailure + : public DiagnosticInfoWithLocationBase { private: /// Message to be reported. const Twine &MsgStr; @@ -434,7 +438,8 @@ public: /// Diagnostic information for stack size etc. reporting. /// This is basically a function and a size. -class DiagnosticInfoResourceLimit : public DiagnosticInfoWithLocationBase { +class LLVM_ABI DiagnosticInfoResourceLimit + : public DiagnosticInfoWithLocationBase { private: /// The function that is concerned by this resource limit diagnostic. const Function &Fn; @@ -469,7 +474,7 @@ public: } }; -class DiagnosticInfoStackSize : public DiagnosticInfoResourceLimit { +class LLVM_ABI DiagnosticInfoStackSize : public DiagnosticInfoResourceLimit { void anchor() override; public: @@ -489,7 +494,8 @@ public: /// Common features for diagnostics dealing with optimization remarks /// that are used by both IR and MIR passes. -class DiagnosticInfoOptimizationBase : public DiagnosticInfoWithLocationBase { +class LLVM_ABI DiagnosticInfoOptimizationBase + : public DiagnosticInfoWithLocationBase { public: /// Used to set IsVerbose via the stream interface. struct setIsVerbose {}; @@ -509,21 +515,21 @@ public: DiagnosticLocation Loc; explicit Argument(StringRef Str = "") : Key("String"), Val(Str) {} - Argument(StringRef Key, const Value *V); - Argument(StringRef Key, const Type *T); - Argument(StringRef Key, StringRef S); + LLVM_ABI Argument(StringRef Key, const Value *V); + LLVM_ABI Argument(StringRef Key, const Type *T); + LLVM_ABI Argument(StringRef Key, StringRef S); Argument(StringRef Key, const char *S) : Argument(Key, StringRef(S)) {}; - Argument(StringRef Key, int N); - Argument(StringRef Key, float N); - Argument(StringRef Key, long N); - Argument(StringRef Key, long long N); - Argument(StringRef Key, unsigned N); - Argument(StringRef Key, unsigned long N); - Argument(StringRef Key, unsigned long long N); - Argument(StringRef Key, ElementCount EC); + LLVM_ABI Argument(StringRef Key, int N); + LLVM_ABI Argument(StringRef Key, float N); + LLVM_ABI Argument(StringRef Key, long N); + LLVM_ABI Argument(StringRef Key, long long N); + LLVM_ABI Argument(StringRef Key, unsigned N); + LLVM_ABI Argument(StringRef Key, unsigned long N); + LLVM_ABI Argument(StringRef Key, unsigned long long N); + LLVM_ABI Argument(StringRef Key, ElementCount EC); Argument(StringRef Key, bool B) : Key(Key), Val(B ? "true" : "false") {} - Argument(StringRef Key, DebugLoc dl); - Argument(StringRef Key, InstructionCost C); + LLVM_ABI Argument(StringRef Key, DebugLoc dl); + LLVM_ABI Argument(StringRef Key, InstructionCost C); }; /// \p PassName is the name of the pass emitting this diagnostic. \p @@ -663,7 +669,8 @@ operator<<(RemarkT &&R, /// Common features for diagnostics dealing with optimization remarks /// that are used by IR passes. -class DiagnosticInfoIROptimization : public DiagnosticInfoOptimizationBase { +class LLVM_ABI DiagnosticInfoIROptimization + : public DiagnosticInfoOptimizationBase { void anchor() override; public: /// \p PassName is the name of the pass emitting this diagnostic. \p @@ -729,7 +736,7 @@ private: }; /// Diagnostic information for applied optimization remarks. -class OptimizationRemark : public DiagnosticInfoIROptimization { +class LLVM_ABI OptimizationRemark : public DiagnosticInfoIROptimization { public: /// \p PassName is the name of the pass emitting this diagnostic. If this name /// matches the regular expression given in -Rpass=, then the diagnostic will @@ -774,7 +781,7 @@ private: }; /// Diagnostic information for missed-optimization remarks. -class OptimizationRemarkMissed : public DiagnosticInfoIROptimization { +class LLVM_ABI OptimizationRemarkMissed : public DiagnosticInfoIROptimization { public: /// \p PassName is the name of the pass emitting this diagnostic. If this name /// matches the regular expression given in -Rpass-missed=, then the @@ -819,7 +826,8 @@ private: }; /// Diagnostic information for optimization analysis remarks. -class OptimizationRemarkAnalysis : public DiagnosticInfoIROptimization { +class LLVM_ABI OptimizationRemarkAnalysis + : public DiagnosticInfoIROptimization { public: /// \p PassName is the name of the pass emitting this diagnostic. If this name /// matches the regular expression given in -Rpass-analysis=, then the @@ -891,7 +899,8 @@ private: /// Diagnostic information for optimization analysis remarks related to /// floating-point non-commutativity. -class OptimizationRemarkAnalysisFPCommute : public OptimizationRemarkAnalysis { +class LLVM_ABI OptimizationRemarkAnalysisFPCommute + : public OptimizationRemarkAnalysis { void anchor() override; public: /// \p PassName is the name of the pass emitting this diagnostic. If this name @@ -933,7 +942,8 @@ private: /// Diagnostic information for optimization analysis remarks related to /// pointer aliasing. -class OptimizationRemarkAnalysisAliasing : public OptimizationRemarkAnalysis { +class LLVM_ABI OptimizationRemarkAnalysisAliasing + : public OptimizationRemarkAnalysis { void anchor() override; public: /// \p PassName is the name of the pass emitting this diagnostic. If this name @@ -974,7 +984,7 @@ private: /// Diagnostic information for machine IR parser. // FIXME: Remove this, use DiagnosticInfoSrcMgr instead. -class DiagnosticInfoMIRParser : public DiagnosticInfo { +class LLVM_ABI DiagnosticInfoMIRParser : public DiagnosticInfo { const SMDiagnostic &Diagnostic; public: @@ -992,7 +1002,7 @@ public: }; /// Diagnostic information for IR instrumentation reporting. -class DiagnosticInfoInstrumentation : public DiagnosticInfo { +class LLVM_ABI DiagnosticInfoInstrumentation : public DiagnosticInfo { const Twine &Msg; public: @@ -1008,7 +1018,7 @@ public: }; /// Diagnostic information for ISel fallback path. -class DiagnosticInfoISelFallback : public DiagnosticInfo { +class LLVM_ABI DiagnosticInfoISelFallback : public DiagnosticInfo { /// The function that is concerned by this diagnostic. const Function &Fn; @@ -1030,7 +1040,8 @@ public: DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DiagnosticInfo, LLVMDiagnosticInfoRef) /// Diagnostic information for optimization failures. -class DiagnosticInfoOptimizationFailure : public DiagnosticInfoIROptimization { +class LLVM_ABI DiagnosticInfoOptimizationFailure + : public DiagnosticInfoIROptimization { public: /// \p Fn is the function where the diagnostic is being emitted. \p Loc is /// the location information to use in the diagnostic. If line table @@ -1061,7 +1072,8 @@ public: }; /// Diagnostic information for unsupported feature in backend. -class DiagnosticInfoUnsupported : public DiagnosticInfoWithLocationBase { +class LLVM_ABI DiagnosticInfoUnsupported + : public DiagnosticInfoWithLocationBase { private: const Twine &Msg; @@ -1089,7 +1101,7 @@ public: }; /// Diagnostic information for MisExpect analysis. -class DiagnosticInfoMisExpect : public DiagnosticInfoWithLocationBase { +class LLVM_ABI DiagnosticInfoMisExpect : public DiagnosticInfoWithLocationBase { public: DiagnosticInfoMisExpect(const Instruction *Inst, const Twine &Msg LLVM_LIFETIME_BOUND); @@ -1127,7 +1139,7 @@ static DiagnosticSeverity getDiagnosticSeverity(SourceMgr::DiagKind DK) { } /// Diagnostic information for SMDiagnostic reporting. -class DiagnosticInfoSrcMgr : public DiagnosticInfo { +class LLVM_ABI DiagnosticInfoSrcMgr : public DiagnosticInfo { const SMDiagnostic &Diagnostic; StringRef ModName; @@ -1153,9 +1165,9 @@ public: } }; -void diagnoseDontCall(const CallInst &CI); +LLVM_ABI void diagnoseDontCall(const CallInst &CI); -class DiagnosticInfoDontCall : public DiagnosticInfo { +class LLVM_ABI DiagnosticInfoDontCall : public DiagnosticInfo { StringRef CalleeName; StringRef Note; uint64_t LocCookie; diff --git a/llvm/include/llvm/IR/DiagnosticPrinter.h b/llvm/include/llvm/IR/DiagnosticPrinter.h index 2df6fc3..331fc94 100644 --- a/llvm/include/llvm/IR/DiagnosticPrinter.h +++ b/llvm/include/llvm/IR/DiagnosticPrinter.h @@ -15,6 +15,7 @@ #ifndef LLVM_IR_DIAGNOSTICPRINTER_H #define LLVM_IR_DIAGNOSTICPRINTER_H +#include "llvm/Support/Compiler.h" #include <string> namespace llvm { @@ -58,7 +59,7 @@ public: }; /// Basic diagnostic printer that uses an underlying raw_ostream. -class DiagnosticPrinterRawOStream : public DiagnosticPrinter { +class LLVM_ABI DiagnosticPrinterRawOStream : public DiagnosticPrinter { protected: raw_ostream &Stream; diff --git a/llvm/include/llvm/IR/Dominators.h b/llvm/include/llvm/IR/Dominators.h index 287f419..bf128a3 100644 --- a/llvm/include/llvm/IR/Dominators.h +++ b/llvm/include/llvm/IR/Dominators.h @@ -30,6 +30,7 @@ #include "llvm/Pass.h" #include "llvm/Support/CFGDiff.h" #include "llvm/Support/CFGUpdate.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/GenericDomTree.h" #include <algorithm> #include <utility> @@ -43,9 +44,11 @@ class Value; class raw_ostream; template <class GraphType> struct GraphTraits; -extern template class DomTreeNodeBase<BasicBlock>; -extern template class DominatorTreeBase<BasicBlock, false>; // DomTree -extern template class DominatorTreeBase<BasicBlock, true>; // PostDomTree +extern template class LLVM_TEMPLATE_ABI DomTreeNodeBase<BasicBlock>; +extern template class LLVM_TEMPLATE_ABI + DominatorTreeBase<BasicBlock, false>; // DomTree +extern template class LLVM_TEMPLATE_ABI + DominatorTreeBase<BasicBlock, true>; // PostDomTree extern template class cfg::Update<BasicBlock *>; @@ -58,35 +61,35 @@ using BBUpdates = ArrayRef<llvm::cfg::Update<BasicBlock *>>; using BBDomTreeGraphDiff = GraphDiff<BasicBlock *, false>; using BBPostDomTreeGraphDiff = GraphDiff<BasicBlock *, true>; -extern template void Calculate<BBDomTree>(BBDomTree &DT); -extern template void CalculateWithUpdates<BBDomTree>(BBDomTree &DT, - BBUpdates U); - -extern template void Calculate<BBPostDomTree>(BBPostDomTree &DT); - -extern template void InsertEdge<BBDomTree>(BBDomTree &DT, BasicBlock *From, - BasicBlock *To); -extern template void InsertEdge<BBPostDomTree>(BBPostDomTree &DT, - BasicBlock *From, - BasicBlock *To); - -extern template void DeleteEdge<BBDomTree>(BBDomTree &DT, BasicBlock *From, - BasicBlock *To); -extern template void DeleteEdge<BBPostDomTree>(BBPostDomTree &DT, - BasicBlock *From, - BasicBlock *To); - -extern template void ApplyUpdates<BBDomTree>(BBDomTree &DT, - BBDomTreeGraphDiff &, - BBDomTreeGraphDiff *); -extern template void ApplyUpdates<BBPostDomTree>(BBPostDomTree &DT, - BBPostDomTreeGraphDiff &, - BBPostDomTreeGraphDiff *); - -extern template bool Verify<BBDomTree>(const BBDomTree &DT, - BBDomTree::VerificationLevel VL); -extern template bool Verify<BBPostDomTree>(const BBPostDomTree &DT, - BBPostDomTree::VerificationLevel VL); +extern template LLVM_TEMPLATE_ABI void Calculate<BBDomTree>(BBDomTree &DT); +extern template LLVM_TEMPLATE_ABI void +CalculateWithUpdates<BBDomTree>(BBDomTree &DT, BBUpdates U); + +extern template LLVM_TEMPLATE_ABI void +Calculate<BBPostDomTree>(BBPostDomTree &DT); + +extern template LLVM_TEMPLATE_ABI void +InsertEdge<BBDomTree>(BBDomTree &DT, BasicBlock *From, BasicBlock *To); +extern template LLVM_TEMPLATE_ABI void +InsertEdge<BBPostDomTree>(BBPostDomTree &DT, BasicBlock *From, BasicBlock *To); + +extern template LLVM_TEMPLATE_ABI void +DeleteEdge<BBDomTree>(BBDomTree &DT, BasicBlock *From, BasicBlock *To); +extern template LLVM_TEMPLATE_ABI void +DeleteEdge<BBPostDomTree>(BBPostDomTree &DT, BasicBlock *From, BasicBlock *To); + +extern template LLVM_TEMPLATE_ABI void +ApplyUpdates<BBDomTree>(BBDomTree &DT, BBDomTreeGraphDiff &, + BBDomTreeGraphDiff *); +extern template LLVM_TEMPLATE_ABI void +ApplyUpdates<BBPostDomTree>(BBPostDomTree &DT, BBPostDomTreeGraphDiff &, + BBPostDomTreeGraphDiff *); + +extern template LLVM_TEMPLATE_ABI bool +Verify<BBDomTree>(const BBDomTree &DT, BBDomTree::VerificationLevel VL); +extern template LLVM_TEMPLATE_ABI bool +Verify<BBPostDomTree>(const BBPostDomTree &DT, + BBPostDomTree::VerificationLevel VL); } // namespace DomTreeBuilder using DomTreeNode = DomTreeNodeBase<BasicBlock>; @@ -114,13 +117,13 @@ public: } /// Check if this is the only edge between Start and End. - bool isSingleEdge() const; + LLVM_ABI bool isSingleEdge() const; }; template <> struct DenseMapInfo<BasicBlockEdge> { using BBInfo = DenseMapInfo<const BasicBlock *>; - static unsigned getHashValue(const BasicBlockEdge *V); + LLVM_ABI static unsigned getHashValue(const BasicBlockEdge *V); static inline BasicBlockEdge getEmptyKey() { return BasicBlockEdge(BBInfo::getEmptyKey(), BBInfo::getEmptyKey()); @@ -170,14 +173,14 @@ class DominatorTree : public DominatorTreeBase<BasicBlock, false> { } /// Handle invalidation explicitly. - bool invalidate(Function &F, const PreservedAnalyses &PA, - FunctionAnalysisManager::Invalidator &); + LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA, + FunctionAnalysisManager::Invalidator &); // Ensure base-class overloads are visible. using Base::dominates; /// Return true if the (end of the) basic block BB dominates the use U. - bool dominates(const BasicBlock *BB, const Use &U) const; + LLVM_ABI bool dominates(const BasicBlock *BB, const Use &U) const; /// Return true if value Def dominates use U, in the sense that Def is /// available at U, and could be substituted as the used value without @@ -188,11 +191,11 @@ class DominatorTree : public DominatorTreeBase<BasicBlock, false> { /// * Def does not dominate a use in Def itself (outside of degenerate cases /// like unreachable code or trivial phi cycles). /// * Invoke Defs only dominate uses in their default destination. - bool dominates(const Value *Def, const Use &U) const; + LLVM_ABI bool dominates(const Value *Def, const Use &U) const; /// Return true if value Def dominates all possible uses inside instruction /// User. Same comments as for the Use-based API apply. - bool dominates(const Value *Def, const Instruction *User) const; + LLVM_ABI bool dominates(const Value *Def, const Instruction *User) const; bool dominates(const Value *Def, BasicBlock::iterator User) const { return dominates(Def, &*User); } @@ -202,34 +205,36 @@ class DominatorTree : public DominatorTreeBase<BasicBlock, false> { /// /// Does not accept Value to avoid ambiguity with dominance checks between /// two basic blocks. - bool dominates(const Instruction *Def, const BasicBlock *BB) const; + LLVM_ABI bool dominates(const Instruction *Def, const BasicBlock *BB) const; /// Return true if an edge dominates a use. /// /// If BBE is not a unique edge between start and end of the edge, it can /// never dominate the use. - bool dominates(const BasicBlockEdge &BBE, const Use &U) const; - bool dominates(const BasicBlockEdge &BBE, const BasicBlock *BB) const; + LLVM_ABI bool dominates(const BasicBlockEdge &BBE, const Use &U) const; + LLVM_ABI bool dominates(const BasicBlockEdge &BBE, + const BasicBlock *BB) const; /// Returns true if edge \p BBE1 dominates edge \p BBE2. - bool dominates(const BasicBlockEdge &BBE1, const BasicBlockEdge &BBE2) const; + LLVM_ABI bool dominates(const BasicBlockEdge &BBE1, + const BasicBlockEdge &BBE2) const; // Ensure base class overloads are visible. using Base::isReachableFromEntry; /// Provide an overload for a Use. - bool isReachableFromEntry(const Use &U) const; + LLVM_ABI bool isReachableFromEntry(const Use &U) const; // Ensure base class overloads are visible. using Base::findNearestCommonDominator; /// Find the nearest instruction I that dominates both I1 and I2, in the sense /// that a result produced before I will be available at both I1 and I2. - Instruction *findNearestCommonDominator(Instruction *I1, - Instruction *I2) const; + LLVM_ABI Instruction *findNearestCommonDominator(Instruction *I1, + Instruction *I2) const; // Pop up a GraphViz/gv window with the Dominator Tree rendered using `dot`. - void viewGraph(const Twine &Name, const Twine &Title); - void viewGraph(); + LLVM_ABI void viewGraph(const Twine &Name, const Twine &Title); + LLVM_ABI void viewGraph(); }; //===------------------------------------- @@ -278,14 +283,14 @@ template <> struct GraphTraits<DominatorTree*> /// Analysis pass which computes a \c DominatorTree. class DominatorTreeAnalysis : public AnalysisInfoMixin<DominatorTreeAnalysis> { friend AnalysisInfoMixin<DominatorTreeAnalysis>; - static AnalysisKey Key; + LLVM_ABI static AnalysisKey Key; public: /// Provide the result typedef for this analysis pass. using Result = DominatorTree; /// Run the analysis pass over a function and produce a dominator tree. - DominatorTree run(Function &F, FunctionAnalysisManager &); + LLVM_ABI DominatorTree run(Function &F, FunctionAnalysisManager &); }; /// Printer pass for the \c DominatorTree. @@ -294,16 +299,16 @@ class DominatorTreePrinterPass raw_ostream &OS; public: - explicit DominatorTreePrinterPass(raw_ostream &OS); + LLVM_ABI explicit DominatorTreePrinterPass(raw_ostream &OS); - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); static bool isRequired() { return true; } }; /// Verifier pass for the \c DominatorTree. struct DominatorTreeVerifierPass : PassInfoMixin<DominatorTreeVerifierPass> { - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); static bool isRequired() { return true; } }; @@ -311,10 +316,10 @@ struct DominatorTreeVerifierPass : PassInfoMixin<DominatorTreeVerifierPass> { /// /// This check is expensive and is disabled by default. `-verify-dom-info` /// allows selectively enabling the check without needing to recompile. -extern bool VerifyDomInfo; +LLVM_ABI extern bool VerifyDomInfo; /// Legacy analysis pass which computes a \c DominatorTree. -class DominatorTreeWrapperPass : public FunctionPass { +class LLVM_ABI DominatorTreeWrapperPass : public FunctionPass { DominatorTree DT; public: diff --git a/llvm/include/llvm/IR/DroppedVariableStats.h b/llvm/include/llvm/IR/DroppedVariableStats.h index ebd74a6..42e86dd 100644 --- a/llvm/include/llvm/IR/DroppedVariableStats.h +++ b/llvm/include/llvm/IR/DroppedVariableStats.h @@ -16,6 +16,7 @@ #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Compiler.h" #include <tuple> namespace llvm { @@ -39,7 +40,7 @@ using VarID = /// statistics. class DroppedVariableStats { public: - DroppedVariableStats(bool DroppedVarStatsEnabled); + LLVM_ABI DroppedVariableStats(bool DroppedVarStatsEnabled); virtual ~DroppedVariableStats() {} @@ -50,9 +51,9 @@ public: bool getPassDroppedVariables() { return PassDroppedVariables; } protected: - void setup(); + LLVM_ABI void setup(); - void cleanup(); + LLVM_ABI void cleanup(); bool DroppedVariableStatsEnabled = false; struct DebugVariables { @@ -75,26 +76,26 @@ protected: SmallVector<DenseMap<StringRef, DenseMap<VarID, DILocation *>>> InlinedAts; /// Calculate the number of dropped variables in an llvm::Function or /// llvm::MachineFunction and print the relevant information to stdout. - void calculateDroppedStatsAndPrint(DebugVariables &DbgVariables, - StringRef FuncName, StringRef PassID, - StringRef FuncOrModName, - StringRef PassLevel, const Function *Func); + LLVM_ABI void calculateDroppedStatsAndPrint( + DebugVariables &DbgVariables, StringRef FuncName, StringRef PassID, + StringRef FuncOrModName, StringRef PassLevel, const Function *Func); /// Check if a \p Var has been dropped or is a false positive. Also update the /// \p DroppedCount if a debug variable is dropped. - bool updateDroppedCount(DILocation *DbgLoc, const DIScope *Scope, - const DIScope *DbgValScope, - DenseMap<VarID, DILocation *> &InlinedAtsMap, - VarID Var, unsigned &DroppedCount); + LLVM_ABI bool updateDroppedCount(DILocation *DbgLoc, const DIScope *Scope, + const DIScope *DbgValScope, + DenseMap<VarID, DILocation *> &InlinedAtsMap, + VarID Var, unsigned &DroppedCount); /// Run code to populate relevant data structures over an llvm::Function or /// llvm::MachineFunction. - void run(DebugVariables &DbgVariables, StringRef FuncName, bool Before); + LLVM_ABI void run(DebugVariables &DbgVariables, StringRef FuncName, + bool Before); /// Populate the VarIDSet and InlinedAtMap with the relevant information /// needed for before and after pass analysis to determine dropped variable /// status. - void populateVarIDSetAndInlinedMap( + LLVM_ABI void populateVarIDSetAndInlinedMap( const DILocalVariable *DbgVar, DebugLoc DbgLoc, DenseSet<VarID> &VarIDSet, DenseMap<StringRef, DenseMap<VarID, DILocation *>> &InlinedAtsMap, StringRef FuncName, bool Before); diff --git a/llvm/include/llvm/IR/DroppedVariableStatsIR.h b/llvm/include/llvm/IR/DroppedVariableStatsIR.h index 72b91db..3e18256 100644 --- a/llvm/include/llvm/IR/DroppedVariableStatsIR.h +++ b/llvm/include/llvm/IR/DroppedVariableStatsIR.h @@ -15,6 +15,7 @@ #define LLVM_CODEGEN_DROPPEDVARIABLESTATSIR_H #include "llvm/IR/DroppedVariableStats.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -28,7 +29,7 @@ class DILocation; /// A class to collect and print dropped debug information due to LLVM IR /// optimization passes. After every LLVM IR pass is run, it will print how many /// #dbg_values were dropped due to that pass. -class DroppedVariableStatsIR : public DroppedVariableStats { +class LLVM_ABI DroppedVariableStatsIR : public DroppedVariableStats { public: DroppedVariableStatsIR(bool DroppedVarStatsEnabled) : llvm::DroppedVariableStats(DroppedVarStatsEnabled) {} diff --git a/llvm/include/llvm/IR/EHPersonalities.h b/llvm/include/llvm/IR/EHPersonalities.h index c70f832..39f6817 100644 --- a/llvm/include/llvm/IR/EHPersonalities.h +++ b/llvm/include/llvm/IR/EHPersonalities.h @@ -11,6 +11,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/TinyPtrVector.h" +#include "llvm/Support/Compiler.h" namespace llvm { class BasicBlock; @@ -39,11 +40,11 @@ enum class EHPersonality { /// See if the given exception handling personality function is one /// that we understand. If so, return a description of it; otherwise return /// Unknown. -EHPersonality classifyEHPersonality(const Value *Pers); +LLVM_ABI EHPersonality classifyEHPersonality(const Value *Pers); -StringRef getEHPersonalityName(EHPersonality Pers); +LLVM_ABI StringRef getEHPersonalityName(EHPersonality Pers); -EHPersonality getDefaultEHPersonality(const Triple &T); +LLVM_ABI EHPersonality getDefaultEHPersonality(const Triple &T); /// Returns true if this personality function catches asynchronous /// exceptions. @@ -104,7 +105,7 @@ inline bool isNoOpWithoutInvoke(EHPersonality Pers) { llvm_unreachable("invalid enum"); } -bool canSimplifyInvokeNoUnwind(const Function *F); +LLVM_ABI bool canSimplifyInvokeNoUnwind(const Function *F); typedef TinyPtrVector<BasicBlock *> ColorVector; @@ -112,7 +113,7 @@ typedef TinyPtrVector<BasicBlock *> ColorVector; /// this will recompute which blocks are in which funclet. It is possible that /// some blocks are in multiple funclets. Consider this analysis to be /// expensive. -DenseMap<BasicBlock *, ColorVector> colorEHFunclets(Function &F); +LLVM_ABI DenseMap<BasicBlock *, ColorVector> colorEHFunclets(Function &F); } // end namespace llvm diff --git a/llvm/include/llvm/IR/FMF.h b/llvm/include/llvm/IR/FMF.h index da274a1..8bd5912 100644 --- a/llvm/include/llvm/IR/FMF.h +++ b/llvm/include/llvm/IR/FMF.h @@ -13,6 +13,8 @@ #ifndef LLVM_IR_FMF_H #define LLVM_IR_FMF_H +#include "llvm/Support/Compiler.h" + namespace llvm { class raw_ostream; @@ -104,7 +106,7 @@ public: } /// Print fast-math flags to \p O. - void print(raw_ostream &O) const; + LLVM_ABI void print(raw_ostream &O) const; /// Intersect rewrite-based flags static inline FastMathFlags intersectRewrite(FastMathFlags LHS, diff --git a/llvm/include/llvm/IR/FPEnv.h b/llvm/include/llvm/IR/FPEnv.h index a019737..38395b1 100644 --- a/llvm/include/llvm/IR/FPEnv.h +++ b/llvm/include/llvm/IR/FPEnv.h @@ -17,6 +17,7 @@ #include "llvm/ADT/FloatingPointMode.h" #include "llvm/IR/FMF.h" +#include "llvm/Support/Compiler.h" #include <optional> namespace llvm { @@ -46,19 +47,21 @@ enum ExceptionBehavior : uint8_t { /// Returns a valid RoundingMode enumerator when given a string /// that is valid as input in constrained intrinsic rounding mode /// metadata. -std::optional<RoundingMode> convertStrToRoundingMode(StringRef); +LLVM_ABI std::optional<RoundingMode> convertStrToRoundingMode(StringRef); /// For any RoundingMode enumerator, returns a string valid as input in /// constrained intrinsic rounding mode metadata. -std::optional<StringRef> convertRoundingModeToStr(RoundingMode); +LLVM_ABI std::optional<StringRef> convertRoundingModeToStr(RoundingMode); /// Returns a valid ExceptionBehavior enumerator when given a string /// valid as input in constrained intrinsic exception behavior metadata. -std::optional<fp::ExceptionBehavior> convertStrToExceptionBehavior(StringRef); +LLVM_ABI std::optional<fp::ExceptionBehavior> + convertStrToExceptionBehavior(StringRef); /// For any ExceptionBehavior enumerator, returns a string valid as /// input in constrained intrinsic exception behavior metadata. -std::optional<StringRef> convertExceptionBehaviorToStr(fp::ExceptionBehavior); +LLVM_ABI std::optional<StringRef> + convertExceptionBehaviorToStr(fp::ExceptionBehavior); /// Returns true if the exception handling behavior and rounding mode /// match what is used in the default floating point environment. @@ -70,7 +73,7 @@ inline bool isDefaultFPEnvironment(fp::ExceptionBehavior EB, RoundingMode RM) { /// strictfp function. If the instruction is already a constrained intrinsic or /// does not have a constrained intrinsic counterpart, the function returns /// zero. -Intrinsic::ID getConstrainedIntrinsicID(const Instruction &Instr); +LLVM_ABI Intrinsic::ID getConstrainedIntrinsicID(const Instruction &Instr); /// Returns true if the rounding mode RM may be QRM at compile time or /// at run time. diff --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h index 6d4a53d..b37c6c6 100644 --- a/llvm/include/llvm/IR/Function.h +++ b/llvm/include/llvm/IR/Function.h @@ -32,6 +32,7 @@ #include "llvm/IR/OperandTraits.h" #include "llvm/IR/SymbolTableListTraits.h" #include "llvm/IR/Value.h" +#include "llvm/Support/Compiler.h" #include <cassert> #include <cstddef> #include <cstdint> @@ -791,8 +792,9 @@ public: private: // These need access to the underlying BB list. - friend void BasicBlock::removeFromParent(); - friend iplist<BasicBlock>::iterator BasicBlock::eraseFromParent(); + LLVM_ABI_FRIEND friend void BasicBlock::removeFromParent(); + LLVM_ABI_FRIEND friend iplist<BasicBlock>::iterator + BasicBlock::eraseFromParent(); template <class BB_t, class BB_i_t, class BI_t, class II_t> friend class InstIterator; friend class llvm::SymbolTableListTraits<llvm::BasicBlock>; @@ -1052,8 +1054,7 @@ namespace CallingConv { // TODO: Need similar function for support of argument in position. General // version on FunctionType + Attributes + CallingConv::ID? -LLVM_READNONE -bool supportsNonVoidReturnType(CallingConv::ID CC); +LLVM_ABI LLVM_READNONE bool supportsNonVoidReturnType(CallingConv::ID CC); } // namespace CallingConv /// Check whether null pointer dereferencing is considered undefined behavior @@ -1061,7 +1062,7 @@ bool supportsNonVoidReturnType(CallingConv::ID CC); /// Null pointer access in non-zero address space is not considered undefined. /// Return value: false => null pointer dereference is undefined. /// Return value: true => null pointer dereference is not undefined. -bool NullPointerIsDefined(const Function *F, unsigned AS = 0); +LLVM_ABI bool NullPointerIsDefined(const Function *F, unsigned AS = 0); template <> struct OperandTraits<Function> : public HungoffOperandTraits {}; diff --git a/llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h b/llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h index 49c5fe0..8aac9d5 100644 --- a/llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h +++ b/llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h @@ -18,6 +18,7 @@ #include "llvm/ADT/APFloat.h" #include "llvm/ADT/FloatingPointMode.h" #include "llvm/IR/Instructions.h" +#include "llvm/Support/Compiler.h" #include <optional> namespace llvm { @@ -29,13 +30,14 @@ template <typename ContextT> class GenericFloatingPointPredicateUtils { constexpr static ValueRefT Invalid = {}; private: - static DenormalMode queryDenormalMode(const FunctionT &F, ValueRefT Val); + LLVM_ABI static DenormalMode queryDenormalMode(const FunctionT &F, + ValueRefT Val); - static bool lookThroughFAbs(const FunctionT &F, ValueRefT LHS, - ValueRefT &Src); + LLVM_ABI static bool lookThroughFAbs(const FunctionT &F, ValueRefT LHS, + ValueRefT &Src); - static std::optional<APFloat> matchConstantFloat(const FunctionT &F, - ValueRefT Val); + LLVM_ABI static std::optional<APFloat> matchConstantFloat(const FunctionT &F, + ValueRefT Val); /// Return the return value for fcmpImpliesClass for a compare that produces /// an exact class test. diff --git a/llvm/include/llvm/IR/GlobalAlias.h b/llvm/include/llvm/IR/GlobalAlias.h index 3db6984..12b9f05 100644 --- a/llvm/include/llvm/IR/GlobalAlias.h +++ b/llvm/include/llvm/IR/GlobalAlias.h @@ -18,6 +18,7 @@ #include "llvm/IR/GlobalValue.h" #include "llvm/IR/OperandTraits.h" #include "llvm/IR/Value.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -39,26 +40,26 @@ public: /// If a parent module is specified, the alias is automatically inserted into /// the end of the specified module's alias list. - static GlobalAlias *create(Type *Ty, unsigned AddressSpace, - LinkageTypes Linkage, const Twine &Name, - Constant *Aliasee, Module *Parent); + LLVM_ABI static GlobalAlias *create(Type *Ty, unsigned AddressSpace, + LinkageTypes Linkage, const Twine &Name, + Constant *Aliasee, Module *Parent); // Without the Aliasee. - static GlobalAlias *create(Type *Ty, unsigned AddressSpace, - LinkageTypes Linkage, const Twine &Name, - Module *Parent); + LLVM_ABI static GlobalAlias *create(Type *Ty, unsigned AddressSpace, + LinkageTypes Linkage, const Twine &Name, + Module *Parent); // The module is taken from the Aliasee. - static GlobalAlias *create(Type *Ty, unsigned AddressSpace, - LinkageTypes Linkage, const Twine &Name, - GlobalValue *Aliasee); + LLVM_ABI static GlobalAlias *create(Type *Ty, unsigned AddressSpace, + LinkageTypes Linkage, const Twine &Name, + GlobalValue *Aliasee); // Type, Parent and AddressSpace taken from the Aliasee. - static GlobalAlias *create(LinkageTypes Linkage, const Twine &Name, - GlobalValue *Aliasee); + LLVM_ABI static GlobalAlias *create(LinkageTypes Linkage, const Twine &Name, + GlobalValue *Aliasee); // Linkage, Type, Parent and AddressSpace taken from the Aliasee. - static GlobalAlias *create(const Twine &Name, GlobalValue *Aliasee); + LLVM_ABI static GlobalAlias *create(const Twine &Name, GlobalValue *Aliasee); // allocate space for exactly one operand void *operator new(size_t S) { return User::operator new(S, AllocMarker); } @@ -74,21 +75,21 @@ public: /// removeFromParent - This method unlinks 'this' from the containing module, /// but does not delete it. /// - void removeFromParent(); + LLVM_ABI void removeFromParent(); /// eraseFromParent - This method unlinks 'this' from the containing module /// and deletes it. /// - void eraseFromParent(); + LLVM_ABI void eraseFromParent(); /// These methods retrieve and set alias target. - void setAliasee(Constant *Aliasee); + LLVM_ABI void setAliasee(Constant *Aliasee); const Constant *getAliasee() const { return static_cast<Constant *>(Op<0>().get()); } Constant *getAliasee() { return static_cast<Constant *>(Op<0>().get()); } - const GlobalObject *getAliaseeObject() const; + LLVM_ABI const GlobalObject *getAliaseeObject() const; GlobalObject *getAliaseeObject() { return const_cast<GlobalObject *>( static_cast<const GlobalAlias *>(this)->getAliaseeObject()); diff --git a/llvm/include/llvm/IR/GlobalIFunc.h b/llvm/include/llvm/IR/GlobalIFunc.h index 0d2f152..d93146a 100644 --- a/llvm/include/llvm/IR/GlobalIFunc.h +++ b/llvm/include/llvm/IR/GlobalIFunc.h @@ -22,6 +22,7 @@ #include "llvm/IR/GlobalObject.h" #include "llvm/IR/OperandTraits.h" #include "llvm/IR/Value.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -45,9 +46,9 @@ public: /// If a parent module is specified, the ifunc is automatically inserted into /// the end of the specified module's ifunc list. - static GlobalIFunc *create(Type *Ty, unsigned AddressSpace, - LinkageTypes Linkage, const Twine &Name, - Constant *Resolver, Module *Parent); + LLVM_ABI static GlobalIFunc *create(Type *Ty, unsigned AddressSpace, + LinkageTypes Linkage, const Twine &Name, + Constant *Resolver, Module *Parent); // allocate space for exactly one operand void *operator new(size_t S) { return User::operator new(S, AllocMarker); } @@ -62,10 +63,10 @@ public: /// This method unlinks 'this' from the containing module, but does not /// delete it. - void removeFromParent(); + LLVM_ABI void removeFromParent(); /// This method unlinks 'this' from the containing module and deletes it. - void eraseFromParent(); + LLVM_ABI void eraseFromParent(); /// These methods retrieve and set ifunc resolver function. void setResolver(Constant *Resolver) { Op<0>().set(Resolver); } @@ -76,7 +77,7 @@ public: // Return the resolver function after peeling off potential ConstantExpr // indirection. - const Function *getResolverFunction() const; + LLVM_ABI const Function *getResolverFunction() const; Function *getResolverFunction() { return const_cast<Function *>( static_cast<const GlobalIFunc *>(this)->getResolverFunction()); @@ -96,7 +97,8 @@ public: // is already a global object, then apply the operation to it directly. If // target is a GlobalExpr or a GlobalAlias, evaluate it to its base object and // apply the operation for the base object and all aliases along the path. - void applyAlongResolverPath(function_ref<void(const GlobalValue &)> Op) const; + LLVM_ABI void + applyAlongResolverPath(function_ref<void(const GlobalValue &)> Op) const; }; template <> diff --git a/llvm/include/llvm/IR/GlobalObject.h b/llvm/include/llvm/IR/GlobalObject.h index 73c1b87..557add9 100644 --- a/llvm/include/llvm/IR/GlobalObject.h +++ b/llvm/include/llvm/IR/GlobalObject.h @@ -18,6 +18,7 @@ #include "llvm/IR/GlobalValue.h" #include "llvm/IR/Value.h" #include "llvm/Support/Alignment.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -45,7 +46,7 @@ protected: : GlobalValue(Ty, VTy, AllocInfo, Linkage, Name, AddressSpace) { setGlobalValueSubClassData(0); } - ~GlobalObject(); + LLVM_ABI ~GlobalObject(); Comdat *ObjComdat = nullptr; enum { @@ -83,12 +84,12 @@ public: } /// Sets the alignment attribute of the GlobalObject. - void setAlignment(Align Align); + LLVM_ABI void setAlignment(Align Align); /// Sets the alignment attribute of the GlobalObject. /// This method will be deprecated as the alignment property should always be /// defined. - void setAlignment(MaybeAlign Align); + LLVM_ABI void setAlignment(MaybeAlign Align); unsigned getGlobalObjectSubClassData() const { unsigned ValueData = getGlobalValueSubClassData(); @@ -122,18 +123,18 @@ public: /// /// Setting the section to the empty string tells LLVM to choose an /// appropriate default object file section. - void setSection(StringRef S); + LLVM_ABI void setSection(StringRef S); /// Set the section prefix for this global object. - void setSectionPrefix(StringRef Prefix); + LLVM_ABI void setSectionPrefix(StringRef Prefix); /// Get the section prefix for this global object. - std::optional<StringRef> getSectionPrefix() const; + LLVM_ABI std::optional<StringRef> getSectionPrefix() const; bool hasComdat() const { return getComdat() != nullptr; } const Comdat *getComdat() const { return ObjComdat; } Comdat *getComdat() { return ObjComdat; } - void setComdat(Comdat *C); + LLVM_ABI void setComdat(Comdat *C); using Value::addMetadata; using Value::clearMetadata; @@ -145,21 +146,21 @@ public: using Value::setMetadata; /// Copy metadata from Src, adjusting offsets by Offset. - void copyMetadata(const GlobalObject *Src, unsigned Offset); + LLVM_ABI void copyMetadata(const GlobalObject *Src, unsigned Offset); - void addTypeMetadata(unsigned Offset, Metadata *TypeID); - void setVCallVisibilityMetadata(VCallVisibility Visibility); - VCallVisibility getVCallVisibility() const; + LLVM_ABI void addTypeMetadata(unsigned Offset, Metadata *TypeID); + LLVM_ABI void setVCallVisibilityMetadata(VCallVisibility Visibility); + LLVM_ABI VCallVisibility getVCallVisibility() const; /// Returns true if the alignment of the value can be unilaterally /// increased. /// /// Note that for functions this is the alignment of the code, not the /// alignment of a function pointer. - bool canIncreaseAlignment() const; + LLVM_ABI bool canIncreaseAlignment() const; protected: - void copyAttributesFrom(const GlobalObject *Src); + LLVM_ABI void copyAttributesFrom(const GlobalObject *Src); public: // Methods for support type inquiry through isa, cast, and dyn_cast: @@ -176,7 +177,7 @@ private: (Val ? Mask : 0u)); } - StringRef getSectionImpl() const; + LLVM_ABI StringRef getSectionImpl() const; }; } // end namespace llvm diff --git a/llvm/include/llvm/IR/GlobalValue.h b/llvm/include/llvm/IR/GlobalValue.h index d9ecbb9..83e695c 100644 --- a/llvm/include/llvm/IR/GlobalValue.h +++ b/llvm/include/llvm/IR/GlobalValue.h @@ -23,6 +23,7 @@ #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Value.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include <cassert> #include <cstdint> @@ -162,7 +163,7 @@ private: /// Returns true if the global is a function definition with the nobuiltin /// attribute. - bool isNobuiltinFnDef() const; + LLVM_ABI bool isNobuiltinFnDef() const; protected: /// The intrinsic ID for this subclass (which must be a Function). @@ -240,7 +241,7 @@ public: } bool hasComdat() const { return getComdat() != nullptr; } - const Comdat *getComdat() const; + LLVM_ABI const Comdat *getComdat() const; Comdat *getComdat() { return const_cast<Comdat *>( static_cast<const GlobalValue *>(this)->getComdat()); @@ -289,7 +290,7 @@ public: } bool hasSection() const { return !getSection().empty(); } - StringRef getSection() const; + LLVM_ABI StringRef getSection() const; /// Global values are always pointers. PointerType *getType() const { return cast<PointerType>(User::getType()); } @@ -310,8 +311,8 @@ public: bool hasPartition() const { return HasPartition; } - StringRef getPartition() const; - void setPartition(StringRef Part); + LLVM_ABI StringRef getPartition() const; + LLVM_ABI void setPartition(StringRef Part); // ASan, HWASan and Memtag sanitizers have some instrumentation that applies // specifically to global variables. @@ -354,14 +355,14 @@ public: }; bool hasSanitizerMetadata() const { return HasSanitizerMetadata; } - const SanitizerMetadata &getSanitizerMetadata() const; + LLVM_ABI const SanitizerMetadata &getSanitizerMetadata() const; // Note: Not byref as it's a POD and otherwise it's too easy to call // G.setSanitizerMetadata(G2.getSanitizerMetadata()), and the argument becomes // dangling when the backing storage allocates the metadata for `G`, as the // storage is shared between `G1` and `G2`. - void setSanitizerMetadata(SanitizerMetadata Meta); - void removeSanitizerMetadata(); - void setNoSanitizeMetadata(); + LLVM_ABI void setSanitizerMetadata(SanitizerMetadata Meta); + LLVM_ABI void removeSanitizerMetadata(); + LLVM_ABI void setNoSanitizeMetadata(); bool isTagged() const { return hasSanitizerMetadata() && getSanitizerMetadata().Memtag; @@ -506,8 +507,8 @@ public: /// *arbitrary* definition at link time or load time. We cannot do any IPO or /// inlining across interposable call edges, since the callee can be /// replaced with something arbitrary. - bool isInterposable() const; - bool canBenefitFromLocalAlias() const; + LLVM_ABI bool isInterposable() const; + LLVM_ABI bool canBenefitFromLocalAlias() const; bool hasExternalLinkage() const { return isExternalLinkage(getLinkage()); } bool hasAvailableExternallyLinkage() const { @@ -555,7 +556,7 @@ public: protected: /// Copy all additional attributes (those not needed to create a GlobalValue) /// from the GlobalValue Src to this one. - void copyAttributesFrom(const GlobalValue *Src); + LLVM_ABI void copyAttributesFrom(const GlobalValue *Src); public: /// If the given string begins with the GlobalValue name mangling escape @@ -579,20 +580,20 @@ public: /// used as the key for a global lookup (e.g. profile or ThinLTO). /// The value's original name is \c Name and has linkage of type /// \c Linkage. The value is defined in module \c FileName. - static std::string getGlobalIdentifier(StringRef Name, - GlobalValue::LinkageTypes Linkage, - StringRef FileName); + LLVM_ABI static std::string + getGlobalIdentifier(StringRef Name, GlobalValue::LinkageTypes Linkage, + StringRef FileName); private: /// Return the modified name for this global value suitable to be /// used as the key for a global lookup (e.g. profile or ThinLTO). - std::string getGlobalIdentifier() const; + LLVM_ABI std::string getGlobalIdentifier() const; public: /// Return a 64-bit global unique ID constructed from the name of a global /// symbol. Since this call doesn't supply the linkage or defining filename, /// the GUID computation will assume that the global has external linkage. - static GUID getGUIDAssumingExternalLinkage(StringRef GlobalName); + LLVM_ABI static GUID getGUIDAssumingExternalLinkage(StringRef GlobalName); /// Return a 64-bit global unique ID constructed from global value name /// (i.e. returned by getGlobalIdentifier()). @@ -610,16 +611,16 @@ public: /// If this function's Module is being lazily streamed in functions from disk /// or some other source, this method can be used to check to see if the /// function has been read in yet or not. - bool isMaterializable() const; + LLVM_ABI bool isMaterializable() const; /// Make sure this GlobalValue is fully read. - Error materialize(); + LLVM_ABI Error materialize(); -/// @} + /// @} /// Return true if the primary definition of this global value is outside of /// the current translation unit. - bool isDeclaration() const; + LLVM_ABI bool isDeclaration() const; bool isDeclarationForLinker() const { if (hasAvailableExternallyLinkage()) @@ -638,25 +639,25 @@ public: return !(isDeclarationForLinker() || isWeakForLinker()); } - const GlobalObject *getAliaseeObject() const; + LLVM_ABI const GlobalObject *getAliaseeObject() const; GlobalObject *getAliaseeObject() { return const_cast<GlobalObject *>( static_cast<const GlobalValue *>(this)->getAliaseeObject()); } /// Returns whether this is a reference to an absolute symbol. - bool isAbsoluteSymbolRef() const; + LLVM_ABI bool isAbsoluteSymbolRef() const; /// If this is an absolute symbol reference, returns the range of the symbol, /// otherwise returns std::nullopt. - std::optional<ConstantRange> getAbsoluteSymbolRange() const; + LLVM_ABI std::optional<ConstantRange> getAbsoluteSymbolRange() const; /// This method unlinks 'this' from the containing module, but does not delete /// it. - void removeFromParent(); + LLVM_ABI void removeFromParent(); /// This method unlinks 'this' from the containing module and deletes it. - void eraseFromParent(); + LLVM_ABI void eraseFromParent(); /// Get the module that this global value is contained inside of... Module *getParent() { return Parent; } @@ -665,7 +666,7 @@ public: /// Get the data layout of the module this global belongs to. /// /// Requires the global to have a parent module. - const DataLayout &getDataLayout() const; + LLVM_ABI const DataLayout &getDataLayout() const; // Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { @@ -680,7 +681,7 @@ public: /// is not normally profitable to omit them from the .o symbol table. Using /// this analysis makes sense when the information can be passed down to the /// linker or we are in LTO. - bool canBeOmittedFromSymbolTable() const; + LLVM_ABI bool canBeOmittedFromSymbolTable() const; }; } // end namespace llvm diff --git a/llvm/include/llvm/IR/GlobalVariable.h b/llvm/include/llvm/IR/GlobalVariable.h index 5ea5d3b..a411897f 100644 --- a/llvm/include/llvm/IR/GlobalVariable.h +++ b/llvm/include/llvm/IR/GlobalVariable.h @@ -25,6 +25,7 @@ #include "llvm/IR/GlobalObject.h" #include "llvm/IR/OperandTraits.h" #include "llvm/IR/Value.h" +#include "llvm/Support/Compiler.h" #include <cassert> #include <cstddef> @@ -57,18 +58,21 @@ private: public: /// GlobalVariable ctor - If a parent module is specified, the global is /// automatically inserted into the end of the specified modules global list. - GlobalVariable(Type *Ty, bool isConstant, LinkageTypes Linkage, - Constant *Initializer = nullptr, const Twine &Name = "", - ThreadLocalMode = NotThreadLocal, unsigned AddressSpace = 0, - bool isExternallyInitialized = false); + LLVM_ABI GlobalVariable(Type *Ty, bool isConstant, LinkageTypes Linkage, + Constant *Initializer = nullptr, + const Twine &Name = "", + ThreadLocalMode = NotThreadLocal, + unsigned AddressSpace = 0, + bool isExternallyInitialized = false); /// GlobalVariable ctor - This creates a global and inserts it before the /// specified other global. - GlobalVariable(Module &M, Type *Ty, bool isConstant, LinkageTypes Linkage, - Constant *Initializer, const Twine &Name = "", - GlobalVariable *InsertBefore = nullptr, - ThreadLocalMode = NotThreadLocal, - std::optional<unsigned> AddressSpace = std::nullopt, - bool isExternallyInitialized = false); + LLVM_ABI GlobalVariable(Module &M, Type *Ty, bool isConstant, + LinkageTypes Linkage, Constant *Initializer, + const Twine &Name = "", + GlobalVariable *InsertBefore = nullptr, + ThreadLocalMode = NotThreadLocal, + std::optional<unsigned> AddressSpace = std::nullopt, + bool isExternallyInitialized = false); GlobalVariable(const GlobalVariable &) = delete; GlobalVariable &operator=(const GlobalVariable &) = delete; @@ -158,13 +162,13 @@ public: /// setInitializer - Sets the initializer for this global variable, removing /// any existing initializer if InitVal==NULL. The initializer must have the /// type getValueType(). - void setInitializer(Constant *InitVal); + LLVM_ABI void setInitializer(Constant *InitVal); /// replaceInitializer - Sets the initializer for this global variable, and /// sets the value type of the global to the type of the initializer. The /// initializer must not be null. This may affect the global's alignment if /// it isn't explicitly set. - void replaceInitializer(Constant *InitVal); + LLVM_ABI void replaceInitializer(Constant *InitVal); /// If the value is a global constant, its value is immutable throughout the /// runtime execution of the program. Assigning a value into the constant @@ -182,27 +186,28 @@ public: /// copyAttributesFrom - copy all additional attributes (those not needed to /// create a GlobalVariable) from the GlobalVariable Src to this one. - void copyAttributesFrom(const GlobalVariable *Src); + LLVM_ABI void copyAttributesFrom(const GlobalVariable *Src); /// removeFromParent - This method unlinks 'this' from the containing module, /// but does not delete it. /// - void removeFromParent(); + LLVM_ABI void removeFromParent(); /// eraseFromParent - This method unlinks 'this' from the containing module /// and deletes it. /// - void eraseFromParent(); + LLVM_ABI void eraseFromParent(); /// Drop all references in preparation to destroy the GlobalVariable. This /// drops not only the reference to the initializer but also to any metadata. - void dropAllReferences(); + LLVM_ABI void dropAllReferences(); /// Attach a DIGlobalVariableExpression. - void addDebugInfo(DIGlobalVariableExpression *GV); + LLVM_ABI void addDebugInfo(DIGlobalVariableExpression *GV); /// Fill the vector with all debug info attachements. - void getDebugInfo(SmallVectorImpl<DIGlobalVariableExpression *> &GVs) const; + LLVM_ABI void + getDebugInfo(SmallVectorImpl<DIGlobalVariableExpression *> &GVs) const; /// Add attribute to this global. void addAttribute(Attribute::AttrKind Kind) { @@ -287,11 +292,11 @@ public: /// Change the code model for this global. /// - void setCodeModel(CodeModel::Model CM); + LLVM_ABI void setCodeModel(CodeModel::Model CM); /// Remove the code model for this global. /// - void clearCodeModel(); + LLVM_ABI void clearCodeModel(); // Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h index 7e0521e..0db5179 100644 --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -41,6 +41,7 @@ #include "llvm/Support/AtomicOrdering.h" #include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" #include <cassert> #include <cstdint> #include <functional> @@ -57,7 +58,7 @@ class Use; /// IRBuilder and needs to be inserted. /// /// By default, this inserts the instruction at the insertion point. -class IRBuilderDefaultInserter { +class LLVM_ABI IRBuilderDefaultInserter { public: virtual ~IRBuilderDefaultInserter(); @@ -71,7 +72,7 @@ public: /// Provides an 'InsertHelper' that calls a user-provided callback after /// performing the default insertion. -class IRBuilderCallbackInserter : public IRBuilderDefaultInserter { +class LLVM_ABI IRBuilderCallbackInserter : public IRBuilderDefaultInserter { std::function<void(Instruction *)> Callback; public: @@ -256,11 +257,11 @@ public: } /// Get location information used by debugging information. - DebugLoc getCurrentDebugLocation() const; + LLVM_ABI DebugLoc getCurrentDebugLocation() const; /// If this builder has a current debug location, set it on the /// specified instruction. - void SetInstDebugLocation(Instruction *I) const; + LLVM_ABI void SetInstDebugLocation(Instruction *I) const; /// Add all entries in MetadataToCopy to \p I. void AddMetadataToInst(Instruction *I) const { @@ -270,7 +271,7 @@ public: /// Get the return type of the current function that we're emitting /// into. - Type *getCurrentFunctionReturnType() const; + LLVM_ABI Type *getCurrentFunctionReturnType() const; /// InsertPoint - A saved insertion point. class InsertPoint { @@ -472,9 +473,11 @@ public: /// /// If no module is given via \p M, it is take from the insertion point basic /// block. - GlobalVariable *CreateGlobalString(StringRef Str, const Twine &Name = "", - unsigned AddressSpace = 0, - Module *M = nullptr, bool AddNull = true); + LLVM_ABI GlobalVariable *CreateGlobalString(StringRef Str, + const Twine &Name = "", + unsigned AddressSpace = 0, + Module *M = nullptr, + bool AddNull = true); /// Get a constant value representing either true or false. ConstantInt *getInt1(bool V) { @@ -616,13 +619,14 @@ public: return CreateMemSet(Ptr, Val, getInt64(Size), Align, isVolatile, AAInfo); } - CallInst *CreateMemSet(Value *Ptr, Value *Val, Value *Size, MaybeAlign Align, - bool isVolatile = false, - const AAMDNodes &AAInfo = AAMDNodes()); + LLVM_ABI CallInst *CreateMemSet(Value *Ptr, Value *Val, Value *Size, + MaybeAlign Align, bool isVolatile = false, + const AAMDNodes &AAInfo = AAMDNodes()); - CallInst *CreateMemSetInline(Value *Dst, MaybeAlign DstAlign, Value *Val, - Value *Size, bool IsVolatile = false, - const AAMDNodes &AAInfo = AAMDNodes()); + LLVM_ABI CallInst *CreateMemSetInline(Value *Dst, MaybeAlign DstAlign, + Value *Val, Value *Size, + bool IsVolatile = false, + const AAMDNodes &AAInfo = AAMDNodes()); /// Create and insert an element unordered-atomic memset of the region of /// memory starting at the given pointer to the given value. @@ -637,22 +641,26 @@ public: Ptr, Val, getInt64(Size), Align(Alignment), ElementSize, AAInfo); } - CallInst *CreateMalloc(Type *IntPtrTy, Type *AllocTy, Value *AllocSize, - Value *ArraySize, ArrayRef<OperandBundleDef> OpB, - Function *MallocF = nullptr, const Twine &Name = ""); + LLVM_ABI CallInst *CreateMalloc(Type *IntPtrTy, Type *AllocTy, + Value *AllocSize, Value *ArraySize, + ArrayRef<OperandBundleDef> OpB, + Function *MallocF = nullptr, + const Twine &Name = ""); /// CreateMalloc - Generate the IR for a call to malloc: /// 1. Compute the malloc call's argument as the specified type's size, /// possibly multiplied by the array size if the array size is not /// constant 1. /// 2. Call malloc with that argument. - CallInst *CreateMalloc(Type *IntPtrTy, Type *AllocTy, Value *AllocSize, - Value *ArraySize, Function *MallocF = nullptr, - const Twine &Name = ""); + LLVM_ABI CallInst *CreateMalloc(Type *IntPtrTy, Type *AllocTy, + Value *AllocSize, Value *ArraySize, + Function *MallocF = nullptr, + const Twine &Name = ""); /// Generate the IR for a call to the builtin free function. - CallInst *CreateFree(Value *Source, ArrayRef<OperandBundleDef> Bundles = {}); + LLVM_ABI CallInst *CreateFree(Value *Source, + ArrayRef<OperandBundleDef> Bundles = {}); - CallInst * + LLVM_ABI CallInst * CreateElementUnorderedAtomicMemSet(Value *Ptr, Value *Val, Value *Size, Align Alignment, uint32_t ElementSize, const AAMDNodes &AAInfo = AAMDNodes()); @@ -670,11 +678,11 @@ public: isVolatile, AAInfo); } - CallInst *CreateMemTransferInst(Intrinsic::ID IntrID, Value *Dst, - MaybeAlign DstAlign, Value *Src, - MaybeAlign SrcAlign, Value *Size, - bool isVolatile = false, - const AAMDNodes &AAInfo = AAMDNodes()); + LLVM_ABI CallInst * + CreateMemTransferInst(Intrinsic::ID IntrID, Value *Dst, MaybeAlign DstAlign, + Value *Src, MaybeAlign SrcAlign, Value *Size, + bool isVolatile = false, + const AAMDNodes &AAInfo = AAMDNodes()); CallInst *CreateMemCpy(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size, @@ -700,7 +708,7 @@ public: /// /// If the pointers aren't i8*, they will be converted. If alias metadata is /// specified, it will be added to the instruction. - CallInst *CreateElementUnorderedAtomicMemCpy( + LLVM_ABI CallInst *CreateElementUnorderedAtomicMemCpy( Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size, uint32_t ElementSize, const AAMDNodes &AAInfo = AAMDNodes()); @@ -728,7 +736,7 @@ public: /// /// If the pointers aren't i8*, they will be converted. If alias metadata is /// specified, it will be added to the instruction. - CallInst *CreateElementUnorderedAtomicMemMove( + LLVM_ABI CallInst *CreateElementUnorderedAtomicMemMove( Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size, uint32_t ElementSize, const AAMDNodes &AAInfo = AAMDNodes()); @@ -740,99 +748,106 @@ public: /// The first parameter is a scalar accumulator value. An unordered reduction /// can be created by adding the reassoc fast-math flag to the resulting /// sequential reduction. - CallInst *CreateFAddReduce(Value *Acc, Value *Src); + LLVM_ABI CallInst *CreateFAddReduce(Value *Acc, Value *Src); /// Create a sequential vector fmul reduction intrinsic of the source vector. /// The first parameter is a scalar accumulator value. An unordered reduction /// can be created by adding the reassoc fast-math flag to the resulting /// sequential reduction. - CallInst *CreateFMulReduce(Value *Acc, Value *Src); + LLVM_ABI CallInst *CreateFMulReduce(Value *Acc, Value *Src); /// Create a vector int add reduction intrinsic of the source vector. - CallInst *CreateAddReduce(Value *Src); + LLVM_ABI CallInst *CreateAddReduce(Value *Src); /// Create a vector int mul reduction intrinsic of the source vector. - CallInst *CreateMulReduce(Value *Src); + LLVM_ABI CallInst *CreateMulReduce(Value *Src); /// Create a vector int AND reduction intrinsic of the source vector. - CallInst *CreateAndReduce(Value *Src); + LLVM_ABI CallInst *CreateAndReduce(Value *Src); /// Create a vector int OR reduction intrinsic of the source vector. - CallInst *CreateOrReduce(Value *Src); + LLVM_ABI CallInst *CreateOrReduce(Value *Src); /// Create a vector int XOR reduction intrinsic of the source vector. - CallInst *CreateXorReduce(Value *Src); + LLVM_ABI CallInst *CreateXorReduce(Value *Src); /// Create a vector integer max reduction intrinsic of the source /// vector. - CallInst *CreateIntMaxReduce(Value *Src, bool IsSigned = false); + LLVM_ABI CallInst *CreateIntMaxReduce(Value *Src, bool IsSigned = false); /// Create a vector integer min reduction intrinsic of the source /// vector. - CallInst *CreateIntMinReduce(Value *Src, bool IsSigned = false); + LLVM_ABI CallInst *CreateIntMinReduce(Value *Src, bool IsSigned = false); /// Create a vector float max reduction intrinsic of the source /// vector. - CallInst *CreateFPMaxReduce(Value *Src); + LLVM_ABI CallInst *CreateFPMaxReduce(Value *Src); /// Create a vector float min reduction intrinsic of the source /// vector. - CallInst *CreateFPMinReduce(Value *Src); + LLVM_ABI CallInst *CreateFPMinReduce(Value *Src); /// Create a vector float maximum reduction intrinsic of the source /// vector. This variant follows the NaN and signed zero semantic of /// llvm.maximum intrinsic. - CallInst *CreateFPMaximumReduce(Value *Src); + LLVM_ABI CallInst *CreateFPMaximumReduce(Value *Src); /// Create a vector float minimum reduction intrinsic of the source /// vector. This variant follows the NaN and signed zero semantic of /// llvm.minimum intrinsic. - CallInst *CreateFPMinimumReduce(Value *Src); + LLVM_ABI CallInst *CreateFPMinimumReduce(Value *Src); /// Create a lifetime.start intrinsic. /// /// If the pointer isn't i8* it will be converted. - CallInst *CreateLifetimeStart(Value *Ptr, ConstantInt *Size = nullptr); + LLVM_ABI CallInst *CreateLifetimeStart(Value *Ptr, + ConstantInt *Size = nullptr); /// Create a lifetime.end intrinsic. /// /// If the pointer isn't i8* it will be converted. - CallInst *CreateLifetimeEnd(Value *Ptr, ConstantInt *Size = nullptr); + LLVM_ABI CallInst *CreateLifetimeEnd(Value *Ptr, ConstantInt *Size = nullptr); /// Create a call to invariant.start intrinsic. /// /// If the pointer isn't i8* it will be converted. - CallInst *CreateInvariantStart(Value *Ptr, ConstantInt *Size = nullptr); + LLVM_ABI CallInst *CreateInvariantStart(Value *Ptr, + ConstantInt *Size = nullptr); /// Create a call to llvm.threadlocal.address intrinsic. - CallInst *CreateThreadLocalAddress(Value *Ptr); + LLVM_ABI CallInst *CreateThreadLocalAddress(Value *Ptr); /// Create a call to Masked Load intrinsic - CallInst *CreateMaskedLoad(Type *Ty, Value *Ptr, Align Alignment, Value *Mask, - Value *PassThru = nullptr, const Twine &Name = ""); + LLVM_ABI CallInst *CreateMaskedLoad(Type *Ty, Value *Ptr, Align Alignment, + Value *Mask, Value *PassThru = nullptr, + const Twine &Name = ""); /// Create a call to Masked Store intrinsic - CallInst *CreateMaskedStore(Value *Val, Value *Ptr, Align Alignment, - Value *Mask); + LLVM_ABI CallInst *CreateMaskedStore(Value *Val, Value *Ptr, Align Alignment, + Value *Mask); /// Create a call to Masked Gather intrinsic - CallInst *CreateMaskedGather(Type *Ty, Value *Ptrs, Align Alignment, - Value *Mask = nullptr, Value *PassThru = nullptr, - const Twine &Name = ""); + LLVM_ABI CallInst *CreateMaskedGather(Type *Ty, Value *Ptrs, Align Alignment, + Value *Mask = nullptr, + Value *PassThru = nullptr, + const Twine &Name = ""); /// Create a call to Masked Scatter intrinsic - CallInst *CreateMaskedScatter(Value *Val, Value *Ptrs, Align Alignment, - Value *Mask = nullptr); + LLVM_ABI CallInst *CreateMaskedScatter(Value *Val, Value *Ptrs, + Align Alignment, + Value *Mask = nullptr); /// Create a call to Masked Expand Load intrinsic - CallInst *CreateMaskedExpandLoad(Type *Ty, Value *Ptr, MaybeAlign Align, - Value *Mask = nullptr, - Value *PassThru = nullptr, - const Twine &Name = ""); + LLVM_ABI CallInst *CreateMaskedExpandLoad(Type *Ty, Value *Ptr, + MaybeAlign Align, + Value *Mask = nullptr, + Value *PassThru = nullptr, + const Twine &Name = ""); /// Create a call to Masked Compress Store intrinsic - CallInst *CreateMaskedCompressStore(Value *Val, Value *Ptr, MaybeAlign Align, - Value *Mask = nullptr); + LLVM_ABI CallInst *CreateMaskedCompressStore(Value *Val, Value *Ptr, + MaybeAlign Align, + Value *Mask = nullptr); /// Return an all true boolean vector (mask) with \p NumElts lanes. Value *getAllOnesMask(ElementCount NumElts) { @@ -845,11 +860,11 @@ public: /// /// The optional argument \p OpBundles specifies operand bundles that are /// added to the call instruction. - CallInst *CreateAssumption(Value *Cond, - ArrayRef<OperandBundleDef> OpBundles = {}); + LLVM_ABI CallInst * + CreateAssumption(Value *Cond, ArrayRef<OperandBundleDef> OpBundles = {}); /// Create a llvm.experimental.noalias.scope.decl intrinsic call. - Instruction *CreateNoAliasScopeDeclaration(Value *Scope); + LLVM_ABI Instruction *CreateNoAliasScopeDeclaration(Value *Scope); Instruction *CreateNoAliasScopeDeclaration(MDNode *ScopeTag) { return CreateNoAliasScopeDeclaration( MetadataAsValue::get(Context, ScopeTag)); @@ -857,36 +872,33 @@ public: /// Create a call to the experimental.gc.statepoint intrinsic to /// start a new statepoint sequence. - CallInst *CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, - FunctionCallee ActualCallee, - ArrayRef<Value *> CallArgs, - std::optional<ArrayRef<Value *>> DeoptArgs, - ArrayRef<Value *> GCArgs, - const Twine &Name = ""); + LLVM_ABI CallInst *CreateGCStatepointCall( + uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualCallee, + ArrayRef<Value *> CallArgs, std::optional<ArrayRef<Value *>> DeoptArgs, + ArrayRef<Value *> GCArgs, const Twine &Name = ""); /// Create a call to the experimental.gc.statepoint intrinsic to /// start a new statepoint sequence. - CallInst *CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, - FunctionCallee ActualCallee, uint32_t Flags, - ArrayRef<Value *> CallArgs, - std::optional<ArrayRef<Use>> TransitionArgs, - std::optional<ArrayRef<Use>> DeoptArgs, - ArrayRef<Value *> GCArgs, - const Twine &Name = ""); + LLVM_ABI CallInst * + CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, + FunctionCallee ActualCallee, uint32_t Flags, + ArrayRef<Value *> CallArgs, + std::optional<ArrayRef<Use>> TransitionArgs, + std::optional<ArrayRef<Use>> DeoptArgs, + ArrayRef<Value *> GCArgs, const Twine &Name = ""); /// Conveninence function for the common case when CallArgs are filled /// in using ArrayRef(CS.arg_begin(), CS.arg_end()); Use needs to be /// .get()'ed to get the Value pointer. - CallInst *CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, - FunctionCallee ActualCallee, - ArrayRef<Use> CallArgs, - std::optional<ArrayRef<Value *>> DeoptArgs, - ArrayRef<Value *> GCArgs, - const Twine &Name = ""); + LLVM_ABI CallInst * + CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, + FunctionCallee ActualCallee, ArrayRef<Use> CallArgs, + std::optional<ArrayRef<Value *>> DeoptArgs, + ArrayRef<Value *> GCArgs, const Twine &Name = ""); /// Create an invoke to the experimental.gc.statepoint intrinsic to /// start a new statepoint sequence. - InvokeInst * + LLVM_ABI InvokeInst * CreateGCStatepointInvoke(uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef<Value *> InvokeArgs, @@ -895,7 +907,7 @@ public: /// Create an invoke to the experimental.gc.statepoint intrinsic to /// start a new statepoint sequence. - InvokeInst *CreateGCStatepointInvoke( + LLVM_ABI InvokeInst *CreateGCStatepointInvoke( uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, uint32_t Flags, ArrayRef<Value *> InvokeArgs, std::optional<ArrayRef<Use>> TransitionArgs, @@ -905,7 +917,7 @@ public: // Convenience function for the common case when CallArgs are filled in using // ArrayRef(CS.arg_begin(), CS.arg_end()); Use needs to be .get()'ed to // get the Value *. - InvokeInst * + LLVM_ABI InvokeInst * CreateGCStatepointInvoke(uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef<Use> InvokeArgs, @@ -914,66 +926,67 @@ public: /// Create a call to the experimental.gc.result intrinsic to extract /// the result from a call wrapped in a statepoint. - CallInst *CreateGCResult(Instruction *Statepoint, - Type *ResultType, - const Twine &Name = ""); + LLVM_ABI CallInst *CreateGCResult(Instruction *Statepoint, Type *ResultType, + const Twine &Name = ""); /// Create a call to the experimental.gc.relocate intrinsics to /// project the relocated value of one pointer from the statepoint. - CallInst *CreateGCRelocate(Instruction *Statepoint, - int BaseOffset, - int DerivedOffset, - Type *ResultType, - const Twine &Name = ""); + LLVM_ABI CallInst *CreateGCRelocate(Instruction *Statepoint, int BaseOffset, + int DerivedOffset, Type *ResultType, + const Twine &Name = ""); /// Create a call to the experimental.gc.pointer.base intrinsic to get the /// base pointer for the specified derived pointer. - CallInst *CreateGCGetPointerBase(Value *DerivedPtr, const Twine &Name = ""); + LLVM_ABI CallInst *CreateGCGetPointerBase(Value *DerivedPtr, + const Twine &Name = ""); /// Create a call to the experimental.gc.get.pointer.offset intrinsic to get /// the offset of the specified derived pointer from its base. - CallInst *CreateGCGetPointerOffset(Value *DerivedPtr, const Twine &Name = ""); + LLVM_ABI CallInst *CreateGCGetPointerOffset(Value *DerivedPtr, + const Twine &Name = ""); /// Create a call to llvm.vscale, multiplied by \p Scaling. The type of VScale /// will be the same type as that of \p Scaling. - Value *CreateVScale(Constant *Scaling, const Twine &Name = ""); + LLVM_ABI Value *CreateVScale(Constant *Scaling, const Twine &Name = ""); /// Create an expression which evaluates to the number of elements in \p EC /// at runtime. - Value *CreateElementCount(Type *DstType, ElementCount EC); + LLVM_ABI Value *CreateElementCount(Type *DstType, ElementCount EC); /// Create an expression which evaluates to the number of units in \p Size /// at runtime. This works for both units of bits and bytes. - Value *CreateTypeSize(Type *DstType, TypeSize Size); + LLVM_ABI Value *CreateTypeSize(Type *DstType, TypeSize Size); /// Creates a vector of type \p DstType with the linear sequence <0, 1, ...> - Value *CreateStepVector(Type *DstType, const Twine &Name = ""); + LLVM_ABI Value *CreateStepVector(Type *DstType, const Twine &Name = ""); /// Create a call to intrinsic \p ID with 1 operand which is mangled on its /// type. - CallInst *CreateUnaryIntrinsic(Intrinsic::ID ID, Value *V, - FMFSource FMFSource = {}, - const Twine &Name = ""); + LLVM_ABI CallInst *CreateUnaryIntrinsic(Intrinsic::ID ID, Value *V, + FMFSource FMFSource = {}, + const Twine &Name = ""); /// Create a call to intrinsic \p ID with 2 operands which is mangled on the /// first type. - Value *CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, Value *RHS, - FMFSource FMFSource = {}, - const Twine &Name = ""); + LLVM_ABI Value *CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, + Value *RHS, FMFSource FMFSource = {}, + const Twine &Name = ""); /// Create a call to intrinsic \p ID with \p Args, mangled using \p Types. If /// \p FMFSource is provided, copy fast-math-flags from that instruction to /// the intrinsic. - CallInst *CreateIntrinsic(Intrinsic::ID ID, ArrayRef<Type *> Types, - ArrayRef<Value *> Args, FMFSource FMFSource = {}, - const Twine &Name = ""); + LLVM_ABI CallInst *CreateIntrinsic(Intrinsic::ID ID, ArrayRef<Type *> Types, + ArrayRef<Value *> Args, + FMFSource FMFSource = {}, + const Twine &Name = ""); /// Create a call to intrinsic \p ID with \p RetTy and \p Args. If /// \p FMFSource is provided, copy fast-math-flags from that instruction to /// the intrinsic. - CallInst *CreateIntrinsic(Type *RetTy, Intrinsic::ID ID, - ArrayRef<Value *> Args, FMFSource FMFSource = {}, - const Twine &Name = ""); + LLVM_ABI CallInst *CreateIntrinsic(Type *RetTy, Intrinsic::ID ID, + ArrayRef<Value *> Args, + FMFSource FMFSource = {}, + const Twine &Name = ""); /// Create a call to non-overloaded intrinsic \p ID with \p Args. If /// \p FMFSource is provided, copy fast-math-flags from that instruction to @@ -1732,19 +1745,19 @@ public: /// the created intrinsic call according to \p Rounding and \p /// Except and it sets \p FPMathTag as the 'fpmath' metadata, using /// defaults if a value equals nullopt/null. - CallInst *CreateConstrainedFPIntrinsic( + LLVM_ABI CallInst *CreateConstrainedFPIntrinsic( Intrinsic::ID ID, ArrayRef<Type *> Types, ArrayRef<Value *> Args, FMFSource FMFSource, const Twine &Name, MDNode *FPMathTag = nullptr, std::optional<RoundingMode> Rounding = std::nullopt, std::optional<fp::ExceptionBehavior> Except = std::nullopt); - CallInst *CreateConstrainedFPBinOp( + LLVM_ABI CallInst *CreateConstrainedFPBinOp( Intrinsic::ID ID, Value *L, Value *R, FMFSource FMFSource = {}, const Twine &Name = "", MDNode *FPMathTag = nullptr, std::optional<RoundingMode> Rounding = std::nullopt, std::optional<fp::ExceptionBehavior> Except = std::nullopt); - CallInst *CreateConstrainedFPUnroundedBinOp( + LLVM_ABI CallInst *CreateConstrainedFPUnroundedBinOp( Intrinsic::ID ID, Value *L, Value *R, FMFSource FMFSource = {}, const Twine &Name = "", MDNode *FPMathTag = nullptr, std::optional<fp::ExceptionBehavior> Except = std::nullopt); @@ -1790,8 +1803,9 @@ public: /// Create either a UnaryOperator or BinaryOperator depending on \p Opc. /// Correct number of operands must be passed accordingly. - Value *CreateNAryOp(unsigned Opc, ArrayRef<Value *> Ops, - const Twine &Name = "", MDNode *FPMathTag = nullptr); + LLVM_ABI Value *CreateNAryOp(unsigned Opc, ArrayRef<Value *> Ops, + const Twine &Name = "", + MDNode *FPMathTag = nullptr); //===--------------------------------------------------------------------===// // Instruction creation methods: Memory Instructions @@ -2271,7 +2285,7 @@ public: return CreateCast(CastOp, V, DestTy, Name, FPMathTag); } - CallInst *CreateConstrainedFPCast( + LLVM_ABI CallInst *CreateConstrainedFPCast( Intrinsic::ID ID, Value *V, Type *DestTy, FMFSource FMFSource = {}, const Twine &Name = "", MDNode *FPMathTag = nullptr, std::optional<RoundingMode> Rounding = std::nullopt, @@ -2287,7 +2301,7 @@ public: /// casted, and then reinserted into a value of type DestTy. The leaf types /// must be castable using a bitcast or ptrcast, because signedness is /// not specified. - Value *CreateAggregateCast(Value *V, Type *DestTy); + LLVM_ABI Value *CreateAggregateCast(Value *V, Type *DestTy); //===--------------------------------------------------------------------===// // Instruction creation methods: Compare Instructions @@ -2444,12 +2458,12 @@ public: private: // Helper routine to create either a signaling or a quiet FP comparison. - Value *CreateFCmpHelper(CmpInst::Predicate P, Value *LHS, Value *RHS, - const Twine &Name, MDNode *FPMathTag, - FMFSource FMFSource, bool IsSignaling); + LLVM_ABI Value *CreateFCmpHelper(CmpInst::Predicate P, Value *LHS, Value *RHS, + const Twine &Name, MDNode *FPMathTag, + FMFSource FMFSource, bool IsSignaling); public: - CallInst *CreateConstrainedFPCmp( + LLVM_ABI CallInst *CreateConstrainedFPCmp( Intrinsic::ID ID, CmpInst::Predicate P, Value *L, Value *R, const Twine &Name = "", std::optional<fp::ExceptionBehavior> Except = std::nullopt); @@ -2507,16 +2521,17 @@ public: OpBundles, Name, FPMathTag); } - CallInst *CreateConstrainedFPCall( + LLVM_ABI CallInst *CreateConstrainedFPCall( Function *Callee, ArrayRef<Value *> Args, const Twine &Name = "", std::optional<RoundingMode> Rounding = std::nullopt, std::optional<fp::ExceptionBehavior> Except = std::nullopt); - Value *CreateSelect(Value *C, Value *True, Value *False, - const Twine &Name = "", Instruction *MDFrom = nullptr); - Value *CreateSelectFMF(Value *C, Value *True, Value *False, - FMFSource FMFSource, const Twine &Name = "", - Instruction *MDFrom = nullptr); + LLVM_ABI Value *CreateSelect(Value *C, Value *True, Value *False, + const Twine &Name = "", + Instruction *MDFrom = nullptr); + LLVM_ABI Value *CreateSelectFMF(Value *C, Value *True, Value *False, + FMFSource FMFSource, const Twine &Name = "", + Instruction *MDFrom = nullptr); VAArgInst *CreateVAArg(Value *List, Type *Ty, const Twine &Name = "") { return Insert(new VAArgInst(List, Ty), Name); @@ -2632,21 +2647,21 @@ public: /// This is intended to implement C-style pointer subtraction. As such, the /// pointers must be appropriately aligned for their element types and /// pointing into the same object. - Value *CreatePtrDiff(Type *ElemTy, Value *LHS, Value *RHS, - const Twine &Name = ""); + LLVM_ABI Value *CreatePtrDiff(Type *ElemTy, Value *LHS, Value *RHS, + const Twine &Name = ""); /// Create a launder.invariant.group intrinsic call. If Ptr type is /// different from pointer to i8, it's casted to pointer to i8 in the same /// address space before call and casted back to Ptr type after call. - Value *CreateLaunderInvariantGroup(Value *Ptr); + LLVM_ABI Value *CreateLaunderInvariantGroup(Value *Ptr); /// \brief Create a strip.invariant.group intrinsic call. If Ptr type is /// different from pointer to i8, it's casted to pointer to i8 in the same /// address space before call and casted back to Ptr type after call. - Value *CreateStripInvariantGroup(Value *Ptr); + LLVM_ABI Value *CreateStripInvariantGroup(Value *Ptr); /// Return a vector value that contains the vector V reversed - Value *CreateVectorReverse(Value *V, const Twine &Name = ""); + LLVM_ABI Value *CreateVectorReverse(Value *V, const Twine &Name = ""); /// Return a vector splice intrinsic if using scalable vectors, otherwise /// return a shufflevector. If the immediate is positive, a vector is @@ -2655,29 +2670,34 @@ public: /// elements from V2. Imm is a signed integer in the range /// -VL <= Imm < VL (where VL is the runtime vector length of the /// source/result vector) - Value *CreateVectorSplice(Value *V1, Value *V2, int64_t Imm, - const Twine &Name = ""); + LLVM_ABI Value *CreateVectorSplice(Value *V1, Value *V2, int64_t Imm, + const Twine &Name = ""); /// Return a vector value that contains \arg V broadcasted to \p /// NumElts elements. - Value *CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name = ""); + LLVM_ABI Value *CreateVectorSplat(unsigned NumElts, Value *V, + const Twine &Name = ""); /// Return a vector value that contains \arg V broadcasted to \p /// EC elements. - Value *CreateVectorSplat(ElementCount EC, Value *V, const Twine &Name = ""); + LLVM_ABI Value *CreateVectorSplat(ElementCount EC, Value *V, + const Twine &Name = ""); - Value *CreatePreserveArrayAccessIndex(Type *ElTy, Value *Base, - unsigned Dimension, unsigned LastIndex, - MDNode *DbgInfo); + LLVM_ABI Value *CreatePreserveArrayAccessIndex(Type *ElTy, Value *Base, + unsigned Dimension, + unsigned LastIndex, + MDNode *DbgInfo); - Value *CreatePreserveUnionAccessIndex(Value *Base, unsigned FieldIndex, - MDNode *DbgInfo); + LLVM_ABI Value *CreatePreserveUnionAccessIndex(Value *Base, + unsigned FieldIndex, + MDNode *DbgInfo); - Value *CreatePreserveStructAccessIndex(Type *ElTy, Value *Base, - unsigned Index, unsigned FieldIndex, - MDNode *DbgInfo); + LLVM_ABI Value *CreatePreserveStructAccessIndex(Type *ElTy, Value *Base, + unsigned Index, + unsigned FieldIndex, + MDNode *DbgInfo); - Value *createIsFPClass(Value *FPNum, unsigned Test); + LLVM_ABI Value *createIsFPClass(Value *FPNum, unsigned Test); private: /// Helper function that creates an assume intrinsic call that @@ -2694,9 +2714,10 @@ public: /// An optional offset can be provided, and if it is provided, the offset /// must be subtracted from the provided pointer to get the pointer with the /// specified alignment. - CallInst *CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue, - unsigned Alignment, - Value *OffsetValue = nullptr); + LLVM_ABI CallInst *CreateAlignmentAssumption(const DataLayout &DL, + Value *PtrValue, + unsigned Alignment, + Value *OffsetValue = nullptr); /// Create an assume intrinsic call that represents an alignment /// assumption on the provided pointer. @@ -2707,13 +2728,15 @@ public: /// /// This overload handles the condition where the Alignment is dependent /// on an existing value rather than a static value. - CallInst *CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue, - Value *Alignment, - Value *OffsetValue = nullptr); + LLVM_ABI CallInst *CreateAlignmentAssumption(const DataLayout &DL, + Value *PtrValue, + Value *Alignment, + Value *OffsetValue = nullptr); /// Create an assume intrinsic call that represents an dereferencable /// assumption on the provided pointer. - CallInst *CreateDereferenceableAssumption(Value *PtrValue, Value *SizeValue); + LLVM_ABI CallInst *CreateDereferenceableAssumption(Value *PtrValue, + Value *SizeValue); }; /// This provides a uniform API for creating instructions and inserting diff --git a/llvm/include/llvm/IR/IRBuilderFolder.h b/llvm/include/llvm/IR/IRBuilderFolder.h index 921001c..db4ab5a 100644 --- a/llvm/include/llvm/IR/IRBuilderFolder.h +++ b/llvm/include/llvm/IR/IRBuilderFolder.h @@ -18,11 +18,12 @@ #include "llvm/IR/GEPNoWrapFlags.h" #include "llvm/IR/InstrTypes.h" #include "llvm/IR/Instruction.h" +#include "llvm/Support/Compiler.h" namespace llvm { /// IRBuilderFolder - Interface for constant folding in IRBuilder. -class IRBuilderFolder { +class LLVM_ABI IRBuilderFolder { public: virtual ~IRBuilderFolder(); diff --git a/llvm/include/llvm/IR/IRPrintingPasses.h b/llvm/include/llvm/IR/IRPrintingPasses.h index 8928ecf..1b2d38d 100644 --- a/llvm/include/llvm/IR/IRPrintingPasses.h +++ b/llvm/include/llvm/IR/IRPrintingPasses.h @@ -15,6 +15,7 @@ #ifndef LLVM_IR_IRPRINTINGPASSES_H #define LLVM_IR_IRPRINTINGPASSES_H +#include "llvm/Support/Compiler.h" #include <string> namespace llvm { @@ -26,23 +27,23 @@ class Pass; /// Create and return a pass that writes the module to the specified /// \c raw_ostream. -ModulePass *createPrintModulePass(raw_ostream &OS, - const std::string &Banner = "", - bool ShouldPreserveUseListOrder = false); +LLVM_ABI ModulePass * +createPrintModulePass(raw_ostream &OS, const std::string &Banner = "", + bool ShouldPreserveUseListOrder = false); /// Create and return a pass that prints functions to the specified /// \c raw_ostream as they are processed. -FunctionPass *createPrintFunctionPass(raw_ostream &OS, - const std::string &Banner = ""); +LLVM_ABI FunctionPass *createPrintFunctionPass(raw_ostream &OS, + const std::string &Banner = ""); /// Print out a name of an LLVM value without any prefixes. /// /// The name is surrounded with ""'s and escaped if it has any special or /// non-printable characters in it. -void printLLVMNameWithoutPrefix(raw_ostream &OS, StringRef Name); +LLVM_ABI void printLLVMNameWithoutPrefix(raw_ostream &OS, StringRef Name); /// Return true if a pass is for IR printing. -bool isIRPrintingPass(Pass *P); +LLVM_ABI bool isIRPrintingPass(Pass *P); } // namespace llvm diff --git a/llvm/include/llvm/IR/InlineAsm.h b/llvm/include/llvm/IR/InlineAsm.h index 3501c87..96887d1 100644 --- a/llvm/include/llvm/IR/InlineAsm.h +++ b/llvm/include/llvm/IR/InlineAsm.h @@ -19,6 +19,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/IR/Value.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include <cassert> #include <string> @@ -63,10 +64,11 @@ public: /// InlineAsm::get - Return the specified uniqued inline asm string. /// - static InlineAsm *get(FunctionType *Ty, StringRef AsmString, - StringRef Constraints, bool hasSideEffects, - bool isAlignStack = false, - AsmDialect asmDialect = AD_ATT, bool canThrow = false); + LLVM_ABI static InlineAsm *get(FunctionType *Ty, StringRef AsmString, + StringRef Constraints, bool hasSideEffects, + bool isAlignStack = false, + AsmDialect asmDialect = AD_ATT, + bool canThrow = false); bool hasSideEffects() const { return HasSideEffects; } bool isAlignStack() const { return IsAlignStack; } @@ -81,15 +83,15 @@ public: /// getFunctionType - InlineAsm's are always pointers to functions. /// - FunctionType *getFunctionType() const; + LLVM_ABI FunctionType *getFunctionType() const; StringRef getAsmString() const { return AsmString; } StringRef getConstraintString() const { return Constraints; } - void collectAsmStrs(SmallVectorImpl<StringRef> &AsmStrs) const; + LLVM_ABI void collectAsmStrs(SmallVectorImpl<StringRef> &AsmStrs) const; /// This static method can be used by the parser to check to see if the /// specified constraint string is legal for the type. - static Error verify(FunctionType *Ty, StringRef Constraints); + LLVM_ABI static Error verify(FunctionType *Ty, StringRef Constraints); // Constraint String Parsing enum ConstraintPrefix { @@ -169,11 +171,11 @@ public: /// Parse - Analyze the specified string (e.g. "=*&{eax}") and fill in the /// fields in this structure. If the constraint string is not understood, /// return true, otherwise return false. - bool Parse(StringRef Str, ConstraintInfoVector &ConstraintsSoFar); + LLVM_ABI bool Parse(StringRef Str, ConstraintInfoVector &ConstraintsSoFar); /// selectAlternative - Point this constraint to the alternative constraint /// indicated by the index. - void selectAlternative(unsigned index); + LLVM_ABI void selectAlternative(unsigned index); /// Whether this constraint corresponds to an argument. bool hasArg() const { @@ -184,7 +186,8 @@ public: /// ParseConstraints - Split up the constraint string into the specific /// constraints and their prefixes. If this returns an empty vector, and if /// the constraint string itself isn't empty, there was an error parsing. - static ConstraintInfoVector ParseConstraints(StringRef ConstraintString); + LLVM_ABI static ConstraintInfoVector + ParseConstraints(StringRef ConstraintString); /// ParseConstraints - Parse the constraints of this inlineasm object, /// returning them the same way that ParseConstraints(str) does. diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h index 8e47e3c..11aaa93 100644 --- a/llvm/include/llvm/IR/InstrTypes.h +++ b/llvm/include/llvm/IR/InstrTypes.h @@ -30,6 +30,7 @@ #include "llvm/IR/LLVMContext.h" #include "llvm/IR/OperandTraits.h" #include "llvm/IR/User.h" +#include "llvm/Support/Compiler.h" #include <algorithm> #include <cassert> #include <cstddef> @@ -101,13 +102,13 @@ class UnaryOperator : public UnaryInstruction { void AssertOK(); protected: - UnaryOperator(UnaryOps iType, Value *S, Type *Ty, const Twine &Name, - InsertPosition InsertBefore); + LLVM_ABI UnaryOperator(UnaryOps iType, Value *S, Type *Ty, const Twine &Name, + InsertPosition InsertBefore); // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - UnaryOperator *cloneImpl() const; + LLVM_ABI UnaryOperator *cloneImpl() const; public: /// Construct a unary instruction, given the opcode and an operand. @@ -115,9 +116,9 @@ public: /// into a BasicBlock right before the specified instruction. The specified /// Instruction is allowed to be a dereferenced end iterator. /// - static UnaryOperator *Create(UnaryOps Op, Value *S, - const Twine &Name = Twine(), - InsertPosition InsertBefore = nullptr); + LLVM_ABI static UnaryOperator *Create(UnaryOps Op, Value *S, + const Twine &Name = Twine(), + InsertPosition InsertBefore = nullptr); /// These methods just forward to Create, and are useful when you /// statically know what type of instruction you're going to create. These @@ -173,13 +174,13 @@ class BinaryOperator : public Instruction { void AssertOK(); protected: - BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty, - const Twine &Name, InsertPosition InsertBefore); + LLVM_ABI BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty, + const Twine &Name, InsertPosition InsertBefore); // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - BinaryOperator *cloneImpl() const; + LLVM_ABI BinaryOperator *cloneImpl() const; public: // allocate space for exactly two operands @@ -194,9 +195,9 @@ public: /// into a BasicBlock right before the specified instruction. The specified /// Instruction is allowed to be a dereferenced end iterator. /// - static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2, - const Twine &Name = Twine(), - InsertPosition InsertBefore = nullptr); + LLVM_ABI static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2, + const Twine &Name = Twine(), + InsertPosition InsertBefore = nullptr); /// These methods just forward to Create, and are useful when you /// statically know what type of instruction you're going to create. These @@ -360,12 +361,15 @@ public: /// /// Create the NEG and NOT instructions out of SUB and XOR instructions. /// - static BinaryOperator *CreateNeg(Value *Op, const Twine &Name = "", - InsertPosition InsertBefore = nullptr); - static BinaryOperator *CreateNSWNeg(Value *Op, const Twine &Name = "", - InsertPosition InsertBefore = nullptr); - static BinaryOperator *CreateNot(Value *Op, const Twine &Name = "", - InsertPosition InsertBefore = nullptr); + LLVM_ABI static BinaryOperator * + CreateNeg(Value *Op, const Twine &Name = "", + InsertPosition InsertBefore = nullptr); + LLVM_ABI static BinaryOperator * + CreateNSWNeg(Value *Op, const Twine &Name = "", + InsertPosition InsertBefore = nullptr); + LLVM_ABI static BinaryOperator * + CreateNot(Value *Op, const Twine &Name = "", + InsertPosition InsertBefore = nullptr); BinaryOps getOpcode() const { return static_cast<BinaryOps>(Instruction::getOpcode()); @@ -376,7 +380,7 @@ public: /// does not modify the semantics of the instruction. If the instruction /// cannot be reversed (ie, it's a Div), then return true. /// - bool swapOperands(); + LLVM_ABI bool swapOperands(); // Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Instruction *I) { @@ -457,7 +461,7 @@ public: /// constructor has insert-before-instruction semantics to automatically /// insert the new CastInst before InsertBefore (if it is non-null). /// Construct any of the CastInst subclasses - static CastInst *Create( + LLVM_ABI static CastInst *Create( Instruction::CastOps, ///< The opcode of the cast instruction Value *S, ///< The value to be casted (operand 0) Type *Ty, ///< The type to which cast should be made @@ -466,7 +470,7 @@ public: ); /// Create a ZExt or BitCast cast instruction - static CastInst *CreateZExtOrBitCast( + LLVM_ABI static CastInst *CreateZExtOrBitCast( Value *S, ///< The value to be casted (operand 0) Type *Ty, ///< The type to which cast should be made const Twine &Name = "", ///< Name for the instruction @@ -474,7 +478,7 @@ public: ); /// Create a SExt or BitCast cast instruction - static CastInst *CreateSExtOrBitCast( + LLVM_ABI static CastInst *CreateSExtOrBitCast( Value *S, ///< The value to be casted (operand 0) Type *Ty, ///< The type to which cast should be made const Twine &Name = "", ///< Name for the instruction @@ -482,7 +486,7 @@ public: ); /// Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction. - static CastInst *CreatePointerCast( + LLVM_ABI static CastInst *CreatePointerCast( Value *S, ///< The pointer value to be casted (operand 0) Type *Ty, ///< The type to which cast should be made const Twine &Name = "", ///< Name for the instruction @@ -490,7 +494,7 @@ public: ); /// Create a BitCast or an AddrSpaceCast cast instruction. - static CastInst *CreatePointerBitCastOrAddrSpaceCast( + LLVM_ABI static CastInst *CreatePointerBitCastOrAddrSpaceCast( Value *S, ///< The pointer value to be casted (operand 0) Type *Ty, ///< The type to which cast should be made const Twine &Name = "", ///< Name for the instruction @@ -503,7 +507,7 @@ public: /// creates a PtrToInt cast. If the value is an integer type and the /// destination a pointer type, creates an IntToPtr cast. Otherwise, creates /// a bitcast. - static CastInst *CreateBitOrPointerCast( + LLVM_ABI static CastInst *CreateBitOrPointerCast( Value *S, ///< The pointer value to be casted (operand 0) Type *Ty, ///< The type to which cast should be made const Twine &Name = "", ///< Name for the instruction @@ -511,7 +515,7 @@ public: ); /// Create a ZExt, BitCast, or Trunc for int -> int casts. - static CastInst *CreateIntegerCast( + LLVM_ABI static CastInst *CreateIntegerCast( Value *S, ///< The pointer value to be casted (operand 0) Type *Ty, ///< The type to which cast should be made bool isSigned, ///< Whether to regard S as signed or not @@ -520,7 +524,7 @@ public: ); /// Create an FPExt, BitCast, or FPTrunc for fp -> fp casts - static CastInst *CreateFPCast( + LLVM_ABI static CastInst *CreateFPCast( Value *S, ///< The floating point value to be casted Type *Ty, ///< The floating point type to cast to const Twine &Name = "", ///< Name for the instruction @@ -528,7 +532,7 @@ public: ); /// Create a Trunc or BitCast cast instruction - static CastInst *CreateTruncOrBitCast( + LLVM_ABI static CastInst *CreateTruncOrBitCast( Value *S, ///< The value to be casted (operand 0) Type *Ty, ///< The type to which cast should be made const Twine &Name = "", ///< Name for the instruction @@ -536,9 +540,9 @@ public: ); /// Check whether a bitcast between these types is valid - static bool isBitCastable( - Type *SrcTy, ///< The Type from which the value should be cast. - Type *DestTy ///< The Type to which the value should be cast. + LLVM_ABI static bool + isBitCastable(Type *SrcTy, ///< The Type from which the value should be cast. + Type *DestTy ///< The Type to which the value should be cast. ); /// Check whether a bitcast, inttoptr, or ptrtoint cast between these @@ -546,7 +550,7 @@ public: /// /// This ensures that any pointer<->integer cast has enough bits in the /// integer and any other cast is a bitcast. - static bool isBitOrNoopPointerCastable( + LLVM_ABI static bool isBitOrNoopPointerCastable( Type *SrcTy, ///< The Type from which the value should be cast. Type *DestTy, ///< The Type to which the value should be cast. const DataLayout &DL); @@ -554,11 +558,11 @@ public: /// Returns the opcode necessary to cast Val into Ty using usual casting /// rules. /// Infer the opcode for cast operand and type - static Instruction::CastOps getCastOpcode( - const Value *Val, ///< The value to cast - bool SrcIsSigned, ///< Whether to treat the source as signed - Type *Ty, ///< The Type to which the value should be casted - bool DstIsSigned ///< Whether to treate the dest. as signed + LLVM_ABI static Instruction::CastOps + getCastOpcode(const Value *Val, ///< The value to cast + bool SrcIsSigned, ///< Whether to treat the source as signed + Type *Ty, ///< The Type to which the value should be casted + bool DstIsSigned ///< Whether to treate the dest. as signed ); /// There are several places where we need to know if a cast instruction @@ -566,7 +570,7 @@ public: /// logic, this method is provided. /// @returns true iff the cast has only integral typed operand and dest type. /// Determine if this is an integer-only cast. - bool isIntegerCast() const; + LLVM_ABI bool isIntegerCast() const; /// A no-op cast is one that can be effected without changing any bits. /// It implies that the source and destination types are the same size. The @@ -575,17 +579,17 @@ public: /// is the same size as the pointer. However, pointer size varies with /// platform. Note that a precondition of this method is that the cast is /// legal - i.e. the instruction formed with these operands would verify. - static bool isNoopCast( - Instruction::CastOps Opcode, ///< Opcode of cast - Type *SrcTy, ///< SrcTy of cast - Type *DstTy, ///< DstTy of cast - const DataLayout &DL ///< DataLayout to get the Int Ptr type from. + LLVM_ABI static bool + isNoopCast(Instruction::CastOps Opcode, ///< Opcode of cast + Type *SrcTy, ///< SrcTy of cast + Type *DstTy, ///< DstTy of cast + const DataLayout &DL ///< DataLayout to get the Int Ptr type from. ); /// Determine if this cast is a no-op cast. /// /// \param DL is the DataLayout to determine pointer size. - bool isNoopCast(const DataLayout &DL) const; + LLVM_ABI bool isNoopCast(const DataLayout &DL) const; /// Determine how a pair of casts can be eliminated, if they can be at all. /// This is a helper function for both CastInst and ConstantExpr. @@ -593,15 +597,15 @@ public: /// returns Instruction::CastOps value for a cast that can replace /// the pair, casting SrcTy to DstTy. /// Determine if a cast pair is eliminable - static unsigned isEliminableCastPair( - Instruction::CastOps firstOpcode, ///< Opcode of first cast - Instruction::CastOps secondOpcode, ///< Opcode of second cast - Type *SrcTy, ///< SrcTy of 1st cast - Type *MidTy, ///< DstTy of 1st cast & SrcTy of 2nd cast - Type *DstTy, ///< DstTy of 2nd cast - Type *SrcIntPtrTy, ///< Integer type corresponding to Ptr SrcTy, or null - Type *MidIntPtrTy, ///< Integer type corresponding to Ptr MidTy, or null - Type *DstIntPtrTy ///< Integer type corresponding to Ptr DstTy, or null + LLVM_ABI static unsigned isEliminableCastPair( + Instruction::CastOps firstOpcode, ///< Opcode of first cast + Instruction::CastOps secondOpcode, ///< Opcode of second cast + Type *SrcTy, ///< SrcTy of 1st cast + Type *MidTy, ///< DstTy of 1st cast & SrcTy of 2nd cast + Type *DstTy, ///< DstTy of 2nd cast + Type *SrcIntPtrTy, ///< Integer type corresponding to Ptr SrcTy, or null + Type *MidIntPtrTy, ///< Integer type corresponding to Ptr MidTy, or null + Type *DstIntPtrTy ///< Integer type corresponding to Ptr DstTy, or null ); /// Return the opcode of this CastInst @@ -618,7 +622,8 @@ public: /// Opcode op is valid or not. /// @returns true iff the proposed cast is valid. /// Determine if a cast is valid without creating one. - static bool castIsValid(Instruction::CastOps op, Type *SrcTy, Type *DstTy); + LLVM_ABI static bool castIsValid(Instruction::CastOps op, Type *SrcTy, + Type *DstTy); static bool castIsValid(Instruction::CastOps op, Value *S, Type *DstTy) { return castIsValid(op, S->getType(), DstTy); } @@ -723,10 +728,10 @@ public: } protected: - CmpInst(Type *ty, Instruction::OtherOps op, Predicate pred, Value *LHS, - Value *RHS, const Twine &Name = "", - InsertPosition InsertBefore = nullptr, - Instruction *FlagsSource = nullptr); + LLVM_ABI CmpInst(Type *ty, Instruction::OtherOps op, Predicate pred, + Value *LHS, Value *RHS, const Twine &Name = "", + InsertPosition InsertBefore = nullptr, + Instruction *FlagsSource = nullptr); public: // allocate space for exactly two operands @@ -738,9 +743,9 @@ public: /// instruction into a BasicBlock right before the specified instruction. /// The specified Instruction is allowed to be a dereferenced end iterator. /// Create a CmpInst - static CmpInst *Create(OtherOps Op, Predicate Pred, Value *S1, Value *S2, - const Twine &Name = "", - InsertPosition InsertBefore = nullptr); + LLVM_ABI static CmpInst *Create(OtherOps Op, Predicate Pred, Value *S1, + Value *S2, const Twine &Name = "", + InsertPosition InsertBefore = nullptr); /// Construct a compare instruction, given the opcode, the predicate, /// the two operands and the instruction to copy the flags from. Optionally @@ -748,11 +753,10 @@ public: /// right before the specified instruction. The specified Instruction is /// allowed to be a dereferenced end iterator. /// Create a CmpInst - static CmpInst *CreateWithCopiedFlags(OtherOps Op, Predicate Pred, Value *S1, - Value *S2, - const Instruction *FlagsSource, - const Twine &Name = "", - InsertPosition InsertBefore = nullptr); + LLVM_ABI static CmpInst * + CreateWithCopiedFlags(OtherOps Op, Predicate Pred, Value *S1, Value *S2, + const Instruction *FlagsSource, const Twine &Name = "", + InsertPosition InsertBefore = nullptr); /// Get the opcode casted to the right type OtherOps getOpcode() const { @@ -775,7 +779,7 @@ public: return P >= FIRST_ICMP_PREDICATE && P <= LAST_ICMP_PREDICATE; } - static StringRef getPredicateName(Predicate P); + LLVM_ABI static StringRef getPredicateName(Predicate P); bool isFPPredicate() const { return isFPPredicate(getPredicate()); } bool isIntPredicate() const { return isIntPredicate(getPredicate()); } @@ -814,7 +818,7 @@ public: /// OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc. /// @returns the inverse predicate for predicate provided in \p pred. /// Return the inverse of a given predicate - static Predicate getInversePredicate(Predicate pred); + LLVM_ABI static Predicate getInversePredicate(Predicate pred); /// For example, EQ->EQ, SLE->SGE, ULT->UGT, /// OEQ->OEQ, ULE->UGE, OLT->OGT, etc. @@ -829,12 +833,12 @@ public: /// This is a static version that you can use without an instruction /// available. /// Return the predicate as if the operands were swapped. - static Predicate getSwappedPredicate(Predicate pred); + LLVM_ABI static Predicate getSwappedPredicate(Predicate pred); /// This is a static version that you can use without an instruction /// available. /// @returns true if the comparison predicate is strict, false otherwise. - static bool isStrictPredicate(Predicate predicate); + LLVM_ABI static bool isStrictPredicate(Predicate predicate); /// @returns true if the comparison predicate is strict, false otherwise. /// Determine if this instruction is using an strict comparison predicate. @@ -843,7 +847,7 @@ public: /// This is a static version that you can use without an instruction /// available. /// @returns true if the comparison predicate is non-strict, false otherwise. - static bool isNonStrictPredicate(Predicate predicate); + LLVM_ABI static bool isNonStrictPredicate(Predicate predicate); /// @returns true if the comparison predicate is non-strict, false otherwise. /// Determine if this instruction is using an non-strict comparison predicate. @@ -862,7 +866,7 @@ public: /// @returns the strict version of comparison provided in \p pred. /// If \p pred is not a strict comparison predicate, returns \p pred. /// Returns the strict version of non-strict comparisons. - static Predicate getStrictPredicate(Predicate pred); + LLVM_ABI static Predicate getStrictPredicate(Predicate pred); /// For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE. /// Returns the non-strict version of strict comparisons. @@ -875,12 +879,12 @@ public: /// @returns the non-strict version of comparison provided in \p pred. /// If \p pred is not a strict comparison predicate, returns \p pred. /// Returns the non-strict version of strict comparisons. - static Predicate getNonStrictPredicate(Predicate pred); + LLVM_ABI static Predicate getNonStrictPredicate(Predicate pred); /// This is a static version that you can use without an instruction /// available. /// Return the flipped strictness of predicate - static Predicate getFlippedStrictnessPredicate(Predicate pred); + LLVM_ABI static Predicate getFlippedStrictnessPredicate(Predicate pred); /// For predicate of kind "is X or equal to 0" returns the predicate "is X". /// For predicate of kind "is X" returns the predicate "is X or equal to 0". @@ -898,16 +902,16 @@ public: /// This is just a convenience that dispatches to the subclasses. /// Swap the operands and adjust predicate accordingly to retain /// the same comparison. - void swapOperands(); + LLVM_ABI void swapOperands(); /// This is just a convenience that dispatches to the subclasses. /// Determine if this CmpInst is commutative. - bool isCommutative() const; + LLVM_ABI bool isCommutative() const; /// Determine if this is an equals/not equals predicate. /// This is a static version that you can use without an instruction /// available. - static bool isEquality(Predicate pred); + LLVM_ABI static bool isEquality(Predicate pred); /// Determine if this is an equals/not equals predicate. bool isEquality() const { return isEquality(getPredicate()); } @@ -915,7 +919,7 @@ public: /// Determine if one operand of this compare can always be replaced by the /// other operand, ignoring provenance considerations. If \p Invert, check for /// equivalence with the inverse predicate. - bool isEquivalence(bool Invert = false) const; + LLVM_ABI bool isEquivalence(bool Invert = false) const; /// Return true if the predicate is relational (not EQ or NE). static bool isRelational(Predicate P) { return !isEquality(P); } @@ -949,23 +953,23 @@ public: /// @returns true if the predicate is unsigned, false otherwise. /// Determine if the predicate is an unsigned operation. - static bool isUnsigned(Predicate predicate); + LLVM_ABI static bool isUnsigned(Predicate predicate); /// @returns true if the predicate is signed, false otherwise. /// Determine if the predicate is an signed operation. - static bool isSigned(Predicate predicate); + LLVM_ABI static bool isSigned(Predicate predicate); /// Determine if the predicate is an ordered operation. - static bool isOrdered(Predicate predicate); + LLVM_ABI static bool isOrdered(Predicate predicate); /// Determine if the predicate is an unordered operation. - static bool isUnordered(Predicate predicate); + LLVM_ABI static bool isUnordered(Predicate predicate); /// Determine if the predicate is true when comparing a value with itself. - static bool isTrueWhenEqual(Predicate predicate); + LLVM_ABI static bool isTrueWhenEqual(Predicate predicate); /// Determine if the predicate is false when comparing a value with itself. - static bool isFalseWhenEqual(Predicate predicate); + LLVM_ABI static bool isFalseWhenEqual(Predicate predicate); /// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Instruction *I) { @@ -1000,7 +1004,7 @@ struct OperandTraits<CmpInst> : public FixedNumOperandTraits<CmpInst, 2> { DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CmpInst, Value) -raw_ostream &operator<<(raw_ostream &OS, CmpInst::Predicate Pred); +LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, CmpInst::Predicate Pred); /// A lightweight accessor for an operand bundle meant to be passed /// around by value. @@ -1148,7 +1152,7 @@ protected: /// Get the number of extra operands for instructions that don't have a fixed /// number of extra operands. - unsigned getNumSubclassExtraOperandsDynamic() const; + LLVM_ABI unsigned getNumSubclassExtraOperandsDynamic() const; public: using Instruction::getContext; @@ -1159,25 +1163,27 @@ public: /// The returned call instruction is identical \p CB in every way except that /// the operand bundles for the new instruction are set to the operand bundles /// in \p Bundles. - static CallBase *Create(CallBase *CB, ArrayRef<OperandBundleDef> Bundles, - InsertPosition InsertPt = nullptr); + LLVM_ABI static CallBase *Create(CallBase *CB, + ArrayRef<OperandBundleDef> Bundles, + InsertPosition InsertPt = nullptr); /// Create a clone of \p CB with the operand bundle with the tag matching /// \p Bundle's tag replaced with Bundle, and insert it before \p InsertPt. /// /// The returned call instruction is identical \p CI in every way except that /// the specified operand bundle has been replaced. - static CallBase *Create(CallBase *CB, OperandBundleDef Bundle, - InsertPosition InsertPt = nullptr); + LLVM_ABI static CallBase *Create(CallBase *CB, OperandBundleDef Bundle, + InsertPosition InsertPt = nullptr); /// Create a clone of \p CB with operand bundle \p OB added. - static CallBase *addOperandBundle(CallBase *CB, uint32_t ID, - OperandBundleDef OB, - InsertPosition InsertPt = nullptr); + LLVM_ABI static CallBase *addOperandBundle(CallBase *CB, uint32_t ID, + OperandBundleDef OB, + InsertPosition InsertPt = nullptr); /// Create a clone of \p CB with operand bundle \p ID removed. - static CallBase *removeOperandBundle(CallBase *CB, uint32_t ID, - InsertPosition InsertPt = nullptr); + LLVM_ABI static CallBase * + removeOperandBundle(CallBase *CB, uint32_t ID, + InsertPosition InsertPt = nullptr); /// Return the convergence control token for this call, if it exists. Value *getConvergenceControlToken() const { @@ -1346,7 +1352,7 @@ public: } /// Return true if the callsite is an indirect call. - bool isIndirectCall() const; + LLVM_ABI bool isIndirectCall() const; /// Determine whether the passed iterator points to the callee operand's Use. bool isCallee(Value::const_user_iterator UI) const { @@ -1357,22 +1363,22 @@ public: bool isCallee(const Use *U) const { return &getCalledOperandUse() == U; } /// Helper to get the caller (the parent function). - Function *getCaller(); + LLVM_ABI Function *getCaller(); const Function *getCaller() const { return const_cast<CallBase *>(this)->getCaller(); } /// Tests if this call site must be tail call optimized. Only a CallInst can /// be tail call optimized. - bool isMustTailCall() const; + LLVM_ABI bool isMustTailCall() const; /// Tests if this call site is marked as a tail call. - bool isTailCall() const; + LLVM_ABI bool isTailCall() const; /// Returns the intrinsic ID of the intrinsic called or /// Intrinsic::not_intrinsic if the called function is not an intrinsic, or if /// this is an indirect call. - Intrinsic::ID getIntrinsicID() const; + LLVM_ABI Intrinsic::ID getIntrinsicID() const; void setCalledOperand(Value *V) { Op<CalledOperandOpEndIdx>() = V; } @@ -1600,7 +1606,7 @@ public: } /// Determine whether the argument or parameter has the given attribute. - bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const; + LLVM_ABI bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const; /// Return true if this argument has the nonnull attribute on either the /// CallBase instruction or the called function. Also returns true if at least @@ -1608,7 +1614,8 @@ public: /// addrspace(0). If \p AllowUndefOrPoison is true, respect the semantics of /// nonnull attribute and return true even if the argument can be undef or /// poison. - bool paramHasNonNullAttr(unsigned ArgNo, bool AllowUndefOrPoison) const; + LLVM_ABI bool paramHasNonNullAttr(unsigned ArgNo, + bool AllowUndefOrPoison) const; /// Get the attribute of a given kind at a position. Attribute getAttributeAtIndex(unsigned i, Attribute::AttrKind Kind) const { @@ -1683,7 +1690,7 @@ public: } /// Return which pointer components this operand may capture. - CaptureInfo getCaptureInfo(unsigned OpNo) const; + LLVM_ABI CaptureInfo getCaptureInfo(unsigned OpNo) const; /// Determine whether this data operand is not captured. // FIXME: Once this API is no longer duplicated in `CallSite`, rename this to @@ -1695,7 +1702,7 @@ public: /// Returns whether the call has an argument that has an attribute like /// captures(ret: address, provenance), where the return capture components /// are not a subset of the other capture components. - bool hasArgumentWithAdditionalReturnCaptureComponents() const; + LLVM_ABI bool hasArgumentWithAdditionalReturnCaptureComponents() const; /// Determine whether this argument is passed by value. bool isByValArgument(unsigned ArgNo) const { @@ -1862,20 +1869,20 @@ public: /// Extract a test mask for disallowed floating-point value classes for the /// return value. - FPClassTest getRetNoFPClass() const; + LLVM_ABI FPClassTest getRetNoFPClass() const; /// Extract a test mask for disallowed floating-point value classes for the /// parameter. - FPClassTest getParamNoFPClass(unsigned i) const; + LLVM_ABI FPClassTest getParamNoFPClass(unsigned i) const; /// If this return value 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 the return value is known to be not null. /// This may be because it has the nonnull attribute, or because at least /// one byte is dereferenceable and the pointer is in addrspace(0). - bool isReturnNonNull() const; + LLVM_ABI bool isReturnNonNull() const; /// Determine if the return value is marked with NoAlias attribute. bool returnDoesNotAlias() const { @@ -1890,7 +1897,7 @@ public: /// If one of the arguments has the specified attribute, returns its /// operand value. Otherwise, return nullptr. - Value *getArgOperandWithAttribute(Attribute::AttrKind Kind) const; + LLVM_ABI Value *getArgOperandWithAttribute(Attribute::AttrKind Kind) const; /// Return true if the call should not be treated as a call to a /// builtin. @@ -1906,35 +1913,35 @@ public: bool isNoInline() const { return hasFnAttr(Attribute::NoInline); } void setIsNoInline() { addFnAttr(Attribute::NoInline); } - MemoryEffects getMemoryEffects() const; - void setMemoryEffects(MemoryEffects ME); + LLVM_ABI MemoryEffects getMemoryEffects() const; + LLVM_ABI void setMemoryEffects(MemoryEffects ME); /// Determine if the call does not access memory. - bool doesNotAccessMemory() const; - void setDoesNotAccessMemory(); + LLVM_ABI bool doesNotAccessMemory() const; + LLVM_ABI void setDoesNotAccessMemory(); /// Determine if the call does not access or only reads memory. - bool onlyReadsMemory() const; - void setOnlyReadsMemory(); + LLVM_ABI bool onlyReadsMemory() const; + LLVM_ABI void setOnlyReadsMemory(); /// Determine if the call does not access or only writes memory. - bool onlyWritesMemory() const; - void setOnlyWritesMemory(); + LLVM_ABI bool onlyWritesMemory() const; + LLVM_ABI void setOnlyWritesMemory(); /// Determine if the call can access memmory only using pointers based /// on its arguments. - bool onlyAccessesArgMemory() const; - void setOnlyAccessesArgMemory(); + LLVM_ABI bool onlyAccessesArgMemory() const; + LLVM_ABI void setOnlyAccessesArgMemory(); /// Determine if the function may only access memory that is /// inaccessible from the IR. - bool onlyAccessesInaccessibleMemory() const; - void setOnlyAccessesInaccessibleMemory(); + LLVM_ABI bool onlyAccessesInaccessibleMemory() const; + LLVM_ABI void setOnlyAccessesInaccessibleMemory(); /// Determine if the function may only access memory that is /// either inaccessible from the IR or pointed to by its arguments. - bool onlyAccessesInaccessibleMemOrArgMem() const; - void setOnlyAccessesInaccessibleMemOrArgMem(); + LLVM_ABI bool onlyAccessesInaccessibleMemOrArgMem() const; + LLVM_ABI void setOnlyAccessesInaccessibleMemOrArgMem(); /// Determine if the call cannot return. bool doesNotReturn() const { return hasFnAttr(Attribute::NoReturn); } @@ -2107,7 +2114,8 @@ public: /// OperandBundleUser to a vector of OperandBundleDefs. Note: /// OperandBundeUses and OperandBundleDefs are non-trivially *different* /// representations of operand bundles (see documentation above). - void getOperandBundlesAsDefs(SmallVectorImpl<OperandBundleDef> &Defs) const; + LLVM_ABI void + getOperandBundlesAsDefs(SmallVectorImpl<OperandBundleDef> &Defs) const; /// Return the operand bundle for the operand at index OpIdx. /// @@ -2119,11 +2127,11 @@ public: /// Return true if this operand bundle user has operand bundles that /// may read from the heap. - bool hasReadingOperandBundles() const; + LLVM_ABI bool hasReadingOperandBundles() const; /// Return true if this operand bundle user has operand bundles that /// may write to the heap. - bool hasClobberingOperandBundles() const; + LLVM_ABI bool hasClobberingOperandBundles() const; /// Return true if the bundle operand at index \p OpIdx has the /// attribute \p A. @@ -2281,8 +2289,8 @@ public: /// /// Each \p OperandBundleDef instance is tracked by a OperandBundleInfo /// instance allocated in this User's descriptor. - op_iterator populateBundleOperandInfos(ArrayRef<OperandBundleDef> Bundles, - const unsigned BeginIndex); + LLVM_ABI op_iterator populateBundleOperandInfos( + ArrayRef<OperandBundleDef> Bundles, const unsigned BeginIndex); /// Return true if the call has deopt state bundle. bool hasDeoptState() const { @@ -2294,7 +2302,7 @@ public: /// /// It is an error to call this with an OpIdx that does not correspond to an /// bundle operand. - BundleOpInfo &getBundleOpInfoForOperand(unsigned OpIdx); + LLVM_ABI BundleOpInfo &getBundleOpInfoForOperand(unsigned OpIdx); const BundleOpInfo &getBundleOpInfoForOperand(unsigned OpIdx) const { return const_cast<CallBase *>(this)->getBundleOpInfoForOperand(OpIdx); } @@ -2312,8 +2320,8 @@ protected: // End of operand bundle API. private: - bool hasFnAttrOnCalledFunction(Attribute::AttrKind Kind) const; - bool hasFnAttrOnCalledFunction(StringRef Kind) const; + LLVM_ABI bool hasFnAttrOnCalledFunction(Attribute::AttrKind Kind) const; + LLVM_ABI bool hasFnAttrOnCalledFunction(StringRef Kind) const; template <typename AttrKind> bool hasFnAttrImpl(AttrKind Kind) const { if (Attrs.hasFnAttr(Kind)) @@ -2350,9 +2358,10 @@ class FuncletPadInst : public Instruction { private: FuncletPadInst(const FuncletPadInst &CPI, AllocInfo AllocInfo); - explicit FuncletPadInst(Instruction::FuncletPadOps Op, Value *ParentPad, - ArrayRef<Value *> Args, AllocInfo AllocInfo, - const Twine &NameStr, InsertPosition InsertBefore); + LLVM_ABI explicit FuncletPadInst(Instruction::FuncletPadOps Op, + Value *ParentPad, ArrayRef<Value *> Args, + AllocInfo AllocInfo, const Twine &NameStr, + InsertPosition InsertBefore); void init(Value *ParentPad, ArrayRef<Value *> Args, const Twine &NameStr); @@ -2362,7 +2371,7 @@ protected: friend class CatchPadInst; friend class CleanupPadInst; - FuncletPadInst *cloneImpl() const; + LLVM_ABI FuncletPadInst *cloneImpl() const; public: /// Provide fast operand accessors diff --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h index d8069b2..10fc9c1 100644 --- a/llvm/include/llvm/IR/Instruction.h +++ b/llvm/include/llvm/IR/Instruction.h @@ -23,6 +23,7 @@ #include "llvm/IR/User.h" #include "llvm/IR/Value.h" #include "llvm/Support/AtomicOrdering.h" +#include "llvm/Support/Compiler.h" #include <cstdint> #include <utility> @@ -42,7 +43,7 @@ template <> struct ilist_alloc_traits<Instruction> { static inline void deleteNode(Instruction *V); }; -iterator_range<simple_ilist<DbgRecord>::iterator> +LLVM_ABI iterator_range<simple_ilist<DbgRecord>::iterator> getDbgRecordRange(DbgMarker *); class InsertPosition { @@ -52,10 +53,10 @@ class InsertPosition { public: InsertPosition(std::nullptr_t) : InsertAt() {} - LLVM_DEPRECATED("Use BasicBlock::iterators for insertion instead", - "BasicBlock::iterator") - InsertPosition(Instruction *InsertBefore); - InsertPosition(BasicBlock *InsertAtEnd); + LLVM_ABI LLVM_DEPRECATED("Use BasicBlock::iterators for insertion instead", + "BasicBlock::iterator") + InsertPosition(Instruction *InsertBefore); + LLVM_ABI InsertPosition(BasicBlock *InsertAtEnd); InsertPosition(InstListType::iterator InsertAt) : InsertAt(InsertAt) {} operator InstListType::iterator() const { return InsertAt; } bool isValid() const { return InsertAt.isValid(); } @@ -95,7 +96,7 @@ public: /// \p InsertAtHead Whether the cloned DbgRecords should be placed at the end /// or the beginning of existing DbgRecords attached to this. /// \returns A range over the newly cloned DbgRecords. - iterator_range<simple_ilist<DbgRecord>::iterator> cloneDebugInfoFrom( + LLVM_ABI iterator_range<simple_ilist<DbgRecord>::iterator> cloneDebugInfoFrom( const Instruction *From, std::optional<simple_ilist<DbgRecord>::iterator> FromHere = std::nullopt, bool InsertAtHead = false); @@ -108,26 +109,27 @@ public: /// Return an iterator to the position of the "Next" DbgRecord after this /// instruction, or std::nullopt. This is the position to pass to /// BasicBlock::reinsertInstInDbgRecords when re-inserting an instruction. - std::optional<simple_ilist<DbgRecord>::iterator> getDbgReinsertionPosition(); + LLVM_ABI std::optional<simple_ilist<DbgRecord>::iterator> + getDbgReinsertionPosition(); /// Returns true if any DbgRecords are attached to this instruction. - bool hasDbgRecords() const; + LLVM_ABI bool hasDbgRecords() const; /// Transfer any DbgRecords on the position \p It onto this instruction, /// by simply adopting the sequence of DbgRecords (which is efficient) if /// possible, by merging two sequences otherwise. - void adoptDbgRecords(BasicBlock *BB, InstListType::iterator It, - bool InsertAtHead); + LLVM_ABI void adoptDbgRecords(BasicBlock *BB, InstListType::iterator It, + bool InsertAtHead); /// Erase any DbgRecords attached to this instruction. - void dropDbgRecords(); + LLVM_ABI void dropDbgRecords(); /// Erase a single DbgRecord \p I that is attached to this instruction. - void dropOneDbgRecord(DbgRecord *I); + LLVM_ABI void dropOneDbgRecord(DbgRecord *I); /// Handle the debug-info implications of this instruction being removed. Any /// attached DbgRecords need to "fall" down onto the next instruction. - void handleMarkerRemoval(); + LLVM_ABI void handleMarkerRemoval(); protected: // The 15 first bits of `Value::SubclassData` are available for subclasses of @@ -158,7 +160,7 @@ private: using HasMetadataField = Bitfield::Element<bool, 15, 1>; protected: - ~Instruction(); // Use deleteValue() to delete a generic Instruction. + LLVM_ABI ~Instruction(); // Use deleteValue() to delete a generic Instruction. public: Instruction(const Instruction &) = delete; @@ -174,7 +176,7 @@ public: /// /// Note: this is undefined behavior if the instruction does not have a /// parent, or the parent basic block does not have a parent function. - const Module *getModule() const; + LLVM_ABI const Module *getModule() const; Module *getModule() { return const_cast<Module *>( static_cast<const Instruction *>(this)->getModule()); @@ -184,7 +186,7 @@ public: /// /// Note: it is undefined behavior to call this on an instruction not /// currently inserted into a function. - const Function *getFunction() const; + LLVM_ABI const Function *getFunction() const; Function *getFunction() { return const_cast<Function *>( static_cast<const Instruction *>(this)->getFunction()); @@ -193,16 +195,16 @@ public: /// Get the data layout of the module this instruction belongs to. /// /// Requires the instruction to have a parent module. - const DataLayout &getDataLayout() const; + LLVM_ABI const DataLayout &getDataLayout() const; /// This method unlinks 'this' from the containing basic block, but does not /// delete it. - void removeFromParent(); + LLVM_ABI void removeFromParent(); /// This method unlinks 'this' from the containing basic block and deletes it. /// /// \returns an iterator pointing to the element after the erased one - InstListType::iterator eraseFromParent(); + LLVM_ABI InstListType::iterator eraseFromParent(); /// Insert an unlinked instruction into a basic block immediately before /// the specified instruction. @@ -211,27 +213,27 @@ public: /// start of a block such as BasicBlock::getFirstNonPHIIt must be passed into /// insertBefore without unwrapping/rewrapping. For all other positions, call /// getIterator to fetch the instruction iterator. - LLVM_DEPRECATED("Use iterators as instruction positions", "") - void insertBefore(Instruction *InsertPos); + LLVM_ABI LLVM_DEPRECATED("Use iterators as instruction positions", + "") void insertBefore(Instruction *InsertPos); /// Insert an unlinked instruction into a basic block immediately before /// the specified position. - void insertBefore(InstListType::iterator InsertPos); + LLVM_ABI void insertBefore(InstListType::iterator InsertPos); /// Insert an unlinked instruction into a basic block immediately after the /// specified instruction. - void insertAfter(Instruction *InsertPos); + LLVM_ABI void insertAfter(Instruction *InsertPos); /// Insert an unlinked instruction into a basic block immediately after the /// specified position. - void insertAfter(InstListType::iterator InsertPos); + LLVM_ABI void insertAfter(InstListType::iterator InsertPos); /// Inserts an unlinked instruction into \p ParentBB at position \p It and /// returns the iterator of the inserted instruction. - InstListType::iterator insertInto(BasicBlock *ParentBB, - InstListType::iterator It); + LLVM_ABI InstListType::iterator insertInto(BasicBlock *ParentBB, + InstListType::iterator It); - void insertBefore(BasicBlock &BB, InstListType::iterator InsertPos); + LLVM_ABI void insertBefore(BasicBlock &BB, InstListType::iterator InsertPos); /// Unlink this instruction from its current basic block and insert it into /// the basic block that MovePos lives in, right before MovePos. @@ -240,22 +242,22 @@ public: /// start of a block such as BasicBlock::getFirstNonPHIIt must be passed into /// moveBefore without unwrapping/rewrapping. For all other positions, call /// getIterator to fetch the instruction iterator. - LLVM_DEPRECATED("Use iterators as instruction positions", "") - void moveBefore(Instruction *MovePos); + LLVM_ABI LLVM_DEPRECATED("Use iterators as instruction positions", + "") void moveBefore(Instruction *MovePos); /// Unlink this instruction from its current basic block and insert it into /// the basic block that MovePos lives in, right before MovePos. - void moveBefore(InstListType::iterator InsertPos); + LLVM_ABI void moveBefore(InstListType::iterator InsertPos); /// Perform a \ref moveBefore operation, while signalling that the caller /// intends to preserve the original ordering of instructions. This implicitly /// means that any adjacent debug-info should move with this instruction. - void moveBeforePreserving(InstListType::iterator MovePos); + LLVM_ABI void moveBeforePreserving(InstListType::iterator MovePos); /// Perform a \ref moveBefore operation, while signalling that the caller /// intends to preserve the original ordering of instructions. This implicitly /// means that any adjacent debug-info should move with this instruction. - void moveBeforePreserving(BasicBlock &BB, InstListType::iterator I); + LLVM_ABI void moveBeforePreserving(BasicBlock &BB, InstListType::iterator I); /// Perform a \ref moveBefore operation, while signalling that the caller /// intends to preserve the original ordering of instructions. This implicitly @@ -263,8 +265,8 @@ public: /// /// Deprecated in favour of the iterator-accepting flavour of /// moveBeforePreserving, as all insertions should be at iterator positions. - LLVM_DEPRECATED("Use iterators as instruction positions", "") - void moveBeforePreserving(Instruction *MovePos); + LLVM_ABI LLVM_DEPRECATED("Use iterators as instruction positions", + "") void moveBeforePreserving(Instruction *MovePos); private: /// RemoveDIs project: all other moves implemented with this method, @@ -275,32 +277,32 @@ public: /// Unlink this instruction and insert into BB before I. /// /// \pre I is a valid iterator into BB. - void moveBefore(BasicBlock &BB, InstListType::iterator I); + LLVM_ABI void moveBefore(BasicBlock &BB, InstListType::iterator I); /// Unlink this instruction from its current basic block and insert it into /// the basic block that MovePos lives in, right after MovePos. - void moveAfter(Instruction *MovePos); + LLVM_ABI void moveAfter(Instruction *MovePos); /// Unlink this instruction from its current basic block and insert it into /// the basic block that MovePos lives in, right after MovePos. - void moveAfter(InstListType::iterator MovePos); + LLVM_ABI void moveAfter(InstListType::iterator MovePos); /// See \ref moveBeforePreserving . - void moveAfterPreserving(Instruction *MovePos); + LLVM_ABI void moveAfterPreserving(Instruction *MovePos); /// Given an instruction Other in the same basic block as this instruction, /// return true if this instruction comes before Other. In this worst case, /// this takes linear time in the number of instructions in the block. The /// results are cached, so in common cases when the block remains unmodified, /// it takes constant time. - bool comesBefore(const Instruction *Other) const; + LLVM_ABI bool comesBefore(const Instruction *Other) const; /// Get the first insertion point at which the result of this instruction /// is defined. This is *not* the directly following instruction in a number /// of cases, e.g. phi nodes or terminators that return values. This function /// may return null if the insertion after the definition is not possible, /// e.g. due to a catchswitch terminator. - std::optional<InstListType::iterator> getInsertionPointAfterDef(); + LLVM_ABI std::optional<InstListType::iterator> getInsertionPointAfterDef(); //===--------------------------------------------------------------------===// // Subclass classification. @@ -322,9 +324,9 @@ public: /// It checks if this instruction is the only user of at least one of /// its operands. - bool isOnlyUserOfAnyOperand(); + LLVM_ABI bool isOnlyUserOfAnyOperand(); - static const char *getOpcodeName(unsigned Opcode); + LLVM_ABI static const char *getOpcodeName(unsigned Opcode); static inline bool isTerminator(unsigned Opcode) { return Opcode >= TermOpsBegin && Opcode < TermOpsEnd; @@ -405,7 +407,7 @@ public: // Return true if this instruction contains loop metadata other than // a debug location - bool hasNonDebugLocLoopMetadata() const; + LLVM_ABI bool hasNonDebugLocLoopMetadata() const; /// Return true if this instruction has metadata attached to it other than a /// debug location. @@ -455,22 +457,22 @@ public: /// Set the metadata of the specified kind to the specified node. This updates /// or replaces metadata if already present, or removes it if Node is null. - void setMetadata(unsigned KindID, MDNode *Node); - void setMetadata(StringRef Kind, MDNode *Node); + LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node); + LLVM_ABI void setMetadata(StringRef Kind, MDNode *Node); /// Copy metadata from \p SrcInst to this instruction. \p WL, if not empty, /// specifies the list of meta data that needs to be copied. If \p WL is /// empty, all meta data will be copied. - void copyMetadata(const Instruction &SrcInst, - ArrayRef<unsigned> WL = ArrayRef<unsigned>()); + LLVM_ABI void copyMetadata(const Instruction &SrcInst, + ArrayRef<unsigned> WL = ArrayRef<unsigned>()); /// Erase all metadata that matches the predicate. - void eraseMetadataIf(function_ref<bool(unsigned, MDNode *)> Pred); + LLVM_ABI void eraseMetadataIf(function_ref<bool(unsigned, MDNode *)> Pred); /// If the instruction has "branch_weights" MD_prof metadata and the MDNode /// has three operands (including name string), swap the order of the /// metadata. - void swapProfMetadata(); + LLVM_ABI void swapProfMetadata(); /// Drop all unknown metadata except for debug locations. /// @{ @@ -478,31 +480,31 @@ public: /// convenience method for passes to do so. /// dropUBImplyingAttrsAndUnknownMetadata should be used instead of /// this API if the Instruction being modified is a call. - void dropUnknownNonDebugMetadata(ArrayRef<unsigned> KnownIDs = {}); + LLVM_ABI void dropUnknownNonDebugMetadata(ArrayRef<unsigned> KnownIDs = {}); /// @} /// Adds an !annotation metadata node with \p Annotation to this instruction. /// If this instruction already has !annotation metadata, append \p Annotation /// to the existing node. - void addAnnotationMetadata(StringRef Annotation); + LLVM_ABI void addAnnotationMetadata(StringRef Annotation); /// Adds an !annotation metadata node with an array of \p Annotations /// as a tuple to this instruction. If this instruction already has /// !annotation metadata, append the tuple to /// the existing node. - void addAnnotationMetadata(SmallVector<StringRef> Annotations); + LLVM_ABI void addAnnotationMetadata(SmallVector<StringRef> Annotations); /// Returns the AA metadata for this instruction. - AAMDNodes getAAMetadata() const; + LLVM_ABI AAMDNodes getAAMetadata() const; /// Sets the AA metadata on this instruction from the AAMDNodes structure. - void setAAMetadata(const AAMDNodes &N); + LLVM_ABI void setAAMetadata(const AAMDNodes &N); /// Sets the nosanitize metadata on this instruction. - void setNoSanitizeMetadata(); + LLVM_ABI void setNoSanitizeMetadata(); /// Retrieve total raw weight values of a branch. /// Returns true on success with profile total weights filled in. /// Returns false if no metadata was found. - bool extractProfTotalWeight(uint64_t &TotalVal) const; + LLVM_ABI bool extractProfTotalWeight(uint64_t &TotalVal) const; /// Set the debug location information for this instruction. void setDebugLoc(DebugLoc Loc) { DbgLoc = std::move(Loc); } @@ -512,52 +514,52 @@ public: /// Fetch the debug location for this node, unless this is a debug intrinsic, /// in which case fetch the debug location of the next non-debug node. - const DebugLoc &getStableDebugLoc() const; + LLVM_ABI const DebugLoc &getStableDebugLoc() const; /// Set or clear the nuw flag on this instruction, which must be an operator /// which supports this flag. See LangRef.html for the meaning of this flag. - void setHasNoUnsignedWrap(bool b = true); + LLVM_ABI void setHasNoUnsignedWrap(bool b = true); /// Set or clear the nsw flag on this instruction, which must be an operator /// which supports this flag. See LangRef.html for the meaning of this flag. - void setHasNoSignedWrap(bool b = true); + LLVM_ABI void setHasNoSignedWrap(bool b = true); /// Set or clear the exact flag on this instruction, which must be an operator /// which supports this flag. See LangRef.html for the meaning of this flag. - void setIsExact(bool b = true); + LLVM_ABI void setIsExact(bool b = true); /// Set or clear the nneg flag on this instruction, which must be a zext /// instruction. - void setNonNeg(bool b = true); + LLVM_ABI void setNonNeg(bool b = true); /// Determine whether the no unsigned wrap flag is set. - bool hasNoUnsignedWrap() const LLVM_READONLY; + LLVM_ABI bool hasNoUnsignedWrap() const LLVM_READONLY; /// Determine whether the no signed wrap flag is set. - bool hasNoSignedWrap() const LLVM_READONLY; + LLVM_ABI bool hasNoSignedWrap() const LLVM_READONLY; /// Determine whether the the nneg flag is set. - bool hasNonNeg() const LLVM_READONLY; + LLVM_ABI bool hasNonNeg() const LLVM_READONLY; /// Return true if this operator has flags which may cause this instruction /// to evaluate to poison despite having non-poison inputs. - bool hasPoisonGeneratingFlags() const LLVM_READONLY; + LLVM_ABI bool hasPoisonGeneratingFlags() const LLVM_READONLY; /// Drops flags that may cause this instruction to evaluate to poison despite /// having non-poison inputs. - void dropPoisonGeneratingFlags(); + LLVM_ABI void dropPoisonGeneratingFlags(); /// Return true if this instruction has poison-generating metadata. - bool hasPoisonGeneratingMetadata() const LLVM_READONLY; + LLVM_ABI bool hasPoisonGeneratingMetadata() const LLVM_READONLY; /// Drops metadata that may generate poison. - void dropPoisonGeneratingMetadata(); + LLVM_ABI void dropPoisonGeneratingMetadata(); /// Return true if this instruction has poison-generating attribute. - bool hasPoisonGeneratingReturnAttributes() const LLVM_READONLY; + LLVM_ABI bool hasPoisonGeneratingReturnAttributes() const LLVM_READONLY; /// Drops return attributes that may generate poison. - void dropPoisonGeneratingReturnAttributes(); + LLVM_ABI void dropPoisonGeneratingReturnAttributes(); /// Return true if this instruction has poison-generating flags, /// return attributes or metadata. @@ -578,109 +580,110 @@ public: /// dropUnknownNonDebugMetadata). For calls, it also drops parameter and /// return attributes that can cause undefined behaviour. Both of these should /// be done by passes which move instructions in IR. - void dropUBImplyingAttrsAndUnknownMetadata(ArrayRef<unsigned> KnownIDs = {}); + LLVM_ABI void + dropUBImplyingAttrsAndUnknownMetadata(ArrayRef<unsigned> KnownIDs = {}); /// Drop any attributes or metadata that can cause immediate undefined /// behavior. Retain other attributes/metadata on a best-effort basis. /// This should be used when speculating instructions. - void dropUBImplyingAttrsAndMetadata(); + LLVM_ABI void dropUBImplyingAttrsAndMetadata(); /// Return true if this instruction has UB-implying attributes /// that can cause immediate undefined behavior. - bool hasUBImplyingAttrs() const LLVM_READONLY; + LLVM_ABI bool hasUBImplyingAttrs() const LLVM_READONLY; /// Determine whether the exact flag is set. - bool isExact() const LLVM_READONLY; + LLVM_ABI bool isExact() const LLVM_READONLY; /// Set or clear all fast-math-flags on this instruction, which must be an /// operator which supports this flag. See LangRef.html for the meaning of /// this flag. - void setFast(bool B); + LLVM_ABI void setFast(bool B); /// Set or clear the reassociation flag on this instruction, which must be /// an operator which supports this flag. See LangRef.html for the meaning of /// this flag. - void setHasAllowReassoc(bool B); + LLVM_ABI void setHasAllowReassoc(bool B); /// Set or clear the no-nans flag on this instruction, which must be an /// operator which supports this flag. See LangRef.html for the meaning of /// this flag. - void setHasNoNaNs(bool B); + LLVM_ABI void setHasNoNaNs(bool B); /// Set or clear the no-infs flag on this instruction, which must be an /// operator which supports this flag. See LangRef.html for the meaning of /// this flag. - void setHasNoInfs(bool B); + LLVM_ABI void setHasNoInfs(bool B); /// Set or clear the no-signed-zeros flag on this instruction, which must be /// an operator which supports this flag. See LangRef.html for the meaning of /// this flag. - void setHasNoSignedZeros(bool B); + LLVM_ABI void setHasNoSignedZeros(bool B); /// Set or clear the allow-reciprocal flag on this instruction, which must be /// an operator which supports this flag. See LangRef.html for the meaning of /// this flag. - void setHasAllowReciprocal(bool B); + LLVM_ABI void setHasAllowReciprocal(bool B); /// Set or clear the allow-contract flag on this instruction, which must be /// an operator which supports this flag. See LangRef.html for the meaning of /// this flag. - void setHasAllowContract(bool B); + LLVM_ABI void setHasAllowContract(bool B); /// Set or clear the approximate-math-functions flag on this instruction, /// which must be an operator which supports this flag. See LangRef.html for /// the meaning of this flag. - void setHasApproxFunc(bool B); + LLVM_ABI void setHasApproxFunc(bool B); /// Convenience function for setting multiple fast-math flags on this /// instruction, which must be an operator which supports these flags. See /// LangRef.html for the meaning of these flags. - void setFastMathFlags(FastMathFlags FMF); + LLVM_ABI void setFastMathFlags(FastMathFlags FMF); /// Convenience function for transferring all fast-math flag values to this /// instruction, which must be an operator which supports these flags. See /// LangRef.html for the meaning of these flags. - void copyFastMathFlags(FastMathFlags FMF); + LLVM_ABI void copyFastMathFlags(FastMathFlags FMF); /// Determine whether all fast-math-flags are set. - bool isFast() const LLVM_READONLY; + LLVM_ABI bool isFast() const LLVM_READONLY; /// Determine whether the allow-reassociation flag is set. - bool hasAllowReassoc() const LLVM_READONLY; + LLVM_ABI bool hasAllowReassoc() const LLVM_READONLY; /// Determine whether the no-NaNs flag is set. - bool hasNoNaNs() const LLVM_READONLY; + LLVM_ABI bool hasNoNaNs() const LLVM_READONLY; /// Determine whether the no-infs flag is set. - bool hasNoInfs() const LLVM_READONLY; + LLVM_ABI bool hasNoInfs() const LLVM_READONLY; /// Determine whether the no-signed-zeros flag is set. - bool hasNoSignedZeros() const LLVM_READONLY; + LLVM_ABI bool hasNoSignedZeros() const LLVM_READONLY; /// Determine whether the allow-reciprocal flag is set. - bool hasAllowReciprocal() const LLVM_READONLY; + LLVM_ABI bool hasAllowReciprocal() const LLVM_READONLY; /// Determine whether the allow-contract flag is set. - bool hasAllowContract() const LLVM_READONLY; + LLVM_ABI bool hasAllowContract() const LLVM_READONLY; /// Determine whether the approximate-math-functions flag is set. - bool hasApproxFunc() const LLVM_READONLY; + LLVM_ABI bool hasApproxFunc() const LLVM_READONLY; /// Convenience function for getting all the fast-math flags, which must be an /// operator which supports these flags. See LangRef.html for the meaning of /// these flags. - FastMathFlags getFastMathFlags() const LLVM_READONLY; + LLVM_ABI FastMathFlags getFastMathFlags() const LLVM_READONLY; /// Copy I's fast-math flags - void copyFastMathFlags(const Instruction *I); + LLVM_ABI void copyFastMathFlags(const Instruction *I); /// Convenience method to copy supported exact, fast-math, and (optionally) /// wrapping flags from V to this instruction. - void copyIRFlags(const Value *V, bool IncludeWrapFlags = true); + LLVM_ABI void copyIRFlags(const Value *V, bool IncludeWrapFlags = true); /// Logical 'and' of any supported wrapping, exact, and fast-math flags of /// V and this instruction. - void andIRFlags(const Value *V); + LLVM_ABI void andIRFlags(const Value *V); /// Merge 2 debug locations and apply it to the Instruction. If the /// instruction is a CallIns, we need to traverse the inline chain to find @@ -695,13 +698,13 @@ public: /// applications, thus the N-way merging should be in code path. /// The DebugLoc attached to this instruction will be overwritten by the /// merged DebugLoc. - void applyMergedLocation(DILocation *LocA, DILocation *LocB); + LLVM_ABI void applyMergedLocation(DILocation *LocA, DILocation *LocB); /// Updates the debug location given that the instruction has been hoisted /// from a block to a predecessor of that block. /// Note: it is undefined behavior to call this on an instruction not /// currently inserted into a function. - void updateLocationAfterHoist(); + LLVM_ABI void updateLocationAfterHoist(); /// Drop the instruction's debug location. This does not guarantee removal /// of the !dbg source location attachment, as it must set a line 0 location @@ -709,7 +712,7 @@ public: /// removal of the !dbg attachment, use the \ref setDebugLoc() API. /// Note: it is undefined behavior to call this on an instruction not /// currently inserted into a function. - void dropLocation(); + LLVM_ABI void dropLocation(); /// Merge the DIAssignID metadata from this instruction and those attached to /// instructions in \p SourceInstructions. This process performs a RAUW on @@ -720,12 +723,13 @@ public: /// SourceInstructions does then the merged one will be attached to /// it. However, instructions without attachments in \p SourceInstructions /// are not modified. - void mergeDIAssignID(ArrayRef<const Instruction *> SourceInstructions); + LLVM_ABI void + mergeDIAssignID(ArrayRef<const Instruction *> SourceInstructions); private: // These are all implemented in Metadata.cpp. - MDNode *getMetadataImpl(StringRef Kind) const; - void + LLVM_ABI MDNode *getMetadataImpl(StringRef Kind) const; + LLVM_ABI void getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned, MDNode *>> &) const; /// Update the LLVMContext ID-to-Instruction(s) mapping. If \p ID is nullptr @@ -743,7 +747,7 @@ public: /// /// In LLVM, the Add, Mul, And, Or, and Xor operators are associative. /// - bool isAssociative() const LLVM_READONLY; + LLVM_ABI bool isAssociative() const LLVM_READONLY; static bool isAssociative(unsigned Opcode) { return Opcode == And || Opcode == Or || Opcode == Xor || Opcode == Add || Opcode == Mul; @@ -756,7 +760,7 @@ public: /// In LLVM, these are the commutative operators, plus SetEQ and SetNE, when /// applied to any type. /// - bool isCommutative() const LLVM_READONLY; + LLVM_ABI bool isCommutative() const LLVM_READONLY; static bool isCommutative(unsigned Opcode) { switch (Opcode) { case Add: case FAdd: @@ -794,10 +798,10 @@ public: } /// Return true if this instruction may modify memory. - bool mayWriteToMemory() const LLVM_READONLY; + LLVM_ABI bool mayWriteToMemory() const LLVM_READONLY; /// Return true if this instruction may read memory. - bool mayReadFromMemory() const LLVM_READONLY; + LLVM_ABI bool mayReadFromMemory() const LLVM_READONLY; /// Return true if this instruction may read or write memory. bool mayReadOrWriteMemory() const { @@ -806,26 +810,27 @@ public: /// Return true if this instruction has an AtomicOrdering of unordered or /// higher. - bool isAtomic() const LLVM_READONLY; + LLVM_ABI bool isAtomic() const LLVM_READONLY; /// Return true if this atomic instruction loads from memory. - bool hasAtomicLoad() const LLVM_READONLY; + LLVM_ABI bool hasAtomicLoad() const LLVM_READONLY; /// Return true if this atomic instruction stores to memory. - bool hasAtomicStore() const LLVM_READONLY; + LLVM_ABI bool hasAtomicStore() const LLVM_READONLY; /// Return true if this instruction has a volatile memory access. - bool isVolatile() const LLVM_READONLY; + LLVM_ABI bool isVolatile() const LLVM_READONLY; /// Return the type this instruction accesses in memory, if any. - Type *getAccessType() const LLVM_READONLY; + LLVM_ABI Type *getAccessType() const LLVM_READONLY; /// Return true if this instruction may throw an exception. /// /// If IncludePhaseOneUnwind is set, this will also include cases where /// phase one unwinding may unwind past this frame due to skipping of /// cleanup landingpads. - bool mayThrow(bool IncludePhaseOneUnwind = false) const LLVM_READONLY; + LLVM_ABI bool + mayThrow(bool IncludePhaseOneUnwind = false) const LLVM_READONLY; /// Return true if this instruction behaves like a memory fence: it can load /// or store to memory location without being given a memory location. @@ -855,7 +860,7 @@ public: /// effects because the newly allocated memory is completely invisible to /// instructions which don't use the returned value. For cases where this /// matters, isSafeToSpeculativelyExecute may be more appropriate. - bool mayHaveSideEffects() const LLVM_READONLY; + LLVM_ABI bool mayHaveSideEffects() const LLVM_READONLY; /// Return true if the instruction can be removed if the result is unused. /// @@ -863,11 +868,11 @@ public: /// results are unused. Specifically terminator instructions and calls that /// may have side effects cannot be removed without semantically changing the /// generated program. - bool isSafeToRemove() const LLVM_READONLY; + LLVM_ABI bool isSafeToRemove() const LLVM_READONLY; /// Return true if the instruction will return (unwinding is considered as /// a form of returning control flow here). - bool willReturn() const LLVM_READONLY; + LLVM_ABI bool willReturn() const LLVM_READONLY; /// Return true if the instruction is a variety of EH-block. bool isEHPad() const { @@ -884,19 +889,19 @@ public: /// Return true if the instruction is a llvm.lifetime.start or /// llvm.lifetime.end marker. - bool isLifetimeStartOrEnd() const LLVM_READONLY; + LLVM_ABI bool isLifetimeStartOrEnd() const LLVM_READONLY; /// Return true if the instruction is a llvm.launder.invariant.group or /// llvm.strip.invariant.group. - bool isLaunderOrStripInvariantGroup() const LLVM_READONLY; + LLVM_ABI bool isLaunderOrStripInvariantGroup() const LLVM_READONLY; /// Return true if the instruction is a DbgInfoIntrinsic or PseudoProbeInst. - bool isDebugOrPseudoInst() const LLVM_READONLY; + LLVM_ABI bool isDebugOrPseudoInst() const LLVM_READONLY; /// Return a pointer to the next non-debug instruction in the same basic /// block as 'this', or nullptr if no such instruction exists. Skip any pseudo /// operations if \c SkipPseudoOp is true. - const Instruction * + LLVM_ABI const Instruction * getNextNonDebugInstruction(bool SkipPseudoOp = false) const; Instruction *getNextNonDebugInstruction(bool SkipPseudoOp = false) { return const_cast<Instruction *>( @@ -907,7 +912,7 @@ public: /// Return a pointer to the previous non-debug instruction in the same basic /// block as 'this', or nullptr if no such instruction exists. Skip any pseudo /// operations if \c SkipPseudoOp is true. - const Instruction * + LLVM_ABI const Instruction * getPrevNonDebugInstruction(bool SkipPseudoOp = false) const; Instruction *getPrevNonDebugInstruction(bool SkipPseudoOp = false) { return const_cast<Instruction *>( @@ -920,17 +925,17 @@ public: /// * The instruction has no parent /// * The instruction has no name /// - Instruction *clone() const; + LLVM_ABI Instruction *clone() const; /// Return true if the specified instruction is exactly identical to the /// current one. This means that all operands match and any extra information /// (e.g. load is volatile) agree. - bool isIdenticalTo(const Instruction *I) const LLVM_READONLY; + LLVM_ABI bool isIdenticalTo(const Instruction *I) const LLVM_READONLY; /// This is like isIdenticalTo, except that it ignores the /// SubclassOptionalData flags, which may specify conditions under which the /// instruction's result is undefined. - bool + LLVM_ABI bool isIdenticalToWhenDefined(const Instruction *I, bool IntersectAttrs = false) const LLVM_READONLY; @@ -954,7 +959,8 @@ public: /// @returns true if the specified instruction is the same operation as /// the current one. /// Determine if one instruction is the same operation as another. - bool isSameOperationAs(const Instruction *I, unsigned flags = 0) const LLVM_READONLY; + LLVM_ABI bool isSameOperationAs(const Instruction *I, + unsigned flags = 0) const LLVM_READONLY; /// This function determines if the speficied instruction has the same /// "special" characteristics as the current one. This means that opcode @@ -964,28 +970,29 @@ public: /// @returns true if the specific instruction has the same opcde specific /// characteristics as the current one. Determine if one instruction has the /// same state as another. - bool hasSameSpecialState(const Instruction *I2, bool IgnoreAlignment = false, - bool IntersectAttrs = false) const LLVM_READONLY; + LLVM_ABI bool + hasSameSpecialState(const Instruction *I2, bool IgnoreAlignment = false, + bool IntersectAttrs = false) const LLVM_READONLY; /// Return true if there are any uses of this instruction in blocks other than /// the specified block. Note that PHI nodes are considered to evaluate their /// operands in the corresponding predecessor block. - bool isUsedOutsideOfBlock(const BasicBlock *BB) const LLVM_READONLY; + LLVM_ABI bool isUsedOutsideOfBlock(const BasicBlock *BB) const LLVM_READONLY; /// Return the number of successors that this instruction has. The instruction /// must be a terminator. - unsigned getNumSuccessors() const LLVM_READONLY; + LLVM_ABI unsigned getNumSuccessors() const LLVM_READONLY; /// Return the specified successor. This instruction must be a terminator. - BasicBlock *getSuccessor(unsigned Idx) const LLVM_READONLY; + LLVM_ABI BasicBlock *getSuccessor(unsigned Idx) const LLVM_READONLY; /// Update the specified successor to point at the provided block. This /// instruction must be a terminator. - void setSuccessor(unsigned Idx, BasicBlock *BB); + LLVM_ABI void setSuccessor(unsigned Idx, BasicBlock *BB); /// Replace specified successor OldBB to point at the provided block. /// This instruction must be a terminator. - void replaceSuccessorWith(BasicBlock *OldBB, BasicBlock *NewBB); + LLVM_ABI void replaceSuccessorWith(BasicBlock *OldBB, BasicBlock *NewBB); /// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { @@ -1083,8 +1090,8 @@ protected: setValueSubclassData(Storage); } - Instruction(Type *Ty, unsigned iType, AllocInfo AllocInfo, - InsertPosition InsertBefore = nullptr); + LLVM_ABI Instruction(Type *Ty, unsigned iType, AllocInfo AllocInfo, + InsertPosition InsertBefore = nullptr); private: /// Create a copy of this instruction. diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h index c164f76..6f69b68 100644 --- a/llvm/include/llvm/IR/Instructions.h +++ b/llvm/include/llvm/IR/Instructions.h @@ -35,6 +35,7 @@ #include "llvm/IR/Use.h" #include "llvm/IR/User.h" #include "llvm/Support/AtomicOrdering.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include <cassert> #include <cstddef> @@ -74,21 +75,22 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - AllocaInst *cloneImpl() const; + LLVM_ABI AllocaInst *cloneImpl() const; public: - explicit AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize, - const Twine &Name, InsertPosition InsertBefore); + LLVM_ABI explicit AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize, + const Twine &Name, InsertPosition InsertBefore); - AllocaInst(Type *Ty, unsigned AddrSpace, const Twine &Name, - InsertPosition InsertBefore); + LLVM_ABI AllocaInst(Type *Ty, unsigned AddrSpace, const Twine &Name, + InsertPosition InsertBefore); - AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize, Align Align, - const Twine &Name = "", InsertPosition InsertBefore = nullptr); + LLVM_ABI AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize, + Align Align, const Twine &Name = "", + InsertPosition InsertBefore = nullptr); /// Return true if there is an allocation size parameter to the allocation /// instruction that is not 1. - bool isArrayAllocation() const; + LLVM_ABI bool isArrayAllocation() const; /// Get the number of elements allocated. For a simple allocation of a single /// element, this will return a constant 1 value. @@ -107,11 +109,13 @@ public: /// Get allocation size in bytes. Returns std::nullopt if size can't be /// determined, e.g. in case of a VLA. - std::optional<TypeSize> getAllocationSize(const DataLayout &DL) const; + LLVM_ABI std::optional<TypeSize> + getAllocationSize(const DataLayout &DL) const; /// Get allocation size in bits. Returns std::nullopt if size can't be /// determined, e.g. in case of a VLA. - std::optional<TypeSize> getAllocationSizeInBits(const DataLayout &DL) const; + LLVM_ABI std::optional<TypeSize> + getAllocationSizeInBits(const DataLayout &DL) const; /// Return the type that is being allocated by the instruction. Type *getAllocatedType() const { return AllocatedType; } @@ -132,7 +136,7 @@ public: /// Return true if this alloca is in the entry block of the function and is a /// constant size. If so, the code generator will fold it into the /// prolog/epilog code, so it is basically free. - bool isStaticAlloca() const; + LLVM_ABI bool isStaticAlloca() const; /// Return true if this alloca is used as an inalloca argument to a call. Such /// allocas are never considered static even if they are in the entry block. @@ -187,19 +191,19 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - LoadInst *cloneImpl() const; + LLVM_ABI LoadInst *cloneImpl() const; public: - LoadInst(Type *Ty, Value *Ptr, const Twine &NameStr, - InsertPosition InsertBefore); - LoadInst(Type *Ty, Value *Ptr, const Twine &NameStr, bool isVolatile, - InsertPosition InsertBefore); - LoadInst(Type *Ty, Value *Ptr, const Twine &NameStr, bool isVolatile, - Align Align, InsertPosition InsertBefore = nullptr); - LoadInst(Type *Ty, Value *Ptr, const Twine &NameStr, bool isVolatile, - Align Align, AtomicOrdering Order, - SyncScope::ID SSID = SyncScope::System, - InsertPosition InsertBefore = nullptr); + LLVM_ABI LoadInst(Type *Ty, Value *Ptr, const Twine &NameStr, + InsertPosition InsertBefore); + LLVM_ABI LoadInst(Type *Ty, Value *Ptr, const Twine &NameStr, bool isVolatile, + InsertPosition InsertBefore); + LLVM_ABI LoadInst(Type *Ty, Value *Ptr, const Twine &NameStr, bool isVolatile, + Align Align, InsertPosition InsertBefore = nullptr); + LLVM_ABI LoadInst(Type *Ty, Value *Ptr, const Twine &NameStr, bool isVolatile, + Align Align, AtomicOrdering Order, + SyncScope::ID SSID = SyncScope::System, + InsertPosition InsertBefore = nullptr); /// Return true if this is a load from a volatile memory location. bool isVolatile() const { return getSubclassData<VolatileField>(); } @@ -305,17 +309,18 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - StoreInst *cloneImpl() const; + LLVM_ABI StoreInst *cloneImpl() const; public: - StoreInst(Value *Val, Value *Ptr, InsertPosition InsertBefore); - StoreInst(Value *Val, Value *Ptr, bool isVolatile, - InsertPosition InsertBefore); - StoreInst(Value *Val, Value *Ptr, bool isVolatile, Align Align, - InsertPosition InsertBefore = nullptr); - StoreInst(Value *Val, Value *Ptr, bool isVolatile, Align Align, - AtomicOrdering Order, SyncScope::ID SSID = SyncScope::System, - InsertPosition InsertBefore = nullptr); + LLVM_ABI StoreInst(Value *Val, Value *Ptr, InsertPosition InsertBefore); + LLVM_ABI StoreInst(Value *Val, Value *Ptr, bool isVolatile, + InsertPosition InsertBefore); + LLVM_ABI StoreInst(Value *Val, Value *Ptr, bool isVolatile, Align Align, + InsertPosition InsertBefore = nullptr); + LLVM_ABI StoreInst(Value *Val, Value *Ptr, bool isVolatile, Align Align, + AtomicOrdering Order, + SyncScope::ID SSID = SyncScope::System, + InsertPosition InsertBefore = nullptr); // allocate space for exactly two operands void *operator new(size_t S) { return User::operator new(S, AllocMarker); } @@ -432,14 +437,14 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - FenceInst *cloneImpl() const; + LLVM_ABI FenceInst *cloneImpl() const; public: // Ordering may only be Acquire, Release, AcquireRelease, or // SequentiallyConsistent. - FenceInst(LLVMContext &C, AtomicOrdering Ordering, - SyncScope::ID SSID = SyncScope::System, - InsertPosition InsertBefore = nullptr); + LLVM_ABI FenceInst(LLVMContext &C, AtomicOrdering Ordering, + SyncScope::ID SSID = SyncScope::System, + InsertPosition InsertBefore = nullptr); // allocate space for exactly zero operands void *operator new(size_t S) { return User::operator new(S, AllocMarker); } @@ -514,13 +519,13 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - AtomicCmpXchgInst *cloneImpl() const; + LLVM_ABI AtomicCmpXchgInst *cloneImpl() const; public: - AtomicCmpXchgInst(Value *Ptr, Value *Cmp, Value *NewVal, Align Alignment, - AtomicOrdering SuccessOrdering, - AtomicOrdering FailureOrdering, SyncScope::ID SSID, - InsertPosition InsertBefore = nullptr); + LLVM_ABI AtomicCmpXchgInst(Value *Ptr, Value *Cmp, Value *NewVal, + Align Alignment, AtomicOrdering SuccessOrdering, + AtomicOrdering FailureOrdering, SyncScope::ID SSID, + InsertPosition InsertBefore = nullptr); // allocate space for exactly three operands void *operator new(size_t S) { return User::operator new(S, AllocMarker); } @@ -706,7 +711,7 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - AtomicRMWInst *cloneImpl() const; + LLVM_ABI AtomicRMWInst *cloneImpl() const; public: /// This enumeration lists the possible modifications atomicrmw can make. In @@ -793,9 +798,10 @@ private: constexpr static IntrusiveOperandsAllocMarker AllocMarker{2}; public: - AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val, Align Alignment, - AtomicOrdering Ordering, SyncScope::ID SSID, - InsertPosition InsertBefore = nullptr); + LLVM_ABI AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val, + Align Alignment, AtomicOrdering Ordering, + SyncScope::ID SSID, + InsertPosition InsertBefore = nullptr); // allocate space for exactly two operands void *operator new(size_t S) { return User::operator new(S, AllocMarker); } @@ -812,7 +818,7 @@ public: BinOp getOperation() const { return getSubclassData<OperationField>(); } - static StringRef getOperationName(BinOp Op); + LLVM_ABI static StringRef getOperationName(BinOp Op); static bool isFPOperation(BinOp Op) { switch (Op) { @@ -954,13 +960,14 @@ class GetElementPtrInst : public Instruction { ArrayRef<Value *> IdxList, AllocInfo AllocInfo, const Twine &NameStr, InsertPosition InsertBefore); - void init(Value *Ptr, ArrayRef<Value *> IdxList, const Twine &NameStr); + LLVM_ABI void init(Value *Ptr, ArrayRef<Value *> IdxList, + const Twine &NameStr); protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - GetElementPtrInst *cloneImpl() const; + LLVM_ABI GetElementPtrInst *cloneImpl() const; public: static GetElementPtrInst *Create(Type *PointeeType, Value *Ptr, @@ -1018,17 +1025,17 @@ public: /// /// Null is returned if the indices are invalid for the specified /// source element type. - static Type *getIndexedType(Type *Ty, ArrayRef<Value *> IdxList); - static Type *getIndexedType(Type *Ty, ArrayRef<Constant *> IdxList); - static Type *getIndexedType(Type *Ty, ArrayRef<uint64_t> IdxList); + LLVM_ABI static Type *getIndexedType(Type *Ty, ArrayRef<Value *> IdxList); + LLVM_ABI static Type *getIndexedType(Type *Ty, ArrayRef<Constant *> IdxList); + LLVM_ABI static Type *getIndexedType(Type *Ty, ArrayRef<uint64_t> IdxList); /// Return the type of the element at the given index of an indexable /// type. This is equivalent to "getIndexedType(Agg, {Zero, Idx})". /// /// Returns null if the type can't be indexed, or the given index is not /// legal for the given type. - static Type *getTypeAtIndex(Type *Ty, Value *Idx); - static Type *getTypeAtIndex(Type *Ty, uint64_t Idx); + LLVM_ABI static Type *getTypeAtIndex(Type *Ty, Value *Idx); + LLVM_ABI static Type *getTypeAtIndex(Type *Ty, uint64_t Idx); inline op_iterator idx_begin() { return op_begin()+1; } inline const_op_iterator idx_begin() const { return op_begin()+1; } @@ -1092,32 +1099,32 @@ public: /// Return true if all of the indices of this GEP are /// zeros. If so, the result pointer and the first operand have the same /// value, just potentially different types. - bool hasAllZeroIndices() const; + LLVM_ABI bool hasAllZeroIndices() const; /// Return true if all of the indices of this GEP are /// constant integers. If so, the result pointer and the first operand have /// a constant offset between them. - bool hasAllConstantIndices() const; + LLVM_ABI bool hasAllConstantIndices() const; /// Set nowrap flags for GEP instruction. - void setNoWrapFlags(GEPNoWrapFlags NW); + LLVM_ABI void setNoWrapFlags(GEPNoWrapFlags NW); /// Set or clear the inbounds flag on this GEP instruction. /// See LangRef.html for the meaning of inbounds on a getelementptr. /// TODO: Remove this method in favor of setNoWrapFlags(). - void setIsInBounds(bool b = true); + LLVM_ABI void setIsInBounds(bool b = true); /// Get the nowrap flags for the GEP instruction. - GEPNoWrapFlags getNoWrapFlags() const; + LLVM_ABI GEPNoWrapFlags getNoWrapFlags() const; /// Determine whether the GEP has the inbounds flag. - bool isInBounds() const; + LLVM_ABI bool isInBounds() const; /// Determine whether the GEP has the nusw flag. - bool hasNoUnsignedSignedWrap() const; + LLVM_ABI bool hasNoUnsignedSignedWrap() const; /// Determine whether the GEP has the nuw flag. - bool hasNoUnsignedWrap() const; + LLVM_ABI bool hasNoUnsignedWrap() const; /// Accumulate the constant address offset of this GEP if possible. /// @@ -1127,10 +1134,12 @@ public: /// undefined (it is *not* preserved!). The APInt passed into this routine /// must be at least as wide as the IntPtr type for the address space of /// the base GEP pointer. - bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const; - bool collectOffset(const DataLayout &DL, unsigned BitWidth, - SmallMapVector<Value *, APInt, 4> &VariableOffsets, - APInt &ConstantOffset) const; + LLVM_ABI bool accumulateConstantOffset(const DataLayout &DL, + APInt &Offset) const; + LLVM_ABI bool + collectOffset(const DataLayout &DL, unsigned BitWidth, + SmallMapVector<Value *, APInt, 4> &VariableOffsets, + APInt &ConstantOffset) const; // Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Instruction *I) { return (I->getOpcode() == Instruction::GetElementPtr); @@ -1184,7 +1193,7 @@ protected: friend class Instruction; /// Clone an identical ICmpInst - ICmpInst *cloneImpl() const; + LLVM_ABI ICmpInst *cloneImpl() const; public: /// Constructor with insertion semantics. @@ -1262,7 +1271,7 @@ public: } /// Return the signed version of the predicate: static variant. - static Predicate getSignedPredicate(Predicate Pred); + LLVM_ABI static Predicate getSignedPredicate(Predicate Pred); /// For example, EQ->EQ, SLE->ULE, UGT->UGT, etc. /// @returns the predicate that would be the result if the operand were @@ -1273,13 +1282,13 @@ public: } /// Return the unsigned version of the predicate: static variant. - static Predicate getUnsignedPredicate(Predicate Pred); + LLVM_ABI static Predicate getUnsignedPredicate(Predicate Pred); /// For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->EQ /// @returns the unsigned version of the signed predicate pred or /// the signed version of the signed predicate pred. /// Static variant. - static Predicate getFlippedSignednessPredicate(Predicate Pred); + LLVM_ABI static Predicate getFlippedSignednessPredicate(Predicate Pred); /// For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->EQ /// @returns the unsigned version of the signed predicate pred or @@ -1290,8 +1299,8 @@ public: /// Determine if Pred1 implies Pred2 is true, false, or if nothing can be /// inferred about the implication, when two compares have matching operands. - static std::optional<bool> isImpliedByMatchingCmp(CmpPredicate Pred1, - CmpPredicate Pred2); + LLVM_ABI static std::optional<bool> + isImpliedByMatchingCmp(CmpPredicate Pred1, CmpPredicate Pred2); void setSameSign(bool B = true) { SubclassOptionalData = (SubclassOptionalData & ~SameSign) | (B * SameSign); @@ -1373,13 +1382,13 @@ public: } /// Return result of `LHS Pred RHS` comparison. - static bool compare(const APInt &LHS, const APInt &RHS, - ICmpInst::Predicate Pred); + LLVM_ABI static bool compare(const APInt &LHS, const APInt &RHS, + ICmpInst::Predicate Pred); /// Return result of `LHS Pred RHS`, if it can be determined from the /// KnownBits. Otherwise return nullopt. - static std::optional<bool> compare(const KnownBits &LHS, const KnownBits &RHS, - ICmpInst::Predicate Pred); + LLVM_ABI static std::optional<bool> + compare(const KnownBits &LHS, const KnownBits &RHS, ICmpInst::Predicate Pred); // Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Instruction *I) { @@ -1413,7 +1422,7 @@ protected: friend class Instruction; /// Clone an identical FCmpInst - FCmpInst *cloneImpl() const; + LLVM_ABI FCmpInst *cloneImpl() const; public: /// Constructor with insertion semantics. @@ -1480,8 +1489,8 @@ public: static auto predicates() { return FCmpPredicates(); } /// Return result of `LHS Pred RHS` comparison. - static bool compare(const APFloat &LHS, const APFloat &RHS, - FCmpInst::Predicate Pred); + LLVM_ABI static bool compare(const APFloat &LHS, const APFloat &RHS, + FCmpInst::Predicate Pred); /// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Instruction *I) { @@ -1511,11 +1520,11 @@ class CallInst : public CallBase { InsertPosition InsertBefore) : CallInst(Ty, Func, Args, {}, NameStr, AllocInfo, InsertBefore) {} - explicit CallInst(FunctionType *Ty, Value *F, const Twine &NameStr, - AllocInfo AllocInfo, InsertPosition InsertBefore); + LLVM_ABI explicit CallInst(FunctionType *Ty, Value *F, const Twine &NameStr, + AllocInfo AllocInfo, InsertPosition InsertBefore); - void init(FunctionType *FTy, Value *Func, ArrayRef<Value *> Args, - ArrayRef<OperandBundleDef> Bundles, const Twine &NameStr); + LLVM_ABI void init(FunctionType *FTy, Value *Func, ArrayRef<Value *> Args, + ArrayRef<OperandBundleDef> Bundles, const Twine &NameStr); void init(FunctionType *FTy, Value *Func, const Twine &NameStr); /// Compute the number of operands to allocate. @@ -1530,7 +1539,7 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - CallInst *cloneImpl() const; + LLVM_ABI CallInst *cloneImpl() const; public: static CallInst *Create(FunctionType *Ty, Value *F, const Twine &NameStr = "", @@ -1587,8 +1596,9 @@ public: /// The returned call instruction is identical \p CI in every way except that /// the operand bundles for the new instruction are set to the operand bundles /// in \p Bundles. - static CallInst *Create(CallInst *CI, ArrayRef<OperandBundleDef> Bundles, - InsertPosition InsertPt = nullptr); + LLVM_ABI static CallInst *Create(CallInst *CI, + ArrayRef<OperandBundleDef> Bundles, + InsertPosition InsertPt = nullptr); // Note that 'musttail' implies 'tail'. enum TailCallKind : unsigned { @@ -1649,7 +1659,7 @@ public: } /// Updates profile metadata by scaling it by \p S / \p T. - void updateProfWeight(uint64_t S, uint64_t T); + LLVM_ABI void updateProfWeight(uint64_t S, uint64_t T); private: // Shadow Instruction::setInstructionSubclassData with a private forwarding @@ -1698,7 +1708,7 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - SelectInst *cloneImpl() const; + LLVM_ABI SelectInst *cloneImpl() const; public: static SelectInst *Create(Value *C, Value *S1, Value *S2, @@ -1729,7 +1739,8 @@ public: /// Return a string if the specified operands are invalid /// for a select operation, otherwise return null. - static const char *areInvalidOperands(Value *Cond, Value *True, Value *False); + LLVM_ABI static const char *areInvalidOperands(Value *Cond, Value *True, + Value *False); /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -1765,7 +1776,7 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - VAArgInst *cloneImpl() const; + LLVM_ABI VAArgInst *cloneImpl() const; public: VAArgInst(Value *List, Type *Ty, const Twine &NameStr = "", @@ -1797,14 +1808,14 @@ public: class ExtractElementInst : public Instruction { constexpr static IntrusiveOperandsAllocMarker AllocMarker{2}; - ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr = "", - InsertPosition InsertBefore = nullptr); + LLVM_ABI ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr = "", + InsertPosition InsertBefore = nullptr); protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - ExtractElementInst *cloneImpl() const; + LLVM_ABI ExtractElementInst *cloneImpl() const; public: static ExtractElementInst *Create(Value *Vec, Value *Idx, @@ -1816,7 +1827,7 @@ public: /// Return true if an extractelement instruction can be /// formed with the specified operands. - static bool isValidOperands(const Value *Vec, const Value *Idx); + LLVM_ABI static bool isValidOperands(const Value *Vec, const Value *Idx); Value *getVectorOperand() { return Op<0>(); } Value *getIndexOperand() { return Op<1>(); } @@ -1856,15 +1867,15 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractElementInst, Value) class InsertElementInst : public Instruction { constexpr static IntrusiveOperandsAllocMarker AllocMarker{3}; - InsertElementInst(Value *Vec, Value *NewElt, Value *Idx, - const Twine &NameStr = "", - InsertPosition InsertBefore = nullptr); + LLVM_ABI InsertElementInst(Value *Vec, Value *NewElt, Value *Idx, + const Twine &NameStr = "", + InsertPosition InsertBefore = nullptr); protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - InsertElementInst *cloneImpl() const; + LLVM_ABI InsertElementInst *cloneImpl() const; public: static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx, @@ -1876,8 +1887,8 @@ public: /// Return true if an insertelement instruction can be /// formed with the specified operands. - static bool isValidOperands(const Value *Vec, const Value *NewElt, - const Value *Idx); + LLVM_ABI static bool isValidOperands(const Value *Vec, const Value *NewElt, + const Value *Idx); /// Overload to return most specific vector type. /// @@ -1930,33 +1941,34 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - ShuffleVectorInst *cloneImpl() const; + LLVM_ABI ShuffleVectorInst *cloneImpl() const; public: - ShuffleVectorInst(Value *V1, Value *Mask, const Twine &NameStr = "", - InsertPosition InsertBefore = nullptr); - ShuffleVectorInst(Value *V1, ArrayRef<int> Mask, const Twine &NameStr = "", - InsertPosition InsertBefore = nullptr); - ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, - const Twine &NameStr = "", - InsertPosition InsertBefore = nullptr); - ShuffleVectorInst(Value *V1, Value *V2, ArrayRef<int> Mask, - const Twine &NameStr = "", - InsertPosition InsertBefore = nullptr); + LLVM_ABI ShuffleVectorInst(Value *V1, Value *Mask, const Twine &NameStr = "", + InsertPosition InsertBefore = nullptr); + LLVM_ABI ShuffleVectorInst(Value *V1, ArrayRef<int> Mask, + const Twine &NameStr = "", + InsertPosition InsertBefore = nullptr); + LLVM_ABI ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, + const Twine &NameStr = "", + InsertPosition InsertBefore = nullptr); + LLVM_ABI ShuffleVectorInst(Value *V1, Value *V2, ArrayRef<int> Mask, + const Twine &NameStr = "", + InsertPosition InsertBefore = nullptr); void *operator new(size_t S) { return User::operator new(S, AllocMarker); } void operator delete(void *Ptr) { return User::operator delete(Ptr); } /// Swap the operands and adjust the mask to preserve the semantics /// of the instruction. - void commute(); + LLVM_ABI void commute(); /// Return true if a shufflevector instruction can be /// formed with the specified operands. - static bool isValidOperands(const Value *V1, const Value *V2, - const Value *Mask); - static bool isValidOperands(const Value *V1, const Value *V2, - ArrayRef<int> Mask); + LLVM_ABI static bool isValidOperands(const Value *V1, const Value *V2, + const Value *Mask); + LLVM_ABI static bool isValidOperands(const Value *V1, const Value *V2, + ArrayRef<int> Mask); /// Overload to return most specific vector type. /// @@ -1973,8 +1985,8 @@ public: /// Convert the input shuffle mask operand to a vector of integers. Undefined /// elements of the mask are returned as PoisonMaskElem. - static void getShuffleMask(const Constant *Mask, - SmallVectorImpl<int> &Result); + LLVM_ABI static void getShuffleMask(const Constant *Mask, + SmallVectorImpl<int> &Result); /// Return the mask for this instruction as a vector of integers. Undefined /// elements of the mask are returned as PoisonMaskElem. @@ -1988,10 +2000,10 @@ public: /// shufflevector. Constant *getShuffleMaskForBitcode() const { return ShuffleMaskForBitcode; } - static Constant *convertShuffleMaskForBitcode(ArrayRef<int> Mask, - Type *ResultTy); + LLVM_ABI static Constant *convertShuffleMaskForBitcode(ArrayRef<int> Mask, + Type *ResultTy); - void setShuffleMask(ArrayRef<int> Mask); + LLVM_ABI void setShuffleMask(ArrayRef<int> Mask); ArrayRef<int> getShuffleMask() const { return ShuffleMask; } @@ -2023,7 +2035,7 @@ public: /// Example: <7,5,undef,7> /// This assumes that vector operands (of length \p NumSrcElts) are the same /// length as the mask. - static bool isSingleSourceMask(ArrayRef<int> Mask, int NumSrcElts); + LLVM_ABI static bool isSingleSourceMask(ArrayRef<int> Mask, int NumSrcElts); static bool isSingleSourceMask(const Constant *Mask, int NumSrcElts) { assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant."); SmallVector<int, 16> MaskAsInts; @@ -2045,7 +2057,7 @@ public: /// necessarily a no-op because it may change the number of elements from its /// input vectors or it may provide demanded bits knowledge via undef lanes. /// Example: <undef,undef,2,3> - static bool isIdentityMask(ArrayRef<int> Mask, int NumSrcElts); + LLVM_ABI static bool isIdentityMask(ArrayRef<int> Mask, int NumSrcElts); static bool isIdentityMask(const Constant *Mask, int NumSrcElts) { assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant."); @@ -2074,16 +2086,16 @@ public: /// Return true if this shuffle lengthens exactly one source vector with /// undefs in the high elements. - bool isIdentityWithPadding() const; + LLVM_ABI bool isIdentityWithPadding() const; /// Return true if this shuffle extracts the first N elements of exactly one /// source vector. - bool isIdentityWithExtract() const; + LLVM_ABI bool isIdentityWithExtract() const; /// Return true if this shuffle concatenates its 2 source vectors. This /// returns false if either input is undefined. In that case, the shuffle is /// is better classified as an identity with padding operation. - bool isConcat() const; + LLVM_ABI bool isConcat() const; /// Return true if this shuffle mask chooses elements from its source vectors /// without lane crossings. A shuffle using this mask would be @@ -2093,7 +2105,7 @@ public: /// In that case, the shuffle is better classified as an identity shuffle. /// This assumes that vector operands are the same length as the mask /// (a length-changing shuffle can never be equivalent to a vector select). - static bool isSelectMask(ArrayRef<int> Mask, int NumSrcElts); + LLVM_ABI static bool isSelectMask(ArrayRef<int> Mask, int NumSrcElts); static bool isSelectMask(const Constant *Mask, int NumSrcElts) { assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant."); SmallVector<int, 16> MaskAsInts; @@ -2118,7 +2130,7 @@ public: /// Example: <7,6,undef,4> /// This assumes that vector operands (of length \p NumSrcElts) are the same /// length as the mask. - static bool isReverseMask(ArrayRef<int> Mask, int NumSrcElts); + LLVM_ABI static bool isReverseMask(ArrayRef<int> Mask, int NumSrcElts); static bool isReverseMask(const Constant *Mask, int NumSrcElts) { assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant."); SmallVector<int, 16> MaskAsInts; @@ -2139,7 +2151,7 @@ public: /// Example: <4,undef,undef,4> /// This assumes that vector operands (of length \p NumSrcElts) are the same /// length as the mask. - static bool isZeroEltSplatMask(ArrayRef<int> Mask, int NumSrcElts); + LLVM_ABI static bool isZeroEltSplatMask(ArrayRef<int> Mask, int NumSrcElts); static bool isZeroEltSplatMask(const Constant *Mask, int NumSrcElts) { assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant."); SmallVector<int, 16> MaskAsInts; @@ -2190,7 +2202,7 @@ public: /// ; Transposed matrix /// t0 = < a, e, c, g > = shufflevector m0, m1 < 0, 4, 2, 6 > /// t1 = < b, f, d, h > = shufflevector m0, m1 < 1, 5, 3, 7 > - static bool isTransposeMask(ArrayRef<int> Mask, int NumSrcElts); + LLVM_ABI static bool isTransposeMask(ArrayRef<int> Mask, int NumSrcElts); static bool isTransposeMask(const Constant *Mask, int NumSrcElts) { assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant."); SmallVector<int, 16> MaskAsInts; @@ -2213,7 +2225,8 @@ public: /// Example: shufflevector <4 x n> A, <4 x n> B, <1,2,3,4> /// This assumes that vector operands (of length \p NumSrcElts) are the same /// length as the mask. - static bool isSpliceMask(ArrayRef<int> Mask, int NumSrcElts, int &Index); + LLVM_ABI static bool isSpliceMask(ArrayRef<int> Mask, int NumSrcElts, + int &Index); static bool isSpliceMask(const Constant *Mask, int NumSrcElts, int &Index) { assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant."); SmallVector<int, 16> MaskAsInts; @@ -2233,8 +2246,8 @@ public: /// Return true if this shuffle mask is an extract subvector mask. /// A valid extract subvector mask returns a smaller vector from a single /// source operand. The base extraction index is returned as well. - static bool isExtractSubvectorMask(ArrayRef<int> Mask, int NumSrcElts, - int &Index); + LLVM_ABI static bool isExtractSubvectorMask(ArrayRef<int> Mask, + int NumSrcElts, int &Index); static bool isExtractSubvectorMask(const Constant *Mask, int NumSrcElts, int &Index) { assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant."); @@ -2263,8 +2276,8 @@ public: /// A valid insert subvector mask inserts the lowest elements of a second /// source operand into an in-place first source operand. /// Both the sub vector width and the insertion index is returned. - static bool isInsertSubvectorMask(ArrayRef<int> Mask, int NumSrcElts, - int &NumSubElts, int &Index); + LLVM_ABI static bool isInsertSubvectorMask(ArrayRef<int> Mask, int NumSrcElts, + int &NumSubElts, int &Index); static bool isInsertSubvectorMask(const Constant *Mask, int NumSrcElts, int &NumSubElts, int &Index) { assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant."); @@ -2293,8 +2306,8 @@ public: /// in a vector \p ReplicationFactor times. /// For example, the mask for \p ReplicationFactor=3 and \p VF=4 is: /// <0,0,0,1,1,1,2,2,2,3,3,3> - static bool isReplicationMask(ArrayRef<int> Mask, int &ReplicationFactor, - int &VF); + LLVM_ABI static bool isReplicationMask(ArrayRef<int> Mask, + int &ReplicationFactor, int &VF); static bool isReplicationMask(const Constant *Mask, int &ReplicationFactor, int &VF) { assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant."); @@ -2308,7 +2321,7 @@ public: } /// Return true if this shuffle mask is a replication mask. - bool isReplicationMask(int &ReplicationFactor, int &VF) const; + LLVM_ABI bool isReplicationMask(int &ReplicationFactor, int &VF) const; /// Return true if this shuffle mask represents "clustered" mask of size VF, /// i.e. each index between [0..VF) is used exactly once in each submask of @@ -2319,11 +2332,11 @@ public: /// 0, 1, 2, 3, 3, 3, 1, 0 - not "clustered", because /// element 3 is used twice in the second submask /// (3,3,1,0) and index 2 is not used at all. - static bool isOneUseSingleSourceMask(ArrayRef<int> Mask, int VF); + LLVM_ABI static bool isOneUseSingleSourceMask(ArrayRef<int> Mask, int VF); /// Return true if this shuffle mask is a one-use-single-source("clustered") /// mask. - bool isOneUseSingleSourceMask(int VF) const; + LLVM_ABI bool isOneUseSingleSourceMask(int VF) const; /// Change values in a shuffle permute mask assuming the two vector operands /// of length InVecNumElts have swapped position. @@ -2339,7 +2352,7 @@ public: } /// Return if this shuffle interleaves its two input vectors together. - bool isInterleave(unsigned Factor); + LLVM_ABI bool isInterleave(unsigned Factor); /// Return true if the mask interleaves one or more input vectors together. /// @@ -2360,9 +2373,9 @@ public: /// Note that this does not check if the input vectors are consecutive: /// It will return true for masks such as /// <0, 4, 6, 1, 5, 7> (Factor=3, LaneLen=2) - static bool isInterleaveMask(ArrayRef<int> Mask, unsigned Factor, - unsigned NumInputElts, - SmallVectorImpl<unsigned> &StartIndexes); + LLVM_ABI static bool + isInterleaveMask(ArrayRef<int> Mask, unsigned Factor, unsigned NumInputElts, + SmallVectorImpl<unsigned> &StartIndexes); static bool isInterleaveMask(ArrayRef<int> Mask, unsigned Factor, unsigned NumInputElts) { SmallVector<unsigned, 8> StartIndexes; @@ -2372,8 +2385,9 @@ public: /// Check if the mask is a DE-interleave mask of the given factor /// \p Factor like: /// <Index, Index+Factor, ..., Index+(NumElts-1)*Factor> - static bool isDeInterleaveMaskOfFactor(ArrayRef<int> Mask, unsigned Factor, - unsigned &Index); + LLVM_ABI static bool isDeInterleaveMaskOfFactor(ArrayRef<int> Mask, + unsigned Factor, + unsigned &Index); static bool isDeInterleaveMaskOfFactor(ArrayRef<int> Mask, unsigned Factor) { unsigned Unused; return isDeInterleaveMaskOfFactor(Mask, Factor, Unused); @@ -2390,9 +2404,11 @@ public: /// /// If it can be expressed as a rotation, returns the number of subelements to /// group by in NumSubElts and the number of bits to rotate left in RotateAmt. - static bool isBitRotateMask(ArrayRef<int> Mask, unsigned EltSizeInBits, - unsigned MinSubElts, unsigned MaxSubElts, - unsigned &NumSubElts, unsigned &RotateAmt); + LLVM_ABI static bool isBitRotateMask(ArrayRef<int> Mask, + unsigned EltSizeInBits, + unsigned MinSubElts, unsigned MaxSubElts, + unsigned &NumSubElts, + unsigned &RotateAmt); // Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Instruction *I) { @@ -2428,13 +2444,13 @@ class ExtractValueInst : public UnaryInstruction { inline ExtractValueInst(Value *Agg, ArrayRef<unsigned> Idxs, const Twine &NameStr, InsertPosition InsertBefore); - void init(ArrayRef<unsigned> Idxs, const Twine &NameStr); + LLVM_ABI void init(ArrayRef<unsigned> Idxs, const Twine &NameStr); protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - ExtractValueInst *cloneImpl() const; + LLVM_ABI ExtractValueInst *cloneImpl() const; public: static ExtractValueInst *Create(Value *Agg, ArrayRef<unsigned> Idxs, @@ -2448,7 +2464,7 @@ public: /// with an extractvalue instruction with the specified parameters. /// /// Null is returned if the indices are invalid for the specified type. - static Type *getIndexedType(Type *Agg, ArrayRef<unsigned> Idxs); + LLVM_ABI static Type *getIndexedType(Type *Agg, ArrayRef<unsigned> Idxs); using idx_iterator = const unsigned*; @@ -2524,14 +2540,14 @@ class InsertValueInst : public Instruction { const Twine &NameStr = "", InsertPosition InsertBefore = nullptr); - void init(Value *Agg, Value *Val, ArrayRef<unsigned> Idxs, - const Twine &NameStr); + LLVM_ABI void init(Value *Agg, Value *Val, ArrayRef<unsigned> Idxs, + const Twine &NameStr); protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - InsertValueInst *cloneImpl() const; + LLVM_ABI InsertValueInst *cloneImpl() const; public: // allocate space for exactly two operands @@ -2642,7 +2658,7 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - PHINode *cloneImpl() const; + LLVM_ABI PHINode *cloneImpl() const; // allocHungoffUses - this is more complicated than the generic // User::allocHungoffUses, because we have to allocate Uses for the incoming @@ -2771,7 +2787,8 @@ public: /// dummy values. The only time there should be zero incoming values to a PHI /// node is when the block is dead, so this strategy is sound. /// - Value *removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty = true); + LLVM_ABI Value *removeIncomingValue(unsigned Idx, + bool DeletePHIIfEmpty = true); Value *removeIncomingValue(const BasicBlock *BB, bool DeletePHIIfEmpty=true) { int Idx = getBasicBlockIndex(BB); @@ -2781,8 +2798,8 @@ public: /// Remove all incoming values for which the predicate returns true. /// The predicate accepts the incoming value index. - void removeIncomingValueIf(function_ref<bool(unsigned)> Predicate, - bool DeletePHIIfEmpty = true); + LLVM_ABI void removeIncomingValueIf(function_ref<bool(unsigned)> Predicate, + bool DeletePHIIfEmpty = true); /// Return the first index of the specified basic /// block in the value list for this PHI. Returns -1 if no instance. @@ -2815,12 +2832,12 @@ public: /// If the specified PHI node always merges together the /// same value, return the value, otherwise return null. - Value *hasConstantValue() const; + LLVM_ABI Value *hasConstantValue() const; /// Whether the specified PHI node always merges /// together the same value, assuming undefs are equal to a unique /// non-undef value. - bool hasConstantOrUndefValue() const; + LLVM_ABI bool hasConstantOrUndefValue() const; /// If the PHI node is complete which means all of its parent's predecessors /// have incoming value in this PHI, return true, otherwise return false. @@ -2840,7 +2857,7 @@ public: } private: - void growOperands(); + LLVM_ABI void growOperands(); }; template <> struct OperandTraits<PHINode> : public HungoffOperandTraits {}; @@ -2880,23 +2897,24 @@ private: // Allocate space for exactly zero operands. void *operator new(size_t S) { return User::operator new(S, AllocMarker); } - void growOperands(unsigned Size); + LLVM_ABI void growOperands(unsigned Size); void init(unsigned NumReservedValues, const Twine &NameStr); protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - LandingPadInst *cloneImpl() const; + LLVM_ABI LandingPadInst *cloneImpl() const; public: void operator delete(void *Ptr) { User::operator delete(Ptr); } /// Constructors - NumReservedClauses is a hint for the number of incoming /// clauses that this landingpad will have (use 0 if you really have no idea). - static LandingPadInst *Create(Type *RetTy, unsigned NumReservedClauses, - const Twine &NameStr = "", - InsertPosition InsertBefore = nullptr); + LLVM_ABI static LandingPadInst *Create(Type *RetTy, + unsigned NumReservedClauses, + const Twine &NameStr = "", + InsertPosition InsertBefore = nullptr); /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -2910,7 +2928,7 @@ public: void setCleanup(bool V) { setSubclassData<CleanupField>(V); } /// Add a catch or filter clause to the landing pad. - void addClause(Constant *ClauseVal); + LLVM_ABI void addClause(Constant *ClauseVal); /// Get the value of the clause at index Idx. Use isCatch/isFilter to /// determine what type of clause this is. @@ -2974,14 +2992,15 @@ private: // // NOTE: If the Value* passed is of type void then the constructor behaves as // if it was passed NULL. - explicit ReturnInst(LLVMContext &C, Value *retVal, AllocInfo AllocInfo, - InsertPosition InsertBefore); + LLVM_ABI explicit ReturnInst(LLVMContext &C, Value *retVal, + AllocInfo AllocInfo, + InsertPosition InsertBefore); protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - ReturnInst *cloneImpl() const; + LLVM_ABI ReturnInst *cloneImpl() const; public: static ReturnInst *Create(LLVMContext &C, Value *retVal = nullptr, @@ -3050,10 +3069,10 @@ class BranchInst : public Instruction { // BranchInst(BB* T, BB *F, Value *C, Inst *I) - 'br C, T, F', insert before I // BranchInst(BB* B, BB *I) - 'br B' insert at end // BranchInst(BB* T, BB *F, Value *C, BB *I) - 'br C, T, F', insert at end - explicit BranchInst(BasicBlock *IfTrue, AllocInfo AllocInfo, - InsertPosition InsertBefore); - BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, - AllocInfo AllocInfo, InsertPosition InsertBefore); + LLVM_ABI explicit BranchInst(BasicBlock *IfTrue, AllocInfo AllocInfo, + InsertPosition InsertBefore); + LLVM_ABI BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, + AllocInfo AllocInfo, InsertPosition InsertBefore); void AssertOK(); @@ -3061,7 +3080,7 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - BranchInst *cloneImpl() const; + LLVM_ABI BranchInst *cloneImpl() const; public: /// Iterator type that casts an operand to a basic block. @@ -3138,7 +3157,7 @@ public: /// Swaps the successors of the branch instruction. This also swaps any /// branch weight metadata associated with the instruction so that it /// continues to map correctly to each operand. - void swapSuccessors(); + LLVM_ABI void swapSuccessors(); iterator_range<succ_op_iterator> successors() { return make_range( @@ -3188,8 +3207,8 @@ class SwitchInst : public Instruction { /// default destination. The number of additional cases can be specified here /// to make memory allocation more efficient. This constructor can also /// auto-insert before another instruction. - SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases, - InsertPosition InsertBefore); + LLVM_ABI SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases, + InsertPosition InsertBefore); // allocate space for exactly zero operands void *operator new(size_t S) { return User::operator new(S, AllocMarker); } @@ -3201,7 +3220,7 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - SwitchInst *cloneImpl() const; + LLVM_ABI SwitchInst *cloneImpl() const; public: void operator delete(void *Ptr) { User::operator delete(Ptr); } @@ -3479,7 +3498,7 @@ public: /// Note: /// This action invalidates case_end(). Old case_end() iterator will /// point to the added case. - void addCase(ConstantInt *OnVal, BasicBlock *Dest); + LLVM_ABI void addCase(ConstantInt *OnVal, BasicBlock *Dest); /// This method removes the specified case and its successor from the switch /// instruction. Note that this operation may reorder the remaining cases at @@ -3488,7 +3507,7 @@ public: /// This action invalidates iterators for all cases following the one removed, /// including the case_end() iterator. It returns an iterator for the next /// case. - CaseIt removeCase(CaseIt I); + LLVM_ABI CaseIt removeCase(CaseIt I); unsigned getNumSuccessors() const { return getNumOperands()/2; } BasicBlock *getSuccessor(unsigned idx) const { @@ -3517,9 +3536,9 @@ class SwitchInstProfUpdateWrapper { bool Changed = false; protected: - MDNode *buildProfBranchWeightsMD(); + LLVM_ABI MDNode *buildProfBranchWeightsMD(); - void init(); + LLVM_ABI void init(); public: using CaseWeightOpt = std::optional<uint32_t>; @@ -3536,20 +3555,21 @@ public: /// Delegate the call to the underlying SwitchInst::removeCase() and remove /// correspondent branch weight. - SwitchInst::CaseIt removeCase(SwitchInst::CaseIt I); + LLVM_ABI SwitchInst::CaseIt removeCase(SwitchInst::CaseIt I); /// Delegate the call to the underlying SwitchInst::addCase() and set the /// specified branch weight for the added case. - void addCase(ConstantInt *OnVal, BasicBlock *Dest, CaseWeightOpt W); + LLVM_ABI void addCase(ConstantInt *OnVal, BasicBlock *Dest, CaseWeightOpt W); /// Delegate the call to the underlying SwitchInst::eraseFromParent() and mark /// this object to not touch the underlying SwitchInst in destructor. - Instruction::InstListType::iterator eraseFromParent(); + LLVM_ABI Instruction::InstListType::iterator eraseFromParent(); - void setSuccessorWeight(unsigned idx, CaseWeightOpt W); - CaseWeightOpt getSuccessorWeight(unsigned idx); + LLVM_ABI void setSuccessorWeight(unsigned idx, CaseWeightOpt W); + LLVM_ABI CaseWeightOpt getSuccessorWeight(unsigned idx); - static CaseWeightOpt getSuccessorWeight(const SwitchInst &SI, unsigned idx); + LLVM_ABI static CaseWeightOpt getSuccessorWeight(const SwitchInst &SI, + unsigned idx); }; template <> struct OperandTraits<SwitchInst> : public HungoffOperandTraits {}; @@ -3576,8 +3596,8 @@ class IndirectBrInst : public Instruction { /// Address to jump to. The number of expected destinations can be specified /// here to make memory allocation more efficient. This constructor can also /// autoinsert before another instruction. - IndirectBrInst(Value *Address, unsigned NumDests, - InsertPosition InsertBefore); + LLVM_ABI IndirectBrInst(Value *Address, unsigned NumDests, + InsertPosition InsertBefore); // allocate space for exactly zero operands void *operator new(size_t S) { return User::operator new(S, AllocMarker); } @@ -3589,7 +3609,7 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - IndirectBrInst *cloneImpl() const; + LLVM_ABI IndirectBrInst *cloneImpl() const; public: void operator delete(void *Ptr) { User::operator delete(Ptr); } @@ -3644,11 +3664,11 @@ public: /// Add a destination. /// - void addDestination(BasicBlock *Dest); + LLVM_ABI void addDestination(BasicBlock *Dest); /// This method removes the specified successor from the /// indirectbr instruction. - void removeDestination(unsigned i); + LLVM_ABI void removeDestination(unsigned i); unsigned getNumSuccessors() const { return getNumOperands()-1; } BasicBlock *getSuccessor(unsigned i) const { @@ -3710,9 +3730,9 @@ class InvokeInst : public CallBase { ArrayRef<OperandBundleDef> Bundles, AllocInfo AllocInfo, const Twine &NameStr, InsertPosition InsertBefore); - void init(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, - BasicBlock *IfException, ArrayRef<Value *> Args, - ArrayRef<OperandBundleDef> Bundles, const Twine &NameStr); + LLVM_ABI void init(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, + BasicBlock *IfException, ArrayRef<Value *> Args, + ArrayRef<OperandBundleDef> Bundles, const Twine &NameStr); /// Compute the number of operands to allocate. static unsigned ComputeNumOperands(unsigned NumArgs, @@ -3726,7 +3746,7 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - InvokeInst *cloneImpl() const; + LLVM_ABI InvokeInst *cloneImpl() const; public: static InvokeInst *Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, @@ -3776,8 +3796,9 @@ public: /// The returned invoke instruction is identical to \p II in every way except /// that the operand bundles for the new instruction are set to the operand /// bundles in \p Bundles. - static InvokeInst *Create(InvokeInst *II, ArrayRef<OperandBundleDef> Bundles, - InsertPosition InsertPt = nullptr); + LLVM_ABI static InvokeInst *Create(InvokeInst *II, + ArrayRef<OperandBundleDef> Bundles, + InsertPosition InsertPt = nullptr); // get*Dest - Return the destination basic blocks... BasicBlock *getNormalDest() const { @@ -3795,7 +3816,7 @@ public: /// Get the landingpad instruction from the landing pad /// block (the unwind destination). - LandingPadInst *getLandingPadInst() const; + LLVM_ABI LandingPadInst *getLandingPadInst() const; BasicBlock *getSuccessor(unsigned i) const { assert(i < 2 && "Successor # out of range for invoke!"); @@ -3813,7 +3834,7 @@ public: unsigned getNumSuccessors() const { return 2; } /// Updates profile metadata by scaling it by \p S / \p T. - void updateProfWeight(uint64_t S, uint64_t T); + LLVM_ABI void updateProfWeight(uint64_t S, uint64_t T); // Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Instruction *I) { @@ -3864,9 +3885,10 @@ class CallBrInst : public CallBase { AllocInfo AllocInfo, const Twine &NameStr, InsertPosition InsertBefore); - void init(FunctionType *FTy, Value *Func, BasicBlock *DefaultDest, - ArrayRef<BasicBlock *> IndirectDests, ArrayRef<Value *> Args, - ArrayRef<OperandBundleDef> Bundles, const Twine &NameStr); + LLVM_ABI void init(FunctionType *FTy, Value *Func, BasicBlock *DefaultDest, + ArrayRef<BasicBlock *> IndirectDests, + ArrayRef<Value *> Args, ArrayRef<OperandBundleDef> Bundles, + const Twine &NameStr); /// Compute the number of operands to allocate. static unsigned ComputeNumOperands(int NumArgs, int NumIndirectDests, @@ -3880,7 +3902,7 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - CallBrInst *cloneImpl() const; + LLVM_ABI CallBrInst *cloneImpl() const; public: static CallBrInst *Create(FunctionType *Ty, Value *Func, @@ -3934,8 +3956,9 @@ public: /// The returned callbr instruction is identical to \p CBI in every way /// except that the operand bundles for the new instruction are set to the /// operand bundles in \p Bundles. - static CallBrInst *Create(CallBrInst *CBI, ArrayRef<OperandBundleDef> Bundles, - InsertPosition InsertBefore = nullptr); + LLVM_ABI static CallBrInst *Create(CallBrInst *CBI, + ArrayRef<OperandBundleDef> Bundles, + InsertPosition InsertBefore = nullptr); /// Return the number of callbr indirect dest labels. /// @@ -4026,13 +4049,14 @@ class ResumeInst : public Instruction { ResumeInst(const ResumeInst &RI); - explicit ResumeInst(Value *Exn, InsertPosition InsertBefore = nullptr); + LLVM_ABI explicit ResumeInst(Value *Exn, + InsertPosition InsertBefore = nullptr); protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - ResumeInst *cloneImpl() const; + LLVM_ABI ResumeInst *cloneImpl() const; public: static ResumeInst *Create(Value *Exn, InsertPosition InsertBefore = nullptr) { @@ -4093,9 +4117,9 @@ class CatchSwitchInst : public Instruction { /// default destination. The number of additional handlers can be specified /// here to make memory allocation more efficient. /// This constructor can also autoinsert before another instruction. - CatchSwitchInst(Value *ParentPad, BasicBlock *UnwindDest, - unsigned NumHandlers, const Twine &NameStr, - InsertPosition InsertBefore); + LLVM_ABI CatchSwitchInst(Value *ParentPad, BasicBlock *UnwindDest, + unsigned NumHandlers, const Twine &NameStr, + InsertPosition InsertBefore); // allocate space for exactly zero operands void *operator new(size_t S) { return User::operator new(S, AllocMarker); } @@ -4107,7 +4131,7 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - CatchSwitchInst *cloneImpl() const; + LLVM_ABI CatchSwitchInst *cloneImpl() const; public: void operator delete(void *Ptr) { return User::operator delete(Ptr); } @@ -4207,9 +4231,9 @@ public: /// Note: /// This action invalidates handler_end(). Old handler_end() iterator will /// point to the added handler. - void addHandler(BasicBlock *Dest); + LLVM_ABI void addHandler(BasicBlock *Dest); - void removeHandler(handler_iterator HI); + LLVM_ABI void removeHandler(handler_iterator HI); unsigned getNumSuccessors() const { return getNumOperands() - 1; } BasicBlock *getSuccessor(unsigned Idx) const { @@ -4312,7 +4336,8 @@ class CatchReturnInst : public Instruction { constexpr static IntrusiveOperandsAllocMarker AllocMarker{2}; CatchReturnInst(const CatchReturnInst &RI); - CatchReturnInst(Value *CatchPad, BasicBlock *BB, InsertPosition InsertBefore); + LLVM_ABI CatchReturnInst(Value *CatchPad, BasicBlock *BB, + InsertPosition InsertBefore); void init(Value *CatchPad, BasicBlock *BB); @@ -4320,7 +4345,7 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - CatchReturnInst *cloneImpl() const; + LLVM_ABI CatchReturnInst *cloneImpl() const; public: static CatchReturnInst *Create(Value *CatchPad, BasicBlock *BB, @@ -4388,8 +4413,9 @@ class CleanupReturnInst : public Instruction { private: CleanupReturnInst(const CleanupReturnInst &RI, AllocInfo AllocInfo); - CleanupReturnInst(Value *CleanupPad, BasicBlock *UnwindBB, - AllocInfo AllocInfo, InsertPosition InsertBefore = nullptr); + LLVM_ABI CleanupReturnInst(Value *CleanupPad, BasicBlock *UnwindBB, + AllocInfo AllocInfo, + InsertPosition InsertBefore = nullptr); void init(Value *CleanupPad, BasicBlock *UnwindBB); @@ -4397,7 +4423,7 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - CleanupReturnInst *cloneImpl() const; + LLVM_ABI CleanupReturnInst *cloneImpl() const; public: static CleanupReturnInst *Create(Value *CleanupPad, @@ -4487,11 +4513,11 @@ protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; - UnreachableInst *cloneImpl() const; + LLVM_ABI UnreachableInst *cloneImpl() const; public: - explicit UnreachableInst(LLVMContext &C, - InsertPosition InsertBefore = nullptr); + LLVM_ABI explicit UnreachableInst(LLVMContext &C, + InsertPosition InsertBefore = nullptr); // allocate space for exactly zero operands void *operator new(size_t S) { return User::operator new(S, AllocMarker); } @@ -4508,7 +4534,8 @@ public: } // Whether to do target lowering in SelectionDAG. - bool shouldLowerToTrap(bool TrapUnreachable, bool NoTrapAfterNoreturn) const; + LLVM_ABI bool shouldLowerToTrap(bool TrapUnreachable, + bool NoTrapAfterNoreturn) const; private: BasicBlock *getSuccessor(unsigned idx) const { @@ -4531,12 +4558,13 @@ protected: friend class Instruction; /// Clone an identical TruncInst - TruncInst *cloneImpl() const; + LLVM_ABI TruncInst *cloneImpl() const; public: enum { AnyWrap = 0, NoUnsignedWrap = (1 << 0), NoSignedWrap = (1 << 1) }; /// Constructor with insert-before-instruction semantics + LLVM_ABI TruncInst(Value *S, ///< The value to be truncated Type *Ty, ///< The (smaller) type to truncate to const Twine &NameStr = "", ///< A name for the new instruction @@ -4597,10 +4625,11 @@ protected: friend class Instruction; /// Clone an identical ZExtInst - ZExtInst *cloneImpl() const; + LLVM_ABI ZExtInst *cloneImpl() const; public: /// Constructor with insert-before-instruction semantics + LLVM_ABI ZExtInst(Value *S, ///< The value to be zero extended Type *Ty, ///< The type to zero extend to const Twine &NameStr = "", ///< A name for the new instruction @@ -4628,10 +4657,11 @@ protected: friend class Instruction; /// Clone an identical SExtInst - SExtInst *cloneImpl() const; + LLVM_ABI SExtInst *cloneImpl() const; public: /// Constructor with insert-before-instruction semantics + LLVM_ABI SExtInst(Value *S, ///< The value to be sign extended Type *Ty, ///< The type to sign extend to const Twine &NameStr = "", ///< A name for the new instruction @@ -4659,11 +4689,12 @@ protected: friend class Instruction; /// Clone an identical FPTruncInst - FPTruncInst *cloneImpl() const; + LLVM_ABI FPTruncInst *cloneImpl() const; public: /// Constructor with insert-before-instruction semantics - FPTruncInst(Value *S, ///< The value to be truncated - Type *Ty, ///< The type to truncate to + LLVM_ABI + FPTruncInst(Value *S, ///< The value to be truncated + Type *Ty, ///< The type to truncate to const Twine &NameStr = "", ///< A name for the new instruction InsertPosition InsertBefore = nullptr ///< Where to insert the new instruction @@ -4689,10 +4720,11 @@ protected: friend class Instruction; /// Clone an identical FPExtInst - FPExtInst *cloneImpl() const; + LLVM_ABI FPExtInst *cloneImpl() const; public: /// Constructor with insert-before-instruction semantics + LLVM_ABI FPExtInst(Value *S, ///< The value to be extended Type *Ty, ///< The type to extend to const Twine &NameStr = "", ///< A name for the new instruction @@ -4720,10 +4752,11 @@ protected: friend class Instruction; /// Clone an identical UIToFPInst - UIToFPInst *cloneImpl() const; + LLVM_ABI UIToFPInst *cloneImpl() const; public: /// Constructor with insert-before-instruction semantics + LLVM_ABI UIToFPInst(Value *S, ///< The value to be converted Type *Ty, ///< The type to convert to const Twine &NameStr = "", ///< A name for the new instruction @@ -4751,10 +4784,11 @@ protected: friend class Instruction; /// Clone an identical SIToFPInst - SIToFPInst *cloneImpl() const; + LLVM_ABI SIToFPInst *cloneImpl() const; public: /// Constructor with insert-before-instruction semantics + LLVM_ABI SIToFPInst(Value *S, ///< The value to be converted Type *Ty, ///< The type to convert to const Twine &NameStr = "", ///< A name for the new instruction @@ -4782,10 +4816,11 @@ protected: friend class Instruction; /// Clone an identical FPToUIInst - FPToUIInst *cloneImpl() const; + LLVM_ABI FPToUIInst *cloneImpl() const; public: /// Constructor with insert-before-instruction semantics + LLVM_ABI FPToUIInst(Value *S, ///< The value to be converted Type *Ty, ///< The type to convert to const Twine &NameStr = "", ///< A name for the new instruction @@ -4813,10 +4848,11 @@ protected: friend class Instruction; /// Clone an identical FPToSIInst - FPToSIInst *cloneImpl() const; + LLVM_ABI FPToSIInst *cloneImpl() const; public: /// Constructor with insert-before-instruction semantics + LLVM_ABI FPToSIInst(Value *S, ///< The value to be converted Type *Ty, ///< The type to convert to const Twine &NameStr = "", ///< A name for the new instruction @@ -4844,6 +4880,7 @@ public: friend class Instruction; /// Constructor with insert-before-instruction semantics + LLVM_ABI IntToPtrInst(Value *S, ///< The value to be converted Type *Ty, ///< The type to convert to const Twine &NameStr = "", ///< A name for the new instruction @@ -4852,7 +4889,7 @@ public: ); /// Clone an identical IntToPtrInst. - IntToPtrInst *cloneImpl() const; + LLVM_ABI IntToPtrInst *cloneImpl() const; /// Returns the address space of this instruction's pointer type. unsigned getAddressSpace() const { @@ -4879,10 +4916,11 @@ protected: friend class Instruction; /// Clone an identical PtrToIntInst. - PtrToIntInst *cloneImpl() const; + LLVM_ABI PtrToIntInst *cloneImpl() const; public: /// Constructor with insert-before-instruction semantics + LLVM_ABI PtrToIntInst(Value *S, ///< The value to be converted Type *Ty, ///< The type to convert to const Twine &NameStr = "", ///< A name for the new instruction @@ -4922,10 +4960,11 @@ protected: friend class Instruction; /// Clone an identical BitCastInst. - BitCastInst *cloneImpl() const; + LLVM_ABI BitCastInst *cloneImpl() const; public: /// Constructor with insert-before-instruction semantics + LLVM_ABI BitCastInst(Value *S, ///< The value to be casted Type *Ty, ///< The type to casted to const Twine &NameStr = "", ///< A name for the new instruction @@ -4954,11 +4993,11 @@ protected: friend class Instruction; /// Clone an identical AddrSpaceCastInst. - AddrSpaceCastInst *cloneImpl() const; + LLVM_ABI AddrSpaceCastInst *cloneImpl() const; public: /// Constructor with insert-before-instruction semantics - AddrSpaceCastInst( + LLVM_ABI AddrSpaceCastInst( Value *S, ///< The value to be casted Type *Ty, ///< The type to casted to const Twine &NameStr = "", ///< A name for the new instruction @@ -5116,11 +5155,11 @@ protected: friend class Instruction; /// Clone an identical FreezeInst - FreezeInst *cloneImpl() const; + LLVM_ABI FreezeInst *cloneImpl() const; public: - explicit FreezeInst(Value *S, const Twine &NameStr = "", - InsertPosition InsertBefore = nullptr); + LLVM_ABI explicit FreezeInst(Value *S, const Twine &NameStr = "", + InsertPosition InsertBefore = nullptr); // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const Instruction *I) { diff --git a/llvm/include/llvm/IR/IntrinsicInst.h b/llvm/include/llvm/IR/IntrinsicInst.h index 1217a62..74bd22e 100644 --- a/llvm/include/llvm/IR/IntrinsicInst.h +++ b/llvm/include/llvm/IR/IntrinsicInst.h @@ -33,6 +33,7 @@ #include "llvm/IR/Intrinsics.h" #include "llvm/IR/Value.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/MathExtras.h" #include <cassert> #include <cstdint> @@ -126,7 +127,7 @@ public: /// Check if the intrinsic might lower into a regular function call in the /// course of IR transformations - static bool mayLowerToFunctionCall(Intrinsic::ID IID); + LLVM_ABI static bool mayLowerToFunctionCall(Intrinsic::ID IID); /// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const CallInst *I) { @@ -257,8 +258,8 @@ public: /// Get the locations corresponding to the variable referenced by the debug /// info intrinsic. Depending on the intrinsic, this could be the /// variable's value or its address. - iterator_range<location_op_iterator> location_ops() const; - Value *getVariableLocationOp(unsigned OpIdx) const; + LLVM_ABI iterator_range<location_op_iterator> location_ops() const; + LLVM_ABI Value *getVariableLocationOp(unsigned OpIdx) const; unsigned getNumVariableLocationOps() const { if (hasArgList()) return cast<DIArgList>(getRawLocation())->getArgs().size(); @@ -310,18 +311,18 @@ public: /// Get the locations corresponding to the variable referenced by the debug /// info intrinsic. Depending on the intrinsic, this could be the /// variable's value or its address. - iterator_range<location_op_iterator> location_ops() const; + LLVM_ABI iterator_range<location_op_iterator> location_ops() const; - Value *getVariableLocationOp(unsigned OpIdx) const; + LLVM_ABI Value *getVariableLocationOp(unsigned OpIdx) const; - void replaceVariableLocationOp(Value *OldValue, Value *NewValue, - bool AllowEmpty = false); - void replaceVariableLocationOp(unsigned OpIdx, Value *NewValue); + LLVM_ABI void replaceVariableLocationOp(Value *OldValue, Value *NewValue, + bool AllowEmpty = false); + LLVM_ABI void replaceVariableLocationOp(unsigned OpIdx, Value *NewValue); /// Adding a new location operand will always result in this intrinsic using /// an ArgList, and must always be accompanied by a new expression that uses /// the new operand. - void addVariableLocationOps(ArrayRef<Value *> NewValues, - DIExpression *NewExpr); + LLVM_ABI void addVariableLocationOps(ArrayRef<Value *> NewValues, + DIExpression *NewExpr); void setVariable(DILocalVariable *NewVar) { setArgOperand(1, MetadataAsValue::get(NewVar->getContext(), NewVar)); @@ -401,7 +402,7 @@ public: /// Get the size (in bits) of the variable, or fragment of the variable that /// is described. - std::optional<uint64_t> getFragmentSizeInBits() const; + LLVM_ABI std::optional<uint64_t> getFragmentSizeInBits() const; /// Get the FragmentInfo for the variable. std::optional<DIExpression::FragmentInfo> getFragment() const { @@ -500,7 +501,7 @@ class DbgAssignIntrinsic : public DbgValueInst { }; public: - Value *getAddress() const; + LLVM_ABI Value *getAddress() const; Metadata *getRawAddress() const { return cast<MetadataAsValue>(getArgOperand(OpAddress))->getMetadata(); } @@ -518,16 +519,16 @@ public: setArgOperand(OpAddressExpr, MetadataAsValue::get(NewExpr->getContext(), NewExpr)); } - void setAssignId(DIAssignID *New); - void setAddress(Value *V); + LLVM_ABI void setAssignId(DIAssignID *New); + LLVM_ABI void setAddress(Value *V); /// Kill the address component. - void setKillAddress(); + LLVM_ABI void setKillAddress(); /// Check whether this kills the address component. This doesn't take into /// account the position of the intrinsic, therefore a returned value of false /// does not guarentee the address is a valid location for the variable at the /// intrinsic's position in IR. - bool isKillAddress() const; - void setValue(Value *V); + LLVM_ABI bool isKillAddress() const; + LLVM_ABI void setValue(Value *V); /// \name Casting methods /// @{ static bool classof(const IntrinsicInst *I) { @@ -568,51 +569,53 @@ public: /// \brief Declares a llvm.vp.* intrinsic in \p M that matches the parameters /// \p Params. Additionally, the load and gather intrinsics require /// \p ReturnType to be specified. - static Function *getOrInsertDeclarationForParams(Module *M, Intrinsic::ID, - Type *ReturnType, - ArrayRef<Value *> Params); + LLVM_ABI static Function * + getOrInsertDeclarationForParams(Module *M, Intrinsic::ID, Type *ReturnType, + ArrayRef<Value *> Params); - static std::optional<unsigned> getMaskParamPos(Intrinsic::ID IntrinsicID); - static std::optional<unsigned> getVectorLengthParamPos( - Intrinsic::ID IntrinsicID); + LLVM_ABI static std::optional<unsigned> + getMaskParamPos(Intrinsic::ID IntrinsicID); + LLVM_ABI static std::optional<unsigned> + getVectorLengthParamPos(Intrinsic::ID IntrinsicID); /// The llvm.vp.* intrinsics for this instruction Opcode - static Intrinsic::ID getForOpcode(unsigned OC); + LLVM_ABI static Intrinsic::ID getForOpcode(unsigned OC); /// The llvm.vp.* intrinsics for this intrinsic ID \p Id. Return \p Id if it /// is already a VP intrinsic. - static Intrinsic::ID getForIntrinsic(Intrinsic::ID Id); + LLVM_ABI static Intrinsic::ID getForIntrinsic(Intrinsic::ID Id); // Whether \p ID is a VP intrinsic ID. - static bool isVPIntrinsic(Intrinsic::ID); + LLVM_ABI static bool isVPIntrinsic(Intrinsic::ID); /// \return The mask parameter or nullptr. - Value *getMaskParam() const; - void setMaskParam(Value *); + LLVM_ABI Value *getMaskParam() const; + LLVM_ABI void setMaskParam(Value *); /// \return The vector length parameter or nullptr. - Value *getVectorLengthParam() const; - void setVectorLengthParam(Value *); + LLVM_ABI Value *getVectorLengthParam() const; + LLVM_ABI void setVectorLengthParam(Value *); /// \return Whether the vector length param can be ignored. - bool canIgnoreVectorLengthParam() const; + LLVM_ABI bool canIgnoreVectorLengthParam() const; /// \return The static element count (vector number of elements) the vector /// length parameter applies to. - ElementCount getStaticVectorLength() const; + LLVM_ABI ElementCount getStaticVectorLength() const; /// \return The alignment of the pointer used by this load/store/gather or /// scatter. - MaybeAlign getPointerAlignment() const; + LLVM_ABI MaybeAlign getPointerAlignment() const; // MaybeAlign setPointerAlignment(Align NewAlign); // TODO /// \return The pointer operand of this load,store, gather or scatter. - Value *getMemoryPointerParam() const; - static std::optional<unsigned> getMemoryPointerParamPos(Intrinsic::ID); + LLVM_ABI Value *getMemoryPointerParam() const; + LLVM_ABI static std::optional<unsigned> + getMemoryPointerParamPos(Intrinsic::ID); /// \return The data (payload) operand of this store or scatter. - Value *getMemoryDataParam() const; - static std::optional<unsigned> getMemoryDataParamPos(Intrinsic::ID); + LLVM_ABI Value *getMemoryDataParam() const; + LLVM_ABI static std::optional<unsigned> getMemoryDataParamPos(Intrinsic::ID); // Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const IntrinsicInst *I) { @@ -638,27 +641,28 @@ public: } // Equivalent non-predicated opcode - static std::optional<unsigned> getFunctionalOpcodeForVP(Intrinsic::ID ID); + LLVM_ABI static std::optional<unsigned> + getFunctionalOpcodeForVP(Intrinsic::ID ID); // Equivalent non-predicated intrinsic ID - static std::optional<Intrinsic::ID> + LLVM_ABI static std::optional<Intrinsic::ID> getFunctionalIntrinsicIDForVP(Intrinsic::ID ID); // Equivalent non-predicated constrained ID - static std::optional<Intrinsic::ID> + LLVM_ABI static std::optional<Intrinsic::ID> getConstrainedIntrinsicIDForVP(Intrinsic::ID ID); }; /// This represents vector predication reduction intrinsics. class VPReductionIntrinsic : public VPIntrinsic { public: - static bool isVPReduction(Intrinsic::ID ID); + LLVM_ABI static bool isVPReduction(Intrinsic::ID ID); - unsigned getStartParamPos() const; - unsigned getVectorParamPos() const; + LLVM_ABI unsigned getStartParamPos() const; + LLVM_ABI unsigned getVectorParamPos() const; - static std::optional<unsigned> getStartParamPos(Intrinsic::ID ID); - static std::optional<unsigned> getVectorParamPos(Intrinsic::ID ID); + LLVM_ABI static std::optional<unsigned> getStartParamPos(Intrinsic::ID ID); + LLVM_ABI static std::optional<unsigned> getVectorParamPos(Intrinsic::ID ID); /// Methods for support type inquiry through isa, cast, and dyn_cast: /// @{ @@ -673,7 +677,7 @@ public: class VPCastIntrinsic : public VPIntrinsic { public: - static bool isVPCast(Intrinsic::ID ID); + LLVM_ABI static bool isVPCast(Intrinsic::ID ID); /// Methods for support type inquiry through isa, cast, and dyn_cast: /// @{ @@ -688,9 +692,9 @@ public: class VPCmpIntrinsic : public VPIntrinsic { public: - static bool isVPCmp(Intrinsic::ID ID); + LLVM_ABI static bool isVPCmp(Intrinsic::ID ID); - CmpInst::Predicate getPredicate() const; + LLVM_ABI CmpInst::Predicate getPredicate() const; /// Methods for support type inquiry through isa, cast, and dyn_cast: /// @{ @@ -705,7 +709,7 @@ public: class VPBinOpIntrinsic : public VPIntrinsic { public: - static bool isVPBinOp(Intrinsic::ID ID); + LLVM_ABI static bool isVPBinOp(Intrinsic::ID ID); /// Methods for support type inquiry through isa, cast, and dyn_cast: /// @{ @@ -722,13 +726,13 @@ public: /// This is the common base class for constrained floating point intrinsics. class ConstrainedFPIntrinsic : public IntrinsicInst { public: - unsigned getNonMetadataArgCount() const; - std::optional<RoundingMode> getRoundingMode() const; - std::optional<fp::ExceptionBehavior> getExceptionBehavior() const; - bool isDefaultFPEnvironment() const; + LLVM_ABI unsigned getNonMetadataArgCount() const; + LLVM_ABI std::optional<RoundingMode> getRoundingMode() const; + LLVM_ABI std::optional<fp::ExceptionBehavior> getExceptionBehavior() const; + LLVM_ABI bool isDefaultFPEnvironment() const; // Methods for support type inquiry through isa, cast, and dyn_cast: - static bool classof(const IntrinsicInst *I); + LLVM_ABI static bool classof(const IntrinsicInst *I); static bool classof(const Value *V) { return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V)); } @@ -737,7 +741,7 @@ public: /// Constrained floating point compare intrinsics. class ConstrainedFPCmpIntrinsic : public ConstrainedFPIntrinsic { public: - FCmpInst::Predicate getPredicate() const; + LLVM_ABI FCmpInst::Predicate getPredicate() const; bool isSignaling() const { return getIntrinsicID() == Intrinsic::experimental_constrained_fcmps; } @@ -914,13 +918,13 @@ public: Value *getRHS() const { return const_cast<Value *>(getArgOperand(1)); } /// Returns the binary operation underlying the intrinsic. - Instruction::BinaryOps getBinaryOp() const; + LLVM_ABI Instruction::BinaryOps getBinaryOp() const; /// Whether the intrinsic is signed or unsigned. - bool isSigned() const; + LLVM_ABI bool isSigned() const; /// Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap. - unsigned getNoWrapKind() const; + LLVM_ABI unsigned getNoWrapKind() const; }; /// Represents an op.with.overflow intrinsic. @@ -1475,10 +1479,10 @@ public: } // The number of counters for the instrumented function. - ConstantInt *getNumCounters() const; + LLVM_ABI ConstantInt *getNumCounters() const; // The index of the counter that this instruction acts on. - ConstantInt *getIndex() const; - void setIndex(uint32_t Idx); + LLVM_ABI ConstantInt *getIndex() const; + LLVM_ABI void setIndex(uint32_t Idx); }; /// This represents the llvm.instrprof.cover intrinsic. @@ -1502,7 +1506,7 @@ public: static bool classof(const Value *V) { return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V)); } - Value *getStep() const; + LLVM_ABI Value *getStep() const; }; /// This represents the llvm.instrprof.increment.step intrinsic. @@ -1534,8 +1538,8 @@ public: (CB.isIndirectCall() || (CB.getCalledFunction() && !CB.getCalledFunction()->isIntrinsic())); } - Value *getCallee() const; - void setCallee(Value *Callee); + LLVM_ABI Value *getCallee() const; + LLVM_ABI void setCallee(Value *Callee); }; /// This represents the llvm.instrprof.timestamp intrinsic. @@ -1701,7 +1705,7 @@ public: } /// The statepoint with which this gc.relocate is associated. - const Value *getStatepoint() const; + LLVM_ABI const Value *getStatepoint() const; }; /// Represents calls to the gc.relocate intrinsic. @@ -1728,8 +1732,8 @@ public: return cast<ConstantInt>(getArgOperand(2))->getZExtValue(); } - Value *getBasePtr() const; - Value *getDerivedPtr() const; + LLVM_ABI Value *getBasePtr() const; + LLVM_ABI Value *getDerivedPtr() const; }; /// Represents calls to the gc.result intrinsic. @@ -1789,10 +1793,10 @@ public: return getIntrinsicID() == Intrinsic::experimental_convergence_loop; } - static ConvergenceControlInst *CreateAnchor(BasicBlock &BB); - static ConvergenceControlInst *CreateEntry(BasicBlock &BB); - static ConvergenceControlInst *CreateLoop(BasicBlock &BB, - ConvergenceControlInst *Parent); + LLVM_ABI static ConvergenceControlInst *CreateAnchor(BasicBlock &BB); + LLVM_ABI static ConvergenceControlInst *CreateEntry(BasicBlock &BB); + LLVM_ABI static ConvergenceControlInst * + CreateLoop(BasicBlock &BB, ConvergenceControlInst *Parent); }; } // end namespace llvm diff --git a/llvm/include/llvm/IR/Intrinsics.h b/llvm/include/llvm/IR/Intrinsics.h index 7aa6cbe..1568052 100644 --- a/llvm/include/llvm/IR/Intrinsics.h +++ b/llvm/include/llvm/IR/Intrinsics.h @@ -16,6 +16,7 @@ #define LLVM_IR_INTRINSICS_H #include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/TypeSize.h" #include <optional> #include <string> @@ -53,11 +54,11 @@ namespace Intrinsic { /// Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx". /// Note, this version is for intrinsics with no overloads. Use the other /// version of getName if overloads are required. - StringRef getName(ID id); + LLVM_ABI StringRef getName(ID id); /// Return the LLVM name for an intrinsic, without encoded types for /// overloading, such as "llvm.ssa.copy". - StringRef getBaseName(ID id); + LLVM_ABI StringRef getBaseName(ID id); /// Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx" or /// "llvm.ssa.copy.p0s_s.1". Note, this version of getName supports overloads. @@ -65,31 +66,32 @@ namespace Intrinsic { /// overloads are required, it is safe to use this version, but better to use /// the StringRef version. If one of the types is based on an unnamed type, a /// function type will be computed. Providing FT will avoid this computation. - std::string getName(ID Id, ArrayRef<Type *> Tys, Module *M, - FunctionType *FT = nullptr); + LLVM_ABI std::string getName(ID Id, ArrayRef<Type *> Tys, Module *M, + FunctionType *FT = nullptr); /// Return the LLVM name for an intrinsic. This is a special version only to /// be used by LLVMIntrinsicCopyOverloadedName. It only supports overloads /// based on named types. - std::string getNameNoUnnamedTypes(ID Id, ArrayRef<Type *> Tys); + LLVM_ABI std::string getNameNoUnnamedTypes(ID Id, ArrayRef<Type *> Tys); /// Return the function type for an intrinsic. - FunctionType *getType(LLVMContext &Context, ID id, ArrayRef<Type *> Tys = {}); + LLVM_ABI FunctionType *getType(LLVMContext &Context, ID id, + ArrayRef<Type *> Tys = {}); /// Returns true if the intrinsic can be overloaded. - bool isOverloaded(ID id); + LLVM_ABI bool isOverloaded(ID id); /// isTargetIntrinsic - Returns true if IID is an intrinsic specific to a /// certain target. If it is a generic intrinsic false is returned. - bool isTargetIntrinsic(ID IID); + LLVM_ABI bool isTargetIntrinsic(ID IID); - ID lookupIntrinsicID(StringRef Name); + LLVM_ABI ID lookupIntrinsicID(StringRef Name); /// Return the attributes for an intrinsic. - AttributeList getAttributes(LLVMContext &C, ID id, FunctionType *FT); + LLVM_ABI AttributeList getAttributes(LLVMContext &C, ID id, FunctionType *FT); /// Return the function attributes for an intrinsic. - AttributeSet getFnAttributes(LLVMContext &C, ID id); + LLVM_ABI AttributeSet getFnAttributes(LLVMContext &C, ID id); /// Look up the Function declaration of the intrinsic \p id in the Module /// \p M. If it does not exist, add a declaration and return it. Otherwise, @@ -99,7 +101,8 @@ namespace Intrinsic { /// using iAny, fAny, vAny, or pAny). For a declaration of an overloaded /// intrinsic, Tys must provide exactly one type for each overloaded type in /// the intrinsic. - Function *getOrInsertDeclaration(Module *M, ID id, ArrayRef<Type *> Tys = {}); + LLVM_ABI Function *getOrInsertDeclaration(Module *M, ID id, + ArrayRef<Type *> Tys = {}); LLVM_DEPRECATED("Use getOrInsertDeclaration instead", "getOrInsertDeclaration") @@ -110,25 +113,28 @@ namespace Intrinsic { /// Look up the Function declaration of the intrinsic \p id in the Module /// \p M and return it if it exists. Otherwise, return nullptr. This version /// supports non-overloaded intrinsics. - Function *getDeclarationIfExists(const Module *M, ID id); + LLVM_ABI Function *getDeclarationIfExists(const Module *M, ID id); /// This version supports overloaded intrinsics. - Function *getDeclarationIfExists(Module *M, ID id, ArrayRef<Type *> Tys, - FunctionType *FT = nullptr); + LLVM_ABI Function *getDeclarationIfExists(Module *M, ID id, + ArrayRef<Type *> Tys, + FunctionType *FT = nullptr); /// Map a Clang builtin name to an intrinsic ID. - ID getIntrinsicForClangBuiltin(StringRef TargetPrefix, StringRef BuiltinName); + LLVM_ABI ID getIntrinsicForClangBuiltin(StringRef TargetPrefix, + StringRef BuiltinName); /// Map a MS builtin name to an intrinsic ID. - ID getIntrinsicForMSBuiltin(StringRef TargetPrefix, StringRef BuiltinName); + LLVM_ABI ID getIntrinsicForMSBuiltin(StringRef TargetPrefix, + StringRef BuiltinName); /// Returns true if the intrinsic ID is for one of the "Constrained /// Floating-Point Intrinsics". - bool isConstrainedFPIntrinsic(ID QID); + LLVM_ABI bool isConstrainedFPIntrinsic(ID QID); /// Returns true if the intrinsic ID is for one of the "Constrained /// Floating-Point Intrinsics" that take rounding mode metadata. - bool hasConstrainedFPRoundingModeOperand(ID QID); + LLVM_ABI bool hasConstrainedFPRoundingModeOperand(ID QID); /// This is a type descriptor which explains the type requirements of an /// intrinsic. This is returned by getIntrinsicInfoTableEntries. @@ -232,7 +238,8 @@ namespace Intrinsic { /// Return the IIT table descriptor for the specified intrinsic into an array /// of IITDescriptors. - void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl<IITDescriptor> &T); + LLVM_ABI void getIntrinsicInfoTableEntries(ID id, + SmallVectorImpl<IITDescriptor> &T); enum MatchIntrinsicTypesResult { MatchIntrinsicTypes_Match = 0, @@ -246,7 +253,7 @@ namespace Intrinsic { /// /// Returns false if the given type matches with the constraints, true /// otherwise. - MatchIntrinsicTypesResult + LLVM_ABI MatchIntrinsicTypesResult matchIntrinsicSignature(FunctionType *FTy, ArrayRef<IITDescriptor> &Infos, SmallVectorImpl<Type *> &ArgTys); @@ -254,7 +261,8 @@ namespace Intrinsic { /// be called after all the fixed arguments have been matched first. /// /// This method returns true on error. - bool matchIntrinsicVarArg(bool isVarArg, ArrayRef<IITDescriptor> &Infos); + LLVM_ABI bool matchIntrinsicVarArg(bool isVarArg, + ArrayRef<IITDescriptor> &Infos); /// Gets the type arguments of an intrinsic call by matching type contraints /// specified by the .td file. The overloaded types are pushed into the @@ -262,17 +270,18 @@ namespace Intrinsic { /// /// Returns false if the given ID and function type combination is not a /// valid intrinsic call. - bool getIntrinsicSignature(Intrinsic::ID, FunctionType *FT, - SmallVectorImpl<Type *> &ArgTys); + LLVM_ABI bool getIntrinsicSignature(Intrinsic::ID, FunctionType *FT, + SmallVectorImpl<Type *> &ArgTys); /// Same as previous, but accepts a Function instead of ID and FunctionType. - bool getIntrinsicSignature(Function *F, SmallVectorImpl<Type *> &ArgTys); + LLVM_ABI bool getIntrinsicSignature(Function *F, + SmallVectorImpl<Type *> &ArgTys); // Checks if the intrinsic name matches with its signature and if not // returns the declaration with the same signature and remangled name. // An existing GlobalValue with the wanted name but with a wrong prototype // or of the wrong kind will be renamed by adding ".renamed" to the name. - std::optional<Function *> remangleIntrinsicFunction(Function *F); + LLVM_ABI std::optional<Function *> remangleIntrinsicFunction(Function *F); } // End Intrinsic namespace diff --git a/llvm/include/llvm/IR/LLVMContext.h b/llvm/include/llvm/IR/LLVMContext.h index 6dde7a9..852a3a4 100644 --- a/llvm/include/llvm/IR/LLVMContext.h +++ b/llvm/include/llvm/IR/LLVMContext.h @@ -17,6 +17,7 @@ #include "llvm-c/Types.h" #include "llvm/IR/DiagnosticHandler.h" #include "llvm/Support/CBindingWrapping.h" +#include "llvm/Support/Compiler.h" #include <cstdint> #include <memory> #include <optional> @@ -67,10 +68,10 @@ enum { class LLVMContext { public: LLVMContextImpl *const pImpl; - LLVMContext(); + LLVM_ABI LLVMContext(); LLVMContext(const LLVMContext &) = delete; LLVMContext &operator=(const LLVMContext &) = delete; - ~LLVMContext(); + LLVM_ABI ~LLVMContext(); // Pinned metadata names, which always have the same value. This is a // compile-time performance optimization, not a correctness optimization. @@ -100,68 +101,69 @@ public: /// getMDKindID - Return a unique non-zero ID for the specified metadata kind. /// This ID is uniqued across modules in the current LLVMContext. - unsigned getMDKindID(StringRef Name) const; + LLVM_ABI unsigned getMDKindID(StringRef Name) const; /// getMDKindNames - Populate client supplied SmallVector with the name for /// custom metadata IDs registered in this LLVMContext. - void getMDKindNames(SmallVectorImpl<StringRef> &Result) const; + LLVM_ABI void getMDKindNames(SmallVectorImpl<StringRef> &Result) const; /// getOperandBundleTags - Populate client supplied SmallVector with the /// bundle tags registered in this LLVMContext. The bundle tags are ordered /// by increasing bundle IDs. /// \see LLVMContext::getOperandBundleTagID - void getOperandBundleTags(SmallVectorImpl<StringRef> &Result) const; + LLVM_ABI void getOperandBundleTags(SmallVectorImpl<StringRef> &Result) const; /// getOrInsertBundleTag - Returns the Tag to use for an operand bundle of /// name TagName. - StringMapEntry<uint32_t> *getOrInsertBundleTag(StringRef TagName) const; + LLVM_ABI StringMapEntry<uint32_t> * + getOrInsertBundleTag(StringRef TagName) const; /// getOperandBundleTagID - Maps a bundle tag to an integer ID. Every bundle /// tag registered with an LLVMContext has an unique ID. - uint32_t getOperandBundleTagID(StringRef Tag) const; + LLVM_ABI uint32_t getOperandBundleTagID(StringRef Tag) const; /// getOrInsertSyncScopeID - Maps synchronization scope name to /// synchronization scope ID. Every synchronization scope registered with /// LLVMContext has unique ID except pre-defined ones. - SyncScope::ID getOrInsertSyncScopeID(StringRef SSN); + LLVM_ABI SyncScope::ID getOrInsertSyncScopeID(StringRef SSN); /// getSyncScopeNames - Populates client supplied SmallVector with /// synchronization scope names registered with LLVMContext. Synchronization /// scope names are ordered by increasing synchronization scope IDs. - void getSyncScopeNames(SmallVectorImpl<StringRef> &SSNs) const; + LLVM_ABI void getSyncScopeNames(SmallVectorImpl<StringRef> &SSNs) const; /// getSyncScopeName - Returns the name of a SyncScope::ID /// registered with LLVMContext, if any. - std::optional<StringRef> getSyncScopeName(SyncScope::ID Id) const; + LLVM_ABI std::optional<StringRef> getSyncScopeName(SyncScope::ID Id) const; /// Define the GC for a function - void setGC(const Function &Fn, std::string GCName); + LLVM_ABI void setGC(const Function &Fn, std::string GCName); /// Return the GC for a function - const std::string &getGC(const Function &Fn); + LLVM_ABI const std::string &getGC(const Function &Fn); /// Remove the GC for a function - void deleteGC(const Function &Fn); + LLVM_ABI void deleteGC(const Function &Fn); /// Return true if the Context runtime configuration is set to discard all /// value names. When true, only GlobalValue names will be available in the /// IR. - bool shouldDiscardValueNames() const; + LLVM_ABI bool shouldDiscardValueNames() const; /// Set the Context runtime configuration to discard all value name (but /// GlobalValue). Clients can use this flag to save memory and runtime, /// especially in release mode. - void setDiscardValueNames(bool Discard); + LLVM_ABI void setDiscardValueNames(bool Discard); /// Whether there is a string map for uniquing debug info /// identifiers across the context. Off by default. - bool isODRUniquingDebugTypes() const; - void enableDebugTypeODRUniquing(); - void disableDebugTypeODRUniquing(); + LLVM_ABI bool isODRUniquingDebugTypes() const; + LLVM_ABI void enableDebugTypeODRUniquing(); + LLVM_ABI void disableDebugTypeODRUniquing(); /// generateMachineFunctionNum - Get a unique number for MachineFunction /// that associated with the given Function. - unsigned generateMachineFunctionNum(Function &); + LLVM_ABI unsigned generateMachineFunctionNum(Function &); /// Defines the type of a yield callback. /// \see LLVMContext::setYieldCallback. @@ -175,7 +177,7 @@ public: /// /// LLVMContext doesn't take ownership or interpret either of these /// pointers. - void setDiagnosticHandlerCallBack( + LLVM_ABI void setDiagnosticHandlerCallBack( DiagnosticHandler::DiagnosticHandlerTy DiagHandler, void *DiagContext = nullptr, bool RespectFilters = false); @@ -186,36 +188,38 @@ public: /// expects enabled diagnostics. /// /// Ownership of this pointer is moved to LLVMContextImpl. - void setDiagnosticHandler(std::unique_ptr<DiagnosticHandler> &&DH, - bool RespectFilters = false); + LLVM_ABI void setDiagnosticHandler(std::unique_ptr<DiagnosticHandler> &&DH, + bool RespectFilters = false); /// getDiagnosticHandlerCallBack - Return the diagnostic handler call back set by /// setDiagnosticHandlerCallBack. - DiagnosticHandler::DiagnosticHandlerTy getDiagnosticHandlerCallBack() const; + LLVM_ABI DiagnosticHandler::DiagnosticHandlerTy + getDiagnosticHandlerCallBack() const; /// getDiagnosticContext - Return the diagnostic context set by /// setDiagnosticContext. - void *getDiagnosticContext() const; + LLVM_ABI void *getDiagnosticContext() const; /// getDiagHandlerPtr - Returns const raw pointer of DiagnosticHandler set by /// setDiagnosticHandler. - const DiagnosticHandler *getDiagHandlerPtr() const; + LLVM_ABI const DiagnosticHandler *getDiagHandlerPtr() const; /// getDiagnosticHandler - transfers ownership of DiagnosticHandler unique_ptr /// to caller. - std::unique_ptr<DiagnosticHandler> getDiagnosticHandler(); + LLVM_ABI std::unique_ptr<DiagnosticHandler> getDiagnosticHandler(); /// Return if a code hotness metric should be included in optimization /// diagnostics. - bool getDiagnosticsHotnessRequested() const; + LLVM_ABI bool getDiagnosticsHotnessRequested() const; /// Set if a code hotness metric should be included in optimization /// diagnostics. - void setDiagnosticsHotnessRequested(bool Requested); + LLVM_ABI void setDiagnosticsHotnessRequested(bool Requested); - bool getMisExpectWarningRequested() const; - void setMisExpectWarningRequested(bool Requested); - void setDiagnosticsMisExpectTolerance(std::optional<uint32_t> Tolerance); - uint32_t getDiagnosticsMisExpectTolerance() const; + LLVM_ABI bool getMisExpectWarningRequested() const; + LLVM_ABI void setMisExpectWarningRequested(bool Requested); + LLVM_ABI void + setDiagnosticsMisExpectTolerance(std::optional<uint32_t> Tolerance); + LLVM_ABI uint32_t getDiagnosticsMisExpectTolerance() const; /// Return the minimum hotness value a diagnostic would need in order /// to be included in optimization diagnostics. @@ -227,14 +231,15 @@ public: /// profile summary. Note that in case of missing profile /// summary, threshold will be kept at "MAX", effectively /// suppresses all remarks output. - uint64_t getDiagnosticsHotnessThreshold() const; + LLVM_ABI uint64_t getDiagnosticsHotnessThreshold() const; /// Set the minimum hotness value a diagnostic needs in order to be /// included in optimization diagnostics. - void setDiagnosticsHotnessThreshold(std::optional<uint64_t> Threshold); + LLVM_ABI void + setDiagnosticsHotnessThreshold(std::optional<uint64_t> Threshold); /// Return if hotness threshold is requested from PSI. - bool isDiagnosticsHotnessThresholdSetFromPSI() const; + LLVM_ABI bool isDiagnosticsHotnessThresholdSetFromPSI() const; /// The "main remark streamer" used by all the specialized remark streamers. /// This streamer keeps generic remark metadata in memory throughout the life @@ -243,9 +248,9 @@ public: /// /// All specialized remark streamers should convert remarks to /// llvm::remarks::Remark and emit them through this streamer. - remarks::RemarkStreamer *getMainRemarkStreamer(); - const remarks::RemarkStreamer *getMainRemarkStreamer() const; - void setMainRemarkStreamer( + LLVM_ABI remarks::RemarkStreamer *getMainRemarkStreamer(); + LLVM_ABI const remarks::RemarkStreamer *getMainRemarkStreamer() const; + LLVM_ABI void setMainRemarkStreamer( std::unique_ptr<remarks::RemarkStreamer> MainRemarkStreamer); /// The "LLVM remark streamer" used by LLVM to serialize remark diagnostics @@ -253,14 +258,15 @@ public: /// /// If it does not exist, diagnostics are not saved in a file but only emitted /// via the diagnostic handler. - LLVMRemarkStreamer *getLLVMRemarkStreamer(); - const LLVMRemarkStreamer *getLLVMRemarkStreamer() const; - void + LLVM_ABI LLVMRemarkStreamer *getLLVMRemarkStreamer(); + LLVM_ABI const LLVMRemarkStreamer *getLLVMRemarkStreamer() const; + LLVM_ABI void setLLVMRemarkStreamer(std::unique_ptr<LLVMRemarkStreamer> RemarkStreamer); /// Get the prefix that should be printed in front of a diagnostic of /// the given \p Severity - static const char *getDiagnosticMessagePrefix(DiagnosticSeverity Severity); + LLVM_ABI static const char * + getDiagnosticMessagePrefix(DiagnosticSeverity Severity); /// Report a message to the currently installed diagnostic handler. /// @@ -272,7 +278,7 @@ public: /// The diagnostic message will be implicitly prefixed with a severity keyword /// according to \p DI.getSeverity(), i.e., "error: " for \a DS_Error, /// "warning: " for \a DS_Warning, and "note: " for \a DS_Note. - void diagnose(const DiagnosticInfo &DI); + LLVM_ABI void diagnose(const DiagnosticInfo &DI); /// Registers a yield callback with the given context. /// @@ -291,33 +297,33 @@ public: /// yield callback are allowed to be used. Any other API calls into the /// context are not supported until the yield callback function returns /// control to LLVM. Other LLVM contexts are unaffected by this restriction. - void setYieldCallback(YieldCallbackTy Callback, void *OpaqueHandle); + LLVM_ABI void setYieldCallback(YieldCallbackTy Callback, void *OpaqueHandle); /// Calls the yield callback (if applicable). /// /// This transfers control of the current thread back to the client, which may /// suspend the current thread. Only call this method when LLVM doesn't hold /// any global mutex or cannot block the execution in another LLVM context. - void yield(); + LLVM_ABI void yield(); /// emitError - Emit an error message to the currently installed error handler /// with optional location information. This function returns, so code should /// be prepared to drop the erroneous construct on the floor and "not crash". /// The generated code need not be correct. The error message will be /// implicitly prefixed with "error: " and should not end with a ".". - void emitError(const Instruction *I, const Twine &ErrorStr); - void emitError(const Twine &ErrorStr); + LLVM_ABI void emitError(const Instruction *I, const Twine &ErrorStr); + LLVM_ABI void emitError(const Twine &ErrorStr); /// Access the object which can disable optional passes and individual /// optimizations at compile time. - OptPassGate &getOptPassGate() const; + LLVM_ABI OptPassGate &getOptPassGate() const; /// Set the object which can disable optional passes and individual /// optimizations at compile time. /// /// The lifetime of the object must be guaranteed to extend as long as the /// LLVMContext is used by compilation. - void setOptPassGate(OptPassGate&); + LLVM_ABI void setOptPassGate(OptPassGate &); /// Get or set the current "default" target CPU (target-cpu function /// attribute). The intent is that compiler frontends will set this to a value @@ -328,20 +334,20 @@ public: /// Function::createWithDefaultAttr() will create functions with this /// attribute. This function should only be called by passes that run at /// compile time and not by the backend or LTO passes. - StringRef getDefaultTargetCPU(); - void setDefaultTargetCPU(StringRef CPU); + LLVM_ABI StringRef getDefaultTargetCPU(); + LLVM_ABI void setDefaultTargetCPU(StringRef CPU); /// Similar to {get,set}DefaultTargetCPU() but for default target-features. - StringRef getDefaultTargetFeatures(); - void setDefaultTargetFeatures(StringRef Features); + LLVM_ABI StringRef getDefaultTargetFeatures(); + LLVM_ABI void setDefaultTargetFeatures(StringRef Features); /// Key Instructions: update the highest number atom group emitted for any /// function. - void updateDILocationAtomGroupWaterline(uint64_t G); + LLVM_ABI void updateDILocationAtomGroupWaterline(uint64_t G); /// Key Instructions: get the next free atom group number and increment /// the global tracker. - uint64_t incNextDILocationAtomGroup(); + LLVM_ABI uint64_t incNextDILocationAtomGroup(); private: // Module needs access to the add/removeModule methods. diff --git a/llvm/include/llvm/IR/LLVMRemarkStreamer.h b/llvm/include/llvm/IR/LLVMRemarkStreamer.h index 7e78c4f..376acde 100644 --- a/llvm/include/llvm/IR/LLVMRemarkStreamer.h +++ b/llvm/include/llvm/IR/LLVMRemarkStreamer.h @@ -15,6 +15,7 @@ #define LLVM_IR_LLVMREMARKSTREAMER_H #include "llvm/Remarks/Remark.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include <memory> #include <optional> @@ -41,7 +42,7 @@ class LLVMRemarkStreamer { public: LLVMRemarkStreamer(remarks::RemarkStreamer &RS) : RS(RS) {} /// Emit a diagnostic through the streamer. - void emit(const DiagnosticInfoOptimizationBase &Diag); + LLVM_ABI void emit(const DiagnosticInfoOptimizationBase &Diag); }; template <typename ThisError> @@ -62,36 +63,35 @@ struct LLVMRemarkSetupErrorInfo : public ErrorInfo<ThisError> { struct LLVMRemarkSetupFileError : LLVMRemarkSetupErrorInfo<LLVMRemarkSetupFileError> { - static char ID; + LLVM_ABI static char ID; using LLVMRemarkSetupErrorInfo< LLVMRemarkSetupFileError>::LLVMRemarkSetupErrorInfo; }; struct LLVMRemarkSetupPatternError : LLVMRemarkSetupErrorInfo<LLVMRemarkSetupPatternError> { - static char ID; + LLVM_ABI static char ID; using LLVMRemarkSetupErrorInfo< LLVMRemarkSetupPatternError>::LLVMRemarkSetupErrorInfo; }; struct LLVMRemarkSetupFormatError : LLVMRemarkSetupErrorInfo<LLVMRemarkSetupFormatError> { - static char ID; + LLVM_ABI static char ID; using LLVMRemarkSetupErrorInfo< LLVMRemarkSetupFormatError>::LLVMRemarkSetupErrorInfo; }; /// Setup optimization remarks that output to a file. -Expected<std::unique_ptr<ToolOutputFile>> -setupLLVMOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename, - StringRef RemarksPasses, StringRef RemarksFormat, - bool RemarksWithHotness, - std::optional<uint64_t> RemarksHotnessThreshold = 0); +LLVM_ABI Expected<std::unique_ptr<ToolOutputFile>> setupLLVMOptimizationRemarks( + LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses, + StringRef RemarksFormat, bool RemarksWithHotness, + std::optional<uint64_t> RemarksHotnessThreshold = 0); /// Setup optimization remarks that output directly to a raw_ostream. /// \p OS is managed by the caller and should be open for writing as long as \p /// Context is streaming remarks to it. -Error setupLLVMOptimizationRemarks( +LLVM_ABI Error setupLLVMOptimizationRemarks( LLVMContext &Context, raw_ostream &OS, StringRef RemarksPasses, StringRef RemarksFormat, bool RemarksWithHotness, std::optional<uint64_t> RemarksHotnessThreshold = 0); diff --git a/llvm/include/llvm/IR/LegacyPassManager.h b/llvm/include/llvm/IR/LegacyPassManager.h index b3a4820..770b3d8 100644 --- a/llvm/include/llvm/IR/LegacyPassManager.h +++ b/llvm/include/llvm/IR/LegacyPassManager.h @@ -17,6 +17,7 @@ #define LLVM_IR_LEGACYPASSMANAGER_H #include "llvm/Support/CBindingWrapping.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -28,7 +29,7 @@ namespace legacy { // Whether or not -debug-pass has been specified. For use to check if it's // specified alongside the new PM. -bool debugPassSpecified(); +LLVM_ABI bool debugPassSpecified(); class PassManagerImpl; class FunctionPassManagerImpl; @@ -36,7 +37,7 @@ class FunctionPassManagerImpl; /// PassManagerBase - An abstract interface to allow code to add passes to /// a pass manager without having to hard-code what kind of pass manager /// it is. -class PassManagerBase { +class LLVM_ABI PassManagerBase { public: virtual ~PassManagerBase(); @@ -49,7 +50,7 @@ public: }; /// PassManager manages ModulePassManagers -class PassManager : public PassManagerBase { +class LLVM_ABI PassManager : public PassManagerBase { public: PassManager(); @@ -68,7 +69,7 @@ private: }; /// FunctionPassManager manages FunctionPasses. -class FunctionPassManager : public PassManagerBase { +class LLVM_ABI FunctionPassManager : public PassManagerBase { public: /// FunctionPassManager ctor - This initializes the pass manager. It needs, /// but does not take ownership of, the specified Module. diff --git a/llvm/include/llvm/IR/LegacyPassManagers.h b/llvm/include/llvm/IR/LegacyPassManagers.h index 6c49079..1e5b926 100644 --- a/llvm/include/llvm/IR/LegacyPassManagers.h +++ b/llvm/include/llvm/IR/LegacyPassManagers.h @@ -18,6 +18,7 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Pass.h" +#include "llvm/Support/Compiler.h" #include <vector> //===----------------------------------------------------------------------===// @@ -106,7 +107,7 @@ enum PassDebuggingString { /// PassManagerPrettyStackEntry - This is used to print informative information /// about what pass is running when/if a stack trace is generated. -class PassManagerPrettyStackEntry : public PrettyStackTraceEntry { +class LLVM_ABI PassManagerPrettyStackEntry : public PrettyStackTraceEntry { Pass *P; Value *V; Module *M; @@ -139,12 +140,12 @@ public: iterator begin() const { return S.rbegin(); } iterator end() const { return S.rend(); } - void pop(); + LLVM_ABI void pop(); PMDataManager *top() const { return S.back(); } - void push(PMDataManager *PM); + LLVM_ABI void push(PMDataManager *PM); bool empty() const { return S.empty(); } - void dump() const; + LLVM_ABI void dump() const; private: std::vector<PMDataManager *> S; @@ -155,7 +156,7 @@ private: // /// PMTopLevelManager manages LastUser info and collects common APIs used by /// top level pass managers. -class PMTopLevelManager { +class LLVM_ABI PMTopLevelManager { protected: explicit PMTopLevelManager(PMDataManager *PMDM); @@ -292,7 +293,7 @@ private: /// PMDataManager provides the common place to manage the analysis data /// used by pass managers. -class PMDataManager { +class LLVM_ABI PMDataManager { public: explicit PMDataManager() { initializeAnalysisInfo(); } @@ -454,7 +455,7 @@ private: /// It batches all function passes and basic block pass managers together and /// sequence them to process one function at a time before processing next /// function. -class FPPassManager : public ModulePass, public PMDataManager { +class LLVM_ABI FPPassManager : public ModulePass, public PMDataManager { public: static char ID; explicit FPPassManager() : ModulePass(ID) {} @@ -508,7 +509,6 @@ public: return PMT_FunctionPassManager; } }; - } #endif diff --git a/llvm/include/llvm/IR/LegacyPassNameParser.h b/llvm/include/llvm/IR/LegacyPassNameParser.h index c33b9fc..3460de0 100644 --- a/llvm/include/llvm/IR/LegacyPassNameParser.h +++ b/llvm/include/llvm/IR/LegacyPassNameParser.h @@ -28,6 +28,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Pass.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include <cstring> @@ -38,8 +39,8 @@ namespace llvm { // PassNameParser class - Make use of the pass registration mechanism to // automatically add a command line argument to opt for each pass. // -class PassNameParser : public PassRegistrationListener, - public cl::parser<const PassInfo*> { +class LLVM_ABI PassNameParser : public PassRegistrationListener, + public cl::parser<const PassInfo *> { public: PassNameParser(cl::Option &O); ~PassNameParser() override; diff --git a/llvm/include/llvm/IR/MDBuilder.h b/llvm/include/llvm/IR/MDBuilder.h index ce4e1da..df1c66c 100644 --- a/llvm/include/llvm/IR/MDBuilder.h +++ b/llvm/include/llvm/IR/MDBuilder.h @@ -18,6 +18,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/IR/GlobalValue.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" #include <utility> @@ -40,10 +41,10 @@ public: MDBuilder(LLVMContext &context) : Context(context) {} /// Return the given string as metadata. - MDString *createString(StringRef Str); + LLVM_ABI MDString *createString(StringRef Str); /// Return the given constant as metadata. - ConstantAsMetadata *createConstant(Constant *C); + LLVM_ABI ConstantAsMetadata *createConstant(Constant *C); //===------------------------------------------------------------------===// // FPMath metadata. @@ -52,7 +53,7 @@ public: /// Return metadata with the given settings. The special value 0.0 /// for the Accuracy parameter indicates the default (maximal precision) /// setting. - MDNode *createFPMath(float Accuracy); + LLVM_ABI MDNode *createFPMath(float Accuracy); //===------------------------------------------------------------------===// // Prof metadata. @@ -62,41 +63,44 @@ public: /// @param TrueWeight the weight of the true branch /// @param FalseWeight the weight of the false branch /// @param Do these weights come from __builtin_expect* - MDNode *createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight, - bool IsExpected = false); + LLVM_ABI MDNode *createBranchWeights(uint32_t TrueWeight, + uint32_t FalseWeight, + bool IsExpected = false); /// Return metadata containing two branch weights, with significant bias /// towards `true` destination. - MDNode *createLikelyBranchWeights(); + LLVM_ABI MDNode *createLikelyBranchWeights(); /// Return metadata containing two branch weights, with significant bias /// towards `false` destination. - MDNode *createUnlikelyBranchWeights(); + LLVM_ABI MDNode *createUnlikelyBranchWeights(); /// Return metadata containing a number of branch weights. /// @param Weights the weights of all the branches /// @param Do these weights come from __builtin_expect* - MDNode *createBranchWeights(ArrayRef<uint32_t> Weights, - bool IsExpected = false); + LLVM_ABI MDNode *createBranchWeights(ArrayRef<uint32_t> Weights, + bool IsExpected = false); /// Return metadata specifying that a branch or switch is unpredictable. - MDNode *createUnpredictable(); + LLVM_ABI MDNode *createUnpredictable(); /// Return metadata containing the entry \p Count for a function, a boolean /// \Synthetic indicating whether the counts were synthetized, and the /// GUIDs stored in \p Imports that need to be imported for sample PGO, to /// enable the same inlines as the profiled optimized binary - MDNode *createFunctionEntryCount(uint64_t Count, bool Synthetic, - const DenseSet<GlobalValue::GUID> *Imports); + LLVM_ABI MDNode * + createFunctionEntryCount(uint64_t Count, bool Synthetic, + const DenseSet<GlobalValue::GUID> *Imports); /// Return metadata containing the section prefix for a global object. - MDNode *createGlobalObjectSectionPrefix(StringRef Prefix); + LLVM_ABI MDNode *createGlobalObjectSectionPrefix(StringRef Prefix); /// Return metadata containing the pseudo probe descriptor for a function. - MDNode *createPseudoProbeDesc(uint64_t GUID, uint64_t Hash, StringRef FName); + LLVM_ABI MDNode *createPseudoProbeDesc(uint64_t GUID, uint64_t Hash, + StringRef FName); /// Return metadata containing llvm statistics. - MDNode * + LLVM_ABI MDNode * createLLVMStats(ArrayRef<std::pair<StringRef, uint64_t>> LLVMStatsVec); //===------------------------------------------------------------------===// @@ -104,10 +108,10 @@ public: //===------------------------------------------------------------------===// /// Return metadata describing the range [Lo, Hi). - MDNode *createRange(const APInt &Lo, const APInt &Hi); + LLVM_ABI MDNode *createRange(const APInt &Lo, const APInt &Hi); /// Return metadata describing the range [Lo, Hi). - MDNode *createRange(Constant *Lo, Constant *Hi); + LLVM_ABI MDNode *createRange(Constant *Lo, Constant *Hi); //===------------------------------------------------------------------===// // Callees metadata. @@ -115,22 +119,25 @@ public: /// Return metadata indicating the possible callees of indirect /// calls. - MDNode *createCallees(ArrayRef<Function *> Callees); + LLVM_ABI MDNode *createCallees(ArrayRef<Function *> Callees); //===------------------------------------------------------------------===// // Callback metadata. //===------------------------------------------------------------------===// /// Return metadata describing a callback (see llvm::AbstractCallSite). - MDNode *createCallbackEncoding(unsigned CalleeArgNo, ArrayRef<int> Arguments, - bool VarArgsArePassed); + LLVM_ABI MDNode *createCallbackEncoding(unsigned CalleeArgNo, + ArrayRef<int> Arguments, + bool VarArgsArePassed); /// Merge the new callback encoding \p NewCB into \p ExistingCallbacks. - MDNode *mergeCallbackEncodings(MDNode *ExistingCallbacks, MDNode *NewCB); + LLVM_ABI MDNode *mergeCallbackEncodings(MDNode *ExistingCallbacks, + MDNode *NewCB); /// Return metadata feeding to the CodeGen about how to generate a function /// prologue for the "function" santizier. - MDNode *createRTTIPointerPrologue(Constant *PrologueSig, Constant *RTTI); + LLVM_ABI MDNode *createRTTIPointerPrologue(Constant *PrologueSig, + Constant *RTTI); //===------------------------------------------------------------------===// // PC sections metadata. @@ -140,7 +147,7 @@ public: using PCSection = std::pair<StringRef, SmallVector<Constant *>>; /// Return metadata for PC sections. - MDNode *createPCSections(ArrayRef<PCSection> Sections); + LLVM_ABI MDNode *createPCSections(ArrayRef<PCSection> Sections); //===------------------------------------------------------------------===// // AA metadata. @@ -150,8 +157,8 @@ protected: /// Return metadata appropriate for a AA root node (scope or TBAA). /// Each returned node is distinct from all other metadata and will never /// be identified (uniqued) with anything else. - MDNode *createAnonymousAARoot(StringRef Name = StringRef(), - MDNode *Extra = nullptr); + LLVM_ABI MDNode *createAnonymousAARoot(StringRef Name = StringRef(), + MDNode *Extra = nullptr); public: /// Return metadata appropriate for a TBAA root node. Each returned @@ -179,22 +186,22 @@ public: /// Return metadata appropriate for a TBAA root node with the given /// name. This may be identified (uniqued) with other roots with the same /// name. - MDNode *createTBAARoot(StringRef Name); + LLVM_ABI MDNode *createTBAARoot(StringRef Name); /// Return metadata appropriate for an alias scope domain node with /// the given name. This may be identified (uniqued) with other roots with /// the same name. - MDNode *createAliasScopeDomain(StringRef Name); + LLVM_ABI MDNode *createAliasScopeDomain(StringRef Name); /// Return metadata appropriate for an alias scope node with /// the given name. This may be identified (uniqued) with other scopes with /// the same name and domain. - MDNode *createAliasScope(StringRef Name, MDNode *Domain); + LLVM_ABI MDNode *createAliasScope(StringRef Name, MDNode *Domain); /// Return metadata for a non-root TBAA node with the given name, /// parent in the TBAA tree, and value for 'pointsToConstantMemory'. - MDNode *createTBAANode(StringRef Name, MDNode *Parent, - bool isConstant = false); + LLVM_ABI MDNode *createTBAANode(StringRef Name, MDNode *Parent, + bool isConstant = false); struct TBAAStructField { uint64_t Offset; @@ -206,44 +213,45 @@ public: /// Return metadata for a tbaa.struct node with the given /// struct field descriptions. - MDNode *createTBAAStructNode(ArrayRef<TBAAStructField> Fields); + LLVM_ABI MDNode *createTBAAStructNode(ArrayRef<TBAAStructField> Fields); /// Return metadata for a TBAA struct node in the type DAG /// with the given name, a list of pairs (offset, field type in the type DAG). - MDNode * + LLVM_ABI MDNode * createTBAAStructTypeNode(StringRef Name, ArrayRef<std::pair<MDNode *, uint64_t>> Fields); /// Return metadata for a TBAA scalar type node with the /// given name, an offset and a parent in the TBAA type DAG. - MDNode *createTBAAScalarTypeNode(StringRef Name, MDNode *Parent, - uint64_t Offset = 0); + LLVM_ABI MDNode *createTBAAScalarTypeNode(StringRef Name, MDNode *Parent, + uint64_t Offset = 0); /// Return metadata for a TBAA tag node with the given /// base type, access type and offset relative to the base type. - MDNode *createTBAAStructTagNode(MDNode *BaseType, MDNode *AccessType, - uint64_t Offset, bool IsConstant = false); + LLVM_ABI MDNode *createTBAAStructTagNode(MDNode *BaseType, MDNode *AccessType, + uint64_t Offset, + bool IsConstant = false); /// Return metadata for a TBAA type node in the TBAA type DAG with the /// given parent type, size in bytes, type identifier and a list of fields. - MDNode *createTBAATypeNode(MDNode *Parent, uint64_t Size, Metadata *Id, - ArrayRef<TBAAStructField> Fields = - ArrayRef<TBAAStructField>()); + LLVM_ABI MDNode *createTBAATypeNode( + MDNode *Parent, uint64_t Size, Metadata *Id, + ArrayRef<TBAAStructField> Fields = ArrayRef<TBAAStructField>()); /// Return metadata for a TBAA access tag with the given base type, /// final access type, offset of the access relative to the base type, size of /// the access and flag indicating whether the accessed object can be /// considered immutable for the purposes of the TBAA analysis. - MDNode *createTBAAAccessTag(MDNode *BaseType, MDNode *AccessType, - uint64_t Offset, uint64_t Size, - bool IsImmutable = false); + LLVM_ABI MDNode *createTBAAAccessTag(MDNode *BaseType, MDNode *AccessType, + uint64_t Offset, uint64_t Size, + bool IsImmutable = false); /// Return mutable version of the given mutable or immutable TBAA /// access tag. - MDNode *createMutableTBAAAccessTag(MDNode *Tag); + LLVM_ABI MDNode *createMutableTBAAAccessTag(MDNode *Tag); /// Return metadata containing an irreducible loop header weight. - MDNode *createIrrLoopHeaderWeight(uint64_t Weight); + LLVM_ABI MDNode *createIrrLoopHeaderWeight(uint64_t Weight); }; } // end namespace llvm diff --git a/llvm/include/llvm/IR/Mangler.h b/llvm/include/llvm/IR/Mangler.h index edbd0a5..e3dfe1e 100644 --- a/llvm/include/llvm/IR/Mangler.h +++ b/llvm/include/llvm/IR/Mangler.h @@ -15,6 +15,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -36,32 +37,37 @@ public: /// Print the appropriate prefix and the specified global variable's name. /// If the global variable doesn't have a name, this fills in a unique name /// for the global. - void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, - bool CannotUsePrivateLabel) const; - void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV, - bool CannotUsePrivateLabel) const; + LLVM_ABI void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, + bool CannotUsePrivateLabel) const; + LLVM_ABI void getNameWithPrefix(SmallVectorImpl<char> &OutName, + const GlobalValue *GV, + bool CannotUsePrivateLabel) const; /// Print the appropriate prefix and the specified name as the global variable /// name. GVName must not be empty. - static void getNameWithPrefix(raw_ostream &OS, const Twine &GVName, - const DataLayout &DL); - static void getNameWithPrefix(SmallVectorImpl<char> &OutName, - const Twine &GVName, const DataLayout &DL); + LLVM_ABI static void getNameWithPrefix(raw_ostream &OS, const Twine &GVName, + const DataLayout &DL); + LLVM_ABI static void getNameWithPrefix(SmallVectorImpl<char> &OutName, + const Twine &GVName, + const DataLayout &DL); }; -void emitLinkerFlagsForGlobalCOFF(raw_ostream &OS, const GlobalValue *GV, - const Triple &TT, Mangler &Mangler); +LLVM_ABI void emitLinkerFlagsForGlobalCOFF(raw_ostream &OS, + const GlobalValue *GV, + const Triple &TT, Mangler &Mangler); -void emitLinkerFlagsForUsedCOFF(raw_ostream &OS, const GlobalValue *GV, - const Triple &T, Mangler &M); +LLVM_ABI void emitLinkerFlagsForUsedCOFF(raw_ostream &OS, const GlobalValue *GV, + const Triple &T, Mangler &M); /// Returns the ARM64EC mangled function name unless the input is already /// mangled. -std::optional<std::string> getArm64ECMangledFunctionName(StringRef Name); +LLVM_ABI std::optional<std::string> +getArm64ECMangledFunctionName(StringRef Name); /// Returns the ARM64EC demangled function name, unless the input is not /// mangled. -std::optional<std::string> getArm64ECDemangledFunctionName(StringRef Name); +LLVM_ABI std::optional<std::string> +getArm64ECDemangledFunctionName(StringRef Name); /// Check if an ARM64EC function name is mangled. bool inline isArm64ECMangledFunctionName(StringRef Name) { diff --git a/llvm/include/llvm/IR/MemoryModelRelaxationAnnotations.h b/llvm/include/llvm/IR/MemoryModelRelaxationAnnotations.h index a9ded60..535635a 100644 --- a/llvm/include/llvm/IR/MemoryModelRelaxationAnnotations.h +++ b/llvm/include/llvm/IR/MemoryModelRelaxationAnnotations.h @@ -20,6 +20,7 @@ #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Compiler.h" #include <tuple> // for std::pair namespace llvm { @@ -52,8 +53,8 @@ public: /// \name Constructors /// @{ MMRAMetadata() = default; - MMRAMetadata(const Instruction &I); - MMRAMetadata(MDNode *MD); + LLVM_ABI MMRAMetadata(const Instruction &I); + LLVM_ABI MMRAMetadata(MDNode *MD); /// @} /// \name Metadata Helpers & Builders @@ -61,25 +62,25 @@ public: /// Combines \p A and \p B according to MMRA semantics. /// \returns !mmra metadata for the combined MMRAs. - static MDNode *combine(LLVMContext &Ctx, const MMRAMetadata &A, - const MMRAMetadata &B); + LLVM_ABI static MDNode *combine(LLVMContext &Ctx, const MMRAMetadata &A, + const MMRAMetadata &B); /// Creates !mmra metadata for a single tag. /// /// !mmra metadata can either be a single tag, or a MDTuple containing /// multiple tags. - static MDTuple *getTagMD(LLVMContext &Ctx, StringRef Prefix, - StringRef Suffix); + LLVM_ABI static MDTuple *getTagMD(LLVMContext &Ctx, StringRef Prefix, + StringRef Suffix); static MDTuple *getTagMD(LLVMContext &Ctx, const TagT &T) { return getTagMD(Ctx, T.first, T.second); } /// Creates !mmra metadata from \p Tags. /// \returns nullptr or a MDTuple* from \p Tags. - static MDTuple *getMD(LLVMContext &Ctx, ArrayRef<TagT> Tags); + LLVM_ABI static MDTuple *getMD(LLVMContext &Ctx, ArrayRef<TagT> Tags); /// \returns true if \p MD is a well-formed MMRA tag. - static bool isTagMD(const Metadata *MD); + LLVM_ABI static bool isTagMD(const Metadata *MD); /// @} @@ -92,25 +93,25 @@ public: } /// \returns whether this set of tags is compatible with \p Other. - bool isCompatibleWith(const MMRAMetadata &Other) const; + LLVM_ABI bool isCompatibleWith(const MMRAMetadata &Other) const; /// @} /// \name Content Queries /// @{ - bool hasTag(StringRef Prefix, StringRef Suffix) const; - bool hasTagWithPrefix(StringRef Prefix) const; + LLVM_ABI bool hasTag(StringRef Prefix, StringRef Suffix) const; + LLVM_ABI bool hasTagWithPrefix(StringRef Prefix) const; - const_iterator begin() const; - const_iterator end() const; - bool empty() const; - unsigned size() const; + LLVM_ABI const_iterator begin() const; + LLVM_ABI const_iterator end() const; + LLVM_ABI bool empty() const; + LLVM_ABI unsigned size() const; /// @} - void print(raw_ostream &OS) const; - void dump() const; + LLVM_ABI void print(raw_ostream &OS) const; + LLVM_ABI void dump() const; operator bool() const { return !Tags.empty(); } bool operator==(const MMRAMetadata &Other) const { @@ -125,7 +126,7 @@ private: }; /// \returns true if \p I can have !mmra metadata. -bool canInstructionHaveMMRAs(const Instruction &I); +LLVM_ABI bool canInstructionHaveMMRAs(const Instruction &I); } // namespace llvm diff --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h index 3d06ede..2de26c0 100644 --- a/llvm/include/llvm/IR/Metadata.h +++ b/llvm/include/llvm/IR/Metadata.h @@ -28,6 +28,7 @@ #include "llvm/IR/Value.h" #include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include <cassert> #include <cstddef> @@ -110,8 +111,8 @@ public: /// the nullptr version is easy to call from a debugger. /// /// @{ - void dump() const; - void dump(const Module *M) const; + LLVM_ABI void dump() const; + LLVM_ABI void dump(const Module *M) const; /// @} /// Print. @@ -121,10 +122,10 @@ public: /// If \c M is provided, metadata nodes will be numbered canonically; /// otherwise, pointer addresses are substituted. /// @{ - void print(raw_ostream &OS, const Module *M = nullptr, - bool IsForDebug = false) const; - void print(raw_ostream &OS, ModuleSlotTracker &MST, const Module *M = nullptr, - bool IsForDebug = false) const; + LLVM_ABI void print(raw_ostream &OS, const Module *M = nullptr, + bool IsForDebug = false) const; + LLVM_ABI void print(raw_ostream &OS, ModuleSlotTracker &MST, + const Module *M = nullptr, bool IsForDebug = false) const; /// @} /// Print as operand. @@ -134,9 +135,10 @@ public: /// If \c M is provided, metadata nodes will be numbered canonically; /// otherwise, pointer addresses are substituted. /// @{ - void printAsOperand(raw_ostream &OS, const Module *M = nullptr) const; - void printAsOperand(raw_ostream &OS, ModuleSlotTracker &MST, - const Module *M = nullptr) const; + LLVM_ABI void printAsOperand(raw_ostream &OS, + const Module *M = nullptr) const; + LLVM_ABI void printAsOperand(raw_ostream &OS, ModuleSlotTracker &MST, + const Module *M = nullptr) const; /// @} /// Metadata IDs that may generate poison. @@ -189,10 +191,11 @@ class MetadataAsValue : public Value { void dropUse() { MD = nullptr; } public: - ~MetadataAsValue(); + LLVM_ABI ~MetadataAsValue(); - static MetadataAsValue *get(LLVMContext &Context, Metadata *MD); - static MetadataAsValue *getIfExists(LLVMContext &Context, Metadata *MD); + LLVM_ABI static MetadataAsValue *get(LLVMContext &Context, Metadata *MD); + LLVM_ABI static MetadataAsValue *getIfExists(LLVMContext &Context, + Metadata *MD); Metadata *getMetadata() const { return MD; } @@ -224,15 +227,15 @@ protected: ArrayRef<Metadata *> getDebugValues() const { return DebugValues; } public: - DbgVariableRecord *getUser(); - const DbgVariableRecord *getUser() const; + LLVM_ABI DbgVariableRecord *getUser(); + LLVM_ABI const DbgVariableRecord *getUser() const; /// To be called by ReplaceableMetadataImpl::replaceAllUsesWith, where `Old` /// is a pointer to one of the pointers in `DebugValues` (so should be type /// Metadata**), and `NewDebugValue` is the new Metadata* that is replacing /// *Old. /// For manually replacing elements of DebugValues, /// `resetDebugValue(Idx, NewDebugValue)` should be used instead. - void handleChangedValue(void *Old, Metadata *NewDebugValue); + LLVM_ABI void handleChangedValue(void *Old, Metadata *NewDebugValue); DebugValueUser() = default; explicit DebugValueUser(std::array<Metadata *, 3> DebugValues) : DebugValues(DebugValues) { @@ -289,13 +292,13 @@ public: } private: - void trackDebugValue(size_t Idx); - void trackDebugValues(); + LLVM_ABI void trackDebugValue(size_t Idx); + LLVM_ABI void trackDebugValues(); - void untrackDebugValue(size_t Idx); - void untrackDebugValues(); + LLVM_ABI void untrackDebugValue(size_t Idx); + LLVM_ABI void untrackDebugValues(); - void retrackDebugValues(DebugValueUser &X); + LLVM_ABI void retrackDebugValues(DebugValueUser &X); }; /// API for tracking metadata references through RAUW and deletion. @@ -351,7 +354,7 @@ public: /// /// Stops \c *MD from tracking \c MD. static void untrack(Metadata *&MD) { untrack(&MD, *MD); } - static void untrack(void *Ref, Metadata &MD); + LLVM_ABI static void untrack(void *Ref, Metadata &MD); /// Move tracking from one reference to another. /// @@ -364,10 +367,10 @@ public: static bool retrack(Metadata *&MD, Metadata *&New) { return retrack(&MD, *MD, &New); } - static bool retrack(void *Ref, Metadata &MD, void *New); + LLVM_ABI static bool retrack(void *Ref, Metadata &MD, void *New); /// Check whether metadata is replaceable. - static bool isReplaceable(const Metadata &MD); + LLVM_ABI static bool isReplaceable(const Metadata &MD); using OwnerTy = PointerUnion<MetadataAsValue *, Metadata *, DebugValueUser *>; @@ -375,7 +378,7 @@ private: /// Track a reference to metadata for an owner. /// /// Generalized version of tracking. - static bool track(void *Ref, Metadata &MD, OwnerTy Owner); + LLVM_ABI static bool track(void *Ref, Metadata &MD, OwnerTy Owner); }; /// Shared implementation of use-lists for replaceable metadata. @@ -406,20 +409,20 @@ public: /// Replace all uses of this with MD. /// /// Replace all uses of this with \c MD, which is allowed to be null. - void replaceAllUsesWith(Metadata *MD); - /// Replace all uses of the constant with Undef in debug info metadata - static void SalvageDebugInfo(const Constant &C); + LLVM_ABI void replaceAllUsesWith(Metadata *MD); + /// Replace all uses of the constant with Undef in debug info metadata + LLVM_ABI static void SalvageDebugInfo(const Constant &C); /// Returns the list of all DIArgList users of this. - SmallVector<Metadata *> getAllArgListUsers(); + LLVM_ABI SmallVector<Metadata *> getAllArgListUsers(); /// Returns the list of all DbgVariableRecord users of this. - SmallVector<DbgVariableRecord *> getAllDbgVariableRecordUsers(); + LLVM_ABI SmallVector<DbgVariableRecord *> getAllDbgVariableRecordUsers(); /// Resolve all uses of this. /// /// Resolve all uses of this, turning off RAUW permanently. If \c /// ResolveUsers, call \a MDNode::resolve() on any users whose last operand /// is resolved. - void resolveAllUses(bool ResolveUsers = true); + LLVM_ABI void resolveAllUses(bool ResolveUsers = true); unsigned getNumUses() const { return UseMap.size(); } @@ -471,7 +474,7 @@ protected: ~ValueAsMetadata() = default; public: - static ValueAsMetadata *get(Value *V); + LLVM_ABI static ValueAsMetadata *get(Value *V); static ConstantAsMetadata *getConstant(Value *C) { return cast<ConstantAsMetadata>(get(C)); @@ -481,7 +484,7 @@ public: return cast<LocalAsMetadata>(get(Local)); } - static ValueAsMetadata *getIfExists(Value *V); + LLVM_ABI static ValueAsMetadata *getIfExists(Value *V); static ConstantAsMetadata *getConstantIfExists(Value *C) { return cast_or_null<ConstantAsMetadata>(getIfExists(C)); @@ -502,8 +505,8 @@ public: return ReplaceableMetadataImpl::getAllDbgVariableRecordUsers(); } - static void handleDeletion(Value *V); - static void handleRAUW(Value *From, Value *To); + LLVM_ABI static void handleDeletion(Value *V); + LLVM_ABI static void handleRAUW(Value *From, Value *To); protected: /// Handle collisions after \a Value::replaceAllUsesWith(). @@ -726,12 +729,12 @@ public: MDString &operator=(MDString &&) = delete; MDString &operator=(const MDString &) = delete; - static MDString *get(LLVMContext &Context, StringRef Str); + LLVM_ABI static MDString *get(LLVMContext &Context, StringRef Str); static MDString *get(LLVMContext &Context, const char *Str) { return get(Context, Str ? StringRef(Str) : StringRef()); } - StringRef getString() const; + LLVM_ABI StringRef getString() const; unsigned getLength() const { return (unsigned)getString().size(); } @@ -783,14 +786,14 @@ struct AAMDNodes { MDNode *NoAlias = nullptr; // Shift tbaa Metadata node to start off bytes later - static MDNode *shiftTBAA(MDNode *M, size_t off); + LLVM_ABI static MDNode *shiftTBAA(MDNode *M, size_t off); // Shift tbaa.struct Metadata node to start off bytes later - static MDNode *shiftTBAAStruct(MDNode *M, size_t off); + LLVM_ABI static MDNode *shiftTBAAStruct(MDNode *M, size_t off); // Extend tbaa Metadata node to apply to a series of bytes of length len. // A size of -1 denotes an unknown size. - static MDNode *extendToTBAA(MDNode *TBAA, ssize_t len); + LLVM_ABI static MDNode *extendToTBAA(MDNode *TBAA, ssize_t len); /// Given two sets of AAMDNodes that apply to the same pointer, /// give the best AAMDNodes that are compatible with both (i.e. a set of @@ -835,22 +838,22 @@ struct AAMDNodes { /// Given two sets of AAMDNodes applying to potentially different locations, /// determine the best AAMDNodes that apply to both. - AAMDNodes merge(const AAMDNodes &Other) const; + LLVM_ABI AAMDNodes merge(const AAMDNodes &Other) const; /// Determine the best AAMDNodes after concatenating two different locations /// together. Different from `merge`, where different locations should /// overlap each other, `concat` puts non-overlapping locations together. - AAMDNodes concat(const AAMDNodes &Other) const; + LLVM_ABI AAMDNodes concat(const AAMDNodes &Other) const; /// Create a new AAMDNode for accessing \p AccessSize bytes of this AAMDNode. /// If this AAMDNode has !tbaa.struct and \p AccessSize matches the size of /// the field at offset 0, get the TBAA tag describing the accessed field. /// If such an AAMDNode already embeds !tbaa, the existing one is retrieved. /// Finally, !tbaa.struct is zeroed out. - AAMDNodes adjustForAccess(unsigned AccessSize); - AAMDNodes adjustForAccess(size_t Offset, Type *AccessTy, - const DataLayout &DL); - AAMDNodes adjustForAccess(size_t Offset, unsigned AccessSize); + LLVM_ABI AAMDNodes adjustForAccess(unsigned AccessSize); + LLVM_ABI AAMDNodes adjustForAccess(size_t Offset, Type *AccessTy, + const DataLayout &DL); + LLVM_ABI AAMDNodes adjustForAccess(size_t Offset, unsigned AccessSize); }; // Specialize DenseMapInfo for AAMDNodes. @@ -1128,7 +1131,7 @@ class MDNode : public Metadata { sizeof(LargeStorageVector); } - void *getSmallPtr(); + LLVM_ABI void *getSmallPtr(); LargeStorageVector &getLarge() { assert(IsLarge); @@ -1140,12 +1143,12 @@ class MDNode : public Metadata { return *reinterpret_cast<const LargeStorageVector *>(getLargePtr()); } - void resizeSmall(size_t NumOps); - void resizeSmallToLarge(size_t NumOps); - void resize(size_t NumOps); + LLVM_ABI void resizeSmall(size_t NumOps); + LLVM_ABI void resizeSmallToLarge(size_t NumOps); + LLVM_ABI void resize(size_t NumOps); - explicit Header(size_t NumOps, StorageType Storage); - ~Header(); + LLVM_ABI explicit Header(size_t NumOps, StorageType Storage); + LLVM_ABI ~Header(); MutableArrayRef<MDOperand> operands() { if (IsLarge) @@ -1177,12 +1180,12 @@ class MDNode : public Metadata { ContextAndReplaceableUses Context; protected: - MDNode(LLVMContext &Context, unsigned ID, StorageType Storage, - ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = {}); + LLVM_ABI MDNode(LLVMContext &Context, unsigned ID, StorageType Storage, + ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = {}); ~MDNode() = default; - void *operator new(size_t Size, size_t NumOps, StorageType Storage); - void operator delete(void *Mem); + LLVM_ABI void *operator new(size_t Size, size_t NumOps, StorageType Storage); + LLVM_ABI void operator delete(void *Mem); /// Required by std, but never called. void operator delete(void *, unsigned) { @@ -1194,7 +1197,7 @@ protected: llvm_unreachable("Constructor throws?"); } - void dropAllReferences(); + LLVM_ABI void dropAllReferences(); MDOperand *mutable_begin() { return getHeader().operands().begin(); } MDOperand *mutable_end() { return getHeader().operands().end(); } @@ -1219,18 +1222,18 @@ public: ArrayRef<Metadata *> MDs); /// Create a (temporary) clone of this. - TempMDNode clone() const; + LLVM_ABI TempMDNode clone() const; /// Deallocate a node created by getTemporary. /// /// Calls \c replaceAllUsesWith(nullptr) before deleting, so any remaining /// references will be reset. - static void deleteTemporary(MDNode *N); + LLVM_ABI static void deleteTemporary(MDNode *N); LLVMContext &getContext() const { return Context.getContext(); } /// Replace a specific operand. - void replaceOperandWith(unsigned I, Metadata *New); + LLVM_ABI void replaceOperandWith(unsigned I, Metadata *New); /// Check if node is fully resolved. /// @@ -1272,10 +1275,10 @@ public: /// resolved. /// /// \pre No operands (or operands' operands, etc.) have \a isTemporary(). - void resolveCycles(); + LLVM_ABI void resolveCycles(); /// Resolve a unique, unresolved node. - void resolve(); + LLVM_ABI void resolve(); /// Replace a temporary node with a permanent one. /// @@ -1316,9 +1319,9 @@ public: /// If \c M is provided, metadata nodes will be numbered canonically; /// otherwise, pointer addresses are substituted. /// @{ - void printTree(raw_ostream &OS, const Module *M = nullptr) const; - void printTree(raw_ostream &OS, ModuleSlotTracker &MST, - const Module *M = nullptr) const; + LLVM_ABI void printTree(raw_ostream &OS, const Module *M = nullptr) const; + LLVM_ABI void printTree(raw_ostream &OS, ModuleSlotTracker &MST, + const Module *M = nullptr) const; /// @} /// User-friendly dump in tree shape. @@ -1330,25 +1333,25 @@ public: /// the nullptr version is easy to call from a debugger. /// /// @{ - void dumpTree() const; - void dumpTree(const Module *M) const; + LLVM_ABI void dumpTree() const; + LLVM_ABI void dumpTree(const Module *M) const; /// @} private: - MDNode *replaceWithPermanentImpl(); - MDNode *replaceWithUniquedImpl(); - MDNode *replaceWithDistinctImpl(); + LLVM_ABI MDNode *replaceWithPermanentImpl(); + LLVM_ABI MDNode *replaceWithUniquedImpl(); + LLVM_ABI MDNode *replaceWithDistinctImpl(); protected: /// Set an operand. /// /// Sets the operand directly, without worrying about uniquing. - void setOperand(unsigned I, Metadata *New); + LLVM_ABI void setOperand(unsigned I, Metadata *New); unsigned getNumUnresolved() const { return getHeader().NumUnresolved; } void setNumUnresolved(unsigned N) { getHeader().NumUnresolved = N; } - void storeDistinctInContext(); + LLVM_ABI void storeDistinctInContext(); template <class T, class StoreT> static T *storeImpl(T *N, StorageType Storage, StoreT &Store); template <class T> static T *storeImpl(T *N, StorageType Storage); @@ -1445,24 +1448,25 @@ public: } /// Check whether MDNode is a vtable access. - bool isTBAAVtableAccess() const; + LLVM_ABI bool isTBAAVtableAccess() const; /// Methods for metadata merging. - static MDNode *concatenate(MDNode *A, MDNode *B); - static MDNode *intersect(MDNode *A, MDNode *B); - static MDNode *getMostGenericTBAA(MDNode *A, MDNode *B); - static MDNode *getMostGenericFPMath(MDNode *A, MDNode *B); - static MDNode *getMostGenericRange(MDNode *A, MDNode *B); - static MDNode *getMostGenericNoaliasAddrspace(MDNode *A, MDNode *B); - static MDNode *getMostGenericAliasScope(MDNode *A, MDNode *B); - static MDNode *getMostGenericAlignmentOrDereferenceable(MDNode *A, MDNode *B); + LLVM_ABI static MDNode *concatenate(MDNode *A, MDNode *B); + LLVM_ABI static MDNode *intersect(MDNode *A, MDNode *B); + LLVM_ABI static MDNode *getMostGenericTBAA(MDNode *A, MDNode *B); + LLVM_ABI static MDNode *getMostGenericFPMath(MDNode *A, MDNode *B); + LLVM_ABI static MDNode *getMostGenericRange(MDNode *A, MDNode *B); + LLVM_ABI static MDNode *getMostGenericNoaliasAddrspace(MDNode *A, MDNode *B); + LLVM_ABI static MDNode *getMostGenericAliasScope(MDNode *A, MDNode *B); + LLVM_ABI static MDNode *getMostGenericAlignmentOrDereferenceable(MDNode *A, + MDNode *B); /// Merge !prof metadata from two instructions. /// Currently only implemented with direct callsites with branch weights. - static MDNode *getMergedProfMetadata(MDNode *A, MDNode *B, - const Instruction *AInstr, - const Instruction *BInstr); - static MDNode *getMergedMemProfMetadata(MDNode *A, MDNode *B); - static MDNode *getMergedCallsiteMetadata(MDNode *A, MDNode *B); + LLVM_ABI static MDNode *getMergedProfMetadata(MDNode *A, MDNode *B, + const Instruction *AInstr, + const Instruction *BInstr); + LLVM_ABI static MDNode *getMergedMemProfMetadata(MDNode *A, MDNode *B); + LLVM_ABI static MDNode *getMergedCallsiteMetadata(MDNode *A, MDNode *B); }; /// Tuple of metadata. @@ -1484,8 +1488,10 @@ class MDTuple : public MDNode { void setHash(unsigned Hash) { SubclassData32 = Hash; } void recalculateHash(); - static MDTuple *getImpl(LLVMContext &Context, ArrayRef<Metadata *> MDs, - StorageType Storage, bool ShouldCreate = true); + LLVM_ABI static MDTuple *getImpl(LLVMContext &Context, + ArrayRef<Metadata *> MDs, + StorageType Storage, + bool ShouldCreate = true); TempMDTuple cloneImpl() const { ArrayRef<MDOperand> Operands = operands(); @@ -1786,29 +1792,29 @@ class NamedMDNode : public ilist_node<NamedMDNode> { public: NamedMDNode(const NamedMDNode &) = delete; - ~NamedMDNode(); + LLVM_ABI ~NamedMDNode(); /// Drop all references and remove the node from parent module. - void eraseFromParent(); + LLVM_ABI void eraseFromParent(); /// Remove all uses and clear node vector. void dropAllReferences() { clearOperands(); } /// Drop all references to this node's operands. - void clearOperands(); + LLVM_ABI void clearOperands(); /// Get the module that holds this named metadata collection. inline Module *getParent() { return Parent; } inline const Module *getParent() const { return Parent; } - MDNode *getOperand(unsigned i) const; - unsigned getNumOperands() const; - void addOperand(MDNode *M); - void setOperand(unsigned I, MDNode *New); - StringRef getName() const; - void print(raw_ostream &ROS, bool IsForDebug = false) const; - void print(raw_ostream &ROS, ModuleSlotTracker &MST, - bool IsForDebug = false) const; - void dump() const; + LLVM_ABI MDNode *getOperand(unsigned i) const; + LLVM_ABI unsigned getNumOperands() const; + LLVM_ABI void addOperand(MDNode *M); + LLVM_ABI void setOperand(unsigned I, MDNode *New); + LLVM_ABI StringRef getName() const; + LLVM_ABI void print(raw_ostream &ROS, bool IsForDebug = false) const; + LLVM_ABI void print(raw_ostream &ROS, ModuleSlotTracker &MST, + bool IsForDebug = false) const; + LLVM_ABI void dump() const; // --------------------------------------------------------------------------- // Operand Iterator interface... diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h index 0dc8164..7a26efb 100644 --- a/llvm/include/llvm/IR/Module.h +++ b/llvm/include/llvm/IR/Module.h @@ -31,6 +31,7 @@ #include "llvm/IR/SymbolTableListTraits.h" #include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/CodeGen.h" +#include "llvm/Support/Compiler.h" #include "llvm/TargetParser/Triple.h" #include <cstddef> #include <cstdint> @@ -817,7 +818,7 @@ public: NamedMDNode *CUs; unsigned Idx; - void SkipNoDebugCUs(); + LLVM_ABI void SkipNoDebugCUs(); public: using iterator_category = std::input_iterator_tag; @@ -851,8 +852,8 @@ public: return Idx != I.Idx; } - DICompileUnit *operator*() const; - DICompileUnit *operator->() const; + LLVM_ABI DICompileUnit *operator*() const; + LLVM_ABI DICompileUnit *operator->() const; }; debug_compile_units_iterator debug_compile_units_begin() const { @@ -1065,9 +1066,9 @@ public: /// Given "llvm.used" or "llvm.compiler.used" as a global name, collect the /// initializer elements of that global in a SmallVector and return the global /// itself. -GlobalVariable *collectUsedGlobalVariables(const Module &M, - SmallVectorImpl<GlobalValue *> &Vec, - bool CompilerUsed); +LLVM_ABI GlobalVariable * +collectUsedGlobalVariables(const Module &M, SmallVectorImpl<GlobalValue *> &Vec, + bool CompilerUsed); /// An raw_ostream inserter for modules. inline raw_ostream &operator<<(raw_ostream &O, const Module &M) { diff --git a/llvm/include/llvm/IR/ModuleSlotTracker.h b/llvm/include/llvm/IR/ModuleSlotTracker.h index 37cfc0f..a3882a8 100644 --- a/llvm/include/llvm/IR/ModuleSlotTracker.h +++ b/llvm/include/llvm/IR/ModuleSlotTracker.h @@ -9,6 +9,7 @@ #ifndef LLVM_IR_MODULESLOTTRACKER_H #define LLVM_IR_MODULESLOTTRACKER_H +#include "llvm/Support/Compiler.h" #include <functional> #include <memory> #include <utility> @@ -23,7 +24,7 @@ class Value; class MDNode; /// Abstract interface of slot tracker storage. -class AbstractSlotTrackerStorage { +class LLVM_ABI AbstractSlotTrackerStorage { public: virtual ~AbstractSlotTrackerStorage(); @@ -41,7 +42,7 @@ public: /// /// If the IR changes from underneath \a ModuleSlotTracker, strings like /// "<badref>" will be printed, or, worse, the wrong slots entirely. -class ModuleSlotTracker { +class LLVM_ABI ModuleSlotTracker { /// Storage for a slot tracker. std::unique_ptr<SlotTracker> MachineStorage; bool ShouldCreateStorage = false; diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h index 65e428a..ac79d91 100644 --- a/llvm/include/llvm/IR/ModuleSummaryIndex.h +++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h @@ -249,14 +249,14 @@ struct ValueInfo { /// Returns the most constraining visibility among summaries. The /// visibilities, ordered from least to most constraining, are: default, /// protected and hidden. - GlobalValue::VisibilityTypes getELFVisibility() const; + LLVM_ABI GlobalValue::VisibilityTypes getELFVisibility() const; /// Checks if all summaries are DSO local (have the flag set). When DSOLocal /// propagation has been done, set the parameter to enable fast check. - bool isDSOLocal(bool WithDSOLocalPropagation = false) const; + LLVM_ABI bool isDSOLocal(bool WithDSOLocalPropagation = false) const; /// Checks if all copies are eligible for auto-hiding (have flag set). - bool canAutoHide() const; + LLVM_ABI bool canAutoHide() const; }; inline raw_ostream &operator<<(raw_ostream &OS, const ValueInfo &VI) { @@ -873,7 +873,7 @@ public: } /// A dummy node to reference external functions that aren't in the index - static FunctionSummary ExternalNode; + LLVM_ABI static FunctionSummary ExternalNode; private: /// Number of instructions (ignoring debug instructions, e.g.) computed @@ -943,7 +943,7 @@ public: Allocs = std::make_unique<AllocsTy>(std::move(AllocList)); } // Gets the number of readonly and writeonly refs in RefEdgeList - std::pair<unsigned, unsigned> specialRefCounts() const; + LLVM_ABI std::pair<unsigned, unsigned> specialRefCounts() const; /// Check if this is a function summary. static bool classof(const GlobalValueSummary *GVS) { @@ -1527,8 +1527,8 @@ public: bool haveGVs() const { return HaveGVs; } - uint64_t getFlags() const; - void setFlags(uint64_t Flags); + LLVM_ABI uint64_t getFlags() const; + LLVM_ABI void setFlags(uint64_t Flags); uint64_t getBlockCount() const { return BlockCount; } void addBlockCount(uint64_t C) { BlockCount += C; } @@ -1672,7 +1672,7 @@ public: bool isGlobalValueLive(const GlobalValueSummary *GVS) const { return !WithGlobalValueDeadStripping || GVS->isLive(); } - bool isGUIDLive(GlobalValue::GUID GUID) const; + LLVM_ABI bool isGUIDLive(GlobalValue::GUID GUID) const; /// Return a ValueInfo for the index value_type (convenient when iterating /// index). @@ -1796,8 +1796,9 @@ public: /// Returns the first GlobalValueSummary for \p ValueGUID, asserting that /// there /// is only one if \p PerModuleIndex. - GlobalValueSummary *getGlobalValueSummary(GlobalValue::GUID ValueGUID, - bool PerModuleIndex = true) const; + LLVM_ABI GlobalValueSummary * + getGlobalValueSummary(GlobalValue::GUID ValueGUID, + bool PerModuleIndex = true) const; /// Table of modules, containing module hash and id. const StringMap<ModuleHash> &modulePaths() const { @@ -1925,8 +1926,9 @@ public: /// Collect for the given module the list of functions it defines /// (GUID -> Summary). - void collectDefinedFunctionsForModule(StringRef ModulePath, - GVSummaryMapTy &GVSummaryMap) const; + LLVM_ABI void + collectDefinedFunctionsForModule(StringRef ModulePath, + GVSummaryMapTy &GVSummaryMap) const; /// Collect for each module the list of Summaries it defines (GUID -> /// Summary). @@ -1942,29 +1944,31 @@ public: } /// Print to an output stream. - void print(raw_ostream &OS, bool IsForDebug = false) const; + LLVM_ABI void print(raw_ostream &OS, bool IsForDebug = false) const; /// Dump to stderr (for debugging). - void dump() const; + LLVM_ABI void dump() const; /// Export summary to dot file for GraphViz. - void + LLVM_ABI void exportToDot(raw_ostream &OS, const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) const; /// Print out strongly connected components for debugging. - void dumpSCCs(raw_ostream &OS); + LLVM_ABI void dumpSCCs(raw_ostream &OS); /// Do the access attribute and DSOLocal propagation in combined index. - void propagateAttributes(const DenseSet<GlobalValue::GUID> &PreservedSymbols); + LLVM_ABI void + propagateAttributes(const DenseSet<GlobalValue::GUID> &PreservedSymbols); /// Checks if we can import global variable from another module. - bool canImportGlobalVar(const GlobalValueSummary *S, bool AnalyzeRefs) const; + LLVM_ABI bool canImportGlobalVar(const GlobalValueSummary *S, + bool AnalyzeRefs) const; /// Same as above but checks whether the global var is importable as a /// declaration. - bool canImportGlobalVar(const GlobalValueSummary *S, bool AnalyzeRefs, - bool &CanImportDecl) const; + LLVM_ABI bool canImportGlobalVar(const GlobalValueSummary *S, + bool AnalyzeRefs, bool &CanImportDecl) const; }; /// GraphTraits definition to build SCC for the index diff --git a/llvm/include/llvm/IR/NoFolder.h b/llvm/include/llvm/IR/NoFolder.h index 2a2318d..9f16c69 100644 --- a/llvm/include/llvm/IR/NoFolder.h +++ b/llvm/include/llvm/IR/NoFolder.h @@ -28,11 +28,12 @@ #include "llvm/IR/InstrTypes.h" #include "llvm/IR/Instruction.h" #include "llvm/IR/Instructions.h" +#include "llvm/Support/Compiler.h" namespace llvm { /// NoFolder - Create "constants" (actually, instructions) with no folding. -class NoFolder final : public IRBuilderFolder { +class LLVM_ABI NoFolder final : public IRBuilderFolder { LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION(); public: diff --git a/llvm/include/llvm/IR/Operator.h b/llvm/include/llvm/IR/Operator.h index 38f8464..8344eae 100644 --- a/llvm/include/llvm/IR/Operator.h +++ b/llvm/include/llvm/IR/Operator.h @@ -22,6 +22,7 @@ #include "llvm/IR/Type.h" #include "llvm/IR/Value.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" #include <cstddef> #include <optional> @@ -63,12 +64,12 @@ public: /// Return true if this operator has flags which may cause this operator /// to evaluate to poison despite having non-poison inputs. - bool hasPoisonGeneratingFlags() const; + LLVM_ABI bool hasPoisonGeneratingFlags() const; /// Return true if this operator has poison-generating flags, /// return attributes or metadata. The latter two is only possible for /// instructions. - bool hasPoisonGeneratingAnnotations() const; + LLVM_ABI bool hasPoisonGeneratingAnnotations() const; }; /// Utility class for integer operators which may exhibit overflow - Add, Sub, @@ -336,7 +337,7 @@ public: /// Get the maximum error permitted by this operation in ULPs. An accuracy of /// 0.0 means that the operation should be performed with the default /// precision. - float getFPAccuracy() const; + LLVM_ABI float getFPAccuracy() const; /// Returns true if `Ty` is a supported floating-point type for phi, select, /// or call FPMathOperators. @@ -438,7 +439,7 @@ public: /// Returns the offset of the index with an inrange attachment, or /// std::nullopt if none. - std::optional<ConstantRange> getInRange() const; + LLVM_ABI std::optional<ConstantRange> getInRange() const; inline op_iterator idx_begin() { return op_begin()+1; } inline const_op_iterator idx_begin() const { return op_begin()+1; } @@ -468,8 +469,8 @@ public: return getPointerOperand()->getType(); } - Type *getSourceElementType() const; - Type *getResultElementType() const; + LLVM_ABI Type *getSourceElementType() const; + LLVM_ABI Type *getResultElementType() const; /// Method to return the address space of the pointer operand. unsigned getPointerAddressSpace() const { @@ -515,7 +516,7 @@ public: } /// Compute the maximum alignment that this GEP is garranteed to preserve. - Align getMaxPreservedAlignment(const DataLayout &DL) const; + LLVM_ABI Align getMaxPreservedAlignment(const DataLayout &DL) const; /// Accumulate the constant address offset of this GEP if possible. /// @@ -534,20 +535,21 @@ public: /// /// The APInt passed into this routine must be at exactly as wide as the /// IntPtr type for the address space of the base GEP pointer. - bool accumulateConstantOffset( + LLVM_ABI bool accumulateConstantOffset( const DataLayout &DL, APInt &Offset, function_ref<bool(Value &, APInt &)> ExternalAnalysis = nullptr) const; - static bool accumulateConstantOffset( + LLVM_ABI static bool accumulateConstantOffset( Type *SourceType, ArrayRef<const Value *> Index, const DataLayout &DL, APInt &Offset, function_ref<bool(Value &, APInt &)> ExternalAnalysis = nullptr); /// Collect the offset of this GEP as a map of Values to their associated /// APInt multipliers, as well as a total Constant Offset. - bool collectOffset(const DataLayout &DL, unsigned BitWidth, - SmallMapVector<Value *, APInt, 4> &VariableOffsets, - APInt &ConstantOffset) const; + LLVM_ABI bool + collectOffset(const DataLayout &DL, unsigned BitWidth, + SmallMapVector<Value *, APInt, 4> &VariableOffsets, + APInt &ConstantOffset) const; }; template <> diff --git a/llvm/include/llvm/IR/OptBisect.h b/llvm/include/llvm/IR/OptBisect.h index 507d415..be6aef3 100644 --- a/llvm/include/llvm/IR/OptBisect.h +++ b/llvm/include/llvm/IR/OptBisect.h @@ -15,6 +15,7 @@ #define LLVM_IR_OPTBISECT_H #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Compiler.h" #include <limits> namespace llvm { @@ -40,7 +41,7 @@ public: /// optimizations at compile time based on a command line option /// (-opt-bisect-limit) in order to perform a bisecting search for /// optimization-related problems. -class OptBisect : public OptPassGate { +class LLVM_ABI OptBisect : public OptPassGate { public: /// Default constructor. Initializes the state to "disabled". The bisection /// will be enabled by the cl::opt call-back when the command line option @@ -83,7 +84,7 @@ private: /// Singleton instance of the OptBisect class, so multiple pass managers don't /// need to coordinate their uses of OptBisect. -OptPassGate &getGlobalPassGate(); +LLVM_ABI OptPassGate &getGlobalPassGate(); } // end namespace llvm diff --git a/llvm/include/llvm/IR/PassInstrumentation.h b/llvm/include/llvm/IR/PassInstrumentation.h index 3172cef..0315715 100644 --- a/llvm/include/llvm/IR/PassInstrumentation.h +++ b/llvm/include/llvm/IR/PassInstrumentation.h @@ -163,9 +163,9 @@ public: } /// Add a class name to pass name mapping for use by pass instrumentation. - void addClassToPassName(StringRef ClassName, StringRef PassName); + LLVM_ABI void addClassToPassName(StringRef ClassName, StringRef PassName); /// Get the pass name for a given pass class name. - StringRef getPassNameForClassName(StringRef ClassName); + LLVM_ABI StringRef getPassNameForClassName(StringRef ClassName); private: friend class PassInstrumentation; @@ -344,14 +344,15 @@ public: } }; -bool isSpecialPass(StringRef PassID, const std::vector<StringRef> &Specials); +LLVM_ABI bool isSpecialPass(StringRef PassID, + const std::vector<StringRef> &Specials); /// Pseudo-analysis pass that exposes the \c PassInstrumentation to pass /// managers. class PassInstrumentationAnalysis : public AnalysisInfoMixin<PassInstrumentationAnalysis> { friend AnalysisInfoMixin<PassInstrumentationAnalysis>; - static AnalysisKey Key; + LLVM_ABI static AnalysisKey Key; PassInstrumentationCallbacks *Callbacks; diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h index b523004..4f44ae5 100644 --- a/llvm/include/llvm/IR/PassManager.h +++ b/llvm/include/llvm/IR/PassManager.h @@ -43,6 +43,7 @@ #include "llvm/ADT/TinyPtrVector.h" #include "llvm/IR/Analysis.h" #include "llvm/IR/PassManagerInternal.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/TypeName.h" #include <cassert> #include <cstring> @@ -229,18 +230,19 @@ template <typename IRUnitT> void printIRUnitNameForStackTrace(raw_ostream &OS, const IRUnitT &IR); template <> -void printIRUnitNameForStackTrace<Module>(raw_ostream &OS, const Module &IR); +LLVM_ABI void printIRUnitNameForStackTrace<Module>(raw_ostream &OS, + const Module &IR); -extern template class PassManager<Module>; +extern template class LLVM_TEMPLATE_ABI PassManager<Module>; /// Convenience typedef for a pass manager over modules. using ModulePassManager = PassManager<Module>; template <> -void printIRUnitNameForStackTrace<Function>(raw_ostream &OS, - const Function &IR); +LLVM_ABI void printIRUnitNameForStackTrace<Function>(raw_ostream &OS, + const Function &IR); -extern template class PassManager<Function>; +extern template class LLVM_TEMPLATE_ABI PassManager<Function>; /// Convenience typedef for a pass manager over functions. using FunctionPassManager = PassManager<Function>; @@ -535,12 +537,12 @@ private: AnalysisResultMapT AnalysisResults; }; -extern template class AnalysisManager<Module>; +extern template class LLVM_TEMPLATE_ABI AnalysisManager<Module>; /// Convenience typedef for the Module analysis manager. using ModuleAnalysisManager = AnalysisManager<Module>; -extern template class AnalysisManager<Function>; +extern template class LLVM_TEMPLATE_ABI AnalysisManager<Function>; /// Convenience typedef for the Function analysis manager. using FunctionAnalysisManager = AnalysisManager<Function>; @@ -562,7 +564,7 @@ using FunctionAnalysisManager = AnalysisManager<Function>; /// Note that the proxy's result is a move-only RAII object. The validity of /// the analyses in the inner analysis manager is tied to its lifetime. template <typename AnalysisManagerT, typename IRUnitT, typename... ExtraArgTs> -class InnerAnalysisManagerProxy +class LLVM_TEMPLATE_ABI InnerAnalysisManagerProxy : public AnalysisInfoMixin< InnerAnalysisManagerProxy<AnalysisManagerT, IRUnitT>> { public: @@ -650,7 +652,7 @@ using FunctionAnalysisManagerModuleProxy = /// Specialization of the invalidate method for the \c /// FunctionAnalysisManagerModuleProxy's result. template <> -bool FunctionAnalysisManagerModuleProxy::Result::invalidate( +LLVM_ABI bool FunctionAnalysisManagerModuleProxy::Result::invalidate( Module &M, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &Inv); @@ -795,8 +797,8 @@ template <typename AnalysisManagerT, typename IRUnitT, typename... ExtraArgTs> AnalysisKey OuterAnalysisManagerProxy<AnalysisManagerT, IRUnitT, ExtraArgTs...>::Key; -extern template class OuterAnalysisManagerProxy<ModuleAnalysisManager, - Function>; +extern template class LLVM_TEMPLATE_ABI + OuterAnalysisManagerProxy<ModuleAnalysisManager, Function>; /// Provide the \c ModuleAnalysisManager to \c Function proxy. using ModuleAnalysisManagerFunctionProxy = OuterAnalysisManagerProxy<ModuleAnalysisManager, Function>; @@ -834,9 +836,10 @@ public: : Pass(std::move(Pass)), EagerlyInvalidate(EagerlyInvalidate) {} /// Runs the function pass across every function in the module. - PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); - void printPipeline(raw_ostream &OS, - function_ref<StringRef(StringRef)> MapClassName2PassName); + LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); + LLVM_ABI void + printPipeline(raw_ostream &OS, + function_ref<StringRef(StringRef)> MapClassName2PassName); static bool isRequired() { return true; } diff --git a/llvm/include/llvm/IR/PassManagerImpl.h b/llvm/include/llvm/IR/PassManagerImpl.h index 55f504c..04ccbbb 100644 --- a/llvm/include/llvm/IR/PassManagerImpl.h +++ b/llvm/include/llvm/IR/PassManagerImpl.h @@ -19,9 +19,10 @@ #include "llvm/IR/PassInstrumentation.h" #include "llvm/IR/PassManager.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/PrettyStackTrace.h" -extern llvm::cl::opt<bool> UseNewDbgInfoFormat; +LLVM_ABI extern llvm::cl::opt<bool> UseNewDbgInfoFormat; namespace llvm { diff --git a/llvm/include/llvm/IR/PassTimingInfo.h b/llvm/include/llvm/IR/PassTimingInfo.h index b47ba7f..03e481a 100644 --- a/llvm/include/llvm/IR/PassTimingInfo.h +++ b/llvm/include/llvm/IR/PassTimingInfo.h @@ -18,6 +18,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Timer.h" #include <memory> #include <utility> @@ -31,10 +32,10 @@ class raw_ostream; /// If -time-passes has been specified, report the timings immediately and then /// reset the timers to zero. By default it uses the stream created by /// CreateInfoOutputFile(). -void reportAndResetTimings(raw_ostream *OutStream = nullptr); +LLVM_ABI void reportAndResetTimings(raw_ostream *OutStream = nullptr); /// Request the timer for this legacy-pass-manager's pass instance. -Timer *getPassTimer(Pass *); +LLVM_ABI Timer *getPassTimer(Pass *); /// This class implements -time-passes functionality for new pass manager. /// It provides the pass-instrumentation callbacks that measure the pass @@ -78,20 +79,20 @@ public: static constexpr StringRef AnalysisGroupDesc = "Analysis execution timing report"; - TimePassesHandler(); - TimePassesHandler(bool Enabled, bool PerRun = false); + LLVM_ABI TimePassesHandler(); + LLVM_ABI TimePassesHandler(bool Enabled, bool PerRun = false); /// Prints out timing information and then resets the timers. - void print(); + LLVM_ABI void print(); // We intend this to be unique per-compilation, thus no copies. TimePassesHandler(const TimePassesHandler &) = delete; void operator=(const TimePassesHandler &) = delete; - void registerCallbacks(PassInstrumentationCallbacks &PIC); + LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC); /// Set a custom output stream for subsequent reporting. - void setOutStream(raw_ostream &OutStream); + LLVM_ABI void setOutStream(raw_ostream &OutStream); private: /// Dumps information for running/triggered timers, useful for debugging diff --git a/llvm/include/llvm/IR/ProfDataUtils.h b/llvm/include/llvm/IR/ProfDataUtils.h index 0bea517..8e8d069 100644 --- a/llvm/include/llvm/IR/ProfDataUtils.h +++ b/llvm/include/llvm/IR/ProfDataUtils.h @@ -18,55 +18,56 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Twine.h" #include "llvm/IR/Metadata.h" +#include "llvm/Support/Compiler.h" namespace llvm { /// Checks if an Instruction has MD_prof Metadata -bool hasProfMD(const Instruction &I); +LLVM_ABI bool hasProfMD(const Instruction &I); /// Checks if an MDNode contains Branch Weight Metadata -bool isBranchWeightMD(const MDNode *ProfileData); +LLVM_ABI bool isBranchWeightMD(const MDNode *ProfileData); /// Checks if an instructions has Branch Weight Metadata /// /// \param I The instruction to check /// \returns True if I has an MD_prof node containing Branch Weights. False /// otherwise. -bool hasBranchWeightMD(const Instruction &I); +LLVM_ABI bool hasBranchWeightMD(const Instruction &I); /// Checks if an instructions has valid Branch Weight Metadata /// /// \param I The instruction to check /// \returns True if I has an MD_prof node containing valid Branch Weights, /// i.e., one weight for each successor. False otherwise. -bool hasValidBranchWeightMD(const Instruction &I); +LLVM_ABI bool hasValidBranchWeightMD(const Instruction &I); /// Get the branch weights metadata node /// /// \param I The Instruction to get the weights from. /// \returns A pointer to I's branch weights metadata node, if it exists. /// Nullptr otherwise. -MDNode *getBranchWeightMDNode(const Instruction &I); +LLVM_ABI MDNode *getBranchWeightMDNode(const Instruction &I); /// Get the valid branch weights metadata node /// /// \param I The Instruction to get the weights from. /// \returns A pointer to I's valid branch weights metadata node, if it exists. /// Nullptr otherwise. -MDNode *getValidBranchWeightMDNode(const Instruction &I); +LLVM_ABI MDNode *getValidBranchWeightMDNode(const Instruction &I); /// Check if Branch Weight Metadata has an "expected" field from an llvm.expect* /// intrinsic -bool hasBranchWeightOrigin(const Instruction &I); +LLVM_ABI bool hasBranchWeightOrigin(const Instruction &I); /// Check if Branch Weight Metadata has an "expected" field from an llvm.expect* /// intrinsic -bool hasBranchWeightOrigin(const MDNode *ProfileData); +LLVM_ABI bool hasBranchWeightOrigin(const MDNode *ProfileData); /// Return the offset to the first branch weight data -unsigned getBranchWeightOffset(const MDNode *ProfileData); +LLVM_ABI unsigned getBranchWeightOffset(const MDNode *ProfileData); -unsigned getNumBranchWeights(const MDNode &ProfileData); +LLVM_ABI unsigned getNumBranchWeights(const MDNode &ProfileData); /// Extract branch weights from MD_prof metadata /// @@ -74,18 +75,18 @@ unsigned getNumBranchWeights(const MDNode &ProfileData); /// \param [out] Weights An output vector to fill with branch weights /// \returns True if weights were extracted, False otherwise. When false Weights /// will be cleared. -bool extractBranchWeights(const MDNode *ProfileData, - SmallVectorImpl<uint32_t> &Weights); +LLVM_ABI bool extractBranchWeights(const MDNode *ProfileData, + SmallVectorImpl<uint32_t> &Weights); /// Faster version of extractBranchWeights() that skips checks and must only /// be called with "branch_weights" metadata nodes. Supports uint32_t. -void extractFromBranchWeightMD32(const MDNode *ProfileData, - SmallVectorImpl<uint32_t> &Weights); +LLVM_ABI void extractFromBranchWeightMD32(const MDNode *ProfileData, + SmallVectorImpl<uint32_t> &Weights); /// Faster version of extractBranchWeights() that skips checks and must only /// be called with "branch_weights" metadata nodes. Supports uint64_t. -void extractFromBranchWeightMD64(const MDNode *ProfileData, - SmallVectorImpl<uint64_t> &Weights); +LLVM_ABI void extractFromBranchWeightMD64(const MDNode *ProfileData, + SmallVectorImpl<uint64_t> &Weights); /// Extract branch weights attatched to an Instruction /// @@ -93,8 +94,8 @@ void extractFromBranchWeightMD64(const MDNode *ProfileData, /// \param [out] Weights An output vector to fill with branch weights /// \returns True if weights were extracted, False otherwise. When false Weights /// will be cleared. -bool extractBranchWeights(const Instruction &I, - SmallVectorImpl<uint32_t> &Weights); +LLVM_ABI bool extractBranchWeights(const Instruction &I, + SmallVectorImpl<uint32_t> &Weights); /// Extract branch weights from a conditional branch or select Instruction. /// @@ -103,8 +104,8 @@ bool extractBranchWeights(const Instruction &I, /// \param [out] FalseVal will contain the branch weight for the False branch /// \returns True on success with profile weights filled in. False if no /// metadata or invalid metadata was found. -bool extractBranchWeights(const Instruction &I, uint64_t &TrueVal, - uint64_t &FalseVal); +LLVM_ABI bool extractBranchWeights(const Instruction &I, uint64_t &TrueVal, + uint64_t &FalseVal); /// Retrieve the total of all weights from MD_prof data. /// @@ -112,7 +113,8 @@ bool extractBranchWeights(const Instruction &I, uint64_t &TrueVal, /// \param [out] TotalWeights input variable to fill with total weights /// \returns True on success with profile total weights filled in. False if no /// metadata was found. -bool extractProfTotalWeight(const MDNode *ProfileData, uint64_t &TotalWeights); +LLVM_ABI bool extractProfTotalWeight(const MDNode *ProfileData, + uint64_t &TotalWeights); /// Retrieve the total of all weights from an instruction. /// @@ -120,18 +122,19 @@ bool extractProfTotalWeight(const MDNode *ProfileData, uint64_t &TotalWeights); /// \param [out] TotalWeights input variable to fill with total weights /// \returns True on success with profile total weights filled in. False if no /// metadata was found. -bool extractProfTotalWeight(const Instruction &I, uint64_t &TotalWeights); +LLVM_ABI bool extractProfTotalWeight(const Instruction &I, + uint64_t &TotalWeights); /// Create a new `branch_weights` metadata node and add or overwrite /// a `prof` metadata reference to instruction `I`. /// \param I the Instruction to set branch weights on. /// \param Weights an array of weights to set on instruction I. /// \param IsExpected were these weights added from an llvm.expect* intrinsic. -void setBranchWeights(Instruction &I, ArrayRef<uint32_t> Weights, - bool IsExpected); +LLVM_ABI void setBranchWeights(Instruction &I, ArrayRef<uint32_t> Weights, + bool IsExpected); /// Scaling the profile data attached to 'I' using the ratio of S/T. -void scaleProfData(Instruction &I, uint64_t S, uint64_t T); +LLVM_ABI void scaleProfData(Instruction &I, uint64_t S, uint64_t T); } // namespace llvm #endif diff --git a/llvm/include/llvm/IR/ProfileSummary.h b/llvm/include/llvm/IR/ProfileSummary.h index b23d5a3..6c087ea 100644 --- a/llvm/include/llvm/IR/ProfileSummary.h +++ b/llvm/include/llvm/IR/ProfileSummary.h @@ -13,6 +13,7 @@ #ifndef LLVM_IR_PROFILESUMMARY_H #define LLVM_IR_PROFILESUMMARY_H +#include "llvm/Support/Compiler.h" #include <algorithm> #include <cassert> #include <cstdint> @@ -81,10 +82,10 @@ public: Kind getKind() const { return PSK; } /// Return summary information as metadata. - Metadata *getMD(LLVMContext &Context, bool AddPartialField = true, - bool AddPartialProfileRatioField = true); + LLVM_ABI Metadata *getMD(LLVMContext &Context, bool AddPartialField = true, + bool AddPartialProfileRatioField = true); /// Construct profile summary from metdata. - static ProfileSummary *getFromMD(Metadata *MD); + LLVM_ABI static ProfileSummary *getFromMD(Metadata *MD); const SummaryEntryVector &getDetailedSummary() { return DetailedSummary; } uint32_t getNumFunctions() const { return NumFunctions; } uint64_t getMaxFunctionCount() const { return MaxFunctionCount; } @@ -99,8 +100,8 @@ public: assert(isPartialProfile() && "Unexpected when not partial profile"); PartialProfileRatio = R; } - void printSummary(raw_ostream &OS) const; - void printDetailedSummary(raw_ostream &OS) const; + LLVM_ABI void printSummary(raw_ostream &OS) const; + LLVM_ABI void printDetailedSummary(raw_ostream &OS) const; }; } // end namespace llvm diff --git a/llvm/include/llvm/IR/PseudoProbe.h b/llvm/include/llvm/IR/PseudoProbe.h index 7308904..5c652b1 100644 --- a/llvm/include/llvm/IR/PseudoProbe.h +++ b/llvm/include/llvm/IR/PseudoProbe.h @@ -13,6 +13,7 @@ #ifndef LLVM_IR_PSEUDOPROBE_H #define LLVM_IR_PSEUDOPROBE_H +#include "llvm/Support/Compiler.h" #include <cassert> #include <cstdint> #include <limits> @@ -133,9 +134,9 @@ static inline bool hasDiscriminator(uint32_t Flags) { return Flags & (uint32_t)PseudoProbeAttributes::HasDiscriminator; } -std::optional<PseudoProbe> extractProbe(const Instruction &Inst); +LLVM_ABI std::optional<PseudoProbe> extractProbe(const Instruction &Inst); -void setProbeDistributionFactor(Instruction &Inst, float Factor); +LLVM_ABI void setProbeDistributionFactor(Instruction &Inst, float Factor); } // end namespace llvm #endif // LLVM_IR_PSEUDOPROBE_H diff --git a/llvm/include/llvm/IR/ReplaceConstant.h b/llvm/include/llvm/IR/ReplaceConstant.h index 8c497eb..cbea221 100644 --- a/llvm/include/llvm/IR/ReplaceConstant.h +++ b/llvm/include/llvm/IR/ReplaceConstant.h @@ -14,6 +14,8 @@ #ifndef LLVM_IR_REPLACECONSTANT_H #define LLVM_IR_REPLACECONSTANT_H +#include "llvm/Support/Compiler.h" + namespace llvm { template <typename T> class ArrayRef; @@ -33,10 +35,9 @@ class Function; /// /// If \p IncludeSelf is enabled, also convert the passed constants themselves /// to instructions, rather than only their users. -bool convertUsersOfConstantsToInstructions(ArrayRef<Constant *> Consts, - Function *RestrictToFunc = nullptr, - bool RemoveDeadConstants = true, - bool IncludeSelf = false); +LLVM_ABI bool convertUsersOfConstantsToInstructions( + ArrayRef<Constant *> Consts, Function *RestrictToFunc = nullptr, + bool RemoveDeadConstants = true, bool IncludeSelf = false); } // end namespace llvm diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h index b3648f5..26c0850 100644 --- a/llvm/include/llvm/IR/RuntimeLibcalls.h +++ b/llvm/include/llvm/IR/RuntimeLibcalls.h @@ -17,6 +17,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/IR/CallingConv.h" #include "llvm/Support/AtomicOrdering.h" +#include "llvm/Support/Compiler.h" #include "llvm/TargetParser/Triple.h" namespace llvm { @@ -96,7 +97,7 @@ private: /// Set default libcall names. If a target wants to opt-out of a libcall it /// should be placed here. - void initLibcalls(const Triple &TT); + LLVM_ABI void initLibcalls(const Triple &TT); }; } // namespace RTLIB diff --git a/llvm/include/llvm/IR/StructuralHash.h b/llvm/include/llvm/IR/StructuralHash.h index 514dd6f..fc4b97e 100644 --- a/llvm/include/llvm/IR/StructuralHash.h +++ b/llvm/include/llvm/IR/StructuralHash.h @@ -17,6 +17,7 @@ #include "llvm/ADT/MapVector.h" #include "llvm/ADT/StableHashing.h" #include "llvm/IR/Instruction.h" +#include "llvm/Support/Compiler.h" #include <cstdint> namespace llvm { @@ -29,16 +30,17 @@ class Module; /// \param DetailedHash Whether or not to encode additional information in the /// hash. The additional information added into the hash when this flag is set /// to true includes instruction and operand type information. -stable_hash StructuralHash(const Function &F, bool DetailedHash = false); +LLVM_ABI stable_hash StructuralHash(const Function &F, + bool DetailedHash = false); /// Returns a hash of the global variable \p G. -stable_hash StructuralHash(const GlobalVariable &G); +LLVM_ABI stable_hash StructuralHash(const GlobalVariable &G); /// Returns a hash of the module \p M by hashing all functions and global /// variables contained within. \param M The module to hash. \param DetailedHash /// Whether or not to encode additional information in the function hashes that /// composed the module hash. -stable_hash StructuralHash(const Module &M, bool DetailedHash = false); +LLVM_ABI stable_hash StructuralHash(const Module &M, bool DetailedHash = false); /// The pair of an instruction index and a operand index. using IndexPair = std::pair<unsigned, unsigned>; @@ -80,8 +82,8 @@ struct FunctionHashInfo { /// \param IgnoreOp A callable that takes an instruction and an operand index, /// and returns true if the operand should be ignored in the hash computation. /// \return A FunctionHashInfo structure -FunctionHashInfo StructuralHashWithDifferences(const Function &F, - IgnoreOperandFunc IgnoreOp); +LLVM_ABI FunctionHashInfo +StructuralHashWithDifferences(const Function &F, IgnoreOperandFunc IgnoreOp); } // end namespace llvm diff --git a/llvm/include/llvm/IR/SymbolTableListTraits.h b/llvm/include/llvm/IR/SymbolTableListTraits.h index fcf6f0f..e8fcab8 100644 --- a/llvm/include/llvm/IR/SymbolTableListTraits.h +++ b/llvm/include/llvm/IR/SymbolTableListTraits.h @@ -26,6 +26,7 @@ #include "llvm/ADT/ilist.h" #include "llvm/ADT/simple_ilist.h" +#include "llvm/Support/Compiler.h" #include <cstddef> namespace llvm { @@ -109,11 +110,11 @@ public: // The SymbolTableListTraits template is explicitly instantiated for the // following data types, so add extern template statements to prevent implicit // instantiation. -extern template class SymbolTableListTraits<BasicBlock>; -extern template class SymbolTableListTraits<Function>; -extern template class SymbolTableListTraits<GlobalAlias>; -extern template class SymbolTableListTraits<GlobalIFunc>; -extern template class SymbolTableListTraits<GlobalVariable>; +extern template class LLVM_TEMPLATE_ABI SymbolTableListTraits<BasicBlock>; +extern template class LLVM_TEMPLATE_ABI SymbolTableListTraits<Function>; +extern template class LLVM_TEMPLATE_ABI SymbolTableListTraits<GlobalAlias>; +extern template class LLVM_TEMPLATE_ABI SymbolTableListTraits<GlobalIFunc>; +extern template class LLVM_TEMPLATE_ABI SymbolTableListTraits<GlobalVariable>; /// List that automatically updates parent links and symbol tables. /// diff --git a/llvm/include/llvm/IR/Type.h b/llvm/include/llvm/IR/Type.h index 37f6b2e..fd98717 100644 --- a/llvm/include/llvm/IR/Type.h +++ b/llvm/include/llvm/IR/Type.h @@ -119,10 +119,10 @@ public: /// When \p NoDetails is true, we only print %st. /// Put differently, \p NoDetails prints the type as if /// inlined with the operands when printing an instruction. - void print(raw_ostream &O, bool IsForDebug = false, - bool NoDetails = false) const; + LLVM_ABI void print(raw_ostream &O, bool IsForDebug = false, + bool NoDetails = false) const; - void dump() const; + LLVM_ABI void dump() const; /// Return the LLVMContext in which this type was uniqued. LLVMContext &getContext() const { return Context; } @@ -194,7 +194,7 @@ public: return getTypeID() == PPC_FP128TyID; } - const fltSemantics &getFltSemantics() const; + LLVM_ABI const fltSemantics &getFltSemantics() const; /// Return true if this is X86 AMX. bool isX86_AMXTy() const { return getTypeID() == X86_AMXTyID; } @@ -203,23 +203,23 @@ public: bool isTargetExtTy() const { return getTypeID() == TargetExtTyID; } /// Return true if this is a target extension type with a scalable layout. - bool isScalableTargetExtTy() const; + LLVM_ABI bool isScalableTargetExtTy() const; /// Return true if this is a type whose size is a known multiple of vscale. - bool isScalableTy(SmallPtrSetImpl<const Type *> &Visited) const; - bool isScalableTy() const; + LLVM_ABI bool isScalableTy(SmallPtrSetImpl<const Type *> &Visited) const; + LLVM_ABI bool isScalableTy() const; /// Return true if this type is or contains a target extension type that /// disallows being used as a global. - bool + LLVM_ABI bool containsNonGlobalTargetExtType(SmallPtrSetImpl<const Type *> &Visited) const; - bool containsNonGlobalTargetExtType() const; + LLVM_ABI bool containsNonGlobalTargetExtType() const; /// Return true if this type is or contains a target extension type that /// disallows being used as a local. - bool + LLVM_ABI bool containsNonLocalTargetExtType(SmallPtrSetImpl<const Type *> &Visited) const; - bool containsNonLocalTargetExtType() const; + LLVM_ABI bool containsNonLocalTargetExtType() const; /// Return true if this is a FP type or a vector of FP. bool isFPOrFPVectorTy() const { return getScalarType()->isFloatingPointTy(); } @@ -237,7 +237,7 @@ public: bool isIntegerTy() const { return getTypeID() == IntegerTyID; } /// Return true if this is an IntegerType of the given width. - bool isIntegerTy(unsigned Bitwidth) const; + LLVM_ABI bool isIntegerTy(unsigned Bitwidth) const; /// Return true if this is an integer type or a vector of integer types. bool isIntOrIntVectorTy() const { return getScalarType()->isIntegerTy(); } @@ -272,21 +272,21 @@ public: } // True if this is an instance of TargetExtType of RISC-V vector tuple. - bool isRISCVVectorTupleTy() const; + LLVM_ABI bool isRISCVVectorTupleTy() const; /// Return true if this type could be converted with a lossless BitCast to /// type 'Ty'. For example, i8* to i32*. BitCasts are valid for types of the /// same size only where no re-interpretation of the bits is done. /// Determine if this type could be losslessly bitcast to Ty - bool canLosslesslyBitCastTo(Type *Ty) const; + LLVM_ABI bool canLosslesslyBitCastTo(Type *Ty) const; /// Return true if this type is empty, that is, it has no elements or all of /// its elements are empty. - bool isEmptyTy() const; + LLVM_ABI bool isEmptyTy() const; /// Return true if the type is "first class", meaning it is a valid type for a /// Value. - bool isFirstClassType() const; + LLVM_ABI bool isFirstClassType() const; /// Return true if the type is a valid type for a register in codegen. This /// includes all first-class types except struct and array types. @@ -332,17 +332,17 @@ public: /// instance of the type is stored to memory. The DataLayout class provides /// additional query functions to provide this information. /// - TypeSize getPrimitiveSizeInBits() const LLVM_READONLY; + LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY; /// If this is a vector type, return the getPrimitiveSizeInBits value for the /// element type. Otherwise return the getPrimitiveSizeInBits value for this /// type. - unsigned getScalarSizeInBits() const LLVM_READONLY; + LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY; /// Return the width of the mantissa of this type. This is only valid on /// floating-point types. If the FP type does not have a stable mantissa (e.g. /// ppc long double), this method returns -1. - int getFPMantissaWidth() const; + LLVM_ABI int getFPMantissaWidth() const; /// If this is a vector type, return the element type, otherwise return /// 'this'. @@ -390,40 +390,40 @@ public: // only intended to cover the core methods that are frequently used, helper // methods should not be added here. - inline unsigned getIntegerBitWidth() const; + LLVM_ABI inline unsigned getIntegerBitWidth() const; - inline Type *getFunctionParamType(unsigned i) const; - inline unsigned getFunctionNumParams() const; - inline bool isFunctionVarArg() const; + LLVM_ABI inline Type *getFunctionParamType(unsigned i) const; + LLVM_ABI inline unsigned getFunctionNumParams() const; + LLVM_ABI inline bool isFunctionVarArg() const; - inline StringRef getStructName() const; - inline unsigned getStructNumElements() const; - inline Type *getStructElementType(unsigned N) const; + LLVM_ABI inline StringRef getStructName() const; + LLVM_ABI inline unsigned getStructNumElements() const; + LLVM_ABI inline Type *getStructElementType(unsigned N) const; - inline uint64_t getArrayNumElements() const; + LLVM_ABI inline uint64_t getArrayNumElements() const; Type *getArrayElementType() const { assert(getTypeID() == ArrayTyID); return ContainedTys[0]; } - inline StringRef getTargetExtName() const; + LLVM_ABI inline StringRef getTargetExtName() const; /// Given vector type, change the element type, /// whilst keeping the old number of elements. /// For non-vectors simply returns \p EltTy. - inline Type *getWithNewType(Type *EltTy) const; + LLVM_ABI inline Type *getWithNewType(Type *EltTy) const; /// Given an integer or vector type, change the lane bitwidth to NewBitwidth, /// whilst keeping the old number of lanes. - inline Type *getWithNewBitWidth(unsigned NewBitWidth) const; + LLVM_ABI inline Type *getWithNewBitWidth(unsigned NewBitWidth) const; /// Given scalar/vector integer type, returns a type with elements twice as /// wide as in the original type. For vectors, preserves element count. - inline Type *getExtendedType() const; + LLVM_ABI inline Type *getExtendedType() const; /// Get the address space of this pointer or pointer vector type. - inline unsigned getPointerAddressSpace() const; + LLVM_ABI inline unsigned getPointerAddressSpace() const; //===--------------------------------------------------------------------===// // Static members exported by the Type class itself. Useful for getting @@ -431,30 +431,30 @@ public: // /// Return a type based on an identifier. - static Type *getPrimitiveType(LLVMContext &C, TypeID IDNumber); + LLVM_ABI static Type *getPrimitiveType(LLVMContext &C, TypeID IDNumber); //===--------------------------------------------------------------------===// // These are the builtin types that are always available. // - static Type *getVoidTy(LLVMContext &C); - static Type *getLabelTy(LLVMContext &C); - static Type *getHalfTy(LLVMContext &C); - static Type *getBFloatTy(LLVMContext &C); - static Type *getFloatTy(LLVMContext &C); - static Type *getDoubleTy(LLVMContext &C); - static Type *getMetadataTy(LLVMContext &C); - static Type *getX86_FP80Ty(LLVMContext &C); - static Type *getFP128Ty(LLVMContext &C); - static Type *getPPC_FP128Ty(LLVMContext &C); - static Type *getX86_AMXTy(LLVMContext &C); - static Type *getTokenTy(LLVMContext &C); - static IntegerType *getIntNTy(LLVMContext &C, unsigned N); - static IntegerType *getInt1Ty(LLVMContext &C); - static IntegerType *getInt8Ty(LLVMContext &C); - static IntegerType *getInt16Ty(LLVMContext &C); - static IntegerType *getInt32Ty(LLVMContext &C); - static IntegerType *getInt64Ty(LLVMContext &C); - static IntegerType *getInt128Ty(LLVMContext &C); + LLVM_ABI static Type *getVoidTy(LLVMContext &C); + LLVM_ABI static Type *getLabelTy(LLVMContext &C); + LLVM_ABI static Type *getHalfTy(LLVMContext &C); + LLVM_ABI static Type *getBFloatTy(LLVMContext &C); + LLVM_ABI static Type *getFloatTy(LLVMContext &C); + LLVM_ABI static Type *getDoubleTy(LLVMContext &C); + LLVM_ABI static Type *getMetadataTy(LLVMContext &C); + LLVM_ABI static Type *getX86_FP80Ty(LLVMContext &C); + LLVM_ABI static Type *getFP128Ty(LLVMContext &C); + LLVM_ABI static Type *getPPC_FP128Ty(LLVMContext &C); + LLVM_ABI static Type *getX86_AMXTy(LLVMContext &C); + LLVM_ABI static Type *getTokenTy(LLVMContext &C); + LLVM_ABI static IntegerType *getIntNTy(LLVMContext &C, unsigned N); + LLVM_ABI static IntegerType *getInt1Ty(LLVMContext &C); + LLVM_ABI static IntegerType *getInt8Ty(LLVMContext &C); + LLVM_ABI static IntegerType *getInt16Ty(LLVMContext &C); + LLVM_ABI static IntegerType *getInt32Ty(LLVMContext &C); + LLVM_ABI static IntegerType *getInt64Ty(LLVMContext &C); + LLVM_ABI static IntegerType *getInt128Ty(LLVMContext &C); template <typename ScalarTy> static Type *getScalarTy(LLVMContext &C) { int noOfBits = sizeof(ScalarTy) * CHAR_BIT; if (std::is_integral<ScalarTy>::value) { @@ -469,25 +469,27 @@ public: } llvm_unreachable("Unsupported type in Type::getScalarTy"); } - static Type *getFloatingPointTy(LLVMContext &C, const fltSemantics &S); + LLVM_ABI static Type *getFloatingPointTy(LLVMContext &C, + const fltSemantics &S); //===--------------------------------------------------------------------===// // Convenience methods for getting pointer types. // - static Type *getWasm_ExternrefTy(LLVMContext &C); - static Type *getWasm_FuncrefTy(LLVMContext &C); + LLVM_ABI static Type *getWasm_ExternrefTy(LLVMContext &C); + LLVM_ABI static Type *getWasm_FuncrefTy(LLVMContext &C); /// Return a pointer to the current type. This is equivalent to /// PointerType::get(Ctx, AddrSpace). /// TODO: Remove this after opaque pointer transition is complete. - LLVM_DEPRECATED("Use PointerType::get instead", "PointerType::get") - PointerType *getPointerTo(unsigned AddrSpace = 0) const; + LLVM_ABI LLVM_DEPRECATED("Use PointerType::get instead", "PointerType::get") + PointerType *getPointerTo(unsigned AddrSpace = 0) const; private: /// Derived types like structures and arrays are sized iff all of the members /// of the type are sized as well. Since asking for their size is relatively /// uncommon, move this operation out-of-line. - bool isSizedDerivedType(SmallPtrSetImpl<Type*> *Visited = nullptr) const; + LLVM_ABI bool + isSizedDerivedType(SmallPtrSetImpl<Type *> *Visited = nullptr) const; }; // Printing of types. diff --git a/llvm/include/llvm/IR/TypedPointerType.h b/llvm/include/llvm/IR/TypedPointerType.h index 1bea715..6d1486b 100644 --- a/llvm/include/llvm/IR/TypedPointerType.h +++ b/llvm/include/llvm/IR/TypedPointerType.h @@ -15,6 +15,7 @@ #define LLVM_IR_TYPEDPOINTERTYPE_H #include "llvm/IR/Type.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -33,10 +34,11 @@ public: /// This constructs a pointer to an object of the specified type in a numbered /// address space. - static TypedPointerType *get(Type *ElementType, unsigned AddressSpace); + LLVM_ABI static TypedPointerType *get(Type *ElementType, + unsigned AddressSpace); /// Return true if the specified type is valid as a element type. - static bool isValidElementType(Type *ElemTy); + LLVM_ABI static bool isValidElementType(Type *ElemTy); /// Return the address space of the Pointer type. unsigned getAddressSpace() const { return getSubclassData(); } diff --git a/llvm/include/llvm/IR/Use.h b/llvm/include/llvm/IR/Use.h index 0d5d878..0894d94 100644 --- a/llvm/include/llvm/IR/Use.h +++ b/llvm/include/llvm/IR/Use.h @@ -38,7 +38,7 @@ public: /// Provide a fast substitute to std::swap<Use> /// that also works with less standard-compliant compilers - void swap(Use &RHS); + LLVM_ABI void swap(Use &RHS); private: /// Destructor - Only for zap() @@ -60,10 +60,10 @@ public: /// instruction. User *getUser() const { return Parent; }; - inline void set(Value *Val); + LLVM_ABI inline void set(Value *Val); - inline Value *operator=(Value *RHS); - inline const Use &operator=(const Use &RHS); + LLVM_ABI inline Value *operator=(Value *RHS); + LLVM_ABI inline const Use &operator=(const Use &RHS); Value *operator->() { return Val; } const Value *operator->() const { return Val; } @@ -71,11 +71,11 @@ public: Use *getNext() const { return Next; } /// Return the operand # of this use in its User. - unsigned getOperandNo() const; + LLVM_ABI unsigned getOperandNo() const; /// Destroys Use operands when the number of operands of /// a User changes. - static void zap(Use *Start, const Use *Stop, bool del = false); + LLVM_ABI static void zap(Use *Start, const Use *Stop, bool del = false); private: diff --git a/llvm/include/llvm/IR/User.h b/llvm/include/llvm/IR/User.h index 25ca8d74..cbb4379 100644 --- a/llvm/include/llvm/IR/User.h +++ b/llvm/include/llvm/IR/User.h @@ -101,18 +101,20 @@ protected: /// /// This is used for subclasses which need to allocate a variable number /// of operands, ie, 'hung off uses'. - void *operator new(size_t Size, HungOffOperandsAllocMarker); + LLVM_ABI void *operator new(size_t Size, HungOffOperandsAllocMarker); /// Allocate a User with the operands co-allocated. /// /// This is used for subclasses which have a fixed number of operands. - void *operator new(size_t Size, IntrusiveOperandsAllocMarker allocTrait); + LLVM_ABI void *operator new(size_t Size, + IntrusiveOperandsAllocMarker allocTrait); /// Allocate a User with the operands co-allocated. If DescBytes is non-zero /// then allocate an additional DescBytes bytes before the operands. These /// bytes can be accessed by calling getDescriptor. - void *operator new(size_t Size, - IntrusiveOperandsAndDescriptorAllocMarker allocTrait); + LLVM_ABI void * + operator new(size_t Size, + IntrusiveOperandsAndDescriptorAllocMarker allocTrait); User(Type *ty, unsigned vty, AllocInfo AllocInfo) : Value(ty, vty) { assert(AllocInfo.NumOps < (1u << NumUserOperandsBits) && @@ -132,11 +134,11 @@ protected: /// (with bottom bit set) to the User. /// \param IsPhi identifies callers which are phi nodes and which need /// N BasicBlock* allocated along with N - void allocHungoffUses(unsigned N, bool IsPhi = false); + LLVM_ABI void allocHungoffUses(unsigned N, bool IsPhi = false); /// Grow the number of hung off uses. Note that allocHungoffUses /// should be called if there are no uses. - void growHungoffUses(unsigned N, bool IsPhi = false); + LLVM_ABI void growHungoffUses(unsigned N, bool IsPhi = false); protected: ~User() = default; // Use deleteValue() to delete a generic Instruction. @@ -145,7 +147,7 @@ public: User(const User &) = delete; /// Free memory allocated for User and Use objects. - void operator delete(void *Usr); + LLVM_ABI void operator delete(void *Usr); /// Placement delete - required by std, called if the ctor throws. void operator delete(void *Usr, HungOffOperandsAllocMarker) { // Note: If a subclass manipulates the information which is required to @@ -252,10 +254,10 @@ public: unsigned getNumOperands() const { return NumUserOperands; } /// Returns the descriptor co-allocated with this User instance. - ArrayRef<const uint8_t> getDescriptor() const; + LLVM_ABI ArrayRef<const uint8_t> getDescriptor() const; /// Returns the descriptor co-allocated with this User instance. - MutableArrayRef<uint8_t> getDescriptor(); + LLVM_ABI MutableArrayRef<uint8_t> getDescriptor(); /// Subclasses with hung off uses need to manage the operand count /// themselves. In these instances, the operand count isn't used to find the @@ -269,7 +271,7 @@ public: /// A droppable user is a user for which uses can be dropped without affecting /// correctness and should be dropped rather than preventing a transformation /// from happening. - bool isDroppable() const; + LLVM_ABI bool isDroppable() const; // --------------------------------------------------------------------------- // Operand Iterator interface... @@ -353,7 +355,7 @@ public: /// /// Replaces all references to the "From" definition with references to the /// "To" definition. Returns whether any uses were replaced. - bool replaceUsesOfWith(Value *From, Value *To); + LLVM_ABI bool replaceUsesOfWith(Value *From, Value *To); // Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { diff --git a/llvm/include/llvm/IR/VFABIDemangler.h b/llvm/include/llvm/IR/VFABIDemangler.h index de731cd..0b28798 100644 --- a/llvm/include/llvm/IR/VFABIDemangler.h +++ b/llvm/include/llvm/IR/VFABIDemangler.h @@ -17,6 +17,7 @@ #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Instructions.h" #include "llvm/Support/Alignment.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/TypeSize.h" namespace llvm { @@ -117,7 +118,7 @@ struct VFShape { return {EC, Parameters}; } /// Validation check on the Parameters in the VFShape. - bool hasValidParameterList() const; + LLVM_ABI bool hasValidParameterList() const; }; /// Holds the VFShape for a specific scalar to vector function mapping. @@ -180,11 +181,11 @@ static constexpr char const *_LLVM_Scalarize_ = "_LLVM_Scalarize_"; /// factor for scalable vectors, since the mangled name doesn't encode that; /// it needs to be derived from the widest element types of vector arguments /// or return values. -std::optional<VFInfo> tryDemangleForVFABI(StringRef MangledName, - const FunctionType *FTy); +LLVM_ABI std::optional<VFInfo> tryDemangleForVFABI(StringRef MangledName, + const FunctionType *FTy); /// Retrieve the `VFParamKind` from a string token. -VFParamKind getVFParamKindFromString(const StringRef Token); +LLVM_ABI VFParamKind getVFParamKindFromString(const StringRef Token); // Name of the attribute where the variant mappings are stored. static constexpr char const *MappingsAttrName = "vector-function-abi-variant"; @@ -194,8 +195,9 @@ static constexpr char const *MappingsAttrName = "vector-function-abi-variant"; /// vector-function-abi-variant attribute, we return without populating /// VariantMappings, i.e. callers of getVectorVariantNames need not check for /// the presence of the attribute (see InjectTLIMappings). -void getVectorVariantNames(const CallInst &CI, - SmallVectorImpl<std::string> &VariantMappings); +LLVM_ABI void +getVectorVariantNames(const CallInst &CI, + SmallVectorImpl<std::string> &VariantMappings); /// Constructs a FunctionType by applying vector function information to the /// type of a matching scalar function. @@ -204,12 +206,13 @@ void getVectorVariantNames(const CallInst &CI, /// \param ScalarFTy gets the Type information of parameters, as it is not /// stored in \p Info. /// \returns a pointer to a newly created vector FunctionType -FunctionType *createFunctionType(const VFInfo &Info, - const FunctionType *ScalarFTy); +LLVM_ABI FunctionType *createFunctionType(const VFInfo &Info, + const FunctionType *ScalarFTy); /// Overwrite the Vector Function ABI variants attribute with the names provide /// in \p VariantMappings. -void setVectorVariantNames(CallInst *CI, ArrayRef<std::string> VariantMappings); +LLVM_ABI void setVectorVariantNames(CallInst *CI, + ArrayRef<std::string> VariantMappings); } // end namespace VFABI diff --git a/llvm/include/llvm/IR/Value.h b/llvm/include/llvm/IR/Value.h index 999eeb3..04d0391 100644 --- a/llvm/include/llvm/IR/Value.h +++ b/llvm/include/llvm/IR/Value.h @@ -21,6 +21,7 @@ #include "llvm/Support/Alignment.h" #include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" #include <cassert> #include <iterator> #include <memory> @@ -212,30 +213,30 @@ private: }; protected: - Value(Type *Ty, unsigned scid); + LLVM_ABI Value(Type *Ty, unsigned scid); /// Value's destructor should be virtual by design, but that would require /// that Value and all of its subclasses have a vtable that effectively /// duplicates the information in the value ID. As a size optimization, the /// destructor has been protected, and the caller should manually call /// deleteValue. - ~Value(); // Use deleteValue() to delete a generic Value. + LLVM_ABI ~Value(); // Use deleteValue() to delete a generic Value. public: Value(const Value &) = delete; Value &operator=(const Value &) = delete; /// Delete a pointer to a generic Value. - void deleteValue(); + LLVM_ABI void deleteValue(); /// Support for debugging, callable in GDB: V->dump() - void dump() const; + LLVM_ABI void dump() const; /// Implement operator<< on Value. /// @{ - void print(raw_ostream &O, bool IsForDebug = false) const; - void print(raw_ostream &O, ModuleSlotTracker &MST, - bool IsForDebug = false) const; + LLVM_ABI void print(raw_ostream &O, bool IsForDebug = false) const; + LLVM_ABI void print(raw_ostream &O, ModuleSlotTracker &MST, + bool IsForDebug = false) const; /// @} /// Print the name of this Value out to the specified raw_ostream. @@ -245,22 +246,22 @@ public: /// even constants get pretty-printed; for example, the type of a null /// pointer is printed symbolically. /// @{ - void printAsOperand(raw_ostream &O, bool PrintType = true, - const Module *M = nullptr) const; - void printAsOperand(raw_ostream &O, bool PrintType, - ModuleSlotTracker &MST) const; + LLVM_ABI void printAsOperand(raw_ostream &O, bool PrintType = true, + const Module *M = nullptr) const; + LLVM_ABI void printAsOperand(raw_ostream &O, bool PrintType, + ModuleSlotTracker &MST) const; /// @} /// All values are typed, get the type of this value. Type *getType() const { return VTy; } /// All values hold a context through their type. - LLVMContext &getContext() const; + LLVM_ABI LLVMContext &getContext() const; // All values can potentially be named. bool hasName() const { return HasName; } - ValueName *getValueName() const; - void setValueName(ValueName *VN); + LLVM_ABI ValueName *getValueName() const; + LLVM_ABI void setValueName(ValueName *VN); private: void destroyValueName(); @@ -274,50 +275,50 @@ public: /// This guaranteed to return the same reference as long as the value is not /// modified. If the value has a name, this does a hashtable lookup, so it's /// not free. - StringRef getName() const; + LLVM_ABI StringRef getName() const; /// Change the name of the value. /// /// Choose a new unique name if the provided name is taken. /// /// \param Name The new name; or "" if the value's name should be removed. - void setName(const Twine &Name); + LLVM_ABI void setName(const Twine &Name); /// Transfer the name from V to this value. /// /// After taking V's name, sets V's name to empty. /// /// \note It is an error to call V->takeName(V). - void takeName(Value *V); + LLVM_ABI void takeName(Value *V); - std::string getNameOrAsOperand() const; + LLVM_ABI std::string getNameOrAsOperand() const; /// Change all uses of this to point to a new Value. /// /// Go through the uses list for this definition and make each use point to /// "V" instead of "this". After this completes, 'this's use list is /// guaranteed to be empty. - void replaceAllUsesWith(Value *V); + LLVM_ABI void replaceAllUsesWith(Value *V); /// Change non-metadata uses of this to point to a new Value. /// /// Go through the uses list for this definition and make each use point to /// "V" instead of "this". This function skips metadata entries in the list. - void replaceNonMetadataUsesWith(Value *V); + LLVM_ABI void replaceNonMetadataUsesWith(Value *V); /// Go through the uses list for this definition and make each use point /// to "V" if the callback ShouldReplace returns true for the given Use. /// Unlike replaceAllUsesWith() this function does not support basic block /// values. - void replaceUsesWithIf(Value *New, - llvm::function_ref<bool(Use &U)> ShouldReplace); + LLVM_ABI void + replaceUsesWithIf(Value *New, llvm::function_ref<bool(Use &U)> ShouldReplace); /// replaceUsesOutsideBlock - Go through the uses list for this definition and /// make each use point to "V" instead of "this" when the use is outside the /// block. 'This's use list is expected to have at least one element. /// Unlike replaceAllUsesWith() this function does not support basic block /// values. - void replaceUsesOutsideBlock(Value *V, BasicBlock *BB); + LLVM_ABI void replaceUsesOutsideBlock(Value *V, BasicBlock *BB); //---------------------------------------------------------------------- // Methods for handling the chain of uses of this Value. @@ -329,7 +330,7 @@ public: // when using them since you might not get all uses. // The methods that don't start with materialized_ assert that modules is // fully materialized. - void assertModuleIsMaterializedImpl() const; + LLVM_ABI void assertModuleIsMaterializedImpl() const; // This indirection exists so we can keep assertModuleIsMaterializedImpl() // around in release builds of Value.cpp to be linked with other code built // in debug mode. But this avoids calling it in any of the release built code. @@ -438,12 +439,12 @@ public: bool hasOneUse() const { return UseList && hasSingleElement(uses()); } /// Return true if this Value has exactly N uses. - bool hasNUses(unsigned N) const; + LLVM_ABI bool hasNUses(unsigned N) const; /// Return true if this value has N uses or more. /// /// This is logically equivalent to getNumUses() >= N. - bool hasNUsesOrMore(unsigned N) const; + LLVM_ABI bool hasNUsesOrMore(unsigned N) const; /// Return true if there is exactly one user of this value. /// @@ -453,18 +454,18 @@ public: /// /// This check is potentially costly, since it requires traversing, /// in the worst case, the whole use list of a value. - bool hasOneUser() const; + LLVM_ABI bool hasOneUser() const; /// Return true if there is exactly one use of this value that cannot be /// dropped. - Use *getSingleUndroppableUse(); + LLVM_ABI Use *getSingleUndroppableUse(); const Use *getSingleUndroppableUse() const { return const_cast<Value *>(this)->getSingleUndroppableUse(); } /// Return true if there is exactly one unique user of this value that cannot be /// dropped (that user can have multiple uses of this value). - User *getUniqueUndroppableUser(); + LLVM_ABI User *getUniqueUndroppableUser(); const User *getUniqueUndroppableUser() const { return const_cast<Value *>(this)->getUniqueUndroppableUser(); } @@ -473,12 +474,12 @@ public: /// /// This is specialized because it is a common request and does not require /// traversing the whole use list. - bool hasNUndroppableUses(unsigned N) const; + LLVM_ABI bool hasNUndroppableUses(unsigned N) const; /// Return true if this value has N uses or more. /// /// This is logically equivalent to getNumUses() >= N. - bool hasNUndroppableUsesOrMore(unsigned N) const; + LLVM_ABI bool hasNUndroppableUsesOrMore(unsigned N) const; /// Remove every uses that can safely be removed. /// @@ -487,25 +488,26 @@ public: /// some Droppable uses pervent it. /// This function optionally takes a filter to only remove some droppable /// uses. - void dropDroppableUses(llvm::function_ref<bool(const Use *)> ShouldDrop = - [](const Use *) { return true; }); + LLVM_ABI void + dropDroppableUses(llvm::function_ref<bool(const Use *)> ShouldDrop = + [](const Use *) { return true; }); /// Remove every use of this value in \p User that can safely be removed. - void dropDroppableUsesIn(User &Usr); + LLVM_ABI void dropDroppableUsesIn(User &Usr); /// Remove the droppable use \p U. - static void dropDroppableUse(Use &U); + LLVM_ABI static void dropDroppableUse(Use &U); /// Check if this value is used in the specified basic block. /// /// Not supported for ConstantData. - bool isUsedInBasicBlock(const BasicBlock *BB) const; + LLVM_ABI bool isUsedInBasicBlock(const BasicBlock *BB) const; /// This method computes the number of uses of this Value. /// /// This is a linear time operation. Use hasOneUse, hasNUses, or /// hasNUsesOrMore to check for specific values. - unsigned getNumUses() const; + LLVM_ABI unsigned getNumUses() const; /// This method should only be used by the Use class. void addUse(Use &U) { @@ -576,22 +578,24 @@ protected: return nullptr; return getMetadataImpl(KindID); } - MDNode *getMetadata(StringRef Kind) const; + LLVM_ABI MDNode *getMetadata(StringRef Kind) const; /// @} /// Appends all attachments with the given ID to \c MDs in insertion order. /// If the Value has no attachments with the given ID, or if ID is invalid, /// leaves MDs unchanged. /// @{ - void getMetadata(unsigned KindID, SmallVectorImpl<MDNode *> &MDs) const; - void getMetadata(StringRef Kind, SmallVectorImpl<MDNode *> &MDs) const; + LLVM_ABI void getMetadata(unsigned KindID, + SmallVectorImpl<MDNode *> &MDs) const; + LLVM_ABI void getMetadata(StringRef Kind, + SmallVectorImpl<MDNode *> &MDs) const; /// @} /// Appends all metadata attached to this value to \c MDs, sorting by /// KindID. The first element of each pair returned is the KindID, the second /// element is the metadata value. Attachments with the same ID appear in /// insertion order. - void + LLVM_ABI void getAllMetadata(SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs) const; /// Return true if this value has any metadata attached to it. @@ -612,44 +616,44 @@ protected: /// Sets the given attachment to \c MD, erasing it if \c MD is \c nullptr or /// replacing it if it already exists. /// @{ - void setMetadata(unsigned KindID, MDNode *Node); - void setMetadata(StringRef Kind, MDNode *Node); + LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node); + LLVM_ABI void setMetadata(StringRef Kind, MDNode *Node); /// @} /// Add a metadata attachment. /// @{ - void addMetadata(unsigned KindID, MDNode &MD); - void addMetadata(StringRef Kind, MDNode &MD); + LLVM_ABI void addMetadata(unsigned KindID, MDNode &MD); + LLVM_ABI void addMetadata(StringRef Kind, MDNode &MD); /// @} /// Erase all metadata attachments with the given kind. /// /// \returns true if any metadata was removed. - bool eraseMetadata(unsigned KindID); + LLVM_ABI bool eraseMetadata(unsigned KindID); /// Erase all metadata attachments matching the given predicate. - void eraseMetadataIf(function_ref<bool(unsigned, MDNode *)> Pred); + LLVM_ABI void eraseMetadataIf(function_ref<bool(unsigned, MDNode *)> Pred); /// Erase all metadata attached to this Value. - void clearMetadata(); + LLVM_ABI void clearMetadata(); /// Get metadata for the given kind, if any. /// This is an internal function that must only be called after /// checking that `hasMetadata()` returns true. - MDNode *getMetadataImpl(unsigned KindID) const; + LLVM_ABI MDNode *getMetadataImpl(unsigned KindID) const; public: /// Return true if this value is a swifterror value. /// /// swifterror values can be either a function argument or an alloca with a /// swifterror attribute. - bool isSwiftError() const; + LLVM_ABI bool isSwiftError() const; /// Strip off pointer casts, all-zero GEPs and address space casts. /// /// Returns the original uncasted value. If this is called on a non-pointer /// value, it returns 'this'. - const Value *stripPointerCasts() const; + LLVM_ABI const Value *stripPointerCasts() const; Value *stripPointerCasts() { return const_cast<Value *>( static_cast<const Value *>(this)->stripPointerCasts()); @@ -659,7 +663,7 @@ public: /// /// Returns the original uncasted value. If this is called on a non-pointer /// value, it returns 'this'. - const Value *stripPointerCastsAndAliases() const; + LLVM_ABI const Value *stripPointerCastsAndAliases() const; Value *stripPointerCastsAndAliases() { return const_cast<Value *>( static_cast<const Value *>(this)->stripPointerCastsAndAliases()); @@ -670,7 +674,7 @@ public: /// /// Returns the original uncasted value with the same representation. If this /// is called on a non-pointer value, it returns 'this'. - const Value *stripPointerCastsSameRepresentation() const; + LLVM_ABI const Value *stripPointerCastsSameRepresentation() const; Value *stripPointerCastsSameRepresentation() { return const_cast<Value *>(static_cast<const Value *>(this) ->stripPointerCastsSameRepresentation()); @@ -682,7 +686,7 @@ public: /// Returns the original uncasted value. If this is called on a non-pointer /// value, it returns 'this'. This function should be used only in /// Alias analysis. - const Value *stripPointerCastsForAliasAnalysis() const; + LLVM_ABI const Value *stripPointerCastsForAliasAnalysis() const; Value *stripPointerCastsForAliasAnalysis() { return const_cast<Value *>(static_cast<const Value *>(this) ->stripPointerCastsForAliasAnalysis()); @@ -692,7 +696,7 @@ public: /// /// Returns the original pointer value. If this is called on a non-pointer /// value, it returns 'this'. - const Value *stripInBoundsConstantOffsets() const; + LLVM_ABI const Value *stripInBoundsConstantOffsets() const; Value *stripInBoundsConstantOffsets() { return const_cast<Value *>( static_cast<const Value *>(this)->stripInBoundsConstantOffsets()); @@ -731,7 +735,7 @@ public: /// between the underlying value and the returned one. Thus, if no constant /// offset was found, the returned value is the underlying one and \p Offset /// is unchanged. - const Value *stripAndAccumulateConstantOffsets( + LLVM_ABI const Value *stripAndAccumulateConstantOffsets( const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool AllowInvariantGroup = false, function_ref<bool(Value &Value, APInt &Offset)> ExternalAnalysis = @@ -767,8 +771,8 @@ public: /// /// Returns the original pointer value. If this is called on a non-pointer /// value, it returns 'this'. - const Value *stripInBoundsOffsets(function_ref<void(const Value *)> Func = - [](const Value *) {}) const; + LLVM_ABI const Value *stripInBoundsOffsets( + function_ref<void(const Value *)> Func = [](const Value *) {}) const; inline Value *stripInBoundsOffsets(function_ref<void(const Value *)> Func = [](const Value *) {}) { return const_cast<Value *>( @@ -777,14 +781,14 @@ public: /// If this ptr is provably equal to \p Other plus a constant offset, return /// that offset in bytes. Essentially `ptr this` subtract `ptr Other`. - std::optional<int64_t> getPointerOffsetFrom(const Value *Other, - const DataLayout &DL) const; + LLVM_ABI std::optional<int64_t> + getPointerOffsetFrom(const Value *Other, const DataLayout &DL) const; /// Return true if the memory object referred to by V can by freed in the /// scope for which the SSA value defining the allocation is statically /// defined. E.g. deallocation after the static scope of a value does not /// count, but a deallocation before that does. - bool canBeFreed() const; + LLVM_ABI bool canBeFreed() const; /// Returns the number of bytes known to be dereferenceable for the /// pointer value. @@ -795,15 +799,15 @@ public: /// IF CanBeFreed is true, the pointer is known to be dereferenceable at /// point of definition only. Caller must prove that allocation is not /// deallocated between point of definition and use. - uint64_t getPointerDereferenceableBytes(const DataLayout &DL, - bool &CanBeNull, - bool &CanBeFreed) const; + LLVM_ABI uint64_t getPointerDereferenceableBytes(const DataLayout &DL, + bool &CanBeNull, + bool &CanBeFreed) const; /// Returns an alignment of the pointer value. /// /// Returns an alignment which is either specified explicitly, e.g. via /// align attribute of a function argument, or guaranteed by DataLayout. - Align getPointerAlignment(const DataLayout &DL) const; + LLVM_ABI Align getPointerAlignment(const DataLayout &DL) const; /// Translate PHI node to its predecessor from the given basic block. /// @@ -811,8 +815,8 @@ public: /// the PHI node corresponding to PredBB. If not, return ourself. This is /// useful if you want to know the value something has in a predecessor /// block. - const Value *DoPHITranslation(const BasicBlock *CurBB, - const BasicBlock *PredBB) const; + LLVM_ABI const Value *DoPHITranslation(const BasicBlock *CurBB, + const BasicBlock *PredBB) const; Value *DoPHITranslation(const BasicBlock *CurBB, const BasicBlock *PredBB) { return const_cast<Value *>( static_cast<const Value *>(this)->DoPHITranslation(CurBB, PredBB)); @@ -842,7 +846,7 @@ public: template <class Compare> void sortUseList(Compare Cmp); /// Reverse the use-list. - void reverseUseList(); + LLVM_ABI void reverseUseList(); private: /// Merge two lists together. diff --git a/llvm/include/llvm/IR/ValueHandle.h b/llvm/include/llvm/IR/ValueHandle.h index 2956081..05555bd 100644 --- a/llvm/include/llvm/IR/ValueHandle.h +++ b/llvm/include/llvm/IR/ValueHandle.h @@ -17,6 +17,7 @@ #include "llvm/ADT/PointerIntPair.h" #include "llvm/IR/Value.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" #include <cassert> namespace llvm { @@ -105,7 +106,7 @@ protected: } /// Remove this ValueHandle from its current use list. - void RemoveFromUseList(); + LLVM_ABI void RemoveFromUseList(); /// Clear the underlying pointer without clearing the use list. /// @@ -115,8 +116,8 @@ protected: public: // Callbacks made from Value. - static void ValueIsDeleted(Value *V); - static void ValueIsRAUWd(Value *Old, Value *New); + LLVM_ABI static void ValueIsDeleted(Value *V); + LLVM_ABI static void ValueIsRAUWd(Value *Old, Value *New); private: // Internal implementation details. @@ -128,13 +129,13 @@ private: /// /// List is the address of either the head of the list or a Next node within /// the existing use list. - void AddToExistingUseList(ValueHandleBase **List); + LLVM_ABI void AddToExistingUseList(ValueHandleBase **List); /// Add this ValueHandle to the use list after Node. void AddToExistingUseListAfter(ValueHandleBase *Node); /// Add this ValueHandle to the use list for V. - void AddToUseList(); + LLVM_ABI void AddToUseList(); }; /// A nullable Value handle that is nullable. @@ -380,7 +381,7 @@ public: /// class can be used as the key of a map, as long as the user takes it out of /// the map before calling setValPtr() (since the map has to rearrange itself /// when the pointer changes). Unlike ValueHandleBase, this class has a vtable. -class CallbackVH : public ValueHandleBase { +class LLVM_ABI CallbackVH : public ValueHandleBase { virtual void anchor(); protected: ~CallbackVH() = default; diff --git a/llvm/include/llvm/IR/ValueSymbolTable.h b/llvm/include/llvm/IR/ValueSymbolTable.h index cd1dbbe..b792ee6 100644 --- a/llvm/include/llvm/IR/ValueSymbolTable.h +++ b/llvm/include/llvm/IR/ValueSymbolTable.h @@ -16,6 +16,7 @@ #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/IR/Value.h" +#include "llvm/Support/Compiler.h" #include <cstdint> namespace llvm { @@ -64,7 +65,7 @@ public: /// @{ ValueSymbolTable(int MaxNameSize = -1) : vmap(0), MaxNameSize(MaxNameSize) {} - ~ValueSymbolTable(); + LLVM_ABI ~ValueSymbolTable(); /// @} /// @name Accessors @@ -91,11 +92,11 @@ public: /// This function can be used from the debugger to display the /// content of the symbol table while debugging. /// Print out symbol table on stderr - void dump() const; + LLVM_ABI void dump() const; -/// @} -/// @name Iteration -/// @{ + /// @} + /// @name Iteration + /// @{ /// Get an iterator that from the beginning of the symbol table. inline iterator begin() { return vmap.begin(); } diff --git a/llvm/include/llvm/IR/VectorBuilder.h b/llvm/include/llvm/IR/VectorBuilder.h index d526d52..bc23842 100644 --- a/llvm/include/llvm/IR/VectorBuilder.h +++ b/llvm/include/llvm/IR/VectorBuilder.h @@ -15,6 +15,7 @@ #ifndef LLVM_IR_VECTORBUILDER_H #define LLVM_IR_VECTORBUILDER_H +#include "llvm/Support/Compiler.h" #include <llvm/IR/IRBuilder.h> #include <llvm/IR/InstrTypes.h> #include <llvm/IR/Instruction.h> @@ -50,7 +51,7 @@ private: Value &requestMask(); Value &requestEVL(); - void handleError(const char *ErrorMsg) const; + LLVM_ABI void handleError(const char *ErrorMsg) const; template <typename RetType> RetType returnWithError(const char *ErrorMsg) const { handleError(ErrorMsg); @@ -69,11 +70,11 @@ public: ExplicitVectorLength(nullptr), StaticVectorLength(ElementCount::getFixed(0)) {} - Module &getModule() const; + LLVM_ABI Module &getModule() const; LLVMContext &getContext() const { return Builder.getContext(); } // All-true mask for the currently configured explicit vector length. - Value *getAllTrueMask(); + LLVM_ABI Value *getAllTrueMask(); VectorBuilder &setMask(Value *NewMask) { Mask = NewMask; @@ -100,18 +101,18 @@ public: // \p Opcode The functional instruction opcode of the emitted intrinsic. // \p ReturnTy The return type of the operation. // \p VecOpArray The operand list. - Value *createVectorInstruction(unsigned Opcode, Type *ReturnTy, - ArrayRef<Value *> VecOpArray, - const Twine &Name = Twine()); + LLVM_ABI Value *createVectorInstruction(unsigned Opcode, Type *ReturnTy, + ArrayRef<Value *> VecOpArray, + const Twine &Name = Twine()); /// Emit a VP reduction intrinsic call for recurrence kind. /// \param RdxID The intrinsic ID of llvm.vector.reduce.* /// \param ValTy The type of operand which the reduction operation is /// performed. /// \param VecOpArray The operand list. - Value *createSimpleReduction(Intrinsic::ID RdxID, Type *ValTy, - ArrayRef<Value *> VecOpArray, - const Twine &Name = Twine()); + LLVM_ABI Value *createSimpleReduction(Intrinsic::ID RdxID, Type *ValTy, + ArrayRef<Value *> VecOpArray, + const Twine &Name = Twine()); }; } // namespace llvm diff --git a/llvm/include/llvm/IR/VectorTypeUtils.h b/llvm/include/llvm/IR/VectorTypeUtils.h index dd9b182..e3d7fad 100644 --- a/llvm/include/llvm/IR/VectorTypeUtils.h +++ b/llvm/include/llvm/IR/VectorTypeUtils.h @@ -10,6 +10,7 @@ #define LLVM_IR_VECTORTYPEUTILS_H #include "llvm/IR/DerivedTypes.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -30,19 +31,19 @@ inline Type *toVectorTy(Type *Scalar, unsigned VF) { /// Note: /// - If \p EC is scalar, \p StructTy is returned unchanged /// - Only unpacked literal struct types are supported -Type *toVectorizedStructTy(StructType *StructTy, ElementCount EC); +LLVM_ABI Type *toVectorizedStructTy(StructType *StructTy, ElementCount EC); /// A helper for converting structs of vector types to structs of scalar types. /// Note: Only unpacked literal struct types are supported. -Type *toScalarizedStructTy(StructType *StructTy); +LLVM_ABI Type *toScalarizedStructTy(StructType *StructTy); /// Returns true if `StructTy` is an unpacked literal struct where all elements /// are vectors of matching element count. This does not include empty structs. -bool isVectorizedStructTy(StructType *StructTy); +LLVM_ABI bool isVectorizedStructTy(StructType *StructTy); /// Returns true if `StructTy` is an unpacked literal struct where all elements /// are scalars that can be used as vector element types. -bool canVectorizeStructTy(StructType *StructTy); +LLVM_ABI bool canVectorizeStructTy(StructType *StructTy); /// A helper for converting to vectorized types. For scalar types, this is /// equivalent to calling `toVectorTy`. For struct types, this returns a new diff --git a/llvm/include/llvm/IR/Verifier.h b/llvm/include/llvm/IR/Verifier.h index b25f8eb..8dbb9c8 100644 --- a/llvm/include/llvm/IR/Verifier.h +++ b/llvm/include/llvm/IR/Verifier.h @@ -22,6 +22,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/IR/PassManager.h" +#include "llvm/Support/Compiler.h" #include <utility> namespace llvm { @@ -76,7 +77,7 @@ public: : Diagnostic(Diagnostic) {} /// Visit an instruction and return true if it is valid, return false if an /// invalid TBAA is attached. - bool visitTBAAMetadata(Instruction &I, const MDNode *MD); + LLVM_ABI bool visitTBAAMetadata(Instruction &I, const MDNode *MD); }; /// Check a function for errors, useful for use when debugging a @@ -85,7 +86,7 @@ public: /// If there are no errors, the function returns false. If an error is found, /// a message describing the error is written to OS (if non-null) and true is /// returned. -bool verifyFunction(const Function &F, raw_ostream *OS = nullptr); +LLVM_ABI bool verifyFunction(const Function &F, raw_ostream *OS = nullptr); /// Check a module for errors. /// @@ -97,25 +98,25 @@ bool verifyFunction(const Function &F, raw_ostream *OS = nullptr); /// supplied, DebugInfo verification failures won't be considered as /// error and instead *BrokenDebugInfo will be set to true. Debug /// info errors can be "recovered" from by stripping the debug info. -bool verifyModule(const Module &M, raw_ostream *OS = nullptr, - bool *BrokenDebugInfo = nullptr); +LLVM_ABI bool verifyModule(const Module &M, raw_ostream *OS = nullptr, + bool *BrokenDebugInfo = nullptr); -FunctionPass *createVerifierPass(bool FatalErrors = true); +LLVM_ABI FunctionPass *createVerifierPass(bool FatalErrors = true); /// Check a module for errors, and report separate error states for IR /// and debug info errors. class VerifierAnalysis : public AnalysisInfoMixin<VerifierAnalysis> { friend AnalysisInfoMixin<VerifierAnalysis>; - static AnalysisKey Key; + LLVM_ABI static AnalysisKey Key; public: struct Result { bool IRBroken, DebugInfoBroken; }; - Result run(Module &M, ModuleAnalysisManager &); - Result run(Function &F, FunctionAnalysisManager &); + LLVM_ABI Result run(Module &M, ModuleAnalysisManager &); + LLVM_ABI Result run(Function &F, FunctionAnalysisManager &); static bool isRequired() { return true; } }; @@ -135,8 +136,8 @@ class VerifierPass : public PassInfoMixin<VerifierPass> { public: explicit VerifierPass(bool FatalErrors = true) : FatalErrors(FatalErrors) {} - PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); + LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); + LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); static bool isRequired() { return true; } }; diff --git a/llvm/include/llvm/IRPrinter/IRPrintingPasses.h b/llvm/include/llvm/IRPrinter/IRPrintingPasses.h index 4be1f3c..0d5dd11 100644 --- a/llvm/include/llvm/IRPrinter/IRPrintingPasses.h +++ b/llvm/include/llvm/IRPrinter/IRPrintingPasses.h @@ -19,6 +19,7 @@ #define LLVM_IRPRINTER_IRPRINTINGPASSES_H #include "llvm/IR/PassManager.h" +#include "llvm/Support/Compiler.h" #include <string> namespace llvm { @@ -36,12 +37,12 @@ class PrintModulePass : public PassInfoMixin<PrintModulePass> { bool EmitSummaryIndex; public: - PrintModulePass(); - PrintModulePass(raw_ostream &OS, const std::string &Banner = "", - bool ShouldPreserveUseListOrder = false, - bool EmitSummaryIndex = false); + LLVM_ABI PrintModulePass(); + LLVM_ABI PrintModulePass(raw_ostream &OS, const std::string &Banner = "", + bool ShouldPreserveUseListOrder = false, + bool EmitSummaryIndex = false); - PreservedAnalyses run(Module &M, AnalysisManager<Module> &); + LLVM_ABI PreservedAnalyses run(Module &M, AnalysisManager<Module> &); static bool isRequired() { return true; } }; @@ -52,10 +53,10 @@ class PrintFunctionPass : public PassInfoMixin<PrintFunctionPass> { std::string Banner; public: - PrintFunctionPass(); - PrintFunctionPass(raw_ostream &OS, const std::string &Banner = ""); + LLVM_ABI PrintFunctionPass(); + LLVM_ABI PrintFunctionPass(raw_ostream &OS, const std::string &Banner = ""); - PreservedAnalyses run(Function &F, AnalysisManager<Function> &); + LLVM_ABI PreservedAnalyses run(Function &F, AnalysisManager<Function> &); static bool isRequired() { return true; } }; diff --git a/llvm/include/llvm/IRReader/IRReader.h b/llvm/include/llvm/IRReader/IRReader.h index 099b958..790140f 100644 --- a/llvm/include/llvm/IRReader/IRReader.h +++ b/llvm/include/llvm/IRReader/IRReader.h @@ -16,6 +16,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Bitcode/BitcodeReader.h" +#include "llvm/Support/Compiler.h" #include <memory> namespace llvm { @@ -32,16 +33,16 @@ class LLVMContext; /// Module. The ShouldLazyLoadMetadata flag is passed down to the bitcode /// reader to optionally enable lazy metadata loading. This takes ownership /// of \p Buffer. -std::unique_ptr<Module> getLazyIRModule(std::unique_ptr<MemoryBuffer> Buffer, - SMDiagnostic &Err, LLVMContext &Context, - bool ShouldLazyLoadMetadata = false); +LLVM_ABI std::unique_ptr<Module> +getLazyIRModule(std::unique_ptr<MemoryBuffer> Buffer, SMDiagnostic &Err, + LLVMContext &Context, bool ShouldLazyLoadMetadata = false); /// If the given file holds a bitcode image, return a Module /// for it which does lazy deserialization of function bodies. Otherwise, /// attempt to parse it as LLVM Assembly and return a fully populated /// Module. The ShouldLazyLoadMetadata flag is passed down to the bitcode /// reader to optionally enable lazy metadata loading. -std::unique_ptr<Module> +LLVM_ABI std::unique_ptr<Module> getLazyIRFileModule(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context, bool ShouldLazyLoadMetadata = false); @@ -49,17 +50,19 @@ getLazyIRFileModule(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context, /// for it. Otherwise, attempt to parse it as LLVM Assembly and return /// a Module for it. /// \param DataLayoutCallback Override datalayout in the llvm assembly. -std::unique_ptr<Module> parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err, - LLVMContext &Context, - ParserCallbacks Callbacks = {}); +LLVM_ABI std::unique_ptr<Module> parseIR(MemoryBufferRef Buffer, + SMDiagnostic &Err, + LLVMContext &Context, + ParserCallbacks Callbacks = {}); /// If the given file holds a bitcode image, return a Module for it. /// Otherwise, attempt to parse it as LLVM Assembly and return a Module /// for it. /// \param DataLayoutCallback Override datalayout in the llvm assembly. -std::unique_ptr<Module> parseIRFile(StringRef Filename, SMDiagnostic &Err, - LLVMContext &Context, - ParserCallbacks Callbacks = {}); +LLVM_ABI std::unique_ptr<Module> parseIRFile(StringRef Filename, + SMDiagnostic &Err, + LLVMContext &Context, + ParserCallbacks Callbacks = {}); } #endif diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp index d56f4d3..628f0625 100644 --- a/llvm/lib/IR/BasicBlock.cpp +++ b/llvm/lib/IR/BasicBlock.cpp @@ -22,6 +22,7 @@ #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Type.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compiler.h" #include "LLVMContextImpl.h" @@ -41,9 +42,9 @@ STATISTIC(NumInstrRenumberings, "Number of renumberings across all blocks"); // that might be needed to remove debug intrinsics. // // https://discourse.llvm.org/t/psa-ir-output-changing-from-debug-intrinsics-to-debug-records/79578 -cl::opt<bool> UseNewDbgInfoFormat( - "dont-pass-this-flag-please-experimental-debuginfo", cl::Hidden, - cl::init(true)); +LLVM_ABI cl::opt<bool> + UseNewDbgInfoFormat("dont-pass-this-flag-please-experimental-debuginfo", + cl::Hidden, cl::init(true)); // This cl-opt collects the --experimental-debuginfo-iterators flag and then // does nothing with it (because the it gets stored into an otherwise unused diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp index 6735bf7..473114b 100644 --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -22,6 +22,7 @@ #include "llvm/IR/Type.h" #include "llvm/IR/Value.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compiler.h" #include <numeric> #include <optional> @@ -36,7 +37,7 @@ cl::opt<bool> EnableFSDiscriminator( // When true, preserves line and column number by picking one of the merged // location info in a deterministic manner to assist sample based PGO. -cl::opt<bool> PickMergedSourceLocations( +LLVM_ABI cl::opt<bool> PickMergedSourceLocations( "pick-merged-source-locations", cl::init(false), cl::Hidden, cl::desc("Preserve line and column number when merging locations.")); } // namespace llvm diff --git a/llvm/lib/IR/DebugProgramInstruction.cpp b/llvm/lib/IR/DebugProgramInstruction.cpp index 92023d6..2b9b0f9 100644 --- a/llvm/lib/IR/DebugProgramInstruction.cpp +++ b/llvm/lib/IR/DebugProgramInstruction.cpp @@ -6,10 +6,11 @@ // //===----------------------------------------------------------------------===// -#include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/DebugProgramInstruction.h" #include "llvm/IR/DIBuilder.h" +#include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/IntrinsicInst.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -24,9 +25,9 @@ template <typename T> T *DbgRecordParamRef<T>::get() const { return cast<T>(Ref); } -template class DbgRecordParamRef<DIExpression>; -template class DbgRecordParamRef<DILabel>; -template class DbgRecordParamRef<DILocalVariable>; +template class LLVM_EXPORT_TEMPLATE DbgRecordParamRef<DIExpression>; +template class LLVM_EXPORT_TEMPLATE DbgRecordParamRef<DILabel>; +template class LLVM_EXPORT_TEMPLATE DbgRecordParamRef<DILocalVariable>; DbgVariableRecord::DbgVariableRecord(const DbgVariableIntrinsic *DVI) : DbgRecord(ValueKind, DVI->getDebugLoc()), diff --git a/llvm/lib/IR/Dominators.cpp b/llvm/lib/IR/Dominators.cpp index cc51b49..e1e88bb 100644 --- a/llvm/lib/IR/Dominators.cpp +++ b/llvm/lib/IR/Dominators.cpp @@ -25,6 +25,7 @@ #include "llvm/PassRegistry.h" #include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/GenericDomTreeConstruction.h" #include "llvm/Support/raw_ostream.h" @@ -70,43 +71,55 @@ bool BasicBlockEdge::isSingleEdge() const { // //===----------------------------------------------------------------------===// -template class llvm::DomTreeNodeBase<BasicBlock>; -template class llvm::DominatorTreeBase<BasicBlock, false>; // DomTreeBase -template class llvm::DominatorTreeBase<BasicBlock, true>; // PostDomTreeBase +template class LLVM_EXPORT_TEMPLATE llvm::DomTreeNodeBase<BasicBlock>; +template class LLVM_EXPORT_TEMPLATE + llvm::DominatorTreeBase<BasicBlock, false>; // DomTreeBase +template class LLVM_EXPORT_TEMPLATE + llvm::DominatorTreeBase<BasicBlock, true>; // PostDomTreeBase template class llvm::cfg::Update<BasicBlock *>; -template void llvm::DomTreeBuilder::Calculate<DomTreeBuilder::BBDomTree>( +template LLVM_EXPORT_TEMPLATE void +llvm::DomTreeBuilder::Calculate<DomTreeBuilder::BBDomTree>( DomTreeBuilder::BBDomTree &DT); -template void +template LLVM_EXPORT_TEMPLATE void llvm::DomTreeBuilder::CalculateWithUpdates<DomTreeBuilder::BBDomTree>( DomTreeBuilder::BBDomTree &DT, BBUpdates U); -template void llvm::DomTreeBuilder::Calculate<DomTreeBuilder::BBPostDomTree>( +template LLVM_EXPORT_TEMPLATE void +llvm::DomTreeBuilder::Calculate<DomTreeBuilder::BBPostDomTree>( DomTreeBuilder::BBPostDomTree &DT); // No CalculateWithUpdates<PostDomTree> instantiation, unless a usecase arises. -template void llvm::DomTreeBuilder::InsertEdge<DomTreeBuilder::BBDomTree>( +template LLVM_EXPORT_TEMPLATE void +llvm::DomTreeBuilder::InsertEdge<DomTreeBuilder::BBDomTree>( DomTreeBuilder::BBDomTree &DT, BasicBlock *From, BasicBlock *To); -template void llvm::DomTreeBuilder::InsertEdge<DomTreeBuilder::BBPostDomTree>( +template LLVM_EXPORT_TEMPLATE void +llvm::DomTreeBuilder::InsertEdge<DomTreeBuilder::BBPostDomTree>( DomTreeBuilder::BBPostDomTree &DT, BasicBlock *From, BasicBlock *To); -template void llvm::DomTreeBuilder::DeleteEdge<DomTreeBuilder::BBDomTree>( +template LLVM_EXPORT_TEMPLATE void +llvm::DomTreeBuilder::DeleteEdge<DomTreeBuilder::BBDomTree>( DomTreeBuilder::BBDomTree &DT, BasicBlock *From, BasicBlock *To); -template void llvm::DomTreeBuilder::DeleteEdge<DomTreeBuilder::BBPostDomTree>( +template LLVM_EXPORT_TEMPLATE void +llvm::DomTreeBuilder::DeleteEdge<DomTreeBuilder::BBPostDomTree>( DomTreeBuilder::BBPostDomTree &DT, BasicBlock *From, BasicBlock *To); -template void llvm::DomTreeBuilder::ApplyUpdates<DomTreeBuilder::BBDomTree>( +template LLVM_EXPORT_TEMPLATE void +llvm::DomTreeBuilder::ApplyUpdates<DomTreeBuilder::BBDomTree>( DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBDomTreeGraphDiff &, DomTreeBuilder::BBDomTreeGraphDiff *); -template void llvm::DomTreeBuilder::ApplyUpdates<DomTreeBuilder::BBPostDomTree>( +template LLVM_EXPORT_TEMPLATE void +llvm::DomTreeBuilder::ApplyUpdates<DomTreeBuilder::BBPostDomTree>( DomTreeBuilder::BBPostDomTree &DT, DomTreeBuilder::BBPostDomTreeGraphDiff &, DomTreeBuilder::BBPostDomTreeGraphDiff *); -template bool llvm::DomTreeBuilder::Verify<DomTreeBuilder::BBDomTree>( +template LLVM_EXPORT_TEMPLATE bool +llvm::DomTreeBuilder::Verify<DomTreeBuilder::BBDomTree>( const DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBDomTree::VerificationLevel VL); -template bool llvm::DomTreeBuilder::Verify<DomTreeBuilder::BBPostDomTree>( +template LLVM_EXPORT_TEMPLATE bool +llvm::DomTreeBuilder::Verify<DomTreeBuilder::BBPostDomTree>( const DomTreeBuilder::BBPostDomTree &DT, DomTreeBuilder::BBPostDomTree::VerificationLevel VL); diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 85c28b0..dfffbbf 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -59,13 +59,13 @@ using ProfileCount = Function::ProfileCount; // Explicit instantiations of SymbolTableListTraits since some of the methods // are not in the public header file... -template class llvm::SymbolTableListTraits<BasicBlock>; +template class LLVM_EXPORT_TEMPLATE llvm::SymbolTableListTraits<BasicBlock>; static cl::opt<int> NonGlobalValueMaxNameSize( "non-global-value-max-name-size", cl::Hidden, cl::init(1024), cl::desc("Maximum size for the name of non-global values.")); -extern cl::opt<bool> UseNewDbgInfoFormat; +LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat; void Function::renumberBlocks() { validateBlockNumbers(); diff --git a/llvm/lib/IR/IRPrintingPasses.cpp b/llvm/lib/IR/IRPrintingPasses.cpp index 96396d0..a26bb0f 100644 --- a/llvm/lib/IR/IRPrintingPasses.cpp +++ b/llvm/lib/IR/IRPrintingPasses.cpp @@ -18,12 +18,13 @@ #include "llvm/IR/PrintPasses.h" #include "llvm/InitializePasses.h" #include "llvm/Pass.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; -extern cl::opt<bool> UseNewDbgInfoFormat; +LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat; namespace { diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp index 54e5e6d5..997f384 100644 --- a/llvm/lib/IR/Instruction.cpp +++ b/llvm/lib/IR/Instruction.cpp @@ -26,6 +26,7 @@ #include "llvm/IR/Operator.h" #include "llvm/IR/ProfDataUtils.h" #include "llvm/IR/Type.h" +#include "llvm/Support/Compiler.h" using namespace llvm; InsertPosition::InsertPosition(Instruction *InsertBefore) @@ -129,7 +130,7 @@ BasicBlock::iterator Instruction::insertInto(BasicBlock *ParentBB, return getIterator(); } -extern cl::opt<bool> UseNewDbgInfoFormat; +LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat; void Instruction::insertBefore(BasicBlock &BB, InstListType::iterator InsertPos) { diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp index e22b04e..b299696 100644 --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -39,6 +39,7 @@ #include "llvm/Support/AtomicOrdering.h" #include "llvm/Support/Casting.h" #include "llvm/Support/CheckedArithmetic.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/KnownBits.h" #include "llvm/Support/MathExtras.h" @@ -485,9 +486,10 @@ Attribute CallBase::getFnAttrOnCalledFunction(AK Kind) const { return Attribute(); } -template Attribute +template LLVM_ABI Attribute CallBase::getFnAttrOnCalledFunction(Attribute::AttrKind Kind) const; -template Attribute CallBase::getFnAttrOnCalledFunction(StringRef Kind) const; +template LLVM_ABI Attribute +CallBase::getFnAttrOnCalledFunction(StringRef Kind) const; template <typename AK> Attribute CallBase::getParamAttrOnCalledFunction(unsigned ArgNo, @@ -499,11 +501,10 @@ Attribute CallBase::getParamAttrOnCalledFunction(unsigned ArgNo, return Attribute(); } -template Attribute -CallBase::getParamAttrOnCalledFunction(unsigned ArgNo, - Attribute::AttrKind Kind) const; -template Attribute CallBase::getParamAttrOnCalledFunction(unsigned ArgNo, - StringRef Kind) const; +template LLVM_ABI Attribute CallBase::getParamAttrOnCalledFunction( + unsigned ArgNo, Attribute::AttrKind Kind) const; +template LLVM_ABI Attribute +CallBase::getParamAttrOnCalledFunction(unsigned ArgNo, StringRef Kind) const; void CallBase::getOperandBundlesAsDefs( SmallVectorImpl<OperandBundleDef> &Defs) const { diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp index 9ac6e9c..110636b 100644 --- a/llvm/lib/IR/LegacyPassManager.cpp +++ b/llvm/lib/IR/LegacyPassManager.cpp @@ -21,6 +21,7 @@ #include "llvm/IR/PrintPasses.h" #include "llvm/Support/Chrono.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" @@ -31,7 +32,7 @@ using namespace llvm; -extern cl::opt<bool> UseNewDbgInfoFormat; +LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat; // See PassManagers.h for Pass Manager infrastructure overview. //===----------------------------------------------------------------------===// diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index eb635dc..132a8c8 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -39,6 +39,7 @@ #include "llvm/IR/ValueSymbolTable.h" #include "llvm/Support/Casting.h" #include "llvm/Support/CodeGen.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" @@ -53,7 +54,7 @@ using namespace llvm; -extern cl::opt<bool> UseNewDbgInfoFormat; +LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat; //===----------------------------------------------------------------------===// // Methods to implement the globals and functions lists. @@ -61,10 +62,10 @@ extern cl::opt<bool> UseNewDbgInfoFormat; // Explicit instantiations of SymbolTableListTraits since some of the methods // are not in the public header file. -template class llvm::SymbolTableListTraits<Function>; -template class llvm::SymbolTableListTraits<GlobalVariable>; -template class llvm::SymbolTableListTraits<GlobalAlias>; -template class llvm::SymbolTableListTraits<GlobalIFunc>; +template class LLVM_EXPORT_TEMPLATE llvm::SymbolTableListTraits<Function>; +template class LLVM_EXPORT_TEMPLATE llvm::SymbolTableListTraits<GlobalVariable>; +template class LLVM_EXPORT_TEMPLATE llvm::SymbolTableListTraits<GlobalAlias>; +template class LLVM_EXPORT_TEMPLATE llvm::SymbolTableListTraits<GlobalIFunc>; //===----------------------------------------------------------------------===// // Primitive Module methods. diff --git a/llvm/lib/IR/PassManager.cpp b/llvm/lib/IR/PassManager.cpp index bf8f790..af22b77 100644 --- a/llvm/lib/IR/PassManager.cpp +++ b/llvm/lib/IR/PassManager.cpp @@ -9,6 +9,7 @@ #include "llvm/IR/PassManager.h" #include "llvm/IR/Module.h" #include "llvm/IR/PassManagerImpl.h" +#include "llvm/Support/Compiler.h" #include <optional> using namespace llvm; @@ -16,14 +17,16 @@ using namespace llvm; namespace llvm { // Explicit template instantiations and specialization defininitions for core // template typedefs. -template class AllAnalysesOn<Module>; -template class AllAnalysesOn<Function>; -template class PassManager<Module>; -template class PassManager<Function>; -template class AnalysisManager<Module>; -template class AnalysisManager<Function>; -template class InnerAnalysisManagerProxy<FunctionAnalysisManager, Module>; -template class OuterAnalysisManagerProxy<ModuleAnalysisManager, Function>; +template class LLVM_EXPORT_TEMPLATE AllAnalysesOn<Module>; +template class LLVM_EXPORT_TEMPLATE AllAnalysesOn<Function>; +template class LLVM_EXPORT_TEMPLATE PassManager<Module>; +template class LLVM_EXPORT_TEMPLATE PassManager<Function>; +template class LLVM_EXPORT_TEMPLATE AnalysisManager<Module>; +template class LLVM_EXPORT_TEMPLATE AnalysisManager<Function>; +template class LLVM_EXPORT_TEMPLATE + InnerAnalysisManagerProxy<FunctionAnalysisManager, Module>; +template class LLVM_EXPORT_TEMPLATE + OuterAnalysisManagerProxy<ModuleAnalysisManager, Function>; template <> bool FunctionAnalysisManagerModuleProxy::Result::invalidate( diff --git a/llvm/lib/IRPrinter/IRPrintingPasses.cpp b/llvm/lib/IRPrinter/IRPrintingPasses.cpp index b1750a5..d6bd6c3 100644 --- a/llvm/lib/IRPrinter/IRPrintingPasses.cpp +++ b/llvm/lib/IRPrinter/IRPrintingPasses.cpp @@ -17,12 +17,13 @@ #include "llvm/IR/Module.h" #include "llvm/IR/PrintPasses.h" #include "llvm/Pass.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; -extern cl::opt<bool> UseNewDbgInfoFormat; +LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat; PrintModulePass::PrintModulePass() : OS(dbgs()) {} PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner, diff --git a/llvm/unittests/IR/DebugInfoTest.cpp b/llvm/unittests/IR/DebugInfoTest.cpp index 8748371..c3a0f66 100644 --- a/llvm/unittests/IR/DebugInfoTest.cpp +++ b/llvm/unittests/IR/DebugInfoTest.cpp @@ -19,6 +19,7 @@ #include "llvm/IR/Metadata.h" #include "llvm/IR/Module.h" #include "llvm/IR/Verifier.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Transforms/Utils/Local.h" @@ -26,7 +27,7 @@ using namespace llvm; -extern cl::opt<bool> UseNewDbgInfoFormat; +LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat; static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) { SMDiagnostic Err; diff --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp index 386a607..acf1692 100644 --- a/llvm/unittests/IR/InstructionsTest.cpp +++ b/llvm/unittests/IR/InstructionsTest.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "llvm/IR/Instructions.h" +#include "llvm-c/Core.h" #include "llvm/ADT/CombinationGenerator.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Analysis/ValueTracking.h" @@ -26,13 +27,13 @@ #include "llvm/IR/NoFolder.h" #include "llvm/IR/Operator.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/SourceMgr.h" -#include "llvm-c/Core.h" #include "gmock/gmock-matchers.h" #include "gtest/gtest.h" #include <memory> -extern llvm::cl::opt<bool> UseNewDbgInfoFormat; +LLVM_ABI extern llvm::cl::opt<bool> UseNewDbgInfoFormat; namespace llvm { namespace { diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp index 56367e07..df41560 100644 --- a/llvm/unittests/IR/MetadataTest.cpp +++ b/llvm/unittests/IR/MetadataTest.cpp @@ -21,13 +21,14 @@ #include "llvm/IR/ModuleSlotTracker.h" #include "llvm/IR/Type.h" #include "llvm/IR/Verifier.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/raw_ostream.h" #include "gtest/gtest.h" #include <optional> using namespace llvm; namespace llvm { -extern cl::opt<bool> PickMergedSourceLocations; +LLVM_ABI extern cl::opt<bool> PickMergedSourceLocations; } // namespace llvm namespace { diff --git a/llvm/unittests/IR/ValueTest.cpp b/llvm/unittests/IR/ValueTest.cpp index ca45e9a..888595e 100644 --- a/llvm/unittests/IR/ValueTest.cpp +++ b/llvm/unittests/IR/ValueTest.cpp @@ -15,11 +15,12 @@ #include "llvm/IR/Module.h" #include "llvm/IR/ModuleSlotTracker.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/SourceMgr.h" #include "gtest/gtest.h" using namespace llvm; -extern cl::opt<bool> UseNewDbgInfoFormat; +LLVM_ABI extern cl::opt<bool> UseNewDbgInfoFormat; namespace { |