diff options
author | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-12-09 22:46:10 +0000 |
---|---|---|
committer | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-12-09 22:46:10 +0000 |
commit | ed455c8fa25dd37a13b33f0afa66be03ac49b5bb (patch) | |
tree | 7bfa961474e22f830710a49d4ed015fe374967b7 | |
parent | 46a6e79e602b23ea3478027d5bdd1f904aea7924 (diff) |
Devirtualizing Value destructor (PR889). Patch by Pawel Kunio!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44747 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Argument.h | 5 | ||||
-rw-r--r-- | include/llvm/BasicBlock.h | 31 | ||||
-rw-r--r-- | include/llvm/Constant.h | 4 | ||||
-rw-r--r-- | include/llvm/Constants.h | 150 | ||||
-rw-r--r-- | include/llvm/Function.h | 4 | ||||
-rw-r--r-- | include/llvm/GlobalAlias.h | 5 | ||||
-rw-r--r-- | include/llvm/GlobalValue.h | 9 | ||||
-rw-r--r-- | include/llvm/GlobalVariable.h | 5 | ||||
-rw-r--r-- | include/llvm/InlineAsm.h | 7 | ||||
-rw-r--r-- | include/llvm/InstrTypes.h | 31 | ||||
-rw-r--r-- | include/llvm/Instruction.h | 6 | ||||
-rw-r--r-- | include/llvm/Instructions.h | 135 | ||||
-rw-r--r-- | include/llvm/IntrinsicInst.h | 50 | ||||
-rw-r--r-- | include/llvm/User.h | 4 | ||||
-rw-r--r-- | include/llvm/Value.h | 3 | ||||
-rw-r--r-- | lib/VMCore/BasicBlock.cpp | 38 | ||||
-rw-r--r-- | lib/VMCore/Constants.cpp | 173 | ||||
-rw-r--r-- | lib/VMCore/Function.cpp | 13 | ||||
-rw-r--r-- | lib/VMCore/InlineAsm.cpp | 6 | ||||
-rw-r--r-- | lib/VMCore/Instruction.cpp | 4 | ||||
-rw-r--r-- | lib/VMCore/Instructions.cpp | 50 | ||||
-rw-r--r-- | lib/VMCore/Value.cpp | 247 |
22 files changed, 752 insertions, 228 deletions
diff --git a/include/llvm/Argument.h b/include/llvm/Argument.h index c995043616..bb71e115fd 100644 --- a/include/llvm/Argument.h +++ b/include/llvm/Argument.h @@ -35,6 +35,11 @@ class Argument : public Value { // Defined in the Function.cpp file friend class SymbolTableListTraits<Argument, Function>; void setParent(Function *parent); +protected: + static void destroyThis(Argument*v) { + Value::destroyThis(v); + } + friend class Value; public: /// Argument ctor - If Function argument is specified, this argument is /// inserted at the end of the argument list for the function. diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h index cd38b4280c..d5a1fe1c33 100644 --- a/include/llvm/BasicBlock.h +++ b/include/llvm/BasicBlock.h @@ -65,6 +65,9 @@ private : BasicBlock(const BasicBlock &); // Do not implement void operator=(const BasicBlock &); // Do not implement +protected: + static void destroyThis(BasicBlock*); + friend class Value; public: /// Instruction iterators... typedef InstListType::iterator iterator; @@ -76,7 +79,6 @@ public: /// explicit BasicBlock(const std::string &Name = "", Function *Parent = 0, BasicBlock *InsertBefore = 0); - ~BasicBlock(); /// getParent - Return the enclosing method, or null if none /// @@ -206,6 +208,33 @@ private: const BasicBlock *getPrev() const { return Prev; } }; +/// DummyInst - An instance of this class is used to mark the end of the +/// instruction list. This is not a real instruction. +class DummyInst : public Instruction { +protected: + static void destroyThis(DummyInst* v) { + Instruction::destroyThis(v); + } + friend class Value; +public: + DummyInst(); + + Instruction *clone() const { + assert(0 && "Cannot clone EOL");abort(); + return 0; + } + const char *getOpcodeName() const { return "*end-of-list-inst*"; } + + // Methods for support type inquiry through isa, cast, and dyn_cast... + static inline bool classof(const DummyInst *) { return true; } + static inline bool classof(const Instruction *I) { + return I->getOpcode() == OtherOpsEnd; + } + static inline bool classof(const Value *V) { + return isa<Instruction>(V) && classof(cast<Instruction>(V)); + } +}; + inline int ilist_traits<Instruction>::getListOffset() { return BasicBlock::getInstListOffset(); diff --git a/include/llvm/Constant.h b/include/llvm/Constant.h index d925fdb618..e48a9c5d74 100644 --- a/include/llvm/Constant.h +++ b/include/llvm/Constant.h @@ -43,6 +43,10 @@ protected: : User(Ty, vty, Ops, NumOps) {} void destroyConstantImpl(); + static void destroyThis(Constant*v) { + User::destroyThis(v); + } + friend class Value; public: /// Static constructor to get a '0' constant of arbitrary type... /// diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index a259590467..2c7f577e34 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -46,6 +46,11 @@ class ConstantInt : public Constant { ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT ConstantInt(const IntegerType *Ty, const APInt& V); APInt Val; +protected: + static void destroyThis(ConstantInt*v) { + Constant::destroyThis(v); + } + friend class Value; public: /// Return the constant as an APInt value reference. This allows clients to /// obtain a copy of the value, with all its precision in tact. @@ -218,6 +223,10 @@ class ConstantFP : public Constant { ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT protected: ConstantFP(const Type *Ty, const APFloat& V); + static void destroyThis(ConstantFP*v) { + Constant::destroyThis(v); + } + friend class Value; public: /// get() - Static factory methods - Return objects of the specified value static ConstantFP *get(const Type *Ty, const APFloat& V); @@ -266,6 +275,11 @@ class ConstantAggregateZero : public Constant { protected: explicit ConstantAggregateZero(const Type *Ty) : Constant(Ty, ConstantAggregateZeroVal, 0, 0) {} + + static void destroyThis(ConstantAggregateZero*v) { + Constant::destroyThis(v); + } + friend class Value; public: /// get() - static factory method for creating a null aggregate. It is /// illegal to call this method with a non-aggregate type. @@ -295,7 +309,8 @@ class ConstantArray : public Constant { ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT protected: ConstantArray(const ArrayType *T, const std::vector<Constant*> &Val); - ~ConstantArray(); + static void destroyThis(ConstantArray*); + friend class Value; public: /// get() - Static factory methods - Return objects of the specified value static Constant *get(const ArrayType *T, const std::vector<Constant*> &); @@ -361,7 +376,8 @@ class ConstantStruct : public Constant { ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT protected: ConstantStruct(const StructType *T, const std::vector<Constant*> &Val); - ~ConstantStruct(); + static void destroyThis(ConstantStruct*); + friend class Value; public: /// get() - Static factory methods - Return objects of the specified value /// @@ -405,7 +421,8 @@ class ConstantVector : public Constant { ConstantVector(const ConstantVector &); // DO NOT IMPLEMENT protected: ConstantVector(const VectorType *T, const std::vector<Constant*> &Val); - ~ConstantVector(); + static void destroyThis(ConstantVector*v); + friend class Value; public: /// get() - Static factory methods - Return objects of the specified value static Constant *get(const VectorType *T, const std::vector<Constant*> &); @@ -462,7 +479,10 @@ protected: explicit ConstantPointerNull(const PointerType *T) : Constant(reinterpret_cast<const Type*>(T), Value::ConstantPointerNullVal, 0, 0) {} - + static void destroyThis(ConstantPointerNull*v) { + Constant::destroyThis(v); + } + friend class Value; public: /// get() - Static factory methods - Return objects of the specified value @@ -524,6 +544,10 @@ protected: static Constant *getShuffleVectorTy(const Type *Ty, Constant *V1, Constant *V2, Constant *Mask); + static void destroyThis(ConstantExpr* v) { + Constant::destroyThis(v); + } + friend class Value; public: // Static methods to construct a ConstantExpr of different kinds. Note that // these methods may return a object that is not an instance of the @@ -709,6 +733,10 @@ class UndefValue : public Constant { UndefValue(const UndefValue &); // DO NOT IMPLEMENT protected: explicit UndefValue(const Type *T) : Constant(T, UndefValueVal, 0, 0) {} + static void destroyThis(UndefValue*v) { + Constant::destroyThis(v); + } + friend class Value; public: /// get() - Static factory methods - Return an 'undef' object of the specified /// type. @@ -728,6 +756,120 @@ public: } }; +/// GetElementPtrConstantExpr - Helper class for Constants.cpp, +/// used behind the scenes to implement getelementpr constant exprs. +class GetElementPtrConstantExpr : public ConstantExpr { +protected: + static void destroyThis(GetElementPtrConstantExpr*v) { + delete [] v->OperandList; + ConstantExpr::destroyThis(v); + } + friend class Value; +public: + GetElementPtrConstantExpr(Constant *C, const std::vector<Constant*> &IdxList, + const Type *DestTy); +}; + +/// UnaryConstantExpr - Helper class for Constants.cpp, used +/// behind the scenes to implement unary constant exprs. +class UnaryConstantExpr : public ConstantExpr { + Use Op; +protected: + static void destroyThis(UnaryConstantExpr*v) { + ConstantExpr::destroyThis(v); + } + friend class Value; +public: + UnaryConstantExpr(unsigned Opcode, Constant *C, const Type *Ty); +}; + +/// BinaryConstantExpr - Helper class for Constants.cpp, used +/// behind the scenes to implement binary constant exprs. +class BinaryConstantExpr : public ConstantExpr { + Use Ops[2]; +protected: + static void destroyThis(BinaryConstantExpr*v) { + ConstantExpr::destroyThis(v); + } + friend class Value; +public: + BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2) + : ConstantExpr(C1->getType(), Opcode, Ops, 2) { + Ops[0].init(C1, this); + Ops[1].init(C2, this); + } +}; + +/// SelectConstantExpr - Helper class for Constants.cpp, used +/// behind the scenes to implement select constant exprs. +class SelectConstantExpr : public ConstantExpr { + Use Ops[3]; +protected: + static void destroyThis(SelectConstantExpr*v) { + ConstantExpr::destroyThis(v); + } + friend class Value; +public: + SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3); +}; + +/// ExtractElementConstantExpr - Helper class for Constants.cpp, used +/// behind the scenes to implement extractelement constant exprs. +class ExtractElementConstantExpr : public ConstantExpr { + Use Ops[2]; +protected: + static void destroyThis(ExtractElementConstantExpr*v) { + ConstantExpr::destroyThis(v); + } + friend class Value; +public: + ExtractElementConstantExpr(Constant *C1, Constant *C2); +}; + +/// InsertElementConstantExpr - Helper class for Constants.cpp, used +/// behind the scenes to implement insertelement constant exprs. +class InsertElementConstantExpr : public ConstantExpr { + Use Ops[3]; +protected: + static void destroyThis(InsertElementConstantExpr*v) { + ConstantExpr::destroyThis(v); + } + friend class Value; +public: + InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3); +}; + +/// ShuffleVectorConstantExpr - Helper class for Constants.cpp, used +/// behind the scenes to implement shufflevector constant exprs. +class ShuffleVectorConstantExpr : public ConstantExpr { + Use Ops[3]; +protected: + static void destroyThis(ShuffleVectorConstantExpr*v) { + ConstantExpr::destroyThis(v); + } + friend class Value; +public: + ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3); +}; + + + +// CompareConstantExpr - Helper class for Constants.cpp, used +// behind the scenes to implement ICmp and FCmp constant expressions. This is +// needed in order to store the predicate value for these instructions. +class CompareConstantExpr : public ConstantExpr { +protected: + static void destroyThis(CompareConstantExpr*v) { + ConstantExpr::destroyThis(v); + } + friend class Value; +public: + unsigned short predicate; + Use Ops[2]; + CompareConstantExpr(unsigned opc, unsigned short pred, + Constant* LHS, Constant* RHS); +}; + } // End llvm namespace #endif diff --git a/include/llvm/Function.h b/include/llvm/Function.h index 20a43e285c..ba91372ec6 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -53,6 +53,9 @@ template<> struct ilist_traits<Argument> }; class Function : public GlobalValue, public Annotable { +protected: + static void destroyThis(Function*v); + friend class Value; public: typedef iplist<Argument> ArgumentListType; typedef iplist<BasicBlock> BasicBlockListType; @@ -109,7 +112,6 @@ public: /// Function(const FunctionType *Ty, LinkageTypes Linkage, const std::string &N = "", Module *M = 0); - ~Function(); const Type *getReturnType() const; // Return the type of the ret val const FunctionType *getFunctionType() const; // Return the FunctionType for me diff --git a/include/llvm/GlobalAlias.h b/include/llvm/GlobalAlias.h index bbd19ba881..8b0dcf5315 100644 --- a/include/llvm/GlobalAlias.h +++ b/include/llvm/GlobalAlias.h @@ -43,6 +43,11 @@ class GlobalAlias : public GlobalValue { const GlobalAlias *getPrev() const { return Prev; } Use Aliasee; +protected: + static void destroyThis(GlobalAlias*v) { + GlobalValue::destroyThis(v); + } + friend class Value; public: /// GlobalAlias ctor - If a parent module is specified, the alias is /// automatically inserted into the end of the specified module's alias list. diff --git a/include/llvm/GlobalValue.h b/include/llvm/GlobalValue.h index fe43ed4f69..40e3a5ace5 100644 --- a/include/llvm/GlobalValue.h +++ b/include/llvm/GlobalValue.h @@ -63,11 +63,12 @@ protected: unsigned Visibility : 2; // The visibility style of this global unsigned Alignment : 16; // Alignment of this symbol, must be power of two std::string Section; // Section to emit this into, empty mean default -public: - ~GlobalValue() { - removeDeadConstantUsers(); // remove any dead constants using this. - } + static void destroyThis(GlobalValue*v) { + v->removeDeadConstantUsers(); // remove any dead constants using this. + Constant::destroyThis(v); + } +public: unsigned getAlignment() const { return Alignment; } void setAlignment(unsigned Align) { assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!"); diff --git a/include/llvm/GlobalVariable.h b/include/llvm/GlobalVariable.h index 00d4acb66d..882dec6885 100644 --- a/include/llvm/GlobalVariable.h +++ b/include/llvm/GlobalVariable.h @@ -45,6 +45,11 @@ class GlobalVariable : public GlobalValue { bool isThreadLocalSymbol : 1; // Is this symbol "Thread Local"? Use Initializer; +protected: + static void destroyThis(GlobalVariable*v) { + GlobalValue::destroyThis(v); + } + friend class Value; public: /// GlobalVariable ctor - If a parent module is specified, the global is /// automatically inserted into the end of the specified modules global list. diff --git a/include/llvm/InlineAsm.h b/include/llvm/InlineAsm.h index 20c184ac2e..bf7b419475 100644 --- a/include/llvm/InlineAsm.h +++ b/include/llvm/InlineAsm.h @@ -36,9 +36,12 @@ class InlineAsm : public Value { InlineAsm(const FunctionType *Ty, const std::string &AsmString, const std::string &Constraints, bool hasSideEffects); - virtual ~InlineAsm(); +protected: + static void destroyThis(InlineAsm*v) { + Value::destroyThis(v); + } + friend class Value; public: - /// InlineAsm::get - Return the the specified uniqued inline asm string. /// static InlineAsm *get(const FunctionType *Ty, const std::string &AsmString, diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index a6a8fff40c..c14b3bbc26 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -38,14 +38,16 @@ protected: Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd) : Instruction(Ty, iType, Ops, NumOps, InsertAtEnd) {} - // Out of line virtual method, so the vtable, etc has a home. - ~TerminatorInst(); - /// Virtual methods - Terminators should overload these and provide inline /// overrides of non-V methods. virtual BasicBlock *getSuccessorV(unsigned idx) const = 0; virtual unsigned getNumSuccessorsV() const = 0; virtual void setSuccessorV(unsigned idx, BasicBlock *B) = 0; + + static void destroyThis(TerminatorInst* v) { + Instruction::destroyThis(v); + } + friend class Value; public: virtual Instruction *clone() const = 0; @@ -94,10 +96,12 @@ protected: UnaryInstruction(const Type *Ty, unsigned iType, Value *V, BasicBlock *IAE) : Instruction(Ty, iType, &Op, 1, IAE), Op(V, this_()) { } -public: - // Out of line virtual method, so the vtable, etc has a home. - ~UnaryInstruction(); + static void destroyThis(UnaryInstruction* v) { + Instruction::destroyThis(v); + } + friend class Value; +public: // Transparently provide more efficient getOperand methods. Value *getOperand(unsigned i) const { assert(i == 0 && "getOperand() out of range!"); @@ -136,6 +140,11 @@ protected: const std::string &Name, Instruction *InsertBefore); BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd); + + static void destroyThis(BinaryOperator* v) { + Instruction::destroyThis(v); + } + friend class Value; public: /// Transparently provide more efficient getOperand methods. @@ -272,6 +281,12 @@ protected: : UnaryInstruction(Ty, iType, S, InsertAtEnd) { setName(Name); } + +protected: + static void destroyThis(CastInst* v) { + UnaryInstruction::destroyThis(v); + } + friend class Value; public: /// Provides a way to construct any of the CastInst subclasses using an /// opcode instead of the subclass's constructor. The opcode must be in the @@ -493,6 +508,10 @@ protected: Use Ops[2]; // CmpInst instructions always have 2 operands, optimize + static void destroyThis(CmpInst* v) { + Instruction::destroyThis(v); + } + friend class Value; public: /// Construct a compare instruction, given the opcode, the predicate and /// the two operands. Optionally (if InstBefore is specified) insert the diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index 8da89e2f38..3875cbe3b1 100644 --- a/include/llvm/Instruction.h +++ b/include/llvm/Instruction.h @@ -42,10 +42,10 @@ protected: Instruction *InsertBefore = 0); Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd); + + static void destroyThis(Instruction*v); + friend class Value; public: - // Out of line virtual method, so the vtable, etc has a home. - ~Instruction(); - /// mayWriteToMemory - Return true if this instruction may modify memory. /// bool mayWriteToMemory() const; diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 2d721bb414..e5a6c98067 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -47,9 +47,6 @@ protected: AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align, const std::string &Name, BasicBlock *InsertAtEnd); public: - // Out of line virtual method, so the vtable, etc has a home. - virtual ~AllocationInst(); - /// isArrayAllocation - Return true if there is an allocation size parameter /// to the allocation instruction that is not 1. /// @@ -190,6 +187,11 @@ public: /// class FreeInst : public UnaryInstruction { void AssertOK(); +protected: + static void destroyThis(FreeInst* v) { + UnaryInstruction::destroyThis(v); + } + friend class Value; public: explicit FreeInst(Value *Ptr, Instruction *InsertBefore = 0); FreeInst(Value *Ptr, BasicBlock *InsertAfter); @@ -230,6 +232,11 @@ class LoadInst : public UnaryInstruction { #endif } void AssertOK(); +protected: + static void destroyThis(LoadInst* v) { + UnaryInstruction::destroyThis(v); + } + friend class Value; public: LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBefore); LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAtEnd); @@ -305,6 +312,11 @@ class StoreInst : public Instruction { #endif } void AssertOK(); +protected: + static void destroyThis(StoreInst* v) { + Instruction::destroyThis(v); + } + friend class Value; public: StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore); StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd); @@ -443,6 +455,9 @@ class GetElementPtrInst : public Instruction { } } +protected: + static void destroyThis(GetElementPtrInst*v); + friend class Value; public: /// Constructors - Create a getelementptr instruction with a base pointer an /// list of indices. The first ctor can optionally insert before an existing @@ -477,7 +492,6 @@ public: const std::string &Name = "", Instruction *InsertBefore =0); GetElementPtrInst(Value *Ptr, Value *Idx, const std::string &Name, BasicBlock *InsertAtEnd); - ~GetElementPtrInst(); virtual GetElementPtrInst *clone() const; @@ -556,6 +570,11 @@ public: /// vectors of integrals. The two operands must be the same type. /// @brief Represent an integer comparison operator. class ICmpInst: public CmpInst { +protected: + static void destroyThis(ICmpInst* v) { + CmpInst::destroyThis(v); + } + friend class Value; public: /// This enumeration lists the possible predicates for the ICmpInst. The /// values in the range 0-31 are reserved for FCmpInst while values in the @@ -712,6 +731,11 @@ public: /// vectors of floating point values. The operands must be identical types. /// @brief Represents a floating point comparison operator. class FCmpInst: public CmpInst { +protected: + static void destroyThis(FCmpInst* v) { + CmpInst::destroyThis(v); + } + friend class Value; public: /// This enumeration lists the possible predicates for the FCmpInst. Values /// in the range 0-31 are reserved for FCmpInst. @@ -857,6 +881,9 @@ class CallInst : public Instruction { setName(Name); } +protected: + static void destroyThis(CallInst*v); + friend class Value; public: /// Construct a CallInst given a range of arguments. InputIterator /// must be a random-access iterator pointing to contiguous storage @@ -897,7 +924,6 @@ public: explicit CallInst(Value *F, const std::string &Name = "", Instruction *InsertBefore = 0); CallInst(Value *F, const std::string &Name, BasicBlock *InsertAtEnd); - ~CallInst(); virtual CallInst *clone() const; @@ -989,6 +1015,11 @@ class SelectInst : public Instruction { : Instruction(SI.getType(), SI.getOpcode(), Ops, 3) { init(SI.Ops[0], SI.Ops[1], SI.Ops[2]); } +protected: + static void destroyThis(SelectInst* v) { + Instruction::destroyThis(v); + } + friend class Value; public: SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "", Instruction *InsertBefore = 0) @@ -1044,6 +1075,11 @@ public: class VAArgInst : public UnaryInstruction { VAArgInst(const VAArgInst &VAA) : UnaryInstruction(VAA.getType(), VAArg, VAA.getOperand(0)) {} +protected: + static void destroyThis(VAArgInst* v) { + UnaryInstruction::destroyThis(v); + } + friend class Value; public: VAArgInst(Value *List, const Type *Ty, const std::string &Name = "", Instruction *InsertBefore = 0) @@ -1083,6 +1119,11 @@ class ExtractElementInst : public Instruction { Ops[1].init(EE.Ops[1], this); } +protected: + static void destroyThis(ExtractElementInst* v) { + Instruction::destroyThis(v); + } + friend class Value; public: ExtractElementInst(Value *Vec, Value *Idx, const std::string &Name = "", Instruction *InsertBefore = 0); @@ -1130,6 +1171,11 @@ public: class InsertElementInst : public Instruction { Use Ops[3]; InsertElementInst(const InsertElementInst &IE); +protected: + static void destroyThis(InsertElementInst* v) { + Instruction::destroyThis(v); + } + friend class Value; public: InsertElementInst(Value *Vec, Value *NewElt, Value *Idx, const std::string &Name = "",Instruction *InsertBefore = 0); @@ -1184,6 +1230,11 @@ public: class ShuffleVectorInst : public Instruction { Use Ops[3]; ShuffleVectorInst(const ShuffleVectorInst &IE); +protected: + static void destroyThis(ShuffleVectorInst* v) { + Instruction::destroyThis(v); + } + friend class Value; public: ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, const std::string &Name = "", Instruction *InsertBefor = 0); @@ -1238,6 +1289,9 @@ class PHINode : public Instruction { /// the number actually in use. unsigned ReservedSpace; PHINode(const PHINode &PN); +protected: + static void destroyThis(PHINode*); + friend class Value; public: explicit PHINode(const Type *Ty, const std::string &Name = "", Instruction *InsertBefore = 0) @@ -1252,8 +1306,6 @@ public: setName(Name); } - ~PHINode(); - /// reserveOperandSpace - This method can be used to avoid repeated /// reallocation of PHI operand lists by reserving space for the correct /// number of operands before adding them. Unlike normal vector reserves, @@ -1522,6 +1574,9 @@ class SwitchInst : public TerminatorInst { SwitchInst(const SwitchInst &RI); void init(Value *Value, BasicBlock *Default, unsigned NumCases); void resizeOperands(unsigned No); +protected: + static void destroyThis(SwitchInst*v); + friend class Value; public: /// SwitchInst ctor - Create a new switch instruction, specifying a value to /// switch on and a default destination. The number of additional cases can @@ -1536,7 +1591,6 @@ public: /// constructor also autoinserts at the end of the specified BasicBlock. SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases, BasicBlock *InsertAtEnd); - ~SwitchInst(); // Accessor Methods for Switch stmt @@ -1664,6 +1718,9 @@ class InvokeInst : public TerminatorInst { setName(Name); } +protected: + static void destroyThis(InvokeInst*v); + friend class Value; public: /// Construct an InvokeInst given a range of arguments. /// InputIterator must be a random-access iterator pointing to @@ -1701,8 +1758,6 @@ public: typename std::iterator_traits<InputIterator>::iterator_category()); } - ~InvokeInst(); - virtual InvokeInst *clone() const; /// getCallingConv/setCallingConv - Get or set the calling convention of this @@ -1872,6 +1927,11 @@ class TruncInst : public CastInst { TruncInst(const TruncInst &CI) : CastInst(CI.getType(), Trunc, CI.getOperand(0)) { } +protected: + static void destroyThis(TruncInst* v) { + CastInst::destroyThis(v); + } + friend class Value; public: /// @brief Constructor with insert-before-instruction semantics TruncInst( @@ -1912,6 +1972,11 @@ class ZExtInst : public CastInst { ZExtInst(const ZExtInst &CI) : CastInst(CI.getType(), ZExt, CI.getOperand(0)) { } +protected: + static void destroyThis(ZExtInst* v) { + CastInst::destroyThis(v); + } + friend class Value; public: /// @brief Constructor with insert-before-instruction semantics ZExtInst( @@ -1952,6 +2017,11 @@ class SExtInst : public CastInst { SExtInst(const SExtInst &CI) : CastInst(CI.getType(), SExt, CI.getOperand(0)) { } +protected: + static void destroyThis(SExtInst* v) { + CastInst::destroyThis(v); + } + friend class Value; public: /// @brief Constructor with insert-before-instruction semantics SExtInst( @@ -1991,6 +2061,11 @@ class FPTruncInst : public CastInst { FPTruncInst(const FPTruncInst &CI) : CastInst(CI.getType(), FPTrunc, CI.getOperand(0)) { } +protected: + static void destroyThis(FPTruncInst* v) { + CastInst::destroyThis(v); + } + friend class Value; public: /// @brief Constructor with insert-before-instruction semantics FPTruncInst( @@ -2030,6 +2105,11 @@ class FPExtInst : public CastInst { FPExtInst(const FPExtInst &CI) : CastInst(CI.getType(), FPExt, CI.getOperand(0)) { } +protected: + static void destroyThis(FPExtInst* v) { + CastInst::destroyThis(v); + } + friend class Value; public: /// @brief Constructor with insert-before-instruction semantics FPExtInst( @@ -2069,6 +2149,11 @@ class UIToFPInst : public CastInst { UIToFPInst(const UIToFPInst &CI) : CastInst(CI.getType(), UIToFP, CI.getOperand(0)) { } +protected: + static void destroyThis(UIToFPInst* v) { + CastInst::destroyThis(v); + } + friend class Value; public: /// @brief Constructor with insert-before-instruction semantics UIToFPInst( @@ -2108,6 +2193,11 @@ class SIToFPInst : public CastInst { SIToFPInst(const SIToFPInst &CI) : CastInst(CI.getType(), SIToFP, CI.getOperand(0)) { } +protected: + static void destroyThis(SIToFPInst* v) { + CastInst::destroyThis(v); + } + friend class Value; public: /// @brief Constructor with insert-before-instruction semantics SIToFPInst( @@ -2147,6 +2237,11 @@ class FPToUIInst : public CastInst { FPToUIInst(const FPToUIInst &CI) : CastInst(CI.getType(), FPToUI, CI.getOperand(0)) { } +protected: + static void destroyThis(FPToUIInst* v) { + CastInst::destroyThis(v); + } + friend class Value; public: /// @brief Constructor with insert-before-instruction semantics FPToUIInst( @@ -2186,6 +2281,11 @@ class FPToSIInst : public CastInst { FPToSIInst(const FPToSIInst &CI) : CastInst(CI.getType(), FPToSI, CI.getOperand(0)) { } +protected: + static void destroyThis(FPToSIInst* v) { + CastInst::destroyThis(v); + } + friend class Value; public: /// @brief Constructor with insert-before-instruction semantics FPToSIInst( @@ -2225,6 + |