From: Eugene Zelenko Date: Mon, 5 Dec 2016 21:55:02 +0000 (+0000) Subject: [IR] Fix some Clang-tidy modernize-use-equals-delete and Include What You Use warning... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=721806c5ce70eb9903cc195acee2c897fee13016;p=platform%2Fupstream%2Fllvm.git [IR] Fix some Clang-tidy modernize-use-equals-delete and Include What You Use warnings; other minor fixes (NFC). Also remove obsolete comment from CommandLine.h spotted by Malcolm Parsons. llvm-svn: 288714 --- diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h index 8892d3c..05e9915 100644 --- a/llvm/include/llvm/IR/DerivedTypes.h +++ b/llvm/include/llvm/IR/DerivedTypes.h @@ -18,17 +18,19 @@ #ifndef LLVM_IR_DERIVEDTYPES_H #define LLVM_IR_DERIVEDTYPES_H +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringRef.h" #include "llvm/IR/Type.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" -#include "llvm/Support/DataTypes.h" +#include +#include namespace llvm { class Value; class APInt; class LLVMContext; -template class ArrayRef; -class StringRef; /// Class to represent integer types. Note that this class is also used to /// represent the built-in integer types: Int1Ty, Int8Ty, Int16Ty, Int32Ty and @@ -98,11 +100,12 @@ unsigned Type::getIntegerBitWidth() const { /// Class to represent function types /// class FunctionType : public Type { - FunctionType(const FunctionType &) = delete; - const FunctionType &operator=(const FunctionType &) = delete; FunctionType(Type *Result, ArrayRef Params, bool IsVarArgs); public: + FunctionType(const FunctionType &) = delete; + FunctionType &operator=(const FunctionType &) = delete; + /// This static method is the primary way of constructing a FunctionType. static FunctionType *get(Type *Result, ArrayRef Params, bool isVarArg); @@ -194,10 +197,9 @@ public: /// generator for a target expects). /// class StructType : public CompositeType { - StructType(const StructType &) = delete; - const StructType &operator=(const StructType &) = delete; StructType(LLVMContext &C) : CompositeType(C, StructTyID), SymbolTableEntry(nullptr) {} + enum { /// This is the contents of the SubClassData field. SCDB_HasBody = 1, @@ -213,6 +215,9 @@ class StructType : public CompositeType { void *SymbolTableEntry; public: + StructType(const StructType &) = delete; + StructType &operator=(const StructType &) = delete; + /// This creates an identified struct. static StructType *create(LLVMContext &Context, StringRef Name); static StructType *create(LLVMContext &Context); @@ -314,8 +319,6 @@ Type *Type::getStructElementType(unsigned N) const { class SequentialType : public CompositeType { Type *ContainedType; ///< Storage for the single contained type. uint64_t NumElements; - SequentialType(const SequentialType &) = delete; - const SequentialType &operator=(const SequentialType &) = delete; protected: SequentialType(TypeID TID, Type *ElType, uint64_t NumElements) @@ -326,6 +329,9 @@ protected: } public: + SequentialType(const SequentialType &) = delete; + SequentialType &operator=(const SequentialType &) = delete; + uint64_t getNumElements() const { return NumElements; } Type *getElementType() const { return ContainedType; } @@ -337,11 +343,12 @@ public: /// Class to represent array types. class ArrayType : public SequentialType { - ArrayType(const ArrayType &) = delete; - const ArrayType &operator=(const ArrayType &) = delete; ArrayType(Type *ElType, uint64_t NumEl); public: + ArrayType(const ArrayType &) = delete; + ArrayType &operator=(const ArrayType &) = delete; + /// This static method is the primary way to construct an ArrayType static ArrayType *get(Type *ElementType, uint64_t NumElements); @@ -360,11 +367,12 @@ uint64_t Type::getArrayNumElements() const { /// Class to represent vector types. class VectorType : public SequentialType { - VectorType(const VectorType &) = delete; - const VectorType &operator=(const VectorType &) = delete; VectorType(Type *ElType, unsigned NumEl); public: + VectorType(const VectorType &) = delete; + VectorType &operator=(const VectorType &) = delete; + /// This static method is the primary way to construct an VectorType. static VectorType *get(Type *ElementType, unsigned NumElements); @@ -433,13 +441,14 @@ unsigned Type::getVectorNumElements() const { /// Class to represent pointers. class PointerType : public Type { - PointerType(const PointerType &) = delete; - const PointerType &operator=(const PointerType &) = delete; explicit PointerType(Type *ElType, unsigned AddrSpace); Type *PointeeTy; public: + PointerType(const PointerType &) = delete; + PointerType &operator=(const PointerType &) = delete; + /// This constructs a pointer to an object of the specified type in a numbered /// address space. static PointerType *get(Type *ElementType, unsigned AddressSpace); @@ -471,6 +480,6 @@ unsigned Type::getPointerAddressSpace() const { return cast(getScalarType())->getAddressSpace(); } -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_IR_DERIVEDTYPES_H diff --git a/llvm/include/llvm/IR/GlobalAlias.h b/llvm/include/llvm/IR/GlobalAlias.h index 3727c10..37a291d 100644 --- a/llvm/include/llvm/IR/GlobalAlias.h +++ b/llvm/include/llvm/IR/GlobalAlias.h @@ -17,6 +17,7 @@ #include "llvm/ADT/ilist_node.h" #include "llvm/IR/GlobalIndirectSymbol.h" +#include "llvm/IR/Value.h" namespace llvm { @@ -27,13 +28,14 @@ template class SymbolTableListTraits; class GlobalAlias : public GlobalIndirectSymbol, public ilist_node { friend class SymbolTableListTraits; - void operator=(const GlobalAlias &) = delete; - GlobalAlias(const GlobalAlias &) = delete; GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Aliasee, Module *Parent); public: + GlobalAlias(const GlobalAlias &) = delete; + GlobalAlias &operator=(const GlobalAlias &) = delete; + /// If a parent module is specified, the alias is automatically inserted into /// the end of the specified module's alias list. static GlobalAlias *create(Type *Ty, unsigned AddressSpace, @@ -87,6 +89,6 @@ public: } }; -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_IR_GLOBALALIAS_H diff --git a/llvm/include/llvm/IR/GlobalIFunc.h b/llvm/include/llvm/IR/GlobalIFunc.h index afe6b3d..bfaa996 100644 --- a/llvm/include/llvm/IR/GlobalIFunc.h +++ b/llvm/include/llvm/IR/GlobalIFunc.h @@ -20,6 +20,7 @@ #include "llvm/ADT/ilist_node.h" #include "llvm/IR/GlobalIndirectSymbol.h" +#include "llvm/IR/Value.h" namespace llvm { @@ -32,13 +33,14 @@ template class SymbolTableListTraits; class GlobalIFunc final : public GlobalIndirectSymbol, public ilist_node { friend class SymbolTableListTraits; - void operator=(const GlobalIFunc &) = delete; - GlobalIFunc(const GlobalIFunc &) = delete; GlobalIFunc(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Resolver, Module *Parent); public: + GlobalIFunc(const GlobalIFunc &) = delete; + GlobalIFunc &operator=(const GlobalIFunc &) = delete; + /// If a parent module is specified, the ifunc is automatically inserted into /// the end of the specified module's ifunc list. static GlobalIFunc *create(Type *Ty, unsigned AddressSpace, @@ -69,6 +71,6 @@ public: } }; -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_IR_GLOBALIFUNC_H diff --git a/llvm/include/llvm/IR/GlobalIndirectSymbol.h b/llvm/include/llvm/IR/GlobalIndirectSymbol.h index 8edb3d1..671309e 100644 --- a/llvm/include/llvm/IR/GlobalIndirectSymbol.h +++ b/llvm/include/llvm/IR/GlobalIndirectSymbol.h @@ -16,20 +16,25 @@ #ifndef LLVM_IR_GLOBALINDIRECTSYMBOL_H #define LLVM_IR_GLOBALINDIRECTSYMBOL_H +#include "llvm/IR/GlobalObject.h" #include "llvm/IR/GlobalValue.h" #include "llvm/IR/OperandTraits.h" +#include "llvm/IR/User.h" +#include "llvm/IR/Value.h" +#include "llvm/Support/Casting.h" +#include namespace llvm { class GlobalIndirectSymbol : public GlobalValue { - void operator=(const GlobalIndirectSymbol &) = delete; - GlobalIndirectSymbol(const GlobalIndirectSymbol &) = delete; - protected: GlobalIndirectSymbol(Type *Ty, ValueTy VTy, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Symbol); public: + GlobalIndirectSymbol(const GlobalIndirectSymbol &) = delete; + GlobalIndirectSymbol &operator=(const GlobalIndirectSymbol &) = delete; + // allocate space for exactly one operand void *operator new(size_t s) { return User::operator new(s, 1); @@ -79,6 +84,6 @@ struct OperandTraits : DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalIndirectSymbol, Constant) -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_IR_GLOBALINDIRECTSYMBOL_H diff --git a/llvm/include/llvm/IR/GlobalObject.h b/llvm/include/llvm/IR/GlobalObject.h index 04737a0..11eb713 100644 --- a/llvm/include/llvm/IR/GlobalObject.h +++ b/llvm/include/llvm/IR/GlobalObject.h @@ -15,18 +15,19 @@ #ifndef LLVM_IR_GLOBALOBJECT_H #define LLVM_IR_GLOBALOBJECT_H -#include "llvm/IR/DerivedTypes.h" +#include "llvm/ADT/StringRef.h" #include "llvm/IR/GlobalValue.h" +#include "llvm/IR/Value.h" +#include +#include namespace llvm { + class Comdat; class MDNode; class Metadata; -class Module; class GlobalObject : public GlobalValue { - GlobalObject(const GlobalObject &) = delete; - protected: GlobalObject(Type *Ty, ValueTy VTy, Use *Ops, unsigned NumOps, LinkageTypes Linkage, const Twine &Name, @@ -53,6 +54,8 @@ private: static const unsigned GlobalObjectMask = (1 << GlobalObjectBits) - 1; public: + GlobalObject(const GlobalObject &) = delete; + unsigned getAlignment() const { unsigned Data = getGlobalValueSubClassData(); unsigned AlignmentData = Data & AlignmentMask; @@ -141,6 +144,6 @@ private: } }; -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_IR_GLOBALOBJECT_H diff --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h index c4fb836..e408bcb 100644 --- a/llvm/include/llvm/IR/Instruction.h +++ b/llvm/include/llvm/IR/Instruction.h @@ -17,23 +17,27 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ilist_node.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/StringRef.h" #include "llvm/IR/DebugLoc.h" #include "llvm/IR/SymbolTableListTraits.h" #include "llvm/IR/User.h" +#include "llvm/IR/Value.h" +#include "llvm/Support/Casting.h" +#include +#include +#include +#include namespace llvm { +class BasicBlock; class FastMathFlags; -class LLVMContext; class MDNode; -class BasicBlock; struct AAMDNodes; class Instruction : public User, public ilist_node_with_parent { - void operator=(const Instruction &) = delete; - Instruction(const Instruction &) = delete; - BasicBlock *Parent; DebugLoc DbgLoc; // 'dbg' Metadata cache. @@ -42,7 +46,11 @@ class Instruction : public User, /// this instruction has metadata attached to it or not. HasMetadataBit = 1 << 15 }; + public: + Instruction(const Instruction &) = delete; + Instruction &operator=(const Instruction &) = delete; + // Out of line virtual method, so the vtable, etc has a home. ~Instruction() override; @@ -352,12 +360,12 @@ private: SmallVectorImpl> &) const; /// Clear all hashtable-based metadata from this instruction. void clearMetadataHashEntries(); + public: //===--------------------------------------------------------------------===// // Predicates and helper methods. //===--------------------------------------------------------------------===// - /// Return true if the instruction is associative: /// /// Associative operators satisfy: x op (y op z) === (x op y) op z @@ -546,12 +554,16 @@ public: #define LAST_OTHER_INST(N) OtherOpsEnd = N+1 #include "llvm/IR/Instruction.def" }; + private: + friend class SymbolTableListTraits; + // Shadow Value::setValueSubclassData with a private forwarding method so that // subclasses cannot accidentally use it. void setValueSubclassData(unsigned short D) { Value::setValueSubclassData(D); } + unsigned short getSubclassDataFromValue() const { return Value::getSubclassDataFromValue(); } @@ -561,8 +573,8 @@ private: (V ? HasMetadataBit : 0)); } - friend class SymbolTableListTraits; void setParent(BasicBlock *P); + protected: // Instruction subclasses can stick up to 15 bits of stuff into the // SubclassData field of instruction with these members. @@ -591,14 +603,17 @@ private: template<> class PointerLikeTypeTraits { typedef Instruction* PT; + public: static inline void *getAsVoidPointer(PT P) { return P; } + static inline PT getFromVoidPointer(void *P) { return static_cast(P); } + enum { NumLowBitsAvailable = 2 }; }; -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_IR_INSTRUCTION_H diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h index 19ca4e4..a5d78a0 100644 --- a/llvm/include/llvm/IR/Instructions.h +++ b/llvm/include/llvm/IR/Instructions.h @@ -17,23 +17,33 @@ #define LLVM_IR_INSTRUCTIONS_H #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/ADT/None.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/iterator_range.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Twine.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/CallingConv.h" +#include "llvm/IR/Constant.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Function.h" #include "llvm/IR/InstrTypes.h" +#include "llvm/IR/OperandTraits.h" +#include "llvm/IR/Type.h" +#include "llvm/IR/Use.h" +#include "llvm/IR/User.h" #include "llvm/Support/AtomicOrdering.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/ErrorHandling.h" -#include +#include +#include +#include namespace llvm { class APInt; class ConstantInt; -class ConstantRange; class DataLayout; class LLVMContext; @@ -53,6 +63,7 @@ class AllocaInst : public UnaryInstruction { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + AllocaInst *cloneImpl() const; public: @@ -156,6 +167,7 @@ class LoadInst : public UnaryInstruction { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + LoadInst *cloneImpl() const; public: @@ -190,7 +202,6 @@ public: unsigned Align, AtomicOrdering Order, SynchronizationScope SynchScope, BasicBlock *InsertAtEnd); - LoadInst(Value *Ptr, const char *NameStr, Instruction *InsertBefore); LoadInst(Value *Ptr, const char *NameStr, BasicBlock *InsertAtEnd); LoadInst(Type *Ty, Value *Ptr, const char *NameStr = nullptr, @@ -287,19 +298,15 @@ private: /// An instruction for storing to memory. class StoreInst : public Instruction { - void *operator new(size_t, unsigned) = delete; void AssertOK(); protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + StoreInst *cloneImpl() const; public: - // allocate space for exactly two operands - void *operator new(size_t s) { - return User::operator new(s, 2); - } StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore); StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd); StoreInst(Value *Val, Value *Ptr, bool isVolatile = false, @@ -318,6 +325,13 @@ public: SynchronizationScope SynchScope, BasicBlock *InsertAtEnd); + // allocate space for exactly two operands + void *operator new(size_t s) { + return User::operator new(s, 2); + } + + void *operator new(size_t, unsigned) = delete; + /// Return true if this is a store to a volatile memory location. bool isVolatile() const { return getSubclassDataFromInstruction() & 1; } @@ -414,20 +428,15 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(StoreInst, Value) /// An instruction for ordering other memory operations. class FenceInst : public Instruction { - void *operator new(size_t, unsigned) = delete; void Init(AtomicOrdering Ordering, SynchronizationScope SynchScope); protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + FenceInst *cloneImpl() const; public: - // allocate space for exactly zero operands - void *operator new(size_t s) { - return User::operator new(s, 0); - } - // Ordering may only be Acquire, Release, AcquireRelease, or // SequentiallyConsistent. FenceInst(LLVMContext &C, AtomicOrdering Ordering, @@ -437,6 +446,13 @@ public: SynchronizationScope SynchScope, BasicBlock *InsertAtEnd); + // allocate space for exactly zero operands + void *operator new(size_t s) { + return User::operator new(s, 0); + } + + void *operator new(size_t, unsigned) = delete; + /// Returns the ordering effect of this fence. AtomicOrdering getOrdering() const { return AtomicOrdering(getSubclassDataFromInstruction() >> 1); @@ -486,7 +502,6 @@ private: /// there. Returns the value that was loaded. /// class AtomicCmpXchgInst : public Instruction { - void *operator new(size_t, unsigned) = delete; void Init(Value *Ptr, Value *Cmp, Value *NewVal, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, SynchronizationScope SynchScope); @@ -494,13 +509,10 @@ class AtomicCmpXchgInst : public Instruction { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + AtomicCmpXchgInst *cloneImpl() const; public: - // allocate space for exactly three operands - void *operator new(size_t s) { - return User::operator new(s, 3); - } AtomicCmpXchgInst(Value *Ptr, Value *Cmp, Value *NewVal, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, @@ -512,6 +524,13 @@ public: SynchronizationScope SynchScope, BasicBlock *InsertAtEnd); + // allocate space for exactly three operands + void *operator new(size_t s) { + return User::operator new(s, 3); + } + + void *operator new(size_t, unsigned) = delete; + /// Return true if this is a cmpxchg from a volatile memory /// location. /// @@ -648,11 +667,10 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(AtomicCmpXchgInst, Value) /// the old value. /// class AtomicRMWInst : public Instruction { - void *operator new(size_t, unsigned) = delete; - protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + AtomicRMWInst *cloneImpl() const; public: @@ -689,10 +707,6 @@ public: BAD_BINOP }; - // allocate space for exactly two operands - void *operator new(size_t s) { - return User::operator new(s, 2); - } AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val, AtomicOrdering Ordering, SynchronizationScope SynchScope, Instruction *InsertBefore = nullptr); @@ -700,6 +714,13 @@ public: AtomicOrdering Ordering, SynchronizationScope SynchScope, BasicBlock *InsertAtEnd); + // allocate space for exactly two operands + void *operator new(size_t s) { + return User::operator new(s, 2); + } + + void *operator new(size_t, unsigned) = delete; + BinOp getOperation() const { return static_cast(getSubclassDataFromInstruction() >> 5); } @@ -776,6 +797,7 @@ public: private: void Init(BinOp Operation, Value *Ptr, Value *Val, AtomicOrdering Ordering, SynchronizationScope SynchScope); + // Shadow Instruction::setInstructionSubclassData with a private forwarding // method so that subclasses cannot accidentally use it. void setInstructionSubclassData(unsigned short D) { @@ -828,6 +850,7 @@ class GetElementPtrInst : public Instruction { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + GetElementPtrInst *cloneImpl() const; public: @@ -846,6 +869,7 @@ public: return new (Values) GetElementPtrInst(PointeeType, Ptr, IdxList, Values, NameStr, InsertBefore); } + static GetElementPtrInst *Create(Type *PointeeType, Value *Ptr, ArrayRef IdxList, const Twine &NameStr, @@ -870,6 +894,7 @@ public: Instruction *InsertBefore = nullptr){ return CreateInBounds(nullptr, Ptr, IdxList, NameStr, InsertBefore); } + static GetElementPtrInst * CreateInBounds(Type *PointeeType, Value *Ptr, ArrayRef IdxList, const Twine &NameStr = "", @@ -879,12 +904,14 @@ public: GEP->setIsInBounds(true); return GEP; } + static GetElementPtrInst *CreateInBounds(Value *Ptr, ArrayRef IdxList, const Twine &NameStr, BasicBlock *InsertAtEnd) { return CreateInBounds(nullptr, Ptr, IdxList, NameStr, InsertAtEnd); } + static GetElementPtrInst *CreateInBounds(Type *PointeeType, Value *Ptr, ArrayRef IdxList, const Twine &NameStr, @@ -1039,6 +1066,7 @@ GetElementPtrInst::GetElementPtrInst(Type *PointeeType, Value *Ptr, cast(getType()->getScalarType())->getElementType()); init(Ptr, IdxList, NameStr); } + GetElementPtrInst::GetElementPtrInst(Type *PointeeType, Value *Ptr, ArrayRef IdxList, unsigned Values, const Twine &NameStr, @@ -1081,6 +1109,7 @@ class ICmpInst: public CmpInst { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + /// Clone an identical ICmpInst ICmpInst *cloneImpl() const; @@ -1211,6 +1240,7 @@ class FCmpInst: public CmpInst { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + /// Clone an identical FCmpInst FCmpInst *cloneImpl() const; @@ -1322,24 +1352,19 @@ public: /// class CallInst : public Instruction, public OperandBundleUser { + friend class OperandBundleUser; + AttributeSet AttributeList; ///< parameter attributes for call FunctionType *FTy; + CallInst(const CallInst &CI); - void init(Value *Func, ArrayRef Args, - ArrayRef Bundles, const Twine &NameStr) { - init(cast( - cast(Func->getType())->getElementType()), - Func, Args, Bundles, NameStr); - } - void init(FunctionType *FTy, Value *Func, ArrayRef Args, - ArrayRef Bundles, const Twine &NameStr); - void init(Value *Func, const Twine &NameStr); /// Construct a CallInst given a range of arguments. /// Construct a CallInst from a range of arguments inline CallInst(FunctionType *Ty, Value *Func, ArrayRef Args, ArrayRef Bundles, const Twine &NameStr, Instruction *InsertBefore); + inline CallInst(Value *Func, ArrayRef Args, ArrayRef Bundles, const Twine &NameStr, Instruction *InsertBefore) @@ -1359,17 +1384,30 @@ class CallInst : public Instruction, explicit CallInst(Value *F, const Twine &NameStr, Instruction *InsertBefore); + CallInst(Value *F, const Twine &NameStr, BasicBlock *InsertAtEnd); - friend class OperandBundleUser; + void init(Value *Func, ArrayRef Args, + ArrayRef Bundles, const Twine &NameStr) { + init(cast( + cast(Func->getType())->getElementType()), + Func, Args, Bundles, NameStr); + } + void init(FunctionType *FTy, Value *Func, ArrayRef Args, + ArrayRef Bundles, const Twine &NameStr); + void init(Value *Func, const Twine &NameStr); + bool hasDescriptor() const { return HasDescriptor; } protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + CallInst *cloneImpl() const; public: + ~CallInst() override; + static CallInst *Create(Value *Func, ArrayRef Args, ArrayRef Bundles = None, const Twine &NameStr = "", @@ -1378,6 +1416,7 @@ public: cast(Func->getType())->getElementType()), Func, Args, Bundles, NameStr, InsertBefore); } + static CallInst *Create(Value *Func, ArrayRef Args, const Twine &NameStr, Instruction *InsertBefore = nullptr) { @@ -1385,12 +1424,14 @@ public: cast(Func->getType())->getElementType()), Func, Args, None, NameStr, InsertBefore); } + static CallInst *Create(FunctionType *Ty, Value *Func, ArrayRef Args, const Twine &NameStr, Instruction *InsertBefore = nullptr) { return new (unsigned(Args.size() + 1)) CallInst(Ty, Func, Args, None, NameStr, InsertBefore); } + static CallInst *Create(FunctionType *Ty, Value *Func, ArrayRef Args, ArrayRef Bundles = None, const Twine &NameStr = "", @@ -1402,6 +1443,7 @@ public: return new (TotalOps, DescriptorBytes) CallInst(Ty, Func, Args, Bundles, NameStr, InsertBefore); } + static CallInst *Create(Value *Func, ArrayRef Args, ArrayRef Bundles, const Twine &NameStr, BasicBlock *InsertAtEnd) { @@ -1412,15 +1454,18 @@ public: return new (TotalOps, DescriptorBytes) CallInst(Func, Args, Bundles, NameStr, InsertAtEnd); } + static CallInst *Create(Value *Func, ArrayRef Args, const Twine &NameStr, BasicBlock *InsertAtEnd) { return new (unsigned(Args.size() + 1)) CallInst(Func, Args, None, NameStr, InsertAtEnd); } + static CallInst *Create(Value *F, const Twine &NameStr = "", Instruction *InsertBefore = nullptr) { return new(1) CallInst(F, NameStr, InsertBefore); } + static CallInst *Create(Value *F, const Twine &NameStr, BasicBlock *InsertAtEnd) { return new(1) CallInst(F, NameStr, InsertAtEnd); @@ -1475,8 +1520,6 @@ public: ArrayRef Bundles, BasicBlock *InsertAtEnd); - ~CallInst() override; - FunctionType *getFunctionType() const { return FTy; } void mutateFunctionType(FunctionType *FTy) { @@ -1490,20 +1533,25 @@ public: TailCallKind getTailCallKind() const { return TailCallKind(getSubclassDataFromInstruction() & 3); } + bool isTailCall() const { unsigned Kind = getSubclassDataFromInstruction() & 3; return Kind == TCK_Tail || Kind == TCK_MustTail; } + bool isMustTailCall() const { return (getSubclassDataFromInstruction() & 3) == TCK_MustTail; } + bool isNoTailCall() const { return (getSubclassDataFromInstruction() & 3) == TCK_NoTail; } + void setTailCall(bool isTC = true) { setInstructionSubclassData((getSubclassDataFromInstruction() & ~3) | unsigned(isTC ? TCK_Tail : TCK_None)); } + void setTailCallKind(TailCallKind TCK) { setInstructionSubclassData((getSubclassDataFromInstruction() & ~3) | unsigned(TCK)); @@ -1869,13 +1917,6 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CallInst, Value) /// This class represents the LLVM 'select' instruction. /// class SelectInst : public Instruction { - void init(Value *C, Value *S1, Value *S2) { - assert(!areInvalidOperands(C, S1, S2) && "Invalid operands for select"); - Op<0>() = C; - Op<1>() = S1; - Op<2>() = S2; - } - SelectInst(Value *C, Value *S1, Value *S2, const Twine &NameStr, Instruction *InsertBefore) : Instruction(S1->getType(), Instruction::Select, @@ -1883,6 +1924,7 @@ class SelectInst : public Instruction { init(C, S1, S2); setName(NameStr); } + SelectInst(Value *C, Value *S1, Value *S2, const Twine &NameStr, BasicBlock *InsertAtEnd) : Instruction(S1->getType(), Instruction::Select, @@ -1891,9 +1933,17 @@ class SelectInst : public Instruction { setName(NameStr); } + void init(Value *C, Value *S1, Value *S2) { + assert(!areInvalidOperands(C, S1, S2) && "Invalid operands for select"); + Op<0>() = C; + Op<1>() = S1; + Op<2>() = S2; + } + protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + SelectInst *cloneImpl() const; public: @@ -1961,6 +2011,7 @@ class VAArgInst : public UnaryInstruction { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + VAArgInst *cloneImpl() const; public: @@ -1969,6 +2020,7 @@ public: : UnaryInstruction(Ty, VAArg, List, InsertBefore) { setName(NameStr); } + VAArgInst(Value *List, Type *Ty, const Twine &NameStr, BasicBlock *InsertAtEnd) : UnaryInstruction(Ty, VAArg, List, InsertAtEnd) { @@ -2004,6 +2056,7 @@ class ExtractElementInst : public Instruction { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + ExtractElementInst *cloneImpl() const; public: @@ -2012,6 +2065,7 @@ public: Instruction *InsertBefore = nullptr) { return new(2) ExtractElementInst(Vec, Idx, NameStr, InsertBefore); } + static ExtractElementInst *Create(Value *Vec, Value *Idx, const Twine &NameStr, BasicBlock *InsertAtEnd) { @@ -2067,6 +2121,7 @@ class InsertElementInst : public Instruction { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + InsertElementInst *cloneImpl() const; public: @@ -2075,6 +2130,7 @@ public: Instruction *InsertBefore = nullptr) { return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertBefore); } + static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr, BasicBlock *InsertAtEnd) { @@ -2122,19 +2178,21 @@ class ShuffleVectorInst : public Instruction { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + ShuffleVectorInst *cloneImpl() const; public: - // allocate space for exactly three operands - void *operator new(size_t s) { - return User::operator new(s, 3); - } ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, const Twine &NameStr = "", Instruction *InsertBefor = nullptr); ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, const Twine &NameStr, BasicBlock *InsertAtEnd); + // allocate space for exactly three operands + void *operator new(size_t s) { + return User::operator new(s, 3); + } + /// Return true if a shufflevector instruction can be /// formed with the specified operands. static bool isValidOperands(const Value *V1, const Value *V2, @@ -2206,8 +2264,6 @@ class ExtractValueInst : public UnaryInstruction { SmallVector Indices; ExtractValueInst(const ExtractValueInst &EVI); - void init(ArrayRef Idxs, const Twine &NameStr); - /// Constructors - Create a extractvalue instruction with a base aggregate /// value and a list of indices. The first ctor can optionally insert before /// an existing instruction, the second appends the new instruction to the @@ -2223,9 +2279,12 @@ class ExtractValueInst : public UnaryInstruction { // allocate space for exactly one operand void *operator new(size_t s) { return User::operator new(s, 1); } + void init(ArrayRef Idxs, const Twine &NameStr); + protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + ExtractValueInst *cloneImpl() const; public: @@ -2236,6 +2295,7 @@ public: return new ExtractValueInst(Agg, Idxs, NameStr, InsertBefore); } + static ExtractValueInst *Create(Value *Agg, ArrayRef Idxs, const Twine &NameStr, @@ -2295,6 +2355,7 @@ ExtractValueInst::ExtractValueInst(Value *Agg, ExtractValue, Agg, InsertBefore) { init(Idxs, NameStr); } + ExtractValueInst::ExtractValueInst(Value *Agg, ArrayRef Idxs, const Twine &NameStr, @@ -2314,10 +2375,7 @@ ExtractValueInst::ExtractValueInst(Value *Agg, class InsertValueInst : public Instruction { SmallVector Indices; - void *operator new(size_t, unsigned) = delete; InsertValueInst(const InsertValueInst &IVI); - void init(Value *Agg, Value *Val, ArrayRef Idxs, - const Twine &NameStr); /// Constructors - Create a insertvalue instruction with a base aggregate /// value, a value to insert, and a list of indices. The first ctor can @@ -2339,9 +2397,13 @@ class InsertValueInst : public Instruction { InsertValueInst(Value *Agg, Value *Val, unsigned Idx, const Twine &NameStr, BasicBlock *InsertAtEnd); + void init(Value *Agg, Value *Val, ArrayRef Idxs, + const Twine &NameStr); + protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + InsertValueInst *cloneImpl() const; public: @@ -2350,12 +2412,15 @@ public: return User::operator new(s, 2); } + void *operator new(size_t, unsigned) = delete; + static InsertValueInst *Create(Value *Agg, Value *Val, ArrayRef Idxs, const Twine &NameStr = "", Instruction *InsertBefore = nullptr) { return new InsertValueInst(Agg, Val, Idxs, NameStr, InsertBefore); } + static InsertValueInst *Create(Value *Agg, Value *Val, ArrayRef Idxs, const Twine &NameStr, @@ -2429,6 +2494,7 @@ InsertValueInst::InsertValueInst(Value *Agg, 2, InsertBefore) { init(Agg, Val, Idxs, NameStr); } + InsertValueInst::InsertValueInst(Value *Agg, Value *Val, ArrayRef Idxs, @@ -2451,17 +2517,13 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertValueInst, Value) // scientist's overactive imagination. // class PHINode : public Instruction { - void anchor() override; - - void *operator new(size_t, unsigned) = delete; /// The number of operands actually allocated. NumOperands is /// the number actually in use. unsigned ReservedSpace; + PHINode(const PHINode &PN); // allocate space for exactly zero operands - void *operator new(size_t s) { - return User::operator new(s); - } + explicit PHINode(Type *Ty, unsigned NumReservedValues, const Twine &NameStr = "", Instruction *InsertBefore = nullptr) @@ -2479,7 +2541,18 @@ class PHINode : public Instruction { allocHungoffUses(ReservedSpace); } + void *operator new(size_t s) { + return User::operator new(s); + } + + void anchor() override; + protected: + // Note: Instruction needs to be a friend here to call cloneImpl. + friend class Instruction; + + PHINode *cloneImpl() const; + // allocHungoffUses - this is more complicated than the generic // User::allocHungoffUses, because we have to allocate Uses for the incoming // values and pointers to the incoming blocks, all in one allocation. @@ -2487,11 +2560,9 @@ protected: User::allocHungoffUses(N, /* IsPhi */ true); } - // Note: Instruction needs to be a friend here to call cloneImpl. - friend class Instruction; - PHINode *cloneImpl() const; - public: + void *operator new(size_t, unsigned) = delete; + /// Constructors - NumReservedValues is a hint for the number of incoming /// edges that this phi node will have (use 0 if you really have no idea). static PHINode *Create(Type *Ty, unsigned NumReservedValues, @@ -2499,6 +2570,7 @@ public: Instruction *InsertBefore = nullptr) { return new PHINode(Ty, NumReservedValues, NameStr, InsertBefore); } + static PHINode *Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr, BasicBlock *InsertAtEnd) { return new PHINode(Ty, NumReservedValues, NameStr, InsertAtEnd); @@ -2679,31 +2751,35 @@ class LandingPadInst : public Instruction { /// The number of operands actually allocated. NumOperands is /// the number actually in use. unsigned ReservedSpace; + LandingPadInst(const LandingPadInst &LP); public: enum ClauseType { Catch, Filter }; private: - void *operator new(size_t, unsigned) = delete; + explicit LandingPadInst(Type *RetTy, unsigned NumReservedValues, + const Twine &NameStr, Instruction *InsertBefore); + explicit LandingPadInst(Type *RetTy, unsigned NumReservedValues, + const Twine &NameStr, BasicBlock *InsertAtEnd); + // Allocate space for exactly zero operands. void *operator new(size_t s) { return User::operator new(s); } + void growOperands(unsigned Size); void init(unsigned NumReservedValues, const Twine &NameStr); - explicit LandingPadInst(Type *RetTy, unsigned NumReservedValues, - const Twine &NameStr, Instruction *InsertBefore); - explicit LandingPadInst(Type *RetTy, unsigned NumReservedValues, - const Twine &NameStr, BasicBlock *InsertAtEnd); - protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + LandingPadInst *cloneImpl() const; public: + void *operator new(size_t, unsigned) = delete; + /// Constructors - NumReservedClauses is a hint for the number of incoming /// clauses that this landingpad will have (use 0 if you really have no idea). static LandingPadInst *Create(Type *RetTy, unsigned NumReservedClauses, @@ -2798,21 +2874,25 @@ private: protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + ReturnInst *cloneImpl() const; public: + ~ReturnInst() override; + static ReturnInst* Create(LLVMContext &C, Value *retVal = nullptr, Instruction *InsertBefore = nullptr) { return new(!!retVal) ReturnInst(C, retVal, InsertBefore); } + static ReturnInst* Create(LLVMContext &C, Value *retVal, BasicBlock *InsertAtEnd) { return new(!!retVal) ReturnInst(C, retVal, InsertAtEnd); } + static ReturnInst* Create(LLVMContext &C, BasicBlock *InsertAtEnd) { return new(0) ReturnInst(C, InsertAtEnd); } - ~ReturnInst() override; /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -2857,7 +2937,6 @@ class BranchInst : public TerminatorInst { /// they don't have to check for cond/uncond branchness. These are mostly /// accessed relative from op_end(). BranchInst(const BranchInst &BI); - void AssertOK(); // BranchInst constructors (where {B, T, F} are blocks, and C is a condition): // BranchInst(BB *B) - 'br B' // BranchInst(BB* T, BB *F, Value *C) - 'br C, T, F' @@ -2872,9 +2951,12 @@ class BranchInst : public TerminatorInst { BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, BasicBlock *InsertAtEnd); + void AssertOK(); + protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + BranchInst *cloneImpl() const; public: @@ -2882,13 +2964,16 @@ public: Instruction *InsertBefore = nullptr) { return new(1) BranchInst(IfTrue, InsertBefore); } + static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, Instruction *InsertBefore = nullptr) { return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertBefore); } + static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *InsertAtEnd) { return new(1) BranchInst(IfTrue, InsertAtEnd); } + static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, BasicBlock *InsertAtEnd) { return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertAtEnd); @@ -2957,19 +3042,14 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BranchInst, Value) /// Multiway switch /// class SwitchInst : public TerminatorInst { - void *operator new(size_t, unsigned) = delete; unsigned ReservedSpace; + // Operand[0] = Value to switch on // Operand[1] = Default basic block destination // Operand[2n ] = Value to match // Operand[2n+1] = BasicBlock to go to on match SwitchInst(const SwitchInst &SI); - void init(Value *Value, BasicBlock *Default, unsigned NumReserved); - void growOperands(); - // allocate space for exactly zero operands - void *operator new(size_t s) { - return User::operator new(s); - } + /// Create a new switch instruction, specifying a value to switch on and a /// default destination. The number of additional cases can be specified here /// to make memory allocation more efficient. This constructor can also @@ -2984,12 +3064,23 @@ class SwitchInst : public TerminatorInst { SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases, BasicBlock *InsertAtEnd); + // allocate space for exactly zero operands + void *operator new(size_t s) { + return User::operator new(s); + } + + void init(Value *Value, BasicBlock *Default, unsigned NumReserved); + void growOperands(); + protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + SwitchInst *cloneImpl() const; public: + void *operator new(size_t, unsigned) = delete; + // -2 static const unsigned DefaultPseudoIndex = static_cast(~0L-1); @@ -3086,7 +3177,6 @@ public: ConstCaseIt; class CaseIt : public CaseIteratorT { - typedef CaseIteratorT ParentTy; public: @@ -3110,6 +3200,7 @@ public: Instruction *InsertBefore = nullptr) { return new SwitchInst(Value, Default, NumCases, InsertBefore); } + static SwitchInst *Create(Value *Value, BasicBlock *Default, unsigned NumCases, BasicBlock *InsertAtEnd) { return new SwitchInst(Value, Default, NumCases, InsertAtEnd); @@ -3141,6 +3232,7 @@ public: CaseIt case_begin() { return CaseIt(this, 0); } + /// Returns a read-only iterator that points to the first case in the /// SwitchInst. ConstCaseIt case_begin() const { @@ -3152,6 +3244,7 @@ public: CaseIt case_end() { return CaseIt(this, getNumCases()); } + /// Returns a read-only iterator that points one past the last in the /// SwitchInst. ConstCaseIt case_end() const { @@ -3264,17 +3357,12 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SwitchInst, Value) /// Indirect Branch Instruction. /// class IndirectBrInst : public TerminatorInst { - void *operator new(size_t, unsigned) = delete; unsigned ReservedSpace; + // Operand[0] = Address to jump to // Operand[n+1] = n-th destination IndirectBrInst(const IndirectBrInst &IBI); - void init(Value *Address, unsigned NumDests); - void growOperands(); - // allocate space for exactly zero operands - void *operator new(size_t s) { - return User::operator new(s); - } + /// Create a new indirectbr instruction, specifying an /// Address to jump to. The number of expected destinations can be specified /// here to make memory allocation more efficient. This constructor can also @@ -3287,16 +3375,28 @@ class IndirectBrInst : public TerminatorInst { /// autoinserts at the end of the specified BasicBlock. IndirectBrInst(Value *Address, unsigned NumDests, BasicBlock *InsertAtEnd); + // allocate space for exactly zero operands + void *operator new(size_t s) { + return User::operator new(s); + } + + void init(Value *Address, unsigned NumDests); + void growOperands(); + protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + IndirectBrInst *cloneImpl() const; public: + void *operator new(size_t, unsigned) = delete; + static IndirectBrInst *Create(Value *Address, unsigned NumDests, Instruction *InsertBefore = nullptr) { return new IndirectBrInst(Address, NumDests, InsertBefore); } + static IndirectBrInst *Create(Value *Address, unsigned NumDests, BasicBlock *InsertAtEnd) { return new IndirectBrInst(Address, NumDests, InsertAtEnd); @@ -3363,19 +3463,12 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(IndirectBrInst, Value) /// class InvokeInst : public TerminatorInst, public OperandBundleUser { + friend class OperandBundleUser; + AttributeSet AttributeList; FunctionType *FTy; + InvokeInst(const InvokeInst &BI); - void init(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, - ArrayRef Args, ArrayRef Bundles, - const Twine &NameStr) { - init(cast( - cast(Func->getType())->getElementType()), - Func, IfNormal, IfException, Args, Bundles, NameStr); - } - void init(FunctionType *FTy, Value *Func, BasicBlock *IfNormal, - BasicBlock *IfException, ArrayRef Args, - ArrayRef Bundles, const Twine &NameStr); /// Construct an InvokeInst given a range of arguments. /// @@ -3401,12 +3494,24 @@ class InvokeInst : public TerminatorInst, unsigned Values, const Twine &NameStr, BasicBlock *InsertAtEnd); - friend class OperandBundleUser; bool hasDescriptor() const { return HasDescriptor; } + void init(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, + ArrayRef Args, ArrayRef Bundles, + const Twine &NameStr) { + init(cast( + cast(Func->getType())->getElementType()), + Func, IfNormal, IfException, Args, Bundles, NameStr); + } + + void init(FunctionType *FTy, Value *Func, BasicBlock *IfNormal, + BasicBlock *IfException, ArrayRef Args, + ArrayRef Bundles, const Twine &NameStr); + protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + InvokeInst *cloneImpl() const; public: @@ -3419,6 +3524,7 @@ public: Func, IfNormal, IfException, Args, None, NameStr, InsertBefore); } + static InvokeInst *Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef Args, ArrayRef Bundles = None, @@ -3429,6 +3535,7 @@ public: Func, IfNormal, IfException, Args, Bundles, NameStr, InsertBefore); } + static InvokeInst *Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef Args, const Twine &NameStr, @@ -3437,6 +3544,7 @@ public: return new (Values) InvokeInst(Ty, Func, IfNormal, IfException, Args, None, Values, NameStr, InsertBefore); } + static InvokeInst *Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef Args, ArrayRef Bundles = None, @@ -3449,6 +3557,7 @@ public: InvokeInst(Ty, Func, IfNormal, IfException, Args, Bundles, Values, NameStr, InsertBefore); } + static InvokeInst *Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef Args, const Twine &NameStr, @@ -3842,6 +3951,7 @@ InvokeInst::InvokeInst(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, InsertBefore) { init(Ty, Func, IfNormal, IfException, Args, Bundles, NameStr); } + InvokeInst::InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef Args, ArrayRef Bundles, unsigned Values, @@ -3872,12 +3982,14 @@ class ResumeInst : public TerminatorInst { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + ResumeInst *cloneImpl() const; public: static ResumeInst *Create(Value *Exn, Instruction *InsertBefore = nullptr) { return new(1) ResumeInst(Exn, InsertBefore); } + static ResumeInst *Create(Value *Exn, BasicBlock *InsertAtEnd) { return new(1) ResumeInst(Exn, InsertAtEnd); } @@ -3915,18 +4027,15 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ResumeInst, Value) // CatchSwitchInst Class //===----------------------------------------------------------------------===// class CatchSwitchInst : public TerminatorInst { - void *operator new(size_t, unsigned) = delete; /// The number of operands actually allocated. NumOperands is /// the number actually in use. unsigned ReservedSpace; + // Operand[0] = Outer scope // Operand[1] = Unwind block destination // Operand[n] = BasicBlock to go to on match CatchSwitchInst(const CatchSwitchInst &CSI); - void init(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumReserved); - void growOperands(unsigned Size); - // allocate space for exactly zero operands - void *operator new(size_t s) { return User::operator new(s); } + /// Create a new switch instruction, specifying a /// default destination. The number of additional handlers can be specified /// here to make memory allocation more efficient. @@ -3943,12 +4052,21 @@ class CatchSwitchInst : public TerminatorInst { unsigned NumHandlers, const Twine &NameStr, BasicBlock *InsertAtEnd); + // allocate space for exactly zero operands + void *operator new(size_t s) { return User::operator new(s); } + + void init(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumReserved); + void growOperands(unsigned Size); + protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + CatchSwitchInst *cloneImpl() const; public: + void *operator new(size_t, unsigned) = delete; + static CatchSwitchInst *Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr = "", @@ -3956,6 +4074,7 @@ public: return new CatchSwitchInst(ParentPad, UnwindDest, NumHandlers, NameStr, InsertBefore); } + static CatchSwitchInst *Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr, BasicBlock *InsertAtEnd) { @@ -4002,8 +4121,6 @@ public: typedef std::pointer_to_unary_function DerefFnTy; typedef mapped_iterator handler_iterator; typedef iterator_range handler_range; - - typedef std::pointer_to_unary_function ConstDerefFnTy; typedef mapped_iterator const_handler_iterator; @@ -4016,6 +4133,7 @@ public: ++It; return handler_iterator(It, DerefFnTy(handler_helper)); } + /// Returns an iterator that points to the first handler in the /// CatchSwitchInst. const_handler_iterator handler_begin() const { @@ -4030,6 +4148,7 @@ public: handler_iterator handler_end() { return handler_iterator(op_end(), DerefFnTy(handler_helper)); } + /// Returns an iterator that points one past the last handler in the /// CatchSwitchInst. const_handler_iterator handler_end() const { @@ -4109,6 +4228,7 @@ public: return new (Values) CleanupPadInst(ParentPad, Args, Values, NameStr, InsertBefore); } + static CleanupPadInst *Create(Value *ParentPad, ArrayRef Args, const Twine &NameStr, BasicBlock *InsertAtEnd) { unsigned Values = 1 + Args.size(); @@ -4149,6 +4269,7 @@ public: return new (Values) CatchPadInst(CatchSwitch, Args, Values, NameStr, InsertBefore); } + static CatchPadInst *Create(Value *CatchSwitch, ArrayRef Args, const Twine &NameStr, BasicBlock *InsertAtEnd) { unsigned Values = 1 + Args.size(); @@ -4180,14 +4301,15 @@ public: class CatchReturnInst : public TerminatorInst { CatchReturnInst(const CatchReturnInst &RI); - - void init(Value *CatchPad, BasicBlock *BB); CatchReturnInst(Value *CatchPad, BasicBlock *BB, Instruction *InsertBefore); CatchReturnInst(Value *CatchPad, BasicBlock *BB, BasicBlock *InsertAtEnd); + void init(Value *CatchPad, BasicBlock *BB); + protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + CatchReturnInst *cloneImpl() const; public: @@ -4197,6 +4319,7 @@ public: assert(BB); return new (2) CatchReturnInst(CatchPad, BB, InsertBefore); } + static CatchReturnInst *Create(Value *CatchPad, BasicBlock *BB, BasicBlock *InsertAtEnd) { assert(CatchPad); @@ -4254,16 +4377,17 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CatchReturnInst, Value) class CleanupReturnInst : public TerminatorInst { private: CleanupReturnInst(const CleanupReturnInst &RI); - - void init(Value *CleanupPad, BasicBlock *UnwindBB); CleanupReturnInst(Value *CleanupPad, BasicBlock *UnwindBB, unsigned Values, Instruction *InsertBefore = nullptr); CleanupReturnInst(Value *CleanupPad, BasicBlock *UnwindBB, unsigned Values, BasicBlock *InsertAtEnd); + void init(Value *CleanupPad, BasicBlock *UnwindBB); + protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + CleanupReturnInst *cloneImpl() const; public: @@ -4277,6 +4401,7 @@ public: return new (Values) CleanupReturnInst(CleanupPad, UnwindBB, Values, InsertBefore); } + static CleanupReturnInst *Create(Value *CleanupPad, BasicBlock *UnwindBB, BasicBlock *InsertAtEnd) { assert(CleanupPad); @@ -4349,20 +4474,22 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CleanupReturnInst, Value) /// end of the block cannot be reached. /// class UnreachableInst : public TerminatorInst { - void *operator new(size_t, unsigned) = delete; - protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + UnreachableInst *cloneImpl() const; public: + explicit UnreachableInst(LLVMContext &C, Instruction *InsertBefore = nullptr); + explicit UnreachableInst(LLVMContext &C, BasicBlock *InsertAtEnd); + // allocate space for exactly zero operands void *operator new(size_t s) { return User::operator new(s, 0); } - explicit UnreachableInst(LLVMContext &C, Instruction *InsertBefore = nullptr); - explicit UnreachableInst(LLVMContext &C, BasicBlock *InsertAtEnd); + + void *operator new(size_t, unsigned) = delete; unsigned getNumSuccessors() const { return 0; } @@ -4389,6 +4516,7 @@ class TruncInst : public CastInst { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + /// Clone an identical TruncInst TruncInst *cloneImpl() const; @@ -4427,6 +4555,7 @@ class ZExtInst : public CastInst { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + /// Clone an identical ZExtInst ZExtInst *cloneImpl() const; @@ -4465,6 +4594,7 @@ class SExtInst : public CastInst { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + /// Clone an identical SExtInst SExtInst *cloneImpl() const; @@ -4503,6 +4633,7 @@ class FPTruncInst : public CastInst { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + /// Clone an identical FPTruncInst FPTruncInst *cloneImpl() const; @@ -4541,6 +4672,7 @@ class FPExtInst : public CastInst { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + /// Clone an identical FPExtInst FPExtInst *cloneImpl() const; @@ -4579,6 +4711,7 @@ class UIToFPInst : public CastInst { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + /// Clone an identical UIToFPInst UIToFPInst *cloneImpl() const; @@ -4617,6 +4750,7 @@ class SIToFPInst : public CastInst { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + /// Clone an identical SIToFPInst SIToFPInst *cloneImpl() const; @@ -4655,6 +4789,7 @@ class FPToUIInst : public CastInst { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + /// Clone an identical FPToUIInst FPToUIInst *cloneImpl() const; @@ -4693,6 +4828,7 @@ class FPToSIInst : public CastInst { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + /// Clone an identical FPToSIInst FPToSIInst *cloneImpl() const; @@ -4729,6 +4865,9 @@ public: /// This class represents a cast from an integer to a pointer. class IntToPtrInst : public CastInst { public: + // Note: Instruction needs to be a friend here to call cloneImpl. + friend class Instruction; + /// Constructor with insert-before-instruction semantics IntToPtrInst( Value *S, ///< The value to be converted @@ -4745,8 +4884,6 @@ public: BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); - // Note: Instruction needs to be a friend here to call cloneImpl. - friend class Instruction; /// Clone an identical IntToPtrInst. IntToPtrInst *cloneImpl() const; @@ -4773,6 +4910,7 @@ class PtrToIntInst : public CastInst { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + /// Clone an identical PtrToIntInst. PtrToIntInst *cloneImpl() const; @@ -4823,6 +4961,7 @@ class BitCastInst : public CastInst { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + /// Clone an identical BitCastInst. BitCastInst *cloneImpl() const; @@ -4862,6 +5001,7 @@ class AddrSpaceCastInst : public CastInst { protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; + /// Clone an identical AddrSpaceCastInst. AddrSpaceCastInst *cloneImpl() const; @@ -4916,6 +5056,6 @@ public: } }; -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_IR_INSTRUCTIONS_H diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h index 515c18e..204672f 100644 --- a/llvm/include/llvm/Support/CommandLine.h +++ b/llvm/include/llvm/Support/CommandLine.h @@ -837,7 +837,6 @@ public: typedef OptionValue OptVal; protected: - // Workaround Clang PR22793 ~basic_parser() = default; };