diff options
Diffstat (limited to 'include/llvm/IR/Instructions.h')
-rw-r--r-- | include/llvm/IR/Instructions.h | 64 |
1 files changed, 27 insertions, 37 deletions
diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h index 8d8c530d2c6b..369b7db0d295 100644 --- a/include/llvm/IR/Instructions.h +++ b/include/llvm/IR/Instructions.h @@ -2226,7 +2226,7 @@ class PHINode : public Instruction { PHINode(const PHINode &PN); // allocate space for exactly zero operands void *operator new(size_t s) { - return User::operator new(s, 0); + return User::operator new(s); } explicit PHINode(Type *Ty, unsigned NumReservedValues, const Twine &NameStr = "", @@ -2234,7 +2234,7 @@ class PHINode : public Instruction { : Instruction(Ty, Instruction::PHI, nullptr, 0, InsertBefore), ReservedSpace(NumReservedValues) { setName(NameStr); - OperandList = allocHungoffUses(ReservedSpace); + allocHungoffUses(ReservedSpace); } PHINode(Type *Ty, unsigned NumReservedValues, const Twine &NameStr, @@ -2242,13 +2242,15 @@ class PHINode : public Instruction { : Instruction(Ty, Instruction::PHI, nullptr, 0, InsertAtEnd), ReservedSpace(NumReservedValues) { setName(NameStr); - OperandList = allocHungoffUses(ReservedSpace); + allocHungoffUses(ReservedSpace); } protected: // 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. - Use *allocHungoffUses(unsigned) const; + void allocHungoffUses(unsigned N) { + User::allocHungoffUses(N, /* IsPhi */ true); + } PHINode *clone_impl() const override; public: @@ -2263,7 +2265,6 @@ public: const Twine &NameStr, BasicBlock *InsertAtEnd) { return new PHINode(Ty, NumReservedValues, NameStr, InsertAtEnd); } - ~PHINode() override; /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -2349,12 +2350,12 @@ public: assert(BB && "PHI node got a null basic block!"); assert(getType() == V->getType() && "All operands to PHI node must be the same type as the PHI node!"); - if (NumOperands == ReservedSpace) + if (getNumOperands() == ReservedSpace) growOperands(); // Get more space! // Initialize some new operands. - ++NumOperands; - setIncomingValue(NumOperands - 1, V); - setIncomingBlock(NumOperands - 1, BB); + setNumHungOffUseOperands(getNumOperands() + 1); + setIncomingValue(getNumOperands() - 1, V); + setIncomingBlock(getNumOperands() - 1, BB); } /// removeIncomingValue - Remove an incoming value. This is useful if a @@ -2433,38 +2434,30 @@ private: void *operator new(size_t, unsigned) = delete; // Allocate space for exactly zero operands. void *operator new(size_t s) { - return User::operator new(s, 0); + return User::operator new(s); } void growOperands(unsigned Size); - void init(Value *PersFn, unsigned NumReservedValues, const Twine &NameStr); + 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); - explicit LandingPadInst(Type *RetTy, Value *PersonalityFn, - unsigned NumReservedValues, const Twine &NameStr, - Instruction *InsertBefore); - explicit LandingPadInst(Type *RetTy, Value *PersonalityFn, - unsigned NumReservedValues, const Twine &NameStr, - BasicBlock *InsertAtEnd); protected: LandingPadInst *clone_impl() const override; public: /// 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, Value *PersonalityFn, - unsigned NumReservedClauses, + static LandingPadInst *Create(Type *RetTy, unsigned NumReservedClauses, const Twine &NameStr = "", Instruction *InsertBefore = nullptr); - static LandingPadInst *Create(Type *RetTy, Value *PersonalityFn, - unsigned NumReservedClauses, + static LandingPadInst *Create(Type *RetTy, unsigned NumReservedClauses, const Twine &NameStr, BasicBlock *InsertAtEnd); - ~LandingPadInst() override; /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); - /// getPersonalityFn - Get the personality function associated with this - /// landing pad. - Value *getPersonalityFn() const { return getOperand(0); } - /// isCleanup - 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. @@ -2482,21 +2475,21 @@ public: /// 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 { - return cast<Constant>(OperandList[Idx + 1]); + return cast<Constant>(getOperandList()[Idx]); } /// isCatch - Return 'true' if the clause and index Idx is a catch clause. bool isCatch(unsigned Idx) const { - return !isa<ArrayType>(OperandList[Idx + 1]->getType()); + return !isa<ArrayType>(getOperandList()[Idx]->getType()); } /// isFilter - Return 'true' if the clause and index Idx is a filter clause. bool isFilter(unsigned Idx) const { - return isa<ArrayType>(OperandList[Idx + 1]->getType()); + return isa<ArrayType>(getOperandList()[Idx]->getType()); } /// getNumClauses - Get the number of clauses for this landing pad. - unsigned getNumClauses() const { return getNumOperands() - 1; } + unsigned getNumClauses() const { return getNumOperands(); } /// reserveClauses - Grow the size of the operand list to accommodate the new /// number of clauses. @@ -2512,7 +2505,7 @@ public: }; template <> -struct OperandTraits<LandingPadInst> : public HungoffOperandTraits<2> { +struct OperandTraits<LandingPadInst> : public HungoffOperandTraits<1> { }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(LandingPadInst, Value) @@ -2708,7 +2701,7 @@ class SwitchInst : public TerminatorInst { void growOperands(); // allocate space for exactly zero operands void *operator new(size_t s) { - return User::operator new(s, 0); + return User::operator new(s); } /// SwitchInst ctor - Create a new switch instruction, specifying a value to /// switch on and a default destination. The number of additional cases can @@ -2855,8 +2848,6 @@ public: return new SwitchInst(Value, Default, NumCases, InsertAtEnd); } - ~SwitchInst() override; - /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -3017,7 +3008,7 @@ class IndirectBrInst : public TerminatorInst { void growOperands(); // allocate space for exactly zero operands void *operator new(size_t s) { - return User::operator new(s, 0); + return User::operator new(s); } /// IndirectBrInst ctor - Create a new indirectbr instruction, specifying an /// Address to jump to. The number of expected destinations can be specified @@ -3041,7 +3032,6 @@ public: BasicBlock *InsertAtEnd) { return new IndirectBrInst(Address, NumDests, InsertAtEnd); } - ~IndirectBrInst() override; /// Provide fast operand accessors. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -3993,6 +3983,6 @@ public: } }; -} // End llvm namespace +} // namespace llvm #endif |