From 1776d78059ac4ef0ec7bd490a69f180abc443f4f Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Wed, 4 Jun 2025 14:42:20 -0700 Subject: [PATCH 1/3] [llvm] annotate interfaces in SandboxIR library for DLL export --- llvm/include/llvm/SandboxIR/BasicBlock.h | 21 +- llvm/include/llvm/SandboxIR/Constant.h | 166 ++++----- llvm/include/llvm/SandboxIR/Context.h | 127 +++---- llvm/include/llvm/SandboxIR/Function.h | 5 +- llvm/include/llvm/SandboxIR/Instruction.h | 391 +++++++++++----------- llvm/include/llvm/SandboxIR/Module.h | 9 +- llvm/include/llvm/SandboxIR/PassManager.h | 5 +- llvm/include/llvm/SandboxIR/Region.h | 19 +- llvm/include/llvm/SandboxIR/Tracker.h | 33 +- llvm/include/llvm/SandboxIR/Type.h | 49 +-- llvm/include/llvm/SandboxIR/Use.h | 9 +- llvm/include/llvm/SandboxIR/User.h | 13 +- llvm/include/llvm/SandboxIR/Value.h | 17 +- 13 files changed, 438 insertions(+), 426 deletions(-) diff --git a/llvm/include/llvm/SandboxIR/BasicBlock.h b/llvm/include/llvm/SandboxIR/BasicBlock.h index 93e79e2a421f9..6c096bb0a153d 100644 --- a/llvm/include/llvm/SandboxIR/BasicBlock.h +++ b/llvm/include/llvm/SandboxIR/BasicBlock.h @@ -9,6 +9,7 @@ #ifndef LLVM_SANDBOXIR_BASICBLOCK_H #define LLVM_SANDBOXIR_BASICBLOCK_H +#include "llvm/Support/Compiler.h" #include "llvm/IR/BasicBlock.h" #include "llvm/SandboxIR/Value.h" @@ -32,20 +33,20 @@ class BBIterator { llvm::BasicBlock *BB; llvm::BasicBlock::iterator It; Context *Ctx; - pointer getInstr(llvm::BasicBlock::iterator It) const; + LLVM_ABI pointer getInstr(llvm::BasicBlock::iterator It) const; public: BBIterator() : BB(nullptr), Ctx(nullptr) {} BBIterator(llvm::BasicBlock *BB, llvm::BasicBlock::iterator It, Context *Ctx) : BB(BB), It(It), Ctx(Ctx) {} reference operator*() const { return *getInstr(It); } - BBIterator &operator++(); + LLVM_ABI BBIterator &operator++(); BBIterator operator++(int) { auto Copy = *this; ++*this; return Copy; } - BBIterator &operator--(); + LLVM_ABI BBIterator &operator--(); BBIterator operator--(int) { auto Copy = *this; --*this; @@ -60,14 +61,14 @@ class BBIterator { /// the instruction is not found in the IR-to-SandboxIR tables. pointer get() const { return getInstr(It); } /// \Returns the parent BB. - BasicBlock *getNodeParent() const; + LLVM_ABI BasicBlock *getNodeParent() const; }; /// Contains a list of sandboxir::Instruction's. class BasicBlock : public Value { /// Builds a graph that contains all values in \p BB in their original form /// i.e., no vectorization is taking place here. - void buildBasicBlockFromLLVMIR(llvm::BasicBlock *LLVMBB); + LLVM_ABI void buildBasicBlockFromLLVMIR(llvm::BasicBlock *LLVMBB); friend class Context; // For `buildBasicBlockFromIR` friend class Instruction; // For LLVM Val. @@ -82,9 +83,9 @@ class BasicBlock : public Value { static bool classof(const Value *From) { return From->getSubclassID() == Value::ClassID::Block; } - Function *getParent() const; + LLVM_ABI Function *getParent() const; using iterator = BBIterator; - iterator begin() const; + LLVM_ABI iterator begin() const; iterator end() const { auto *BB = cast(Val); return iterator(BB, BB->end(), &Ctx); @@ -96,10 +97,10 @@ class BasicBlock : public Value { return std::make_reverse_iterator(begin()); } Context &getContext() const { return Ctx; } - Instruction *getTerminator() const; + LLVM_ABI Instruction *getTerminator() const; bool empty() const { return begin() == end(); } - Instruction &front() const; - Instruction &back() const; + LLVM_ABI Instruction &front() const; + LLVM_ABI Instruction &back() const; #ifndef NDEBUG void verify() const final; diff --git a/llvm/include/llvm/SandboxIR/Constant.h b/llvm/include/llvm/SandboxIR/Constant.h index e7b18a442d330..1ce12ba969e8d 100644 --- a/llvm/include/llvm/SandboxIR/Constant.h +++ b/llvm/include/llvm/SandboxIR/Constant.h @@ -76,16 +76,16 @@ class ConstantInt : public Constant { } public: - static ConstantInt *getTrue(Context &Ctx); - static ConstantInt *getFalse(Context &Ctx); - static ConstantInt *getBool(Context &Ctx, bool V); - static Constant *getTrue(Type *Ty); - static Constant *getFalse(Type *Ty); - static Constant *getBool(Type *Ty, bool V); + LLVM_ABI static ConstantInt *getTrue(Context &Ctx); + LLVM_ABI static ConstantInt *getFalse(Context &Ctx); + LLVM_ABI static ConstantInt *getBool(Context &Ctx, 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 ConstantInt *get(Type *Ty, uint64_t V, bool IsSigned = false); + LLVM_ABI static ConstantInt *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 @@ -93,27 +93,27 @@ class ConstantInt : public Constant { /// 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 /// either getSExtValue() or getZExtValue() will yield a correctly sized and /// signed value for the type Ty. /// Get a ConstantInt for a specific signed value. - static ConstantInt *getSigned(IntegerType *Ty, int64_t V); - static Constant *getSigned(Type *Ty, int64_t V); + LLVM_ABI static ConstantInt *getSigned(IntegerType *Ty, int64_t V); + LLVM_ABI static Constant *getSigned(Type *Ty, int64_t V); /// 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(Context &Ctx, const APInt &V); + LLVM_ABI static ConstantInt *get(Context &Ctx, 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. @@ -166,7 +166,7 @@ class ConstantInt : public Constant { /// Variant of the getType() method to always return an IntegerType, which /// reduces the amount of casting needed in parts of the compiler. - IntegerType *getIntegerType() const; + LLVM_ABI IntegerType *getIntegerType() const; /// This static method returns true if the type Ty is big enough to /// represent the value V. This can be used to avoid having the get method @@ -177,8 +177,8 @@ class ConstantInt : public Constant { /// 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 cast(Val)->isNegative(); } @@ -264,29 +264,29 @@ class ConstantFP final : public Constant { /// 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); + LLVM_ABI static Constant *get(Type *Ty, const APFloat &V); - static Constant *get(Type *Ty, StringRef Str); + LLVM_ABI static Constant *get(Type *Ty, StringRef Str); - static ConstantFP *get(const APFloat &V, Context &Ctx); + LLVM_ABI static ConstantFP *get(const APFloat &V, Context &Ctx); - static Constant *getNaN(Type *Ty, bool Negative = false, + LLVM_ABI static Constant *getNaN(Type *Ty, bool Negative = false, uint64_t Payload = 0); - static Constant *getQNaN(Type *Ty, bool Negative = false, + LLVM_ABI static Constant *getQNaN(Type *Ty, bool Negative = false, APInt *Payload = nullptr); - static Constant *getSNaN(Type *Ty, bool Negative = false, + LLVM_ABI static Constant *getSNaN(Type *Ty, bool Negative = false, APInt *Payload = nullptr); - static Constant *getZero(Type *Ty, bool Negative = false); + LLVM_ABI static Constant *getZero(Type *Ty, bool Negative = false); - static Constant *getNegativeZero(Type *Ty); - static Constant *getInfinity(Type *Ty, bool Negative = false); + LLVM_ABI static Constant *getNegativeZero(Type *Ty); + 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 cast(Val)->getValueAPF(); @@ -362,8 +362,8 @@ class ConstantArray final : public ConstantAggregate { friend class Context; // For constructor. public: - static Constant *get(ArrayType *T, ArrayRef V); - ArrayType *getType() const; + LLVM_ABI static Constant *get(ArrayType *T, ArrayRef V); + LLVM_ABI ArrayType *getType() const; // TODO: Missing functions: getType(), getTypeForElements(), getAnon(), get(). @@ -379,7 +379,7 @@ class ConstantStruct final : public ConstantAggregate { friend class Context; // For constructor. public: - static Constant *get(StructType *T, ArrayRef V); + LLVM_ABI static Constant *get(StructType *T, ArrayRef V); template static std::enable_if_t::value, Constant *> @@ -396,7 +396,7 @@ class ConstantStruct final : public ConstantAggregate { return get(getTypeForElements(Ctx, V, Packed), V); } /// This version of the method allows an empty list. - static StructType *getTypeForElements(Context &Ctx, ArrayRef V, + LLVM_ABI static StructType *getTypeForElements(Context &Ctx, ArrayRef V, bool Packed = false); /// Return an anonymous struct type to use for a constant with the specified /// set of elements. The list must not be empty. @@ -424,10 +424,10 @@ class ConstantVector final : public ConstantAggregate { friend class Context; // For constructor. public: - static Constant *get(ArrayRef V); + LLVM_ABI static Constant *get(ArrayRef V); /// 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. inline FixedVectorType *getType() const { @@ -436,7 +436,7 @@ class ConstantVector final : public ConstantAggregate { /// 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; /// For isa/dyn_cast. static bool classof(const Value *From) { @@ -451,18 +451,18 @@ class ConstantAggregateZero final : public Constant { friend class Context; // For constructor. public: - 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 { return cast(Val)->getElementCount(); @@ -769,9 +769,9 @@ class ConstantPointerNull final : public Constant { friend class Context; // For constructor. public: - static ConstantPointerNull *get(PointerType *Ty); + LLVM_ABI static ConstantPointerNull *get(PointerType *Ty); - PointerType *getType() const; + LLVM_ABI PointerType *getType() const; /// For isa/dyn_cast. static bool classof(const sandboxir::Value *From) { @@ -802,22 +802,22 @@ class UndefValue : public Constant { public: /// 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 { @@ -850,22 +850,22 @@ class PoisonValue final : public UndefValue { public: /// 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; /// For isa/dyn_cast. static bool classof(const sandboxir::Value *From) { @@ -924,7 +924,7 @@ class GlobalValue : public Constant { UnnamedAddr getUnnamedAddr() const { return cast(Val)->getUnnamedAddr(); } - void setUnnamedAddr(UnnamedAddr V); + LLVM_ABI void setUnnamedAddr(UnnamedAddr V); static UnnamedAddr getMinUnnamedAddr(UnnamedAddr A, UnnamedAddr B) { return llvm::GlobalValue::getMinUnnamedAddr(A, B); @@ -946,7 +946,7 @@ class GlobalValue : public Constant { bool hasProtectedVisibility() const { return cast(Val)->hasProtectedVisibility(); } - void setVisibility(VisibilityTypes V); + LLVM_ABI void setVisibility(VisibilityTypes V); // TODO: Add missing functions. }; @@ -996,7 +996,7 @@ class GlobalObject : public GlobalValue { /// /// 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); bool hasComdat() const { return cast(Val)->hasComdat(); } @@ -1097,13 +1097,13 @@ class GlobalIFunc final // TODO: Missing functions: copyAttributesFrom(), removeFromParent(), // eraseFromParent() - void setResolver(Constant *Resolver); + LLVM_ABI void setResolver(Constant *Resolver); - Constant *getResolver() const; + LLVM_ABI Constant *getResolver() const; // Return the resolver function after peeling off potential ConstantExpr // indirection. - Function *getResolverFunction(); + LLVM_ABI Function *getResolverFunction(); const Function *getResolverFunction() const { return const_cast(this)->getResolverFunction(); } @@ -1136,7 +1136,7 @@ class GlobalVariable final struct LLVMGVToGV { Context &Ctx; LLVMGVToGV(Context &Ctx) : Ctx(Ctx) {} - GlobalVariable &operator()(llvm::GlobalVariable &LLVMGV) const; + LLVM_ABI GlobalVariable &operator()(llvm::GlobalVariable &LLVMGV) const; }; public: @@ -1181,11 +1181,11 @@ class GlobalVariable final /// illegal to call this method if the global is external, because we cannot /// tell what the value is initialized to! /// - Constant *getInitializer() const; + LLVM_ABI Constant *getInitializer() const; /// 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); // TODO: Add missing replaceInitializer(). Requires special tracker @@ -1196,12 +1196,12 @@ class GlobalVariable final bool isConstant() const { return cast(Val)->isConstant(); } - void setConstant(bool V); + LLVM_ABI void setConstant(bool V); bool isExternallyInitialized() const { return cast(Val)->isExternallyInitialized(); } - void setExternallyInitialized(bool Val); + LLVM_ABI void setExternallyInitialized(bool Val); // TODO: Missing copyAttributesFrom() @@ -1278,7 +1278,7 @@ class GlobalVariable final /// Sets the alignment attribute of the GlobalVariable. /// This method will be deprecated as the alignment property should always be /// defined. - void setAlignment(MaybeAlign Align); + LLVM_ABI void setAlignment(MaybeAlign Align); // TODO: Missing setCodeModel(). Requires custom tracker. @@ -1311,10 +1311,10 @@ class GlobalAlias final // TODO: Missing copyAttributresFrom(). // TODO: Missing removeFromParent(), eraseFromParent(). - void setAliasee(Constant *Aliasee); - Constant *getAliasee() const; + LLVM_ABI void setAliasee(Constant *Aliasee); + LLVM_ABI Constant *getAliasee() const; - const GlobalObject *getAliaseeObject() const; + LLVM_ABI const GlobalObject *getAliaseeObject() const; GlobalObject *getAliaseeObject() { return const_cast( static_cast(this)->getAliaseeObject()); @@ -1336,12 +1336,12 @@ 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); - GlobalValue *getGlobalValue() const; + LLVM_ABI GlobalValue *getGlobalValue() const; /// NoCFIValue is always a pointer. - PointerType *getType() const; + LLVM_ABI PointerType *getType() const; /// For isa/dyn_cast. static bool classof(const sandboxir::Value *From) { return From->getSubclassID() == ClassID::NoCFIValue; @@ -1369,21 +1369,21 @@ class ConstantPtrAuth final : public Constant { public: /// Return a pointer signed with the specified parameters. - static ConstantPtrAuth *get(Constant *Ptr, ConstantInt *Key, + LLVM_ABI static ConstantPtrAuth *get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc); /// The pointer that is signed in this ptrauth signed pointer. - Constant *getPointer() const; + LLVM_ABI Constant *getPointer() const; /// The Key ID, an i32 constant. - ConstantInt *getKey() const; + LLVM_ABI ConstantInt *getKey() const; /// The integer discriminator, an i64 constant, or 0. - ConstantInt *getDiscriminator() const; + LLVM_ABI ConstantInt *getDiscriminator() const; /// The address discriminator if any, or the null constant. /// If present, this must be a value equivalent to the storage location of /// the only global-initializer user of the ptrauth signed pointer. - Constant *getAddrDiscriminator() const; + LLVM_ABI Constant *getAddrDiscriminator() const; /// Whether there is any non-null address discriminator. bool hasAddressDiscriminator() const { @@ -1410,7 +1410,7 @@ class ConstantPtrAuth final : public Constant { /// 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; /// For isa/dyn_cast. static bool classof(const sandboxir::Value *From) { @@ -1438,19 +1438,19 @@ class BlockAddress final : public Constant { public: /// 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); /// 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); - Function *getFunction() const; - BasicBlock *getBasicBlock() const; + LLVM_ABI Function *getFunction() const; + LLVM_ABI BasicBlock *getBasicBlock() const; /// For isa/dyn_cast. static bool classof(const sandboxir::Value *From) { @@ -1465,9 +1465,9 @@ class DSOLocalEquivalent final : public Constant { public: /// Return a DSOLocalEquivalent for the specified global value. - static DSOLocalEquivalent *get(GlobalValue *GV); + LLVM_ABI static DSOLocalEquivalent *get(GlobalValue *GV); - GlobalValue *getGlobalValue() const; + LLVM_ABI GlobalValue *getGlobalValue() const; /// For isa/dyn_cast. static bool classof(const sandboxir::Value *From) { @@ -1498,7 +1498,7 @@ class ConstantTokenNone final : public Constant { public: /// Return the ConstantTokenNone. - static ConstantTokenNone *get(Context &Ctx); + LLVM_ABI static ConstantTokenNone *get(Context &Ctx); /// For isa/dyn_cast. static bool classof(const sandboxir::Value *From) { diff --git a/llvm/include/llvm/SandboxIR/Context.h b/llvm/include/llvm/SandboxIR/Context.h index a8a21b0db855e..25adff9aecb21 100644 --- a/llvm/include/llvm/SandboxIR/Context.h +++ b/llvm/include/llvm/SandboxIR/Context.h @@ -9,6 +9,7 @@ #ifndef LLVM_SANDBOXIR_CONTEXT_H #define LLVM_SANDBOXIR_CONTEXT_H +#include "llvm/Support/Compiler.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/SmallVector.h" @@ -112,32 +113,32 @@ class Context { CallbackID::ValTy NextCallbackID = 1; /// Remove \p V from the maps and returns the unique_ptr. - std::unique_ptr detachLLVMValue(llvm::Value *V); + LLVM_ABI std::unique_ptr detachLLVMValue(llvm::Value *V); /// Remove \p SBV from all SandboxIR maps and stop owning it. This effectively /// detaches \p V from the underlying IR. - std::unique_ptr detach(Value *V); + LLVM_ABI std::unique_ptr detach(Value *V); friend class Instruction; // For detach(). /// Take ownership of VPtr and store it in `LLVMValueToValueMap`. - Value *registerValue(std::unique_ptr &&VPtr); + LLVM_ABI Value *registerValue(std::unique_ptr &&VPtr); friend class EraseFromParent; // For registerValue(). /// This is the actual function that creates sandboxir values for \p V, /// and among others handles all instruction types. - Value *getOrCreateValueInternal(llvm::Value *V, llvm::User *U = nullptr); + LLVM_ABI Value *getOrCreateValueInternal(llvm::Value *V, llvm::User *U = nullptr); /// Get or create a sandboxir::Argument for an existing LLVM IR \p LLVMArg. - Argument *getOrCreateArgument(llvm::Argument *LLVMArg); + LLVM_ABI Argument *getOrCreateArgument(llvm::Argument *LLVMArg); /// Get or create a sandboxir::Value for an existing LLVM IR \p LLVMV. Value *getOrCreateValue(llvm::Value *LLVMV) { return getOrCreateValueInternal(LLVMV, 0); } /// Get or create a sandboxir::Constant from an existing LLVM IR \p LLVMC. - Constant *getOrCreateConstant(llvm::Constant *LLVMC); + LLVM_ABI Constant *getOrCreateConstant(llvm::Constant *LLVMC); friend class ConstantDataSequential; // For getOrCreateConstant(). friend class Utils; // For getMemoryBase - void runEraseInstrCallbacks(Instruction *I); - void runCreateInstrCallbacks(Instruction *I); - void runMoveInstrCallbacks(Instruction *I, const BBIterator &Where); - void runSetUseCallbacks(const Use &U, Value *NewSrc); + LLVM_ABI void runEraseInstrCallbacks(Instruction *I); + LLVM_ABI void runCreateInstrCallbacks(Instruction *I); + LLVM_ABI void runMoveInstrCallbacks(Instruction *I, const BBIterator &Where); + LLVM_ABI void runSetUseCallbacks(const Use &U, Value *NewSrc); friend class User; // For runSetUseCallbacks(). friend class Value; // For runSetUseCallbacks(). @@ -148,90 +149,90 @@ class Context { /// Create a sandboxir::BasicBlock for an existing LLVM IR \p BB. This will /// also create all contents of the block. - BasicBlock *createBasicBlock(llvm::BasicBlock *BB); + LLVM_ABI BasicBlock *createBasicBlock(llvm::BasicBlock *BB); friend class BasicBlock; // For getOrCreateValue(). IRBuilder LLVMIRBuilder; auto &getLLVMIRBuilder() { return LLVMIRBuilder; } - VAArgInst *createVAArgInst(llvm::VAArgInst *SI); + LLVM_ABI VAArgInst *createVAArgInst(llvm::VAArgInst *SI); friend VAArgInst; // For createVAArgInst() - FreezeInst *createFreezeInst(llvm::FreezeInst *SI); + LLVM_ABI FreezeInst *createFreezeInst(llvm::FreezeInst *SI); friend FreezeInst; // For createFreezeInst() - FenceInst *createFenceInst(llvm::FenceInst *SI); + LLVM_ABI FenceInst *createFenceInst(llvm::FenceInst *SI); friend FenceInst; // For createFenceInst() - SelectInst *createSelectInst(llvm::SelectInst *SI); + LLVM_ABI SelectInst *createSelectInst(llvm::SelectInst *SI); friend SelectInst; // For createSelectInst() - InsertElementInst *createInsertElementInst(llvm::InsertElementInst *IEI); + LLVM_ABI InsertElementInst *createInsertElementInst(llvm::InsertElementInst *IEI); friend InsertElementInst; // For createInsertElementInst() - ExtractElementInst *createExtractElementInst(llvm::ExtractElementInst *EEI); + LLVM_ABI ExtractElementInst *createExtractElementInst(llvm::ExtractElementInst *EEI); friend ExtractElementInst; // For createExtractElementInst() - ShuffleVectorInst *createShuffleVectorInst(llvm::ShuffleVectorInst *SVI); + LLVM_ABI ShuffleVectorInst *createShuffleVectorInst(llvm::ShuffleVectorInst *SVI); friend ShuffleVectorInst; // For createShuffleVectorInst() - ExtractValueInst *createExtractValueInst(llvm::ExtractValueInst *IVI); + LLVM_ABI ExtractValueInst *createExtractValueInst(llvm::ExtractValueInst *IVI); friend ExtractValueInst; // For createExtractValueInst() - InsertValueInst *createInsertValueInst(llvm::InsertValueInst *IVI); + LLVM_ABI InsertValueInst *createInsertValueInst(llvm::InsertValueInst *IVI); friend InsertValueInst; // For createInsertValueInst() - BranchInst *createBranchInst(llvm::BranchInst *I); + LLVM_ABI BranchInst *createBranchInst(llvm::BranchInst *I); friend BranchInst; // For createBranchInst() - LoadInst *createLoadInst(llvm::LoadInst *LI); + LLVM_ABI LoadInst *createLoadInst(llvm::LoadInst *LI); friend LoadInst; // For createLoadInst() - StoreInst *createStoreInst(llvm::StoreInst *SI); + LLVM_ABI StoreInst *createStoreInst(llvm::StoreInst *SI); friend StoreInst; // For createStoreInst() - ReturnInst *createReturnInst(llvm::ReturnInst *I); + LLVM_ABI ReturnInst *createReturnInst(llvm::ReturnInst *I); friend ReturnInst; // For createReturnInst() - CallInst *createCallInst(llvm::CallInst *I); + LLVM_ABI CallInst *createCallInst(llvm::CallInst *I); friend CallInst; // For createCallInst() - InvokeInst *createInvokeInst(llvm::InvokeInst *I); + LLVM_ABI InvokeInst *createInvokeInst(llvm::InvokeInst *I); friend InvokeInst; // For createInvokeInst() - CallBrInst *createCallBrInst(llvm::CallBrInst *I); + LLVM_ABI CallBrInst *createCallBrInst(llvm::CallBrInst *I); friend CallBrInst; // For createCallBrInst() - LandingPadInst *createLandingPadInst(llvm::LandingPadInst *I); + LLVM_ABI LandingPadInst *createLandingPadInst(llvm::LandingPadInst *I); friend LandingPadInst; // For createLandingPadInst() - CatchPadInst *createCatchPadInst(llvm::CatchPadInst *I); + LLVM_ABI CatchPadInst *createCatchPadInst(llvm::CatchPadInst *I); friend CatchPadInst; // For createCatchPadInst() - CleanupPadInst *createCleanupPadInst(llvm::CleanupPadInst *I); + LLVM_ABI CleanupPadInst *createCleanupPadInst(llvm::CleanupPadInst *I); friend CleanupPadInst; // For createCleanupPadInst() - CatchReturnInst *createCatchReturnInst(llvm::CatchReturnInst *I); + LLVM_ABI CatchReturnInst *createCatchReturnInst(llvm::CatchReturnInst *I); friend CatchReturnInst; // For createCatchReturnInst() - CleanupReturnInst *createCleanupReturnInst(llvm::CleanupReturnInst *I); + LLVM_ABI CleanupReturnInst *createCleanupReturnInst(llvm::CleanupReturnInst *I); friend CleanupReturnInst; // For createCleanupReturnInst() - GetElementPtrInst *createGetElementPtrInst(llvm::GetElementPtrInst *I); + LLVM_ABI GetElementPtrInst *createGetElementPtrInst(llvm::GetElementPtrInst *I); friend GetElementPtrInst; // For createGetElementPtrInst() - CatchSwitchInst *createCatchSwitchInst(llvm::CatchSwitchInst *I); + LLVM_ABI CatchSwitchInst *createCatchSwitchInst(llvm::CatchSwitchInst *I); friend CatchSwitchInst; // For createCatchSwitchInst() - ResumeInst *createResumeInst(llvm::ResumeInst *I); + LLVM_ABI ResumeInst *createResumeInst(llvm::ResumeInst *I); friend ResumeInst; // For createResumeInst() - SwitchInst *createSwitchInst(llvm::SwitchInst *I); + LLVM_ABI SwitchInst *createSwitchInst(llvm::SwitchInst *I); friend SwitchInst; // For createSwitchInst() - UnaryOperator *createUnaryOperator(llvm::UnaryOperator *I); + LLVM_ABI UnaryOperator *createUnaryOperator(llvm::UnaryOperator *I); friend UnaryOperator; // For createUnaryOperator() - BinaryOperator *createBinaryOperator(llvm::BinaryOperator *I); + LLVM_ABI BinaryOperator *createBinaryOperator(llvm::BinaryOperator *I); friend BinaryOperator; // For createBinaryOperator() - AtomicRMWInst *createAtomicRMWInst(llvm::AtomicRMWInst *I); + LLVM_ABI AtomicRMWInst *createAtomicRMWInst(llvm::AtomicRMWInst *I); friend AtomicRMWInst; // For createAtomicRMWInst() - AtomicCmpXchgInst *createAtomicCmpXchgInst(llvm::AtomicCmpXchgInst *I); + LLVM_ABI AtomicCmpXchgInst *createAtomicCmpXchgInst(llvm::AtomicCmpXchgInst *I); friend AtomicCmpXchgInst; // For createAtomicCmpXchgInst() - AllocaInst *createAllocaInst(llvm::AllocaInst *I); + LLVM_ABI AllocaInst *createAllocaInst(llvm::AllocaInst *I); friend AllocaInst; // For createAllocaInst() - CastInst *createCastInst(llvm::CastInst *I); + LLVM_ABI CastInst *createCastInst(llvm::CastInst *I); friend CastInst; // For createCastInst() - PHINode *createPHINode(llvm::PHINode *I); + LLVM_ABI PHINode *createPHINode(llvm::PHINode *I); friend PHINode; // For createPHINode() - UnreachableInst *createUnreachableInst(llvm::UnreachableInst *UI); + LLVM_ABI UnreachableInst *createUnreachableInst(llvm::UnreachableInst *UI); friend UnreachableInst; // For createUnreachableInst() - CmpInst *createCmpInst(llvm::CmpInst *I); + LLVM_ABI CmpInst *createCmpInst(llvm::CmpInst *I); friend CmpInst; // For createCmpInst() - ICmpInst *createICmpInst(llvm::ICmpInst *I); + LLVM_ABI ICmpInst *createICmpInst(llvm::ICmpInst *I); friend ICmpInst; // For createICmpInst() - FCmpInst *createFCmpInst(llvm::FCmpInst *I); + LLVM_ABI FCmpInst *createFCmpInst(llvm::FCmpInst *I); friend FCmpInst; // For createFCmpInst() public: - Context(LLVMContext &LLVMCtx); - ~Context(); + LLVM_ABI Context(LLVMContext &LLVMCtx); + LLVM_ABI ~Context(); /// Clears function-level state. - void clear(); + LLVM_ABI void clear(); Tracker &getTracker() { return IRTracker; } /// Convenience function for `getTracker().save()` @@ -241,14 +242,14 @@ class Context { /// Convenience function for `getTracker().accept()` void accept() { IRTracker.accept(); } - sandboxir::Value *getValue(llvm::Value *V) const; + LLVM_ABI sandboxir::Value *getValue(llvm::Value *V) const; const sandboxir::Value *getValue(const llvm::Value *V) const { return getValue(const_cast(V)); } - Module *getModule(llvm::Module *LLVMM) const; + LLVM_ABI Module *getModule(llvm::Module *LLVMM) const; - Module *getOrCreateModule(llvm::Module *LLVMM); + LLVM_ABI Module *getOrCreateModule(llvm::Module *LLVMM); Type *getType(llvm::Type *LLVMTy) { if (LLVMTy == nullptr) @@ -265,10 +266,10 @@ class Context { /// This is the main API function for creating Sandbox IR. /// Note: this will not fully populate its parent module. The only globals /// that will be available are those used within the function. - Function *createFunction(llvm::Function *F); + LLVM_ABI Function *createFunction(llvm::Function *F); /// Create a sandboxir::Module corresponding to \p LLVMM. - Module *createModule(llvm::Module *LLVMM); + LLVM_ABI Module *createModule(llvm::Module *LLVMM); /// \Returns the number of values registered with Context. size_t getNumValues() const { return LLVMValueToValueMap.size(); } @@ -277,26 +278,26 @@ class Context { /// to be removed from its parent. Note that this will also be called when /// reverting the creation of an instruction. /// \Returns a callback ID for later deregistration. - CallbackID registerEraseInstrCallback(EraseInstrCallback CB); - void unregisterEraseInstrCallback(CallbackID ID); + LLVM_ABI CallbackID registerEraseInstrCallback(EraseInstrCallback CB); + LLVM_ABI void unregisterEraseInstrCallback(CallbackID ID); /// Register a callback that gets called right after a SandboxIR instruction /// is created. Note that this will also be called when reverting the removal /// of an instruction. /// \Returns a callback ID for later deregistration. - CallbackID registerCreateInstrCallback(CreateInstrCallback CB); - void unregisterCreateInstrCallback(CallbackID ID); + LLVM_ABI CallbackID registerCreateInstrCallback(CreateInstrCallback CB); + LLVM_ABI void unregisterCreateInstrCallback(CallbackID ID); /// Register a callback that gets called when a SandboxIR instruction is about /// to be moved. Note that this will also be called when reverting a move. /// \Returns a callback ID for later deregistration. - CallbackID registerMoveInstrCallback(MoveInstrCallback CB); - void unregisterMoveInstrCallback(CallbackID ID); + LLVM_ABI CallbackID registerMoveInstrCallback(MoveInstrCallback CB); + LLVM_ABI void unregisterMoveInstrCallback(CallbackID ID); /// Register a callback that gets called when a Use gets set. /// \Returns a callback ID for later deregistration. - CallbackID registerSetUseCallback(SetUseCallback CB); - void unregisterSetUseCallback(CallbackID ID); + LLVM_ABI CallbackID registerSetUseCallback(SetUseCallback CB); + LLVM_ABI void unregisterSetUseCallback(CallbackID ID); }; } // namespace sandboxir diff --git a/llvm/include/llvm/SandboxIR/Function.h b/llvm/include/llvm/SandboxIR/Function.h index 2c4b53ef6c1e6..565761bfdbdce 100644 --- a/llvm/include/llvm/SandboxIR/Function.h +++ b/llvm/include/llvm/SandboxIR/Function.h @@ -9,6 +9,7 @@ #ifndef LLVM_SANDBOXIR_FUNCTION_H #define LLVM_SANDBOXIR_FUNCTION_H +#include "llvm/Support/Compiler.h" #include "llvm/IR/Function.h" #include "llvm/SandboxIR/Constant.h" @@ -56,7 +57,7 @@ class Function : public GlobalWithNodeAPI(Val)->end(), BBGetter); } - FunctionType *getFunctionType() const; + LLVM_ABI FunctionType *getFunctionType() const; /// Returns the alignment of the given function. MaybeAlign getAlign() const { return cast(Val)->getAlign(); } @@ -66,7 +67,7 @@ class Function : public GlobalWithNodeAPIgetParent(), Before->getIterator()); @@ -217,9 +218,9 @@ class Instruction : public User { } /// \Returns the BasicBlock containing this Instruction, or null if it is /// detached. - BasicBlock *getParent() const; + LLVM_ABI BasicBlock *getParent() const; /// For isa/dyn_cast. - static bool classof(const sandboxir::Value *From); + LLVM_ABI static bool classof(const sandboxir::Value *From); /// Determine whether the no signed wrap flag is set. bool hasNoUnsignedWrap() const { @@ -227,20 +228,20 @@ class Instruction : public User { } /// 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); /// Determine whether the no signed wrap flag is set. bool hasNoSignedWrap() const { return cast(Val)->hasNoSignedWrap(); } /// 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); /// Determine whether all fast-math-flags are set. bool isFast() const { return cast(Val)->isFast(); } /// 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); /// Determine whether the allow-reassociation flag is set. bool hasAllowReassoc() const { return cast(Val)->hasAllowReassoc(); @@ -248,24 +249,24 @@ class Instruction : public User { /// 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); /// Determine whether the exact flag is set. bool isExact() const { return cast(Val)->isExact(); } /// 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); /// Determine whether the no-NaNs flag is set. bool hasNoNaNs() const { return cast(Val)->hasNoNaNs(); } /// 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); /// Determine whether the no-infs flag is set. bool hasNoInfs() const { return cast(Val)->hasNoInfs(); } /// 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); /// Determine whether the no-signed-zeros flag is set. bool hasNoSignedZeros() const { return cast(Val)->hasNoSignedZeros(); @@ -273,7 +274,7 @@ class Instruction : public User { /// 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); /// Determine whether the allow-reciprocal flag is set. bool hasAllowReciprocal() const { return cast(Val)->hasAllowReciprocal(); @@ -281,7 +282,7 @@ class Instruction : public User { /// 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); /// Determine whether the allow-contract flag is set. bool hasAllowContract() const { return cast(Val)->hasAllowContract(); @@ -289,7 +290,7 @@ class Instruction : public User { /// 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); /// Determine whether the approximate-math-functions flag is set. bool hasApproxFunc() const { return cast(Val)->hasApproxFunc(); @@ -297,7 +298,7 @@ class Instruction : public User { /// 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 getting all the fast-math flags, which must be an /// operator which supports these flags. See LangRef.html for the meaning of /// these flags. @@ -307,11 +308,11 @@ class Instruction : public User { /// 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); bool isAssociative() const { return cast(Val)->isAssociative(); @@ -352,7 +353,7 @@ class Instruction : public User { bool isVolatile() const { return cast(Val)->isVolatile(); } - Type *getAccessType() const; + LLVM_ABI Type *getAccessType() const; bool mayThrow(bool IncludePhaseOneUnwind = false) const { return cast(Val)->mayThrow(IncludePhaseOneUnwind); @@ -414,7 +415,7 @@ class FenceInst : public SingleLLVMInstructionImpl { friend Context; // For constructor; public: - static FenceInst *create(AtomicOrdering Ordering, InsertPosition Pos, + LLVM_ABI static FenceInst *create(AtomicOrdering Ordering, InsertPosition Pos, Context &Ctx, SyncScope::ID SSID = SyncScope::System); /// Returns the ordering constraint of this fence instruction. @@ -423,13 +424,13 @@ class FenceInst : public SingleLLVMInstructionImpl { } /// Sets the ordering constraint of this fence instruction. May only be /// Acquire, Release, AcquireRelease, or SequentiallyConsistent. - void setOrdering(AtomicOrdering Ordering); + LLVM_ABI void setOrdering(AtomicOrdering Ordering); /// Returns the synchronization scope ID of this fence instruction. SyncScope::ID getSyncScopeID() const { return cast(Val)->getSyncScopeID(); } /// Sets the synchronization scope ID of this fence instruction. - void setSyncScopeID(SyncScope::ID SSID); + LLVM_ABI void setSyncScopeID(SyncScope::ID SSID); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::Fence; } @@ -443,7 +444,7 @@ class SelectInst : public SingleLLVMInstructionImpl { friend Context; // for SelectInst() public: - static Value *create(Value *Cond, Value *True, Value *False, + LLVM_ABI static Value *create(Value *Cond, Value *True, Value *False, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); @@ -457,7 +458,7 @@ class SelectInst : public SingleLLVMInstructionImpl { void setCondition(Value *New) { setOperand(0, New); } void setTrueValue(Value *New) { setOperand(1, New); } void setFalseValue(Value *New) { setOperand(2, New); } - void swapValues(); + LLVM_ABI void swapValues(); /// Return a string if the specified operands are invalid for a select /// operation, otherwise return null. @@ -468,7 +469,7 @@ class SelectInst : public SingleLLVMInstructionImpl { } /// For isa/dyn_cast. - static bool classof(const Value *From); + LLVM_ABI static bool classof(const Value *From); }; class InsertElementInst final @@ -480,7 +481,7 @@ class InsertElementInst final friend class Context; // For accessing the constructor in create*() public: - static Value *create(Value *Vec, Value *NewElt, Value *Idx, + LLVM_ABI static Value *create(Value *Vec, Value *NewElt, Value *Idx, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); static bool classof(const Value *From) { @@ -503,7 +504,7 @@ class ExtractElementInst final // create*() public: - static Value *create(Value *Vec, Value *Idx, InsertPosition Pos, Context &Ctx, + LLVM_ABI static Value *create(Value *Vec, Value *Idx, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::ExtractElement; @@ -516,7 +517,7 @@ class ExtractElementInst final Value *getIndexOperand() { return getOperand(1); } const Value *getVectorOperand() const { return getOperand(0); } const Value *getIndexOperand() const { return getOperand(1); } - VectorType *getVectorOperandType() const; + LLVM_ABI VectorType *getVectorOperandType() const; }; class ShuffleVectorInst final @@ -528,9 +529,9 @@ class ShuffleVectorInst final friend class Context; // For accessing the constructor in create*() public: - static Value *create(Value *V1, Value *V2, Value *Mask, InsertPosition Pos, + LLVM_ABI static Value *create(Value *V1, Value *V2, Value *Mask, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); - static Value *create(Value *V1, Value *V2, ArrayRef Mask, + LLVM_ABI static Value *create(Value *V1, Value *V2, ArrayRef Mask, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); static bool classof(const Value *From) { @@ -539,7 +540,7 @@ class ShuffleVectorInst final /// 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. @@ -554,7 +555,7 @@ class ShuffleVectorInst final } /// Overload to return most specific vector type. - VectorType *getType() const; + LLVM_ABI VectorType *getType() const; /// Return the shuffle mask value of this instruction for the given element /// index. Return PoisonMaskElem if the element is undef. @@ -577,12 +578,12 @@ class ShuffleVectorInst final } /// Return the mask for this instruction, for use in bitcode. - Constant *getShuffleMaskForBitcode() const; + LLVM_ABI Constant *getShuffleMaskForBitcode() const; - static Constant *convertShuffleMaskForBitcode(ArrayRef Mask, + LLVM_ABI static Constant *convertShuffleMaskForBitcode(ArrayRef Mask, Type *ResultTy); - void setShuffleMask(ArrayRef Mask); + LLVM_ABI void setShuffleMask(ArrayRef Mask); ArrayRef getShuffleMask() const { return cast(Val)->getShuffleMask(); @@ -965,7 +966,7 @@ class InsertValueInst friend Context; // for InsertValueInst() public: - static Value *create(Value *Agg, Value *Val, ArrayRef Idxs, + LLVM_ABI static Value *create(Value *Agg, Value *Val, ArrayRef Idxs, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); @@ -1024,36 +1025,36 @@ class BranchInst : public SingleLLVMInstructionImpl { friend Context; // for BranchInst() public: - static BranchInst *create(BasicBlock *IfTrue, InsertPosition Pos, + LLVM_ABI static BranchInst *create(BasicBlock *IfTrue, InsertPosition Pos, Context &Ctx); - static BranchInst *create(BasicBlock *IfTrue, BasicBlock *IfFalse, + LLVM_ABI static BranchInst *create(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, InsertPosition Pos, Context &Ctx); /// For isa/dyn_cast. - static bool classof(const Value *From); + LLVM_ABI static bool classof(const Value *From); bool isUnconditional() const { return cast(Val)->isUnconditional(); } bool isConditional() const { return cast(Val)->isConditional(); } - Value *getCondition() const; + LLVM_ABI Value *getCondition() const; void setCondition(Value *V) { setOperand(0, V); } unsigned getNumSuccessors() const { return 1 + isConditional(); } - BasicBlock *getSuccessor(unsigned SuccIdx) const; - void setSuccessor(unsigned Idx, BasicBlock *NewSucc); + LLVM_ABI BasicBlock *getSuccessor(unsigned SuccIdx) const; + LLVM_ABI void setSuccessor(unsigned Idx, BasicBlock *NewSucc); void swapSuccessors() { swapOperandsInternal(1, 2); } private: struct LLVMBBToSBBB { Context &Ctx; LLVMBBToSBBB(Context &Ctx) : Ctx(Ctx) {} - BasicBlock *operator()(llvm::BasicBlock *BB) const; + LLVM_ABI BasicBlock *operator()(llvm::BasicBlock *BB) const; }; struct ConstLLVMBBToSBBB { Context &Ctx; ConstLLVMBBToSBBB(Context &Ctx) : Ctx(Ctx) {} - const BasicBlock *operator()(const llvm::BasicBlock *BB) const; + LLVM_ABI const BasicBlock *operator()(const llvm::BasicBlock *BB) const; }; public: @@ -1109,7 +1110,7 @@ class ExtractValueInst : public UnaryInstruction { friend Context; // for ExtractValueInst() public: - static Value *create(Value *Agg, ArrayRef Idxs, InsertPosition Pos, + LLVM_ABI static Value *create(Value *Agg, ArrayRef Idxs, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); static bool classof(const Value *From) { @@ -1120,7 +1121,7 @@ class ExtractValueInst : public UnaryInstruction { /// 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 Idxs); + LLVM_ABI static Type *getIndexedType(Type *Agg, ArrayRef Idxs); using idx_iterator = llvm::ExtractValueInst::idx_iterator; @@ -1163,9 +1164,9 @@ class VAArgInst : public UnaryInstruction { friend Context; // For constructor; public: - static VAArgInst *create(Value *List, Type *Ty, InsertPosition Pos, + LLVM_ABI static VAArgInst *create(Value *List, Type *Ty, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); - Value *getPointerOperand(); + LLVM_ABI Value *getPointerOperand(); const Value *getPointerOperand() const { return const_cast(this)->getPointerOperand(); } @@ -1183,7 +1184,7 @@ class FreezeInst : public UnaryInstruction { friend Context; // For constructor; public: - static FreezeInst *create(Value *V, InsertPosition Pos, Context &Ctx, + LLVM_ABI static FreezeInst *create(Value *V, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::Freeze; @@ -1200,9 +1201,9 @@ class LoadInst final : public UnaryInstruction { /// Return true if this is a load from a volatile memory location. bool isVolatile() const { return cast(Val)->isVolatile(); } /// Specify whether this is a volatile load or not. - void setVolatile(bool V); + LLVM_ABI void setVolatile(bool V); - static LoadInst *create(Type *Ty, Value *Ptr, MaybeAlign Align, + LLVM_ABI static LoadInst *create(Type *Ty, Value *Ptr, MaybeAlign Align, InsertPosition Pos, bool IsVolatile, Context &Ctx, const Twine &Name = ""); static LoadInst *create(Type *Ty, Value *Ptr, MaybeAlign Align, @@ -1212,8 +1213,8 @@ class LoadInst final : public UnaryInstruction { } /// For isa/dyn_cast. - static bool classof(const Value *From); - Value *getPointerOperand() const; + LLVM_ABI static bool classof(const Value *From); + LLVM_ABI Value *getPointerOperand() const; Align getAlign() const { return cast(Val)->getAlign(); } bool isUnordered() const { return cast(Val)->isUnordered(); } bool isSimple() const { return cast(Val)->isSimple(); } @@ -1229,9 +1230,9 @@ class StoreInst final : public SingleLLVMInstructionImpl { /// Return true if this is a store from a volatile memory location. bool isVolatile() const { return cast(Val)->isVolatile(); } /// Specify whether this is a volatile store or not. - void setVolatile(bool V); + LLVM_ABI void setVolatile(bool V); - static StoreInst *create(Value *V, Value *Ptr, MaybeAlign Align, + LLVM_ABI static StoreInst *create(Value *V, Value *Ptr, MaybeAlign Align, InsertPosition Pos, bool IsVolatile, Context &Ctx); static StoreInst *create(Value *V, Value *Ptr, MaybeAlign Align, InsertPosition Pos, Context &Ctx) { @@ -1239,9 +1240,9 @@ class StoreInst final : public SingleLLVMInstructionImpl { } /// For isa/dyn_cast. - static bool classof(const Value *From); - Value *getValueOperand() const; - Value *getPointerOperand() const; + LLVM_ABI static bool classof(const Value *From); + LLVM_ABI Value *getValueOperand() const; + LLVM_ABI Value *getPointerOperand() const; Align getAlign() const { return cast(Val)->getAlign(); } bool isSimple() const { return cast(Val)->isSimple(); } bool isUnordered() const { return cast(Val)->isUnordered(); } @@ -1260,8 +1261,8 @@ class UnreachableInst final : public Instruction { } public: - static UnreachableInst *create(InsertPosition Pos, Context &Ctx); - static bool classof(const Value *From); + LLVM_ABI static UnreachableInst *create(InsertPosition Pos, Context &Ctx); + LLVM_ABI static bool classof(const Value *From); unsigned getNumSuccessors() const { return 0; } unsigned getUseOperandNo(const Use &Use) const final { llvm_unreachable("UnreachableInst has no operands!"); @@ -1280,12 +1281,12 @@ class ReturnInst final : public SingleLLVMInstructionImpl { Context &Ctx); public: - static ReturnInst *create(Value *RetVal, InsertPosition Pos, Context &Ctx); + LLVM_ABI static ReturnInst *create(Value *RetVal, InsertPosition Pos, Context &Ctx); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::Ret; } /// \Returns null if there is no return value. - Value *getReturnValue() const; + LLVM_ABI Value *getReturnValue() const; }; class CallBase : public SingleLLVMInstructionImpl { @@ -1303,7 +1304,7 @@ class CallBase : public SingleLLVMInstructionImpl { Opc == Instruction::ClassID::CallBr; } - FunctionType *getFunctionType() const; + LLVM_ABI FunctionType *getFunctionType() const; op_iterator data_operands_begin() { return op_begin(); } const_op_iterator data_operands_begin() const { @@ -1390,17 +1391,17 @@ class CallBase : public SingleLLVMInstructionImpl { } bool hasArgument(const Value *V) const { return is_contained(args(), V); } - Value *getCalledOperand() const; - Use getCalledOperandUse() const; + LLVM_ABI Value *getCalledOperand() const; + LLVM_ABI Use getCalledOperandUse() const; - Function *getCalledFunction() const; + LLVM_ABI Function *getCalledFunction() const; bool isIndirectCall() const { return cast(Val)->isIndirectCall(); } bool isCallee(Use U) const { return cast(Val)->isCallee(U.LLVMUse); } - Function *getCaller(); + LLVM_ABI Function *getCaller(); const Function *getCaller() const { return const_cast(this)->getCaller(); } @@ -1412,7 +1413,7 @@ class CallBase : public SingleLLVMInstructionImpl { return cast(Val)->getIntrinsicID(); } void setCalledOperand(Value *V) { getCalledOperandUse().set(V); } - void setCalledFunction(Function *F); + LLVM_ABI void setCalledFunction(Function *F); CallingConv::ID getCallingConv() const { return cast(Val)->getCallingConv(); } @@ -1428,7 +1429,7 @@ class CallInst : public CallBase { friend class IntrinsicInst; // For constructor public: - static CallInst *create(FunctionType *FTy, Value *Func, + LLVM_ABI static CallInst *create(FunctionType *FTy, Value *Func, ArrayRef Args, InsertPosition Pos, Context &Ctx, const Twine &NameStr = ""); @@ -1446,7 +1447,7 @@ class InvokeInst final : public CallBase { // create*() public: - static InvokeInst *create(FunctionType *FTy, Value *Func, + LLVM_ABI static InvokeInst *create(FunctionType *FTy, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef Args, InsertPosition Pos, Context &Ctx, const Twine &NameStr = ""); @@ -1454,12 +1455,12 @@ class InvokeInst final : public CallBase { static bool classof(const Value *From) { return From->getSubclassID() == ClassID::Invoke; } - BasicBlock *getNormalDest() const; - BasicBlock *getUnwindDest() const; - void setNormalDest(BasicBlock *BB); - void setUnwindDest(BasicBlock *BB); - LandingPadInst *getLandingPadInst() const; - BasicBlock *getSuccessor(unsigned SuccIdx) const; + LLVM_ABI BasicBlock *getNormalDest() const; + LLVM_ABI BasicBlock *getUnwindDest() const; + LLVM_ABI void setNormalDest(BasicBlock *BB); + LLVM_ABI void setUnwindDest(BasicBlock *BB); + LLVM_ABI LandingPadInst *getLandingPadInst() const; + LLVM_ABI BasicBlock *getSuccessor(unsigned SuccIdx) const; void setSuccessor(unsigned SuccIdx, BasicBlock *NewSucc) { assert(SuccIdx < 2 && "Successor # out of range for invoke!"); if (SuccIdx == 0) @@ -1481,7 +1482,7 @@ class CallBrInst final : public CallBase { // create*() public: - static CallBrInst *create(FunctionType *FTy, Value *Func, + LLVM_ABI static CallBrInst *create(FunctionType *FTy, Value *Func, BasicBlock *DefaultDest, ArrayRef IndirectDests, ArrayRef Args, InsertPosition Pos, @@ -1492,14 +1493,14 @@ class CallBrInst final : public CallBase { unsigned getNumIndirectDests() const { return cast(Val)->getNumIndirectDests(); } - Value *getIndirectDestLabel(unsigned Idx) const; - Value *getIndirectDestLabelUse(unsigned Idx) const; - BasicBlock *getDefaultDest() const; - BasicBlock *getIndirectDest(unsigned Idx) const; - SmallVector getIndirectDests() const; - void setDefaultDest(BasicBlock *BB); - void setIndirectDest(unsigned Idx, BasicBlock *BB); - BasicBlock *getSuccessor(unsigned Idx) const; + LLVM_ABI Value *getIndirectDestLabel(unsigned Idx) const; + LLVM_ABI Value *getIndirectDestLabelUse(unsigned Idx) const; + LLVM_ABI BasicBlock *getDefaultDest() const; + LLVM_ABI BasicBlock *getIndirectDest(unsigned Idx) const; + LLVM_ABI SmallVector getIndirectDests() const; + LLVM_ABI void setDefaultDest(BasicBlock *BB); + LLVM_ABI void setIndirectDest(unsigned Idx, BasicBlock *BB); + LLVM_ABI BasicBlock *getSuccessor(unsigned Idx) const; unsigned getNumSuccessors() const { return cast(Val)->getNumSuccessors(); } @@ -1512,7 +1513,7 @@ class LandingPadInst : public SingleLLVMInstructionImpl { friend class Context; // For constructor. public: - static LandingPadInst *create(Type *RetTy, unsigned NumReservedClauses, + LLVM_ABI static LandingPadInst *create(Type *RetTy, unsigned NumReservedClauses, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); /// Return 'true' if this landingpad instruction is a @@ -1522,14 +1523,14 @@ class LandingPadInst : public SingleLLVMInstructionImpl { return cast(Val)->isCleanup(); } /// Indicate that this landingpad instruction is a cleanup. - void setCleanup(bool V); + LLVM_ABI void setCleanup(bool V); // TODO: We are not implementing addClause() because we have no way to revert // it for now. /// Get the value of the clause at index Idx. Use isCatch/isFilter to /// determine what type of clause this is. - Constant *getClause(unsigned Idx) const; + LLVM_ABI Constant *getClause(unsigned Idx) const; /// Return 'true' if the clause and index Idx is a catch clause. bool isCatch(unsigned Idx) const { @@ -1565,12 +1566,12 @@ class FuncletPadInst : public SingleLLVMInstructionImpl { /// /// Note: This returns the associated CatchSwitchInst if this FuncletPadInst /// is a CatchPadInst. - Value *getParentPad() const; - void setParentPad(Value *ParentPad); + LLVM_ABI Value *getParentPad() const; + LLVM_ABI void setParentPad(Value *ParentPad); /// Return the Idx-th funcletpad argument. - Value *getArgOperand(unsigned Idx) const; + LLVM_ABI Value *getArgOperand(unsigned Idx) const; /// Set the Idx-th funcletpad argument. - void setArgOperand(unsigned Idx, Value *V); + LLVM_ABI void setArgOperand(unsigned Idx, Value *V); // TODO: Implement missing functions: arg_operands(). static bool classof(const Value *From) { @@ -1585,11 +1586,11 @@ class CatchPadInst : public FuncletPadInst { friend class Context; // For constructor. public: - CatchSwitchInst *getCatchSwitch() const; + LLVM_ABI CatchSwitchInst *getCatchSwitch() const; // TODO: We have not implemented setCatchSwitch() because we can't revert it // for now, as there is no CatchPadInst member function that can undo it. - static CatchPadInst *create(Value *ParentPad, ArrayRef Args, + LLVM_ABI static CatchPadInst *create(Value *ParentPad, ArrayRef Args, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); static bool classof(const Value *From) { @@ -1603,7 +1604,7 @@ class CleanupPadInst : public FuncletPadInst { friend class Context; // For constructor. public: - static CleanupPadInst *create(Value *ParentPad, ArrayRef Args, + LLVM_ABI static CleanupPadInst *create(Value *ParentPad, ArrayRef Args, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); static bool classof(const Value *From) { @@ -1619,16 +1620,16 @@ class CatchReturnInst friend class Context; // For constructor. public: - static CatchReturnInst *create(CatchPadInst *CatchPad, BasicBlock *BB, + LLVM_ABI static CatchReturnInst *create(CatchPadInst *CatchPad, BasicBlock *BB, InsertPosition Pos, Context &Ctx); - CatchPadInst *getCatchPad() const; - void setCatchPad(CatchPadInst *CatchPad); - BasicBlock *getSuccessor() const; - void setSuccessor(BasicBlock *NewSucc); + LLVM_ABI CatchPadInst *getCatchPad() const; + LLVM_ABI void setCatchPad(CatchPadInst *CatchPad); + LLVM_ABI BasicBlock *getSuccessor() const; + LLVM_ABI void setSuccessor(BasicBlock *NewSucc); unsigned getNumSuccessors() { return cast(Val)->getNumSuccessors(); } - Value *getCatchSwitchParentPad() const; + LLVM_ABI Value *getCatchSwitchParentPad() const; static bool classof(const Value *From) { return From->getSubclassID() == ClassID::CatchRet; } @@ -1642,7 +1643,7 @@ class CleanupReturnInst friend class Context; // For constructor. public: - static CleanupReturnInst *create(CleanupPadInst *CleanupPad, + LLVM_ABI static CleanupReturnInst *create(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB, InsertPosition Pos, Context &Ctx); bool hasUnwindDest() const { @@ -1651,13 +1652,13 @@ class CleanupReturnInst bool unwindsToCaller() const { return cast(Val)->unwindsToCaller(); } - CleanupPadInst *getCleanupPad() const; - void setCleanupPad(CleanupPadInst *CleanupPad); + LLVM_ABI CleanupPadInst *getCleanupPad() const; + LLVM_ABI void setCleanupPad(CleanupPadInst *CleanupPad); unsigned getNumSuccessors() const { return cast(Val)->getNumSuccessors(); } - BasicBlock *getUnwindDest() const; - void setUnwindDest(BasicBlock *NewDest); + LLVM_ABI BasicBlock *getUnwindDest() const; + LLVM_ABI void setUnwindDest(BasicBlock *NewDest); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::CleanupRet; @@ -1677,7 +1678,7 @@ class GetElementPtrInst final // create*() public: - static Value *create(Type *Ty, Value *Ptr, ArrayRef IdxList, + LLVM_ABI static Value *create(Type *Ty, Value *Ptr, ArrayRef IdxList, InsertPosition Pos, Context &Ctx, const Twine &NameStr = ""); @@ -1685,8 +1686,8 @@ class GetElementPtrInst final return From->getSubclassID() == ClassID::GetElementPtr; } - Type *getSourceElementType() const; - Type *getResultElementType() const; + LLVM_ABI Type *getSourceElementType() const; + LLVM_ABI Type *getResultElementType() const; unsigned getAddressSpace() const { return cast(Val)->getAddressSpace(); } @@ -1706,11 +1707,11 @@ class GetElementPtrInst final return const_cast(this)->indices(); } - Value *getPointerOperand() const; + LLVM_ABI Value *getPointerOperand() const; static unsigned getPointerOperandIndex() { return llvm::GetElementPtrInst::getPointerOperandIndex(); } - Type *getPointerOperandType() const; + LLVM_ABI Type *getPointerOperandType() const; unsigned getPointerAddressSpace() const { return cast(Val)->getPointerAddressSpace(); } @@ -1750,12 +1751,12 @@ class CatchSwitchInst friend class Context; // For accessing the constructor in create*() public: - static CatchSwitchInst *create(Value *ParentPad, BasicBlock *UnwindBB, + LLVM_ABI static CatchSwitchInst *create(Value *ParentPad, BasicBlock *UnwindBB, unsigned NumHandlers, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); - Value *getParentPad() const; - void setParentPad(Value *ParentPad); + LLVM_ABI Value *getParentPad() const; + LLVM_ABI void setParentPad(Value *ParentPad); bool hasUnwindDest() const { return cast(Val)->hasUnwindDest(); @@ -1763,8 +1764,8 @@ class CatchSwitchInst bool unwindsToCaller() const { return cast(Val)->unwindsToCaller(); } - BasicBlock *getUnwindDest() const; - void setUnwindDest(BasicBlock *UnwindDest); + LLVM_ABI BasicBlock *getUnwindDest() const; + LLVM_ABI void setUnwindDest(BasicBlock *UnwindDest); unsigned getNumHandlers() const { return cast(Val)->getNumHandlers(); @@ -1810,7 +1811,7 @@ class CatchSwitchInst return make_range(handler_begin(), handler_end()); } - void addHandler(BasicBlock *Dest); + LLVM_ABI void addHandler(BasicBlock *Dest); // TODO: removeHandler() cannot be reverted because there is no equivalent // addHandler() with a handler_iterator to specify the position. So we can't @@ -1839,8 +1840,8 @@ class ResumeInst : public SingleLLVMInstructionImpl { friend class Context; // For accessing the constructor in create*() public: - static ResumeInst *create(Value *Exn, InsertPosition Pos, Context &Ctx); - Value *getValue() const; + LLVM_ABI static ResumeInst *create(Value *Exn, InsertPosition Pos, Context &Ctx); + LLVM_ABI Value *getValue() const; unsigned getNumSuccessors() const { return cast(Val)->getNumSuccessors(); } @@ -1858,17 +1859,17 @@ class SwitchInst : public SingleLLVMInstructionImpl { static constexpr const unsigned DefaultPseudoIndex = llvm::SwitchInst::DefaultPseudoIndex; - static SwitchInst *create(Value *V, BasicBlock *Dest, unsigned NumCases, + LLVM_ABI static SwitchInst *create(Value *V, BasicBlock *Dest, unsigned NumCases, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); - Value *getCondition() const; - void setCondition(Value *V); - BasicBlock *getDefaultDest() const; + LLVM_ABI Value *getCondition() const; + LLVM_ABI void setCondition(Value *V); + LLVM_ABI BasicBlock *getDefaultDest() const; bool defaultDestUnreachable() const { return cast(Val)->defaultDestUnreachable(); } - void setDefaultDest(BasicBlock *DefaultCase); + LLVM_ABI void setDefaultDest(BasicBlock *DefaultCase); unsigned getNumCases() const { return cast(Val)->getNumCases(); } @@ -1913,9 +1914,9 @@ class SwitchInst : public SingleLLVMInstructionImpl { return I; return case_default(); } - ConstantInt *findCaseDest(BasicBlock *BB); + LLVM_ABI ConstantInt *findCaseDest(BasicBlock *BB); - 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 /// index idx and above. @@ -1923,13 +1924,13 @@ class SwitchInst : public SingleLLVMInstructionImpl { /// 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 It); + LLVM_ABI CaseIt removeCase(CaseIt It); unsigned getNumSuccessors() const { return cast(Val)->getNumSuccessors(); } - BasicBlock *getSuccessor(unsigned Idx) const; - void setSuccessor(unsigned Idx, BasicBlock *NewSucc); + LLVM_ABI BasicBlock *getSuccessor(unsigned Idx) const; + LLVM_ABI void setSuccessor(unsigned Idx, BasicBlock *NewSucc); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::Switch; } @@ -1950,9 +1951,9 @@ class UnaryOperator : public UnaryInstruction { Ctx) {} friend Context; // for constructor. public: - static Value *create(Instruction::Opcode Op, Value *OpV, InsertPosition Pos, + LLVM_ABI static Value *create(Instruction::Opcode Op, Value *OpV, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); - static Value *createWithCopiedFlags(Instruction::Opcode Op, Value *OpV, + LLVM_ABI static Value *createWithCopiedFlags(Instruction::Opcode Op, Value *OpV, Value *CopyFrom, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); /// For isa/dyn_cast. @@ -2013,11 +2014,11 @@ class BinaryOperator : public SingleLLVMInstructionImpl { friend class Context; // For constructor. public: - static Value *create(Instruction::Opcode Op, Value *LHS, Value *RHS, + LLVM_ABI static Value *create(Instruction::Opcode Op, Value *LHS, Value *RHS, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); - static Value *createWithCopiedFlags(Instruction::Opcode Op, Value *LHS, + LLVM_ABI static Value *createWithCopiedFlags(Instruction::Opcode Op, Value *LHS, Value *RHS, Value *CopyFrom, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); @@ -2033,7 +2034,7 @@ class BinaryOperator : public SingleLLVMInstructionImpl { /// can also be treated as an add. class PossiblyDisjointInst : public BinaryOperator { public: - void setIsDisjoint(bool B); + LLVM_ABI void setIsDisjoint(bool B); bool isDisjoint() const { return cast(Val)->isDisjoint(); } @@ -2066,24 +2067,24 @@ class AtomicRMWInst : public SingleLLVMInstructionImpl { cast(Val)->setOperation(Op); } Align getAlign() const { return cast(Val)->getAlign(); } - void setAlignment(Align Align); + LLVM_ABI void setAlignment(Align Align); bool isVolatile() const { return cast(Val)->isVolatile(); } - void setVolatile(bool V); + LLVM_ABI void setVolatile(bool V); AtomicOrdering getOrdering() const { return cast(Val)->getOrdering(); } - void setOrdering(AtomicOrdering Ordering); + LLVM_ABI void setOrdering(AtomicOrdering Ordering); SyncScope::ID getSyncScopeID() const { return cast(Val)->getSyncScopeID(); } - void setSyncScopeID(SyncScope::ID SSID); - Value *getPointerOperand(); + LLVM_ABI void setSyncScopeID(SyncScope::ID SSID); + LLVM_ABI Value *getPointerOperand(); const Value *getPointerOperand() const { return const_cast(this)->getPointerOperand(); } - Value *getValOperand(); + LLVM_ABI Value *getValOperand(); const Value *getValOperand() const { return const_cast(this)->getValOperand(); } @@ -2097,7 +2098,7 @@ class AtomicRMWInst : public SingleLLVMInstructionImpl { return From->getSubclassID() == ClassID::AtomicRMW; } - static AtomicRMWInst *create(BinOp Op, Value *Ptr, Value *Val, + LLVM_ABI static AtomicRMWInst *create(BinOp Op, Value *Ptr, Value *Val, MaybeAlign Align, AtomicOrdering Ordering, InsertPosition Pos, Context &Ctx, SyncScope::ID SSID = SyncScope::System, @@ -2119,17 +2120,17 @@ class AtomicCmpXchgInst return cast(Val)->getAlign(); } - void setAlignment(Align Align); + LLVM_ABI void setAlignment(Align Align); /// Return true if this is a cmpxchg from a volatile memory /// location. bool isVolatile() const { return cast(Val)->isVolatile(); } /// Specify whether this is a volatile cmpxchg. - void setVolatile(bool V); + LLVM_ABI void setVolatile(bool V); /// Return true if this cmpxchg may spuriously fail. bool isWeak() const { return cast(Val)->isWeak(); } - void setWeak(bool IsWeak); + LLVM_ABI void setWeak(bool IsWeak); static bool isValidSuccessOrdering(AtomicOrdering Ordering) { return llvm::AtomicCmpXchgInst::isValidSuccessOrdering(Ordering); } @@ -2139,30 +2140,30 @@ class AtomicCmpXchgInst AtomicOrdering getSuccessOrdering() const { return cast(Val)->getSuccessOrdering(); } - void setSuccessOrdering(AtomicOrdering Ordering); + LLVM_ABI void setSuccessOrdering(AtomicOrdering Ordering); AtomicOrdering getFailureOrdering() const { return cast(Val)->getFailureOrdering(); } - void setFailureOrdering(AtomicOrdering Ordering); + LLVM_ABI void setFailureOrdering(AtomicOrdering Ordering); AtomicOrdering getMergedOrdering() const { return cast(Val)->getMergedOrdering(); } SyncScope::ID getSyncScopeID() const { return cast(Val)->getSyncScopeID(); } - void setSyncScopeID(SyncScope::ID SSID); - Value *getPointerOperand(); + LLVM_ABI void setSyncScopeID(SyncScope::ID SSID); + LLVM_ABI Value *getPointerOperand(); const Value *getPointerOperand() const { return const_cast(this)->getPointerOperand(); } - Value *getCompareOperand(); + LLVM_ABI Value *getCompareOperand(); const Value *getCompareOperand() const { return const_cast(this)->getCompareOperand(); } - Value *getNewValOperand(); + LLVM_ABI Value *getNewValOperand(); const Value *getNewValOperand() const { return const_cast(this)->getNewValOperand(); } @@ -2172,7 +2173,7 @@ class AtomicCmpXchgInst return cast(Val)->getPointerAddressSpace(); } - static AtomicCmpXchgInst * + LLVM_ABI static AtomicCmpXchgInst * create(Value *Ptr, Value *Cmp, Value *New, MaybeAlign Align, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, InsertPosition Pos, Context &Ctx, @@ -2190,7 +2191,7 @@ class AllocaInst final : public UnaryInstruction { friend class Context; // For constructor. public: - static AllocaInst *create(Type *Ty, unsigned AddrSpace, InsertPosition Pos, + LLVM_ABI static AllocaInst *create(Type *Ty, unsigned AddrSpace, InsertPosition Pos, Context &Ctx, Value *ArraySize = nullptr, const Twine &Name = ""); @@ -2201,12 +2202,12 @@ class AllocaInst final : public UnaryInstruction { } /// Get the number of elements allocated. For a simple allocation of a single /// element, this will return a constant 1 value. - Value *getArraySize(); + LLVM_ABI Value *getArraySize(); const Value *getArraySize() const { return const_cast(this)->getArraySize(); } /// Overload to return most specific pointer type. - PointerType *getType() const; + LLVM_ABI PointerType *getType() const; /// Return the address space for the allocation. unsigned getAddressSpace() const { return cast(Val)->getAddressSpace(); @@ -2222,14 +2223,14 @@ class AllocaInst final : public UnaryInstruction { return cast(Val)->getAllocationSizeInBits(DL); } /// Return the type that is being allocated by the instruction. - Type *getAllocatedType() const; + LLVM_ABI Type *getAllocatedType() const; /// for use only in special circumstances that need to generically /// transform a whole instruction (eg: IR linking and vectorization). - void setAllocatedType(Type *Ty); + LLVM_ABI void setAllocatedType(Type *Ty); /// Return the alignment of the memory that is being allocated by the /// instruction. Align getAlign() const { return cast(Val)->getAlign(); } - void setAlignment(Align Align); + LLVM_ABI void setAlignment(Align Align); /// 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. @@ -2242,7 +2243,7 @@ class AllocaInst final : public UnaryInstruction { return cast(Val)->isUsedWithInAlloca(); } /// Specify whether this alloca is used to represent the arguments to a call. - void setUsedWithInAlloca(bool V); + LLVM_ABI void setUsedWithInAlloca(bool V); static bool classof(const Value *From) { if (auto *I = dyn_cast(From)) @@ -2293,13 +2294,13 @@ class CastInst : public UnaryInstruction { friend Context; // for SBCastInstruction() public: - static Value *create(Type *DestTy, Opcode Op, Value *Operand, + LLVM_ABI static Value *create(Type *DestTy, Opcode Op, Value *Operand, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); /// For isa/dyn_cast. - static bool classof(const Value *From); - Type *getSrcTy() const; - Type *getDestTy() const; + LLVM_ABI static bool classof(const Value *From); + LLVM_ABI Type *getSrcTy() const; + LLVM_ABI Type *getDestTy() const; }; /// Instruction that can have a nneg flag (zext/uitofp). @@ -2308,7 +2309,7 @@ class PossiblyNonNegInst : public CastInst { bool hasNonNeg() const { return cast(Val)->hasNonNeg(); } - void setNonNeg(bool B); + LLVM_ABI void setNonNeg(bool B); /// For isa/dyn_cast. static bool classof(const Value *From) { if (auto *I = dyn_cast(From)) { @@ -2383,15 +2384,15 @@ class PHINode final : public SingleLLVMInstructionImpl { struct LLVMBBToBB { Context &Ctx; LLVMBBToBB(Context &Ctx) : Ctx(Ctx) {} - BasicBlock *operator()(llvm::BasicBlock *LLVMBB) const; + LLVM_ABI BasicBlock *operator()(llvm::BasicBlock *LLVMBB) const; }; public: - static PHINode *create(Type *Ty, unsigned NumReservedValues, + LLVM_ABI static PHINode *create(Type *Ty, unsigned NumReservedValues, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); /// For isa/dyn_cast. - static bool classof(const Value *From); + LLVM_ABI static bool classof(const Value *From); using const_block_iterator = mapped_iterator; @@ -2417,35 +2418,35 @@ class PHINode final : public SingleLLVMInstructionImpl { unsigned getNumIncomingValues() const { return cast(Val)->getNumIncomingValues(); } - Value *getIncomingValue(unsigned Idx) const; - void setIncomingValue(unsigned Idx, Value *V); + LLVM_ABI Value *getIncomingValue(unsigned Idx) const; + LLVM_ABI void setIncomingValue(unsigned Idx, Value *V); static unsigned getOperandNumForIncomingValue(unsigned Idx) { return llvm::PHINode::getOperandNumForIncomingValue(Idx); } static unsigned getIncomingValueNumForOperand(unsigned Idx) { return llvm::PHINode::getIncomingValueNumForOperand(Idx); } - BasicBlock *getIncomingBlock(unsigned Idx) const; - BasicBlock *getIncomingBlock(const Use &U) const; + LLVM_ABI BasicBlock *getIncomingBlock(unsigned Idx) const; + LLVM_ABI BasicBlock *getIncomingBlock(const Use &U) const; - void setIncomingBlock(unsigned Idx, BasicBlock *BB); + LLVM_ABI void setIncomingBlock(unsigned Idx, BasicBlock *BB); - void addIncoming(Value *V, BasicBlock *BB); + LLVM_ABI void addIncoming(Value *V, BasicBlock *BB); - Value *removeIncomingValue(unsigned Idx); - Value *removeIncomingValue(BasicBlock *BB); + LLVM_ABI Value *removeIncomingValue(unsigned Idx); + LLVM_ABI Value *removeIncomingValue(BasicBlock *BB); - int getBasicBlockIndex(const BasicBlock *BB) const; - Value *getIncomingValueForBlock(const BasicBlock *BB) const; + LLVM_ABI int getBasicBlockIndex(const BasicBlock *BB) const; + LLVM_ABI Value *getIncomingValueForBlock(const BasicBlock *BB) const; - Value *hasConstantValue() const; + LLVM_ABI Value *hasConstantValue() const; bool hasConstantOrUndefValue() const { return cast(Val)->hasConstantOrUndefValue(); } bool isComplete() const { return cast(Val)->isComplete(); } - void replaceIncomingBlockWith(const BasicBlock *Old, BasicBlock *New); - void removeIncomingValueIf(function_ref Predicate); + LLVM_ABI void replaceIncomingBlockWith(const BasicBlock *Old, BasicBlock *New); + LLVM_ABI void removeIncomingValueIf(function_ref Predicate); // TODO: Implement // void copyIncomingBlocks(iterator_range BBRange, // uint32_t ToIdx = 0) @@ -2471,21 +2472,21 @@ class CmpInst : public SingleLLVMInstructionImpl { CmpInst(llvm::CmpInst *CI, Context &Ctx, ClassID Id, Opcode Opc) : SingleLLVMInstructionImpl(Id, Opc, CI, Ctx) {} friend Context; // for CmpInst() - static Value *createCommon(Value *Cond, Value *True, Value *False, + LLVM_ABI static Value *createCommon(Value *Cond, Value *True, Value *False, const Twine &Name, IRBuilder<> &Builder, Context &Ctx); public: using Predicate = llvm::CmpInst::Predicate; - static Value *create(Predicate Pred, Value *S1, Value *S2, InsertPosition Pos, + LLVM_ABI static Value *create(Predicate Pred, Value *S1, Value *S2, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); - static Value *createWithCopiedFlags(Predicate Pred, Value *S1, Value *S2, + LLVM_ABI static Value *createWithCopiedFlags(Predicate Pred, Value *S1, Value *S2, const Instruction *FlagsSource, InsertPosition Pos, Context &Ctx, const Twine &Name = ""); - void setPredicate(Predicate P); - void swapOperands(); + LLVM_ABI void setPredicate(Predicate P); + LLVM_ABI void swapOperands(); WRAP_MEMBER(getPredicate); WRAP_BOTH(isFPPredicate); @@ -2517,7 +2518,7 @@ class CmpInst : public SingleLLVMInstructionImpl { } /// Create a result type for fcmp/icmp - static Type *makeCmpResultType(Type *OpndType); + LLVM_ABI static Type *makeCmpResultType(Type *OpndType); #ifndef NDEBUG void dumpOS(raw_ostream &OS) const override; @@ -2533,7 +2534,7 @@ class ICmpInst : public CmpInst { using LLVMValType = llvm::ICmpInst; public: - void swapOperands(); + LLVM_ABI void swapOperands(); WRAP_BOTH(getSignedPredicate); WRAP_BOTH(getUnsignedPredicate); @@ -2570,7 +2571,7 @@ class FCmpInst : public CmpInst { using LLVMValType = llvm::FCmpInst; public: - void swapOperands(); + LLVM_ABI void swapOperands(); WRAP_BOTH(isEquality); WRAP_MEMBER(isCommutative); diff --git a/llvm/include/llvm/SandboxIR/Module.h b/llvm/include/llvm/SandboxIR/Module.h index 429bb04539bcb..9c76d135bb1f9 100644 --- a/llvm/include/llvm/SandboxIR/Module.h +++ b/llvm/include/llvm/SandboxIR/Module.h @@ -9,6 +9,7 @@ #ifndef LLVM_SANDBOXIR_MODULE_H #define LLVM_SANDBOXIR_MODULE_H +#include "llvm/Support/Compiler.h" #include "llvm/ADT/STLExtras.h" #include "llvm/IR/Module.h" #include @@ -38,7 +39,7 @@ class Module { public: Context &getContext() const { return Ctx; } - Function *getFunction(StringRef Name) const; + LLVM_ABI Function *getFunction(StringRef Name) const; const DataLayout &getDataLayout() const { return LLVMM.getDataLayout(); } @@ -50,7 +51,7 @@ class Module { /// does not exist, return null. If AllowInternal is set to true, this /// function will return types that have InternalLinkage. By default, these /// types are not returned. - GlobalVariable *getGlobalVariable(StringRef Name, bool AllowInternal) const; + LLVM_ABI GlobalVariable *getGlobalVariable(StringRef Name, bool AllowInternal) const; GlobalVariable *getGlobalVariable(StringRef Name) const { return getGlobalVariable(Name, /*AllowInternal=*/false); } @@ -66,12 +67,12 @@ class Module { /// Return the global alias in the module with the specified name, of /// arbitrary type. This method returns null if a global with the specified /// name is not found. - GlobalAlias *getNamedAlias(StringRef Name) const; + LLVM_ABI GlobalAlias *getNamedAlias(StringRef Name) const; /// Return the global ifunc in the module with the specified name, of /// arbitrary type. This method returns null if a global with the specified /// name is not found. - GlobalIFunc *getNamedIFunc(StringRef Name) const; + LLVM_ABI GlobalIFunc *getNamedIFunc(StringRef Name) const; // TODO: Missing removeGlobalVariable() eraseGlobalVariable(), // insertGlobalVariable() diff --git a/llvm/include/llvm/SandboxIR/PassManager.h b/llvm/include/llvm/SandboxIR/PassManager.h index 55a0301f4756b..11cf3df5d14be 100644 --- a/llvm/include/llvm/SandboxIR/PassManager.h +++ b/llvm/include/llvm/SandboxIR/PassManager.h @@ -18,6 +18,7 @@ #ifndef LLVM_SANDBOXIR_PASSMANAGER_H #define LLVM_SANDBOXIR_PASSMANAGER_H +#include "llvm/Support/Compiler.h" #include #include "llvm/ADT/DenseMap.h" @@ -201,7 +202,7 @@ class PassManager : public ParentPass { } }; -class FunctionPassManager final +class LLVM_ABI FunctionPassManager final : public PassManager { public: FunctionPassManager(StringRef Name) : PassManager(Name) {} @@ -211,7 +212,7 @@ class FunctionPassManager final bool runOnFunction(Function &F, const Analyses &A) final; }; -class RegionPassManager final : public PassManager { +class LLVM_ABI RegionPassManager final : public PassManager { public: RegionPassManager(StringRef Name) : PassManager(Name) {} RegionPassManager(StringRef Name, StringRef Pipeline, diff --git a/llvm/include/llvm/SandboxIR/Region.h b/llvm/include/llvm/SandboxIR/Region.h index f86199ab6c228..d70f21277fb1b 100644 --- a/llvm/include/llvm/SandboxIR/Region.h +++ b/llvm/include/llvm/SandboxIR/Region.h @@ -9,6 +9,7 @@ #ifndef LLVM_SANDBOXIR_REGION_H #define LLVM_SANDBOXIR_REGION_H +#include "llvm/Support/Compiler.h" #include #include "llvm/ADT/SetVector.h" @@ -30,7 +31,7 @@ class ScoreBoard { /// The cost of all instructions that got removed and replaced by new ones. InstructionCost BeforeCost = 0; /// Helper for both add() and remove(). \Returns the TTI cost of \p I. - InstructionCost getCost(Instruction *I) const; + LLVM_ABI InstructionCost getCost(Instruction *I) const; /// No need to allow copies. ScoreBoard(const ScoreBoard &) = delete; const ScoreBoard &operator=(const ScoreBoard &) = delete; @@ -40,7 +41,7 @@ class ScoreBoard { /// Mark \p I as a newly added instruction to the region. void add(Instruction *I) { AfterCost += getCost(I); } /// Mark \p I as a deleted instruction from the region. - void remove(Instruction *I); + LLVM_ABI void remove(Instruction *I); /// \Returns the cost of the newly added instructions. InstructionCost getAfterCost() const { return AfterCost; } /// \Returns the cost of the Removed instructions. @@ -122,12 +123,12 @@ class Region { /// add an instruction to the auxiliary vector it does get tagged as being a /// member of the region (for ownership reasons), but its cost does not get /// counted because the instruction hasn't been added in the "normal" way. - void addImpl(Instruction *I, bool IgnoreCost); + LLVM_ABI void addImpl(Instruction *I, bool IgnoreCost); /// Adds I to the set. This is the main API for adding an instruction to the /// region. void add(Instruction *I) { addImpl(I, /*IgnoreCost=*/false); } /// Removes I from the set. - void remove(Instruction *I); + LLVM_ABI void remove(Instruction *I); friend class Context; // The callbacks need to call add() and remove(). friend class RegionInternalsAttorney; // For unit tests. friend class RegionsFromBBs; // For add(). @@ -141,8 +142,8 @@ class Region { void removeFromAux(Instruction *I); public: - Region(Context &Ctx, TargetTransformInfo &TTI); - ~Region(); + LLVM_ABI Region(Context &Ctx, TargetTransformInfo &TTI); + LLVM_ABI ~Region(); Context &getContext() const { return Ctx; } /// Returns true if I is in the Region. @@ -150,18 +151,18 @@ class Region { /// Returns true if the Region has no instructions. bool empty() const { return Insts.empty(); } /// Set the auxiliary vector. - void setAux(ArrayRef Aux); + LLVM_ABI void setAux(ArrayRef Aux); /// \Returns the auxiliary vector. const SmallVector &getAux() const { return Aux; } /// Clears all auxiliary data. - void clearAux(); + LLVM_ABI void clearAux(); using iterator = decltype(Insts.begin()); iterator begin() { return Insts.begin(); } iterator end() { return Insts.end(); } iterator_range insts() { return make_range(begin(), end()); } - static SmallVector> + LLVM_ABI static SmallVector> createRegionsFromMD(Function &F, TargetTransformInfo &TTI); /// \Returns the ScoreBoard data structure that keeps track of instr costs. const ScoreBoard &getScoreboard() const { return Scoreboard; } diff --git a/llvm/include/llvm/SandboxIR/Tracker.h b/llvm/include/llvm/SandboxIR/Tracker.h index f7b469965eae8..653cc53074475 100644 --- a/llvm/include/llvm/SandboxIR/Tracker.h +++ b/llvm/include/llvm/SandboxIR/Tracker.h @@ -40,6 +40,7 @@ #ifndef LLVM_SANDBOXIR_TRACKER_H #define LLVM_SANDBOXIR_TRACKER_H +#include "llvm/Support/Compiler.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StableHashing.h" @@ -149,7 +150,7 @@ class UseSet : public IRChangeBase { #endif }; -class PHIRemoveIncoming : public IRChangeBase { +class LLVM_ABI PHIRemoveIncoming : public IRChangeBase { PHINode *PHI; unsigned RemovedIdx; Value *RemovedV; @@ -165,7 +166,7 @@ class PHIRemoveIncoming : public IRChangeBase { #endif }; -class PHIAddIncoming : public IRChangeBase { +class LLVM_ABI PHIAddIncoming : public IRChangeBase { PHINode *PHI; unsigned Idx; @@ -179,7 +180,7 @@ class PHIAddIncoming : public IRChangeBase { #endif }; -class CmpSwapOperands : public IRChangeBase { +class LLVM_ABI CmpSwapOperands : public IRChangeBase { CmpInst *Cmp; public: @@ -210,7 +211,7 @@ class UseSwap : public IRChangeBase { #endif }; -class EraseFromParent : public IRChangeBase { +class LLVM_ABI EraseFromParent : public IRChangeBase { /// Contains all the data we need to restore an "erased" (i.e., detached) /// instruction: the instruction itself and its operands in order. struct InstrAndOperands { @@ -242,7 +243,7 @@ class EraseFromParent : public IRChangeBase { #endif }; -class RemoveFromParent : public IRChangeBase { +class LLVM_ABI RemoveFromParent : public IRChangeBase { /// The instruction that is about to get removed. Instruction *RemovedI = nullptr; /// This is either the next instr, or the parent BB if at the end of the BB. @@ -327,7 +328,7 @@ class GenericSetterWithIdx final : public IRChangeBase { #endif }; -class CatchSwitchAddHandler : public IRChangeBase { +class LLVM_ABI CatchSwitchAddHandler : public IRChangeBase { CatchSwitchInst *CSI; unsigned HandlerIdx; @@ -344,7 +345,7 @@ class CatchSwitchAddHandler : public IRChangeBase { #endif // NDEBUG }; -class SwitchAddCase : public IRChangeBase { +class LLVM_ABI SwitchAddCase : public IRChangeBase { SwitchInst *Switch; ConstantInt *Val; @@ -359,7 +360,7 @@ class SwitchAddCase : public IRChangeBase { #endif // NDEBUG }; -class SwitchRemoveCase : public IRChangeBase { +class LLVM_ABI SwitchRemoveCase : public IRChangeBase { SwitchInst *Switch; struct Case { ConstantInt *Val; @@ -378,7 +379,7 @@ class SwitchRemoveCase : public IRChangeBase { #endif // NDEBUG }; -class MoveInstr : public IRChangeBase { +class LLVM_ABI MoveInstr : public IRChangeBase { /// The instruction that moved. Instruction *MovedI; /// This is either the next instruction in the block, or the parent BB if at @@ -395,7 +396,7 @@ class MoveInstr : public IRChangeBase { #endif // NDEBUG }; -class InsertIntoBB final : public IRChangeBase { +class LLVM_ABI InsertIntoBB final : public IRChangeBase { Instruction *InsertedI = nullptr; public: @@ -408,7 +409,7 @@ class InsertIntoBB final : public IRChangeBase { #endif // NDEBUG }; -class CreateAndInsertInst final : public IRChangeBase { +class LLVM_ABI CreateAndInsertInst final : public IRChangeBase { Instruction *NewI = nullptr; public: @@ -421,7 +422,7 @@ class CreateAndInsertInst final : public IRChangeBase { #endif }; -class ShuffleVectorSetMask final : public IRChangeBase { +class LLVM_ABI ShuffleVectorSetMask final : public IRChangeBase { ShuffleVectorInst *SVI; SmallVector PrevMask; @@ -472,7 +473,7 @@ class Tracker { { } - ~Tracker(); + LLVM_ABI ~Tracker(); Context &getContext() const { return Ctx; } /// \Returns true if there are no changes tracked. bool empty() const { return Changes.empty(); } @@ -506,11 +507,11 @@ class Tracker { /// \Returns the current state of the tracker. TrackerState getState() const { return State; } /// Turns on IR tracking. - void save(); + LLVM_ABI void save(); /// Stops tracking and accept changes. - void accept(); + LLVM_ABI void accept(); /// Stops tracking and reverts to saved state. - void revert(); + LLVM_ABI void revert(); #ifndef NDEBUG void dump(raw_ostream &OS) const; diff --git a/llvm/include/llvm/SandboxIR/Type.h b/llvm/include/llvm/SandboxIR/Type.h index f90ae096443b5..dfc4c0e7eae87 100644 --- a/llvm/include/llvm/SandboxIR/Type.h +++ b/llvm/include/llvm/SandboxIR/Type.h @@ -13,6 +13,7 @@ #ifndef LLVM_SANDBOXIR_TYPE_H #define LLVM_SANDBOXIR_TYPE_H +#include "llvm/Support/Compiler.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Type.h" @@ -264,18 +265,18 @@ class Type { /// If this is a vector type, return the element type, otherwise return /// 'this'. - Type *getScalarType() const; + LLVM_ABI Type *getScalarType() const; // TODO: ADD MISSING - static Type *getInt64Ty(Context &Ctx); - static Type *getInt32Ty(Context &Ctx); - static Type *getInt16Ty(Context &Ctx); - static Type *getInt8Ty(Context &Ctx); - static Type *getInt1Ty(Context &Ctx); - static Type *getDoubleTy(Context &Ctx); - static Type *getFloatTy(Context &Ctx); - static Type *getHalfTy(Context &Ctx); + LLVM_ABI static Type *getInt64Ty(Context &Ctx); + LLVM_ABI static Type *getInt32Ty(Context &Ctx); + LLVM_ABI static Type *getInt16Ty(Context &Ctx); + LLVM_ABI static Type *getInt8Ty(Context &Ctx); + LLVM_ABI static Type *getInt1Ty(Context &Ctx); + LLVM_ABI static Type *getDoubleTy(Context &Ctx); + LLVM_ABI static Type *getFloatTy(Context &Ctx); + LLVM_ABI static Type *getHalfTy(Context &Ctx); // TODO: missing get* /// Get the address space of this pointer or pointer vector type. @@ -293,7 +294,7 @@ class PointerType : public Type { public: // TODO: add missing functions - static PointerType *get(Context &Ctx, unsigned AddressSpace); + LLVM_ABI static PointerType *get(Context &Ctx, unsigned AddressSpace); static bool classof(const Type *From) { return isa(From->LLVMTy); @@ -302,7 +303,7 @@ class PointerType : public Type { class ArrayType : public Type { public: - static ArrayType *get(Type *ElementType, uint64_t NumElements); + LLVM_ABI static ArrayType *get(Type *ElementType, uint64_t NumElements); // TODO: add missing functions static bool classof(const Type *From) { return isa(From->LLVMTy); @@ -312,7 +313,7 @@ class ArrayType : public Type { class StructType : public Type { public: /// This static method is the primary way to create a literal StructType. - static StructType *get(Context &Ctx, ArrayRef Elements, + LLVM_ABI static StructType *get(Context &Ctx, ArrayRef Elements, bool IsPacked = false); bool isPacked() const { return cast(LLVMTy)->isPacked(); } @@ -325,13 +326,13 @@ class StructType : public Type { class VectorType : public Type { public: - 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) { return VectorType::get(ElementType, ElementCount::get(NumElements, Scalable)); } - Type *getElementType() const; + LLVM_ABI Type *getElementType() const; static VectorType *get(Type *ElementType, const VectorType *Other) { return VectorType::get(ElementType, Other->getElementCount()); @@ -340,13 +341,13 @@ class VectorType : public Type { inline ElementCount getElementCount() const { return cast(LLVMTy)->getElementCount(); } - static VectorType *getInteger(VectorType *VTy); - static VectorType *getExtendedElementVectorType(VectorType *VTy); - static VectorType *getTruncatedElementVectorType(VectorType *VTy); - static VectorType *getSubdividedVectorType(VectorType *VTy, int NumSubdivs); - static VectorType *getHalfElementsVectorType(VectorType *VTy); - static VectorType *getDoubleElementsVectorType(VectorType *VTy); - static bool isValidElementType(Type *ElemTy); + LLVM_ABI static VectorType *getInteger(VectorType *VTy); + LLVM_ABI static VectorType *getExtendedElementVectorType(VectorType *VTy); + LLVM_ABI static VectorType *getTruncatedElementVectorType(VectorType *VTy); + LLVM_ABI static VectorType *getSubdividedVectorType(VectorType *VTy, int NumSubdivs); + LLVM_ABI static VectorType *getHalfElementsVectorType(VectorType *VTy); + LLVM_ABI static VectorType *getDoubleElementsVectorType(VectorType *VTy); + LLVM_ABI static bool isValidElementType(Type *ElemTy); static bool classof(const Type *From) { return isa(From->LLVMTy); @@ -355,7 +356,7 @@ class VectorType : public Type { class FixedVectorType : public VectorType { 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()); @@ -399,7 +400,7 @@ class FixedVectorType : public VectorType { class ScalableVectorType : public VectorType { 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) { @@ -462,7 +463,7 @@ class FunctionType : public Type { /// Integer representation type class IntegerType : public Type { public: - static IntegerType *get(Context &C, unsigned NumBits); + LLVM_ABI static IntegerType *get(Context &C, unsigned NumBits); // TODO: add missing functions static bool classof(const Type *From) { return isa(From->LLVMTy); diff --git a/llvm/include/llvm/SandboxIR/Use.h b/llvm/include/llvm/SandboxIR/Use.h index c4a774aa3a89e..fc26000ad24e0 100644 --- a/llvm/include/llvm/SandboxIR/Use.h +++ b/llvm/include/llvm/SandboxIR/Use.h @@ -13,6 +13,7 @@ #ifndef LLVM_SANDBOXIR_USE_H #define LLVM_SANDBOXIR_USE_H +#include "llvm/Support/Compiler.h" #include "llvm/IR/Use.h" #include "llvm/Support/raw_ostream.h" @@ -49,11 +50,11 @@ class Use { public: operator Value *() const { return get(); } - Value *get() const; - void set(Value *V); + LLVM_ABI Value *get() const; + LLVM_ABI void set(Value *V); class User *getUser() const { return Usr; } - unsigned getOperandNo() const; - void swap(Use &OtherUse); + LLVM_ABI unsigned getOperandNo() const; + LLVM_ABI void swap(Use &OtherUse); Context *getContext() const { return Ctx; } bool operator==(const Use &Other) const { assert(Ctx == Other.Ctx && "Contexts differ!"); diff --git a/llvm/include/llvm/SandboxIR/User.h b/llvm/include/llvm/SandboxIR/User.h index 80e672de34905..36498167dbc59 100644 --- a/llvm/include/llvm/SandboxIR/User.h +++ b/llvm/include/llvm/SandboxIR/User.h @@ -9,6 +9,7 @@ #ifndef LLVM_SANDBOXIR_USER_H #define LLVM_SANDBOXIR_USER_H +#include "llvm/Support/Compiler.h" #include "llvm/IR/User.h" #include "llvm/IR/Value.h" #include "llvm/SandboxIR/Use.h" @@ -36,8 +37,8 @@ class OperandUseIterator { using iterator_category = std::input_iterator_tag; OperandUseIterator() = default; - value_type operator*() const; - OperandUseIterator &operator++(); + LLVM_ABI value_type operator*() const; + LLVM_ABI OperandUseIterator &operator++(); OperandUseIterator operator++(int) { auto Copy = *this; this->operator++(); @@ -49,13 +50,13 @@ class OperandUseIterator { bool operator!=(const OperandUseIterator &Other) const { return !(*this == Other); } - OperandUseIterator operator+(unsigned Num) const; - OperandUseIterator operator-(unsigned Num) const; - int operator-(const OperandUseIterator &Other) const; + LLVM_ABI OperandUseIterator operator+(unsigned Num) const; + LLVM_ABI OperandUseIterator operator-(unsigned Num) const; + LLVM_ABI int operator-(const OperandUseIterator &Other) const; }; /// A sandboxir::User has operands. -class User : public Value { +class LLVM_ABI User : public Value { protected: User(ClassID ID, llvm::Value *V, Context &Ctx) : Value(ID, V, Ctx) {} diff --git a/llvm/include/llvm/SandboxIR/Value.h b/llvm/include/llvm/SandboxIR/Value.h index dbd0208b4f3f3..10fe0db44df67 100644 --- a/llvm/include/llvm/SandboxIR/Value.h +++ b/llvm/include/llvm/SandboxIR/Value.h @@ -9,6 +9,7 @@ #ifndef LLVM_SANDBOXIR_VALUE_H #define LLVM_SANDBOXIR_VALUE_H +#include "llvm/Support/Compiler.h" #include "llvm/IR/Metadata.h" #include "llvm/IR/Value.h" #include "llvm/SandboxIR/Use.h" @@ -50,7 +51,7 @@ class UserUseIterator { UserUseIterator() = default; value_type operator*() const { return Use; } - UserUseIterator &operator++(); + LLVM_ABI UserUseIterator &operator++(); bool operator==(const UserUseIterator &Other) const { return Use == Other.Use; } @@ -179,7 +180,7 @@ class Value { void clearValue() { Val = nullptr; } template friend class LLVMOpUserItToSBTy; - Value(ClassID SubclassID, llvm::Value *Val, Context &Ctx); + LLVM_ABI Value(ClassID SubclassID, llvm::Value *Val, Context &Ctx); /// Disable copies. Value(const Value &) = delete; Value &operator=(const Value &) = delete; @@ -191,7 +192,7 @@ class Value { using use_iterator = UserUseIterator; using const_use_iterator = UserUseIterator; - use_iterator use_begin(); + LLVM_ABI use_iterator use_begin(); const_use_iterator use_begin() const { return const_cast(this)->use_begin(); } @@ -215,7 +216,7 @@ class Value { using user_iterator = mapped_iterator; using const_user_iterator = user_iterator; - user_iterator user_begin(); + LLVM_ABI user_iterator user_begin(); user_iterator user_end() { return user_iterator(Use(nullptr, nullptr, Ctx), UseToUser()); } @@ -234,7 +235,7 @@ class Value { } /// \Returns the number of user edges (not necessarily to unique users). /// WARNING: This is a linear-time operation. - unsigned getNumUses() const; + LLVM_ABI unsigned getNumUses() const; /// Return true if this value has N uses or more. /// This is logically equivalent to getNumUses() >= N. /// WARNING: This can be expensive, as it is linear to the number of users. @@ -256,13 +257,13 @@ class Value { return Cnt == Num; } - Type *getType() const; + LLVM_ABI Type *getType() const; Context &getContext() const { return Ctx; } - void replaceUsesWithIf(Value *OtherV, + LLVM_ABI void replaceUsesWithIf(Value *OtherV, llvm::function_ref ShouldReplace); - void replaceAllUsesWith(Value *Other); + LLVM_ABI void replaceAllUsesWith(Value *Other); /// \Returns the LLVM IR name of the bottom-most LLVM value. StringRef getName() const { return Val->getName(); } From bf5cff084116e1bd00edf10dc6fbfa5737bad534 Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Wed, 4 Jun 2025 14:48:28 -0700 Subject: [PATCH 2/3] [llvm] manual fix-ups to IDS codemod of SandboxIR library --- llvm/include/llvm/SandboxIR/Constant.h | 29 +++++++++----------------- llvm/include/llvm/SandboxIR/Tracker.h | 1 + llvm/lib/SandboxIR/Constant.cpp | 29 ++++---------------------- 3 files changed, 15 insertions(+), 44 deletions(-) diff --git a/llvm/include/llvm/SandboxIR/Constant.h b/llvm/include/llvm/SandboxIR/Constant.h index 1ce12ba969e8d..3bc1f29a1aaad 100644 --- a/llvm/include/llvm/SandboxIR/Constant.h +++ b/llvm/include/llvm/SandboxIR/Constant.h @@ -1031,7 +1031,7 @@ class GlobalWithNodeAPI : public ParentT { struct LLVMGVToGV { Context &Ctx; LLVMGVToGV(Context &Ctx) : Ctx(Ctx) {} - GlobalT &operator()(LLVMGlobalT &LLVMGV) const; + LLVM_ABI GlobalT &operator()(LLVMGlobalT &LLVMGV) const; }; public: @@ -1060,24 +1060,15 @@ class GlobalWithNodeAPI : public ParentT { } }; -// These are needed for SandboxIRTest when building with LLVM_BUILD_LLVM_DYLIB -extern template LLVM_TEMPLATE_ABI GlobalIFunc & -GlobalWithNodeAPI::LLVMGVToGV::operator()(llvm::GlobalIFunc - &LLVMGV) - const; -extern template LLVM_TEMPLATE_ABI Function & -GlobalWithNodeAPI:: - LLVMGVToGV::operator()(llvm::Function &LLVMGV) const; - -extern template LLVM_TEMPLATE_ABI GlobalVariable &GlobalWithNodeAPI< - GlobalVariable, llvm::GlobalVariable, GlobalObject, - llvm::GlobalObject>::LLVMGVToGV::operator()(llvm::GlobalVariable &LLVMGV) - const; -extern template LLVM_TEMPLATE_ABI GlobalAlias & -GlobalWithNodeAPI::LLVMGVToGV::operator()(llvm::GlobalAlias - &LLVMGV) const; +// Explicit instantiations. +extern template class LLVM_TEMPLATE_ABI GlobalWithNodeAPI; +extern template class LLVM_TEMPLATE_ABI GlobalWithNodeAPI; +extern template class LLVM_TEMPLATE_ABI GlobalWithNodeAPI; +extern template class LLVM_TEMPLATE_ABI GlobalWithNodeAPI; class GlobalIFunc final : public GlobalWithNodeAPI diff --git a/llvm/lib/SandboxIR/Constant.cpp b/llvm/lib/SandboxIR/Constant.cpp index 82cf0876d5800..78e565712e60e 100644 --- a/llvm/lib/SandboxIR/Constant.cpp +++ b/llvm/lib/SandboxIR/Constant.cpp @@ -305,36 +305,15 @@ GlobalT &GlobalWithNodeAPI:: } // Explicit instantiations. -template class GlobalWithNodeAPI; -template class GlobalWithNodeAPI; -template class GlobalWithNodeAPI; -template class GlobalWithNodeAPI; -#if defined(_MSC_VER) && !defined(__clang__) -// These are needed for SandboxIRTest when building with LLVM_BUILD_LLVM_DYLIB -template LLVM_EXPORT_TEMPLATE GlobalIFunc & -GlobalWithNodeAPI::LLVMGVToGV::operator()(llvm::GlobalIFunc - &LLVMGV) - const; -template LLVM_EXPORT_TEMPLATE Function & -GlobalWithNodeAPI:: - LLVMGVToGV::operator()(llvm::Function &LLVMGV) const; - -template LLVM_EXPORT_TEMPLATE GlobalVariable &GlobalWithNodeAPI< - GlobalVariable, llvm::GlobalVariable, GlobalObject, - llvm::GlobalObject>::LLVMGVToGV::operator()(llvm::GlobalVariable &LLVMGV) - const; -template LLVM_EXPORT_TEMPLATE GlobalAlias & -GlobalWithNodeAPI::LLVMGVToGV::operator()(llvm::GlobalAlias - &LLVMGV) const; -#endif - void GlobalIFunc::setResolver(Constant *Resolver) { Ctx.getTracker() .emplaceIfTracking< From 106cff79084ccf6c69b3c0da965eb4dbe06b46b6 Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Wed, 4 Jun 2025 14:48:48 -0700 Subject: [PATCH 3/3] [llvm] clang-format changes to SandboxIR library --- llvm/include/llvm/SandboxIR/BasicBlock.h | 2 +- llvm/include/llvm/SandboxIR/Constant.h | 34 ++-- llvm/include/llvm/SandboxIR/Context.h | 26 ++- llvm/include/llvm/SandboxIR/Function.h | 2 +- llvm/include/llvm/SandboxIR/Instruction.h | 192 ++++++++++++---------- llvm/include/llvm/SandboxIR/Module.h | 5 +- llvm/include/llvm/SandboxIR/PassManager.h | 3 +- llvm/include/llvm/SandboxIR/Tracker.h | 2 +- llvm/include/llvm/SandboxIR/Type.h | 10 +- llvm/include/llvm/SandboxIR/Use.h | 2 +- llvm/include/llvm/SandboxIR/User.h | 2 +- llvm/include/llvm/SandboxIR/Value.h | 7 +- llvm/lib/SandboxIR/Constant.cpp | 16 +- 13 files changed, 167 insertions(+), 136 deletions(-) diff --git a/llvm/include/llvm/SandboxIR/BasicBlock.h b/llvm/include/llvm/SandboxIR/BasicBlock.h index 6c096bb0a153d..25bbb6c058faa 100644 --- a/llvm/include/llvm/SandboxIR/BasicBlock.h +++ b/llvm/include/llvm/SandboxIR/BasicBlock.h @@ -9,9 +9,9 @@ #ifndef LLVM_SANDBOXIR_BASICBLOCK_H #define LLVM_SANDBOXIR_BASICBLOCK_H -#include "llvm/Support/Compiler.h" #include "llvm/IR/BasicBlock.h" #include "llvm/SandboxIR/Value.h" +#include "llvm/Support/Compiler.h" namespace llvm::sandboxir { diff --git a/llvm/include/llvm/SandboxIR/Constant.h b/llvm/include/llvm/SandboxIR/Constant.h index 3bc1f29a1aaad..6f682a7059d10 100644 --- a/llvm/include/llvm/SandboxIR/Constant.h +++ b/llvm/include/llvm/SandboxIR/Constant.h @@ -93,7 +93,8 @@ class ConstantInt : public Constant { /// be interpreted as a 64-bit signed integer and sign-extended to fit /// the type. /// Get a ConstantInt for a specific value. - LLVM_ABI 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 @@ -109,7 +110,8 @@ class ConstantInt : public Constant { /// Return a ConstantInt constructed from the string strStart with the given /// radix. - LLVM_ABI 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. @@ -275,11 +277,11 @@ class ConstantFP final : public Constant { LLVM_ABI static ConstantFP *get(const APFloat &V, Context &Ctx); LLVM_ABI static Constant *getNaN(Type *Ty, bool Negative = false, - uint64_t Payload = 0); + uint64_t Payload = 0); LLVM_ABI static Constant *getQNaN(Type *Ty, bool Negative = false, - APInt *Payload = nullptr); + APInt *Payload = nullptr); LLVM_ABI static Constant *getSNaN(Type *Ty, bool Negative = false, - APInt *Payload = nullptr); + APInt *Payload = nullptr); LLVM_ABI static Constant *getZero(Type *Ty, bool Negative = false); LLVM_ABI static Constant *getNegativeZero(Type *Ty); @@ -396,8 +398,8 @@ class ConstantStruct final : public ConstantAggregate { return get(getTypeForElements(Ctx, V, Packed), V); } /// This version of the method allows an empty list. - LLVM_ABI static StructType *getTypeForElements(Context &Ctx, ArrayRef V, - bool Packed = false); + LLVM_ABI static StructType * + getTypeForElements(Context &Ctx, ArrayRef V, bool Packed = false); /// 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 V, @@ -1061,14 +1063,14 @@ class GlobalWithNodeAPI : public ParentT { }; // Explicit instantiations. -extern template class LLVM_TEMPLATE_ABI GlobalWithNodeAPI; -extern template class LLVM_TEMPLATE_ABI GlobalWithNodeAPI; -extern template class LLVM_TEMPLATE_ABI GlobalWithNodeAPI; -extern template class LLVM_TEMPLATE_ABI GlobalWithNodeAPI; +extern template class LLVM_TEMPLATE_ABI GlobalWithNodeAPI< + GlobalIFunc, llvm::GlobalIFunc, GlobalObject, llvm::GlobalObject>; +extern template class LLVM_TEMPLATE_ABI GlobalWithNodeAPI< + Function, llvm::Function, GlobalObject, llvm::GlobalObject>; +extern template class LLVM_TEMPLATE_ABI GlobalWithNodeAPI< + GlobalVariable, llvm::GlobalVariable, GlobalObject, llvm::GlobalObject>; +extern template class LLVM_TEMPLATE_ABI GlobalWithNodeAPI< + GlobalAlias, llvm::GlobalAlias, GlobalValue, llvm::GlobalValue>; class GlobalIFunc final : public GlobalWithNodeAPI @@ -123,7 +123,8 @@ class Context { friend class EraseFromParent; // For registerValue(). /// This is the actual function that creates sandboxir values for \p V, /// and among others handles all instruction types. - LLVM_ABI Value *getOrCreateValueInternal(llvm::Value *V, llvm::User *U = nullptr); + LLVM_ABI Value *getOrCreateValueInternal(llvm::Value *V, + llvm::User *U = nullptr); /// Get or create a sandboxir::Argument for an existing LLVM IR \p LLVMArg. LLVM_ABI Argument *getOrCreateArgument(llvm::Argument *LLVMArg); /// Get or create a sandboxir::Value for an existing LLVM IR \p LLVMV. @@ -163,13 +164,17 @@ class Context { friend FenceInst; // For createFenceInst() LLVM_ABI SelectInst *createSelectInst(llvm::SelectInst *SI); friend SelectInst; // For createSelectInst() - LLVM_ABI InsertElementInst *createInsertElementInst(llvm::InsertElementInst *IEI); + LLVM_ABI InsertElementInst * + createInsertElementInst(llvm::InsertElementInst *IEI); friend InsertElementInst; // For createInsertElementInst() - LLVM_ABI ExtractElementInst *createExtractElementInst(llvm::ExtractElementInst *EEI); + LLVM_ABI ExtractElementInst * + createExtractElementInst(llvm::ExtractElementInst *EEI); friend ExtractElementInst; // For createExtractElementInst() - LLVM_ABI ShuffleVectorInst *createShuffleVectorInst(llvm::ShuffleVectorInst *SVI); + LLVM_ABI ShuffleVectorInst * + createShuffleVectorInst(llvm::ShuffleVectorInst *SVI); friend ShuffleVectorInst; // For createShuffleVectorInst() - LLVM_ABI ExtractValueInst *createExtractValueInst(llvm::ExtractValueInst *IVI); + LLVM_ABI ExtractValueInst * + createExtractValueInst(llvm::ExtractValueInst *IVI); friend ExtractValueInst; // For createExtractValueInst() LLVM_ABI InsertValueInst *createInsertValueInst(llvm::InsertValueInst *IVI); friend InsertValueInst; // For createInsertValueInst() @@ -195,9 +200,11 @@ class Context { friend CleanupPadInst; // For createCleanupPadInst() LLVM_ABI CatchReturnInst *createCatchReturnInst(llvm::CatchReturnInst *I); friend CatchReturnInst; // For createCatchReturnInst() - LLVM_ABI CleanupReturnInst *createCleanupReturnInst(llvm::CleanupReturnInst *I); + LLVM_ABI CleanupReturnInst * + createCleanupReturnInst(llvm::CleanupReturnInst *I); friend CleanupReturnInst; // For createCleanupReturnInst() - LLVM_ABI GetElementPtrInst *createGetElementPtrInst(llvm::GetElementPtrInst *I); + LLVM_ABI GetElementPtrInst * + createGetElementPtrInst(llvm::GetElementPtrInst *I); friend GetElementPtrInst; // For createGetElementPtrInst() LLVM_ABI CatchSwitchInst *createCatchSwitchInst(llvm::CatchSwitchInst *I); friend CatchSwitchInst; // For createCatchSwitchInst() @@ -211,7 +218,8 @@ class Context { friend BinaryOperator; // For createBinaryOperator() LLVM_ABI AtomicRMWInst *createAtomicRMWInst(llvm::AtomicRMWInst *I); friend AtomicRMWInst; // For createAtomicRMWInst() - LLVM_ABI AtomicCmpXchgInst *createAtomicCmpXchgInst(llvm::AtomicCmpXchgInst *I); + LLVM_ABI AtomicCmpXchgInst * + createAtomicCmpXchgInst(llvm::AtomicCmpXchgInst *I); friend AtomicCmpXchgInst; // For createAtomicCmpXchgInst() LLVM_ABI AllocaInst *createAllocaInst(llvm::AllocaInst *I); friend AllocaInst; // For createAllocaInst() diff --git a/llvm/include/llvm/SandboxIR/Function.h b/llvm/include/llvm/SandboxIR/Function.h index 565761bfdbdce..28c69112b2b7e 100644 --- a/llvm/include/llvm/SandboxIR/Function.h +++ b/llvm/include/llvm/SandboxIR/Function.h @@ -9,9 +9,9 @@ #ifndef LLVM_SANDBOXIR_FUNCTION_H #define LLVM_SANDBOXIR_FUNCTION_H -#include "llvm/Support/Compiler.h" #include "llvm/IR/Function.h" #include "llvm/SandboxIR/Constant.h" +#include "llvm/Support/Compiler.h" namespace llvm::sandboxir { diff --git a/llvm/include/llvm/SandboxIR/Instruction.h b/llvm/include/llvm/SandboxIR/Instruction.h index 738723644c837..4e3ff19d47787 100644 --- a/llvm/include/llvm/SandboxIR/Instruction.h +++ b/llvm/include/llvm/SandboxIR/Instruction.h @@ -9,7 +9,6 @@ #ifndef LLVM_SANDBOXIR_INSTRUCTION_H #define LLVM_SANDBOXIR_INSTRUCTION_H -#include "llvm/Support/Compiler.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" @@ -17,6 +16,7 @@ #include "llvm/SandboxIR/BasicBlock.h" #include "llvm/SandboxIR/Constant.h" #include "llvm/SandboxIR/User.h" +#include "llvm/Support/Compiler.h" namespace llvm::sandboxir { @@ -416,8 +416,8 @@ class FenceInst : public SingleLLVMInstructionImpl { public: LLVM_ABI static FenceInst *create(AtomicOrdering Ordering, InsertPosition Pos, - Context &Ctx, - SyncScope::ID SSID = SyncScope::System); + Context &Ctx, + SyncScope::ID SSID = SyncScope::System); /// Returns the ordering constraint of this fence instruction. AtomicOrdering getOrdering() const { return cast(Val)->getOrdering(); @@ -445,8 +445,8 @@ class SelectInst : public SingleLLVMInstructionImpl { public: LLVM_ABI static Value *create(Value *Cond, Value *True, Value *False, - InsertPosition Pos, Context &Ctx, - const Twine &Name = ""); + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); const Value *getCondition() const { return getOperand(0); } const Value *getTrueValue() const { return getOperand(1); } @@ -482,8 +482,8 @@ class InsertElementInst final public: LLVM_ABI static Value *create(Value *Vec, Value *NewElt, Value *Idx, - InsertPosition Pos, Context &Ctx, - const Twine &Name = ""); + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::InsertElement; } @@ -504,8 +504,8 @@ class ExtractElementInst final // create*() public: - LLVM_ABI static Value *create(Value *Vec, Value *Idx, InsertPosition Pos, Context &Ctx, - const Twine &Name = ""); + LLVM_ABI static Value *create(Value *Vec, Value *Idx, InsertPosition Pos, + Context &Ctx, const Twine &Name = ""); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::ExtractElement; } @@ -529,11 +529,12 @@ class ShuffleVectorInst final friend class Context; // For accessing the constructor in create*() public: - LLVM_ABI static Value *create(Value *V1, Value *V2, Value *Mask, InsertPosition Pos, - Context &Ctx, const Twine &Name = ""); + LLVM_ABI static Value *create(Value *V1, Value *V2, Value *Mask, + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); LLVM_ABI static Value *create(Value *V1, Value *V2, ArrayRef Mask, - InsertPosition Pos, Context &Ctx, - const Twine &Name = ""); + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::ShuffleVector; } @@ -581,7 +582,7 @@ class ShuffleVectorInst final LLVM_ABI Constant *getShuffleMaskForBitcode() const; LLVM_ABI static Constant *convertShuffleMaskForBitcode(ArrayRef Mask, - Type *ResultTy); + Type *ResultTy); LLVM_ABI void setShuffleMask(ArrayRef Mask); @@ -967,8 +968,8 @@ class InsertValueInst public: LLVM_ABI static Value *create(Value *Agg, Value *Val, ArrayRef Idxs, - InsertPosition Pos, Context &Ctx, - const Twine &Name = ""); + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::InsertValue; @@ -1026,9 +1027,10 @@ class BranchInst : public SingleLLVMInstructionImpl { public: LLVM_ABI static BranchInst *create(BasicBlock *IfTrue, InsertPosition Pos, - Context &Ctx); + Context &Ctx); LLVM_ABI static BranchInst *create(BasicBlock *IfTrue, BasicBlock *IfFalse, - Value *Cond, InsertPosition Pos, Context &Ctx); + Value *Cond, InsertPosition Pos, + Context &Ctx); /// For isa/dyn_cast. LLVM_ABI static bool classof(const Value *From); bool isUnconditional() const { @@ -1110,8 +1112,9 @@ class ExtractValueInst : public UnaryInstruction { friend Context; // for ExtractValueInst() public: - LLVM_ABI static Value *create(Value *Agg, ArrayRef Idxs, InsertPosition Pos, - Context &Ctx, const Twine &Name = ""); + LLVM_ABI static Value *create(Value *Agg, ArrayRef Idxs, + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::ExtractValue; @@ -1165,7 +1168,7 @@ class VAArgInst : public UnaryInstruction { public: LLVM_ABI static VAArgInst *create(Value *List, Type *Ty, InsertPosition Pos, - Context &Ctx, const Twine &Name = ""); + Context &Ctx, const Twine &Name = ""); LLVM_ABI Value *getPointerOperand(); const Value *getPointerOperand() const { return const_cast(this)->getPointerOperand(); @@ -1185,7 +1188,7 @@ class FreezeInst : public UnaryInstruction { public: LLVM_ABI static FreezeInst *create(Value *V, InsertPosition Pos, Context &Ctx, - const Twine &Name = ""); + const Twine &Name = ""); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::Freeze; } @@ -1204,8 +1207,8 @@ class LoadInst final : public UnaryInstruction { LLVM_ABI void setVolatile(bool V); LLVM_ABI static LoadInst *create(Type *Ty, Value *Ptr, MaybeAlign Align, - InsertPosition Pos, bool IsVolatile, Context &Ctx, - const Twine &Name = ""); + InsertPosition Pos, bool IsVolatile, + Context &Ctx, const Twine &Name = ""); static LoadInst *create(Type *Ty, Value *Ptr, MaybeAlign Align, InsertPosition Pos, Context &Ctx, const Twine &Name = "") { @@ -1233,7 +1236,8 @@ class StoreInst final : public SingleLLVMInstructionImpl { LLVM_ABI void setVolatile(bool V); LLVM_ABI static StoreInst *create(Value *V, Value *Ptr, MaybeAlign Align, - InsertPosition Pos, bool IsVolatile, Context &Ctx); + InsertPosition Pos, bool IsVolatile, + Context &Ctx); static StoreInst *create(Value *V, Value *Ptr, MaybeAlign Align, InsertPosition Pos, Context &Ctx) { return create(V, Ptr, Align, Pos, /*IsVolatile=*/false, Ctx); @@ -1281,7 +1285,8 @@ class ReturnInst final : public SingleLLVMInstructionImpl { Context &Ctx); public: - LLVM_ABI static ReturnInst *create(Value *RetVal, InsertPosition Pos, Context &Ctx); + LLVM_ABI static ReturnInst *create(Value *RetVal, InsertPosition Pos, + Context &Ctx); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::Ret; } @@ -1430,8 +1435,8 @@ class CallInst : public CallBase { public: LLVM_ABI static CallInst *create(FunctionType *FTy, Value *Func, - ArrayRef Args, InsertPosition Pos, - Context &Ctx, const Twine &NameStr = ""); + ArrayRef Args, InsertPosition Pos, + Context &Ctx, const Twine &NameStr = ""); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::Call; @@ -1448,9 +1453,10 @@ class InvokeInst final : public CallBase { public: LLVM_ABI static InvokeInst *create(FunctionType *FTy, Value *Func, - BasicBlock *IfNormal, BasicBlock *IfException, - ArrayRef Args, InsertPosition Pos, - Context &Ctx, const Twine &NameStr = ""); + BasicBlock *IfNormal, + BasicBlock *IfException, + ArrayRef Args, InsertPosition Pos, + Context &Ctx, const Twine &NameStr = ""); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::Invoke; @@ -1483,10 +1489,10 @@ class CallBrInst final : public CallBase { public: LLVM_ABI static CallBrInst *create(FunctionType *FTy, Value *Func, - BasicBlock *DefaultDest, - ArrayRef IndirectDests, - ArrayRef Args, InsertPosition Pos, - Context &Ctx, const Twine &NameStr = ""); + BasicBlock *DefaultDest, + ArrayRef IndirectDests, + ArrayRef Args, InsertPosition Pos, + Context &Ctx, const Twine &NameStr = ""); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::CallBr; } @@ -1513,9 +1519,10 @@ class LandingPadInst : public SingleLLVMInstructionImpl { friend class Context; // For constructor. public: - LLVM_ABI static LandingPadInst *create(Type *RetTy, unsigned NumReservedClauses, - InsertPosition Pos, Context &Ctx, - const Twine &Name = ""); + LLVM_ABI static LandingPadInst *create(Type *RetTy, + unsigned NumReservedClauses, + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); /// Return 'true' if this landingpad instruction is a /// cleanup. I.e., it should be run when unwinding even if its landing pad /// doesn't catch the exception. @@ -1591,8 +1598,8 @@ class CatchPadInst : public FuncletPadInst { // for now, as there is no CatchPadInst member function that can undo it. LLVM_ABI static CatchPadInst *create(Value *ParentPad, ArrayRef Args, - InsertPosition Pos, Context &Ctx, - const Twine &Name = ""); + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::CatchPad; } @@ -1604,9 +1611,10 @@ class CleanupPadInst : public FuncletPadInst { friend class Context; // For constructor. public: - LLVM_ABI static CleanupPadInst *create(Value *ParentPad, ArrayRef Args, - InsertPosition Pos, Context &Ctx, - const Twine &Name = ""); + LLVM_ABI static CleanupPadInst *create(Value *ParentPad, + ArrayRef Args, + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::CleanupPad; } @@ -1620,8 +1628,9 @@ class CatchReturnInst friend class Context; // For constructor. public: - LLVM_ABI static CatchReturnInst *create(CatchPadInst *CatchPad, BasicBlock *BB, - InsertPosition Pos, Context &Ctx); + LLVM_ABI static CatchReturnInst *create(CatchPadInst *CatchPad, + BasicBlock *BB, InsertPosition Pos, + Context &Ctx); LLVM_ABI CatchPadInst *getCatchPad() const; LLVM_ABI void setCatchPad(CatchPadInst *CatchPad); LLVM_ABI BasicBlock *getSuccessor() const; @@ -1644,8 +1653,8 @@ class CleanupReturnInst public: LLVM_ABI static CleanupReturnInst *create(CleanupPadInst *CleanupPad, - BasicBlock *UnwindBB, InsertPosition Pos, - Context &Ctx); + BasicBlock *UnwindBB, + InsertPosition Pos, Context &Ctx); bool hasUnwindDest() const { return cast(Val)->hasUnwindDest(); } @@ -1679,8 +1688,8 @@ class GetElementPtrInst final public: LLVM_ABI static Value *create(Type *Ty, Value *Ptr, ArrayRef IdxList, - InsertPosition Pos, Context &Ctx, - const Twine &NameStr = ""); + InsertPosition Pos, Context &Ctx, + const Twine &NameStr = ""); static bool classof(const Value *From) { return From->getSubclassID() == ClassID::GetElementPtr; @@ -1751,9 +1760,9 @@ class CatchSwitchInst friend class Context; // For accessing the constructor in create*() public: - LLVM_ABI static CatchSwitchInst *create(Value *ParentPad, BasicBlock *UnwindBB, - unsigned NumHandlers, InsertPosition Pos, - Context &Ctx, const Twine &Name = ""); + LLVM_ABI static CatchSwitchInst * + create(Value *ParentPad, BasicBlock *UnwindBB, unsigned NumHandlers, + InsertPosition Pos, Context &Ctx, const Twine &Name = ""); LLVM_ABI Value *getParentPad() const; LLVM_ABI void setParentPad(Value *ParentPad); @@ -1840,7 +1849,8 @@ class ResumeInst : public SingleLLVMInstructionImpl { friend class Context; // For accessing the constructor in create*() public: - LLVM_ABI static ResumeInst *create(Value *Exn, InsertPosition Pos, Context &Ctx); + LLVM_ABI static ResumeInst *create(Value *Exn, InsertPosition Pos, + Context &Ctx); LLVM_ABI Value *getValue() const; unsigned getNumSuccessors() const { return cast(Val)->getNumSuccessors(); @@ -1859,9 +1869,9 @@ class SwitchInst : public SingleLLVMInstructionImpl { static constexpr const unsigned DefaultPseudoIndex = llvm::SwitchInst::DefaultPseudoIndex; - LLVM_ABI static SwitchInst *create(Value *V, BasicBlock *Dest, unsigned NumCases, - InsertPosition Pos, Context &Ctx, - const Twine &Name = ""); + LLVM_ABI static SwitchInst *create(Value *V, BasicBlock *Dest, + unsigned NumCases, InsertPosition Pos, + Context &Ctx, const Twine &Name = ""); LLVM_ABI Value *getCondition() const; LLVM_ABI void setCondition(Value *V); @@ -1951,11 +1961,13 @@ class UnaryOperator : public UnaryInstruction { Ctx) {} friend Context; // for constructor. public: - LLVM_ABI static Value *create(Instruction::Opcode Op, Value *OpV, InsertPosition Pos, - Context &Ctx, const Twine &Name = ""); - LLVM_ABI static Value *createWithCopiedFlags(Instruction::Opcode Op, Value *OpV, - Value *CopyFrom, InsertPosition Pos, - Context &Ctx, const Twine &Name = ""); + LLVM_ABI static Value *create(Instruction::Opcode Op, Value *OpV, + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); + LLVM_ABI static Value *createWithCopiedFlags(Instruction::Opcode Op, + Value *OpV, Value *CopyFrom, + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); /// For isa/dyn_cast. static bool classof(const Value *From) { return From->getSubclassID() == ClassID::UnOp; @@ -2015,13 +2027,14 @@ class BinaryOperator : public SingleLLVMInstructionImpl { public: LLVM_ABI static Value *create(Instruction::Opcode Op, Value *LHS, Value *RHS, - InsertPosition Pos, Context &Ctx, - const Twine &Name = ""); + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); - LLVM_ABI static Value *createWithCopiedFlags(Instruction::Opcode Op, Value *LHS, - Value *RHS, Value *CopyFrom, - InsertPosition Pos, Context &Ctx, - const Twine &Name = ""); + LLVM_ABI static Value *createWithCopiedFlags(Instruction::Opcode Op, + Value *LHS, Value *RHS, + Value *CopyFrom, + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); /// For isa/dyn_cast. static bool classof(const Value *From) { return From->getSubclassID() == ClassID::BinaryOperator; @@ -2098,11 +2111,10 @@ class AtomicRMWInst : public SingleLLVMInstructionImpl { return From->getSubclassID() == ClassID::AtomicRMW; } - LLVM_ABI static AtomicRMWInst *create(BinOp Op, Value *Ptr, Value *Val, - MaybeAlign Align, AtomicOrdering Ordering, - InsertPosition Pos, Context &Ctx, - SyncScope::ID SSID = SyncScope::System, - const Twine &Name = ""); + LLVM_ABI static AtomicRMWInst * + create(BinOp Op, Value *Ptr, Value *Val, MaybeAlign Align, + AtomicOrdering Ordering, InsertPosition Pos, Context &Ctx, + SyncScope::ID SSID = SyncScope::System, const Twine &Name = ""); }; class AtomicCmpXchgInst @@ -2191,9 +2203,10 @@ class AllocaInst final : public UnaryInstruction { friend class Context; // For constructor. public: - LLVM_ABI static AllocaInst *create(Type *Ty, unsigned AddrSpace, InsertPosition Pos, - Context &Ctx, Value *ArraySize = nullptr, - const Twine &Name = ""); + LLVM_ABI static AllocaInst *create(Type *Ty, unsigned AddrSpace, + InsertPosition Pos, Context &Ctx, + Value *ArraySize = nullptr, + const Twine &Name = ""); /// Return true if there is an allocation size parameter to the allocation /// instruction that is not 1. @@ -2295,8 +2308,8 @@ class CastInst : public UnaryInstruction { public: LLVM_ABI static Value *create(Type *DestTy, Opcode Op, Value *Operand, - InsertPosition Pos, Context &Ctx, - const Twine &Name = ""); + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); /// For isa/dyn_cast. LLVM_ABI static bool classof(const Value *From); LLVM_ABI Type *getSrcTy() const; @@ -2389,8 +2402,8 @@ class PHINode final : public SingleLLVMInstructionImpl { public: LLVM_ABI static PHINode *create(Type *Ty, unsigned NumReservedValues, - InsertPosition Pos, Context &Ctx, - const Twine &Name = ""); + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); /// For isa/dyn_cast. LLVM_ABI static bool classof(const Value *From); @@ -2445,7 +2458,8 @@ class PHINode final : public SingleLLVMInstructionImpl { return cast(Val)->hasConstantOrUndefValue(); } bool isComplete() const { return cast(Val)->isComplete(); } - LLVM_ABI void replaceIncomingBlockWith(const BasicBlock *Old, BasicBlock *New); + LLVM_ABI void replaceIncomingBlockWith(const BasicBlock *Old, + BasicBlock *New); LLVM_ABI void removeIncomingValueIf(function_ref Predicate); // TODO: Implement // void copyIncomingBlocks(iterator_range BBRange, @@ -2473,18 +2487,20 @@ class CmpInst : public SingleLLVMInstructionImpl { : SingleLLVMInstructionImpl(Id, Opc, CI, Ctx) {} friend Context; // for CmpInst() LLVM_ABI static Value *createCommon(Value *Cond, Value *True, Value *False, - const Twine &Name, IRBuilder<> &Builder, - Context &Ctx); + const Twine &Name, IRBuilder<> &Builder, + Context &Ctx); public: using Predicate = llvm::CmpInst::Predicate; - LLVM_ABI static Value *create(Predicate Pred, Value *S1, Value *S2, InsertPosition Pos, - Context &Ctx, const Twine &Name = ""); - LLVM_ABI static Value *createWithCopiedFlags(Predicate Pred, Value *S1, Value *S2, - const Instruction *FlagsSource, - InsertPosition Pos, Context &Ctx, - const Twine &Name = ""); + LLVM_ABI static Value *create(Predicate Pred, Value *S1, Value *S2, + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); + LLVM_ABI static Value *createWithCopiedFlags(Predicate Pred, Value *S1, + Value *S2, + const Instruction *FlagsSource, + InsertPosition Pos, Context &Ctx, + const Twine &Name = ""); LLVM_ABI void setPredicate(Predicate P); LLVM_ABI void swapOperands(); diff --git a/llvm/include/llvm/SandboxIR/Module.h b/llvm/include/llvm/SandboxIR/Module.h index 9c76d135bb1f9..275960392211d 100644 --- a/llvm/include/llvm/SandboxIR/Module.h +++ b/llvm/include/llvm/SandboxIR/Module.h @@ -9,9 +9,9 @@ #ifndef LLVM_SANDBOXIR_MODULE_H #define LLVM_SANDBOXIR_MODULE_H -#include "llvm/Support/Compiler.h" #include "llvm/ADT/STLExtras.h" #include "llvm/IR/Module.h" +#include "llvm/Support/Compiler.h" #include namespace llvm { @@ -51,7 +51,8 @@ class Module { /// does not exist, return null. If AllowInternal is set to true, this /// function will return types that have InternalLinkage. By default, these /// types are not returned. - LLVM_ABI GlobalVariable *getGlobalVariable(StringRef Name, bool AllowInternal) const; + LLVM_ABI GlobalVariable *getGlobalVariable(StringRef Name, + bool AllowInternal) const; GlobalVariable *getGlobalVariable(StringRef Name) const { return getGlobalVariable(Name, /*AllowInternal=*/false); } diff --git a/llvm/include/llvm/SandboxIR/PassManager.h b/llvm/include/llvm/SandboxIR/PassManager.h index 11cf3df5d14be..6fccaf04b270a 100644 --- a/llvm/include/llvm/SandboxIR/PassManager.h +++ b/llvm/include/llvm/SandboxIR/PassManager.h @@ -212,7 +212,8 @@ class LLVM_ABI FunctionPassManager final bool runOnFunction(Function &F, const Analyses &A) final; }; -class LLVM_ABI RegionPassManager final : public PassManager { +class LLVM_ABI RegionPassManager final + : public PassManager { public: RegionPassManager(StringRef Name) : PassManager(Name) {} RegionPassManager(StringRef Name, StringRef Pipeline, diff --git a/llvm/include/llvm/SandboxIR/Tracker.h b/llvm/include/llvm/SandboxIR/Tracker.h index 07a49929aa7be..9a2c9dd516489 100644 --- a/llvm/include/llvm/SandboxIR/Tracker.h +++ b/llvm/include/llvm/SandboxIR/Tracker.h @@ -40,7 +40,6 @@ #ifndef LLVM_SANDBOXIR_TRACKER_H #define LLVM_SANDBOXIR_TRACKER_H -#include "llvm/Support/Compiler.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StableHashing.h" @@ -48,6 +47,7 @@ #include "llvm/IR/Instruction.h" #include "llvm/SandboxIR/Use.h" #include "llvm/SandboxIR/Value.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include diff --git a/llvm/include/llvm/SandboxIR/Type.h b/llvm/include/llvm/SandboxIR/Type.h index dfc4c0e7eae87..d9c5e6c098dad 100644 --- a/llvm/include/llvm/SandboxIR/Type.h +++ b/llvm/include/llvm/SandboxIR/Type.h @@ -13,10 +13,10 @@ #ifndef LLVM_SANDBOXIR_TYPE_H #define LLVM_SANDBOXIR_TYPE_H -#include "llvm/Support/Compiler.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Type.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" @@ -314,7 +314,7 @@ class StructType : public Type { public: /// This static method is the primary way to create a literal StructType. LLVM_ABI static StructType *get(Context &Ctx, ArrayRef Elements, - bool IsPacked = false); + bool IsPacked = false); bool isPacked() const { return cast(LLVMTy)->isPacked(); } @@ -344,7 +344,8 @@ class VectorType : public Type { LLVM_ABI static VectorType *getInteger(VectorType *VTy); LLVM_ABI static VectorType *getExtendedElementVectorType(VectorType *VTy); LLVM_ABI static VectorType *getTruncatedElementVectorType(VectorType *VTy); - LLVM_ABI static VectorType *getSubdividedVectorType(VectorType *VTy, int NumSubdivs); + LLVM_ABI static VectorType *getSubdividedVectorType(VectorType *VTy, + int NumSubdivs); LLVM_ABI static VectorType *getHalfElementsVectorType(VectorType *VTy); LLVM_ABI static VectorType *getDoubleElementsVectorType(VectorType *VTy); LLVM_ABI static bool isValidElementType(Type *ElemTy); @@ -400,7 +401,8 @@ class FixedVectorType : public VectorType { class ScalableVectorType : public VectorType { public: - LLVM_ABI static ScalableVectorType *get(Type *ElementType, unsigned MinNumElts); + LLVM_ABI static ScalableVectorType *get(Type *ElementType, + unsigned MinNumElts); static ScalableVectorType *get(Type *ElementType, const ScalableVectorType *SVTy) { diff --git a/llvm/include/llvm/SandboxIR/Use.h b/llvm/include/llvm/SandboxIR/Use.h index fc26000ad24e0..5c02c4f2b3495 100644 --- a/llvm/include/llvm/SandboxIR/Use.h +++ b/llvm/include/llvm/SandboxIR/Use.h @@ -13,8 +13,8 @@ #ifndef LLVM_SANDBOXIR_USE_H #define LLVM_SANDBOXIR_USE_H -#include "llvm/Support/Compiler.h" #include "llvm/IR/Use.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/raw_ostream.h" namespace llvm::sandboxir { diff --git a/llvm/include/llvm/SandboxIR/User.h b/llvm/include/llvm/SandboxIR/User.h index 36498167dbc59..c552e2e3378be 100644 --- a/llvm/include/llvm/SandboxIR/User.h +++ b/llvm/include/llvm/SandboxIR/User.h @@ -9,11 +9,11 @@ #ifndef LLVM_SANDBOXIR_USER_H #define LLVM_SANDBOXIR_USER_H -#include "llvm/Support/Compiler.h" #include "llvm/IR/User.h" #include "llvm/IR/Value.h" #include "llvm/SandboxIR/Use.h" #include "llvm/SandboxIR/Value.h" +#include "llvm/Support/Compiler.h" namespace llvm::sandboxir { diff --git a/llvm/include/llvm/SandboxIR/Value.h b/llvm/include/llvm/SandboxIR/Value.h index 10fe0db44df67..dd0bc76db3e37 100644 --- a/llvm/include/llvm/SandboxIR/Value.h +++ b/llvm/include/llvm/SandboxIR/Value.h @@ -9,10 +9,10 @@ #ifndef LLVM_SANDBOXIR_VALUE_H #define LLVM_SANDBOXIR_VALUE_H -#include "llvm/Support/Compiler.h" #include "llvm/IR/Metadata.h" #include "llvm/IR/Value.h" #include "llvm/SandboxIR/Use.h" +#include "llvm/Support/Compiler.h" namespace llvm::sandboxir { @@ -261,8 +261,9 @@ class Value { Context &getContext() const { return Ctx; } - LLVM_ABI void replaceUsesWithIf(Value *OtherV, - llvm::function_ref ShouldReplace); + LLVM_ABI void + replaceUsesWithIf(Value *OtherV, + llvm::function_ref ShouldReplace); LLVM_ABI void replaceAllUsesWith(Value *Other); /// \Returns the LLVM IR name of the bottom-most LLVM value. diff --git a/llvm/lib/SandboxIR/Constant.cpp b/llvm/lib/SandboxIR/Constant.cpp index 78e565712e60e..9de88ef2cf0a0 100644 --- a/llvm/lib/SandboxIR/Constant.cpp +++ b/llvm/lib/SandboxIR/Constant.cpp @@ -305,14 +305,14 @@ GlobalT &GlobalWithNodeAPI:: } // Explicit instantiations. -template class LLVM_EXPORT_TEMPLATE GlobalWithNodeAPI; -template class LLVM_EXPORT_TEMPLATE GlobalWithNodeAPI; -template class LLVM_EXPORT_TEMPLATE GlobalWithNodeAPI; -template class LLVM_EXPORT_TEMPLATE GlobalWithNodeAPI; +template class LLVM_EXPORT_TEMPLATE GlobalWithNodeAPI< + GlobalIFunc, llvm::GlobalIFunc, GlobalObject, llvm::GlobalObject>; +template class LLVM_EXPORT_TEMPLATE GlobalWithNodeAPI< + Function, llvm::Function, GlobalObject, llvm::GlobalObject>; +template class LLVM_EXPORT_TEMPLATE GlobalWithNodeAPI< + GlobalVariable, llvm::GlobalVariable, GlobalObject, llvm::GlobalObject>; +template class LLVM_EXPORT_TEMPLATE GlobalWithNodeAPI< + GlobalAlias, llvm::GlobalAlias, GlobalValue, llvm::GlobalValue>; void GlobalIFunc::setResolver(Constant *Resolver) { Ctx.getTracker()