llvm.org GIT mirror llvm / afba8fe
Reverting dtor devirtualization patch. _sabre_: it has a major problem: by the time ~Value is run, all of the "parts" of the derived classes have been destroyed _sabre_: the vtable lives to fight another day git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44760 91177308-0d34-0410-b5e6-96231b3b80d8 Gordon Henriksen 12 years ago
21 changed file(s) with 236 addition(s) and 671 deletion(s). Raw diff Collapse all Expand all
3434 friend class SymbolTableListTraits;
3535 void setParent(Function *parent);
3636
37 protected:
38 static void destroyThis(Argument*v) {
39 Value::destroyThis(v);
40 }
41 friend class Value;
4237 public:
4338 /// Argument ctor - If Function argument is specified, this argument is
4439 /// inserted at the end of the argument list for the function.
6464 BasicBlock(const BasicBlock &); // Do not implement
6565 void operator=(const BasicBlock &); // Do not implement
6666
67 protected:
68 static void destroyThis(BasicBlock*);
69 friend class Value;
7067 public:
7168 /// Instruction iterators...
7269 typedef InstListType::iterator iterator;
7875 ///
7976 explicit BasicBlock(const std::string &Name = "", Function *Parent = 0,
8077 BasicBlock *InsertBefore = 0);
78 ~BasicBlock();
8179
8280 /// getParent - Return the enclosing method, or null if none
8381 ///
207205 const BasicBlock *getPrev() const { return Prev; }
208206 };
209207
210 /// DummyInst - An instance of this class is used to mark the end of the
211 /// instruction list. This is not a real instruction.
212 class DummyInst : public Instruction {
213 protected:
214 static void destroyThis(DummyInst* v) {
215 Instruction::destroyThis(v);
216 }
217 friend class Value;
218 public:
219 DummyInst();
220
221 Instruction *clone() const {
222 assert(0 && "Cannot clone EOL");abort();
223 return 0;
224 }
225 const char *getOpcodeName() const { return "*end-of-list-inst*"; }
226
227 // Methods for support type inquiry through isa, cast, and dyn_cast...
228 static inline bool classof(const DummyInst *) { return true; }
229 static inline bool classof(const Instruction *I) {
230 return I->getOpcode() == OtherOpsEnd;
231 }
232 static inline bool classof(const Value *V) {
233 return isa(V) && classof(cast(V));
234 }
235 };
236
237208 inline int
238209 ilist_traits::getListOffset() {
239210 return BasicBlock::getInstListOffset();
4242 : User(Ty, vty, Ops, NumOps) {}
4343
4444 void destroyConstantImpl();
45 static void destroyThis(Constant*v) {
46 User::destroyThis(v);
47 }
48 friend class Value;
4945 public:
5046 /// Static constructor to get a '0' constant of arbitrary type...
5147 ///
4545 ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT
4646 ConstantInt(const IntegerType *Ty, const APInt& V);
4747 APInt Val;
48 protected:
49 static void destroyThis(ConstantInt*v) {
50 Constant::destroyThis(v);
51 }
52 friend class Value;
5348 public:
5449 /// Return the constant as an APInt value reference. This allows clients to
5550 /// obtain a copy of the value, with all its precision in tact.
222217 ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT
223218 protected:
224219 ConstantFP(const Type *Ty, const APFloat& V);
225 static void destroyThis(ConstantFP*v) {
226 Constant::destroyThis(v);
227 }
228 friend class Value;
229220 public:
230221 /// get() - Static factory methods - Return objects of the specified value
231222 static ConstantFP *get(const Type *Ty, const APFloat& V);
274265 protected:
275266 explicit ConstantAggregateZero(const Type *Ty)
276267 : Constant(Ty, ConstantAggregateZeroVal, 0, 0) {}
277
278 static void destroyThis(ConstantAggregateZero*v) {
279 Constant::destroyThis(v);
280 }
281 friend class Value;
282268 public:
283269 /// get() - static factory method for creating a null aggregate. It is
284270 /// illegal to call this method with a non-aggregate type.
308294 ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT
309295 protected:
310296 ConstantArray(const ArrayType *T, const std::vector &Val);
311 static void destroyThis(ConstantArray*);
312 friend class Value;
297 ~ConstantArray();
313298 public:
314299 /// get() - Static factory methods - Return objects of the specified value
315300 static Constant *get(const ArrayType *T, const std::vector &);
375360 ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT
376361 protected:
377362 ConstantStruct(const StructType *T, const std::vector &Val);
378 static void destroyThis(ConstantStruct*);
379 friend class Value;
363 ~ConstantStruct();
380364 public:
381365 /// get() - Static factory methods - Return objects of the specified value
382366 ///
420404 ConstantVector(const ConstantVector &); // DO NOT IMPLEMENT
421405 protected:
422406 ConstantVector(const VectorType *T, const std::vector &Val);
423 static void destroyThis(ConstantVector*v);
424 friend class Value;
407 ~ConstantVector();
425408 public:
426409 /// get() - Static factory methods - Return objects of the specified value
427410 static Constant *get(const VectorType *T, const std::vector &);
478461 explicit ConstantPointerNull(const PointerType *T)
479462 : Constant(reinterpret_cast(T),
480463 Value::ConstantPointerNullVal, 0, 0) {}
481 static void destroyThis(ConstantPointerNull*v) {
482 Constant::destroyThis(v);
483 }
484 friend class Value;
464
485465 public:
486466
487467 /// get() - Static factory methods - Return objects of the specified value
543523 static Constant *getShuffleVectorTy(const Type *Ty, Constant *V1,
544524 Constant *V2, Constant *Mask);
545525
546 static void destroyThis(ConstantExpr* v) {
547 Constant::destroyThis(v);
548 }
549 friend class Value;
550526 public:
551527 // Static methods to construct a ConstantExpr of different kinds. Note that
552528 // these methods may return a object that is not an instance of the
732708 UndefValue(const UndefValue &); // DO NOT IMPLEMENT
733709 protected:
734710 explicit UndefValue(const Type *T) : Constant(T, UndefValueVal, 0, 0) {}
735 static void destroyThis(UndefValue*v) {
736 Constant::destroyThis(v);
737 }
738 friend class Value;
739711 public:
740712 /// get() - Static factory methods - Return an 'undef' object of the specified
741713 /// type.
755727 }
756728 };
757729
758 /// GetElementPtrConstantExpr - Helper class for Constants.cpp,
759 /// used behind the scenes to implement getelementpr constant exprs.
760 class GetElementPtrConstantExpr : public ConstantExpr {
761 protected:
762 static void destroyThis(GetElementPtrConstantExpr*v) {
763 delete [] v->OperandList;
764 ConstantExpr::destroyThis(v);
765 }
766 friend class Value;
767 public:
768 GetElementPtrConstantExpr(Constant *C, const std::vector &IdxList,
769 const Type *DestTy);
770 };
771
772 /// UnaryConstantExpr - Helper class for Constants.cpp, used
773 /// behind the scenes to implement unary constant exprs.
774 class UnaryConstantExpr : public ConstantExpr {
775 Use Op;
776 protected:
777 static void destroyThis(UnaryConstantExpr*v) {
778 ConstantExpr::destroyThis(v);
779 }
780 friend class Value;
781 public:
782 UnaryConstantExpr(unsigned Opcode, Constant *C, const Type *Ty);
783 };
784
785 /// BinaryConstantExpr - Helper class for Constants.cpp, used
786 /// behind the scenes to implement binary constant exprs.
787 class BinaryConstantExpr : public ConstantExpr {
788 Use Ops[2];
789 protected:
790 static void destroyThis(BinaryConstantExpr*v) {
791 ConstantExpr::destroyThis(v);
792 }
793 friend class Value;
794 public:
795 BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2)
796 : ConstantExpr(C1->getType(), Opcode, Ops, 2) {
797 Ops[0].init(C1, this);
798 Ops[1].init(C2, this);
799 }
800 };
801
802 /// SelectConstantExpr - Helper class for Constants.cpp, used
803 /// behind the scenes to implement select constant exprs.
804 class SelectConstantExpr : public ConstantExpr {
805 Use Ops[3];
806 protected:
807 static void destroyThis(SelectConstantExpr*v) {
808 ConstantExpr::destroyThis(v);
809 }
810 friend class Value;
811 public:
812 SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3);
813 };
814
815 /// ExtractElementConstantExpr - Helper class for Constants.cpp, used
816 /// behind the scenes to implement extractelement constant exprs.
817 class ExtractElementConstantExpr : public ConstantExpr {
818 Use Ops[2];
819 protected:
820 static void destroyThis(ExtractElementConstantExpr*v) {
821 ConstantExpr::destroyThis(v);
822 }
823 friend class Value;
824 public:
825 ExtractElementConstantExpr(Constant *C1, Constant *C2);
826 };
827
828 /// InsertElementConstantExpr - Helper class for Constants.cpp, used
829 /// behind the scenes to implement insertelement constant exprs.
830 class InsertElementConstantExpr : public ConstantExpr {
831 Use Ops[3];
832 protected:
833 static void destroyThis(InsertElementConstantExpr*v) {
834 ConstantExpr::destroyThis(v);
835 }
836 friend class Value;
837 public:
838 InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3);
839 };
840
841 /// ShuffleVectorConstantExpr - Helper class for Constants.cpp, used
842 /// behind the scenes to implement shufflevector constant exprs.
843 class ShuffleVectorConstantExpr : public ConstantExpr {
844 Use Ops[3];
845 protected:
846 static void destroyThis(ShuffleVectorConstantExpr*v) {
847 ConstantExpr::destroyThis(v);
848 }
849 friend class Value;
850 public:
851 ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3);
852 };
853
854
855
856 // CompareConstantExpr - Helper class for Constants.cpp, used
857 // behind the scenes to implement ICmp and FCmp constant expressions. This is
858 // needed in order to store the predicate value for these instructions.
859 class CompareConstantExpr : public ConstantExpr {
860 protected:
861 static void destroyThis(CompareConstantExpr*v) {
862 ConstantExpr::destroyThis(v);
863 }
864 friend class Value;
865 public:
866 unsigned short predicate;
867 Use Ops[2];
868 CompareConstantExpr(unsigned opc, unsigned short pred,
869 Constant* LHS, Constant* RHS);
870 };
871
872730 } // End llvm namespace
873731
874732 #endif
5252 };
5353
5454 class Function : public GlobalValue, public Annotable {
55 protected:
56 static void destroyThis(Function*v);
57 friend class Value;
5855 public:
5956 typedef iplist ArgumentListType;
6057 typedef iplist BasicBlockListType;
111108 ///
112109 Function(const FunctionType *Ty, LinkageTypes Linkage,
113110 const std::string &N = "", Module *M = 0);
111 ~Function();
114112
115113 const Type *getReturnType() const; // Return the type of the ret val
116114 const FunctionType *getFunctionType() const; // Return the FunctionType for me
4242 const GlobalAlias *getPrev() const { return Prev; }
4343
4444 Use Aliasee;
45 protected:
46 static void destroyThis(GlobalAlias*v) {
47 GlobalValue::destroyThis(v);
48 }
49 friend class Value;
5045 public:
5146 /// GlobalAlias ctor - If a parent module is specified, the alias is
5247 /// automatically inserted into the end of the specified module's alias list.
6262 unsigned Visibility : 2; // The visibility style of this global
6363 unsigned Alignment : 16; // Alignment of this symbol, must be power of two
6464 std::string Section; // Section to emit this into, empty mean default
65 public:
66 ~GlobalValue() {
67 removeDeadConstantUsers(); // remove any dead constants using this.
68 }
6569
66 static void destroyThis(GlobalValue*v) {
67 v->removeDeadConstantUsers(); // remove any dead constants using this.
68 Constant::destroyThis(v);
69 }
70 public:
7170 unsigned getAlignment() const { return Alignment; }
7271 void setAlignment(unsigned Align) {
7372 assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
4444 bool isThreadLocalSymbol : 1; // Is this symbol "Thread Local"?
4545 Use Initializer;
4646
47 protected:
48 static void destroyThis(GlobalVariable*v) {
49 GlobalValue::destroyThis(v);
50 }
51 friend class Value;
5247 public:
5348 /// GlobalVariable ctor - If a parent module is specified, the global is
5449 /// automatically inserted into the end of the specified modules global list.
3535
3636 InlineAsm(const FunctionType *Ty, const std::string &AsmString,
3737 const std::string &Constraints, bool hasSideEffects);
38 protected:
39 static void destroyThis(InlineAsm*v) {
40 Value::destroyThis(v);
41 }
42 friend class Value;
38 virtual ~InlineAsm();
4339 public:
40
4441 /// InlineAsm::get - Return the the specified uniqued inline asm string.
4542 ///
4643 static InlineAsm *get(const FunctionType *Ty, const std::string &AsmString,
3737 Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd)
3838 : Instruction(Ty, iType, Ops, NumOps, InsertAtEnd) {}
3939
40 // Out of line virtual method, so the vtable, etc has a home.
41 ~TerminatorInst();
42
4043 /// Virtual methods - Terminators should overload these and provide inline
4144 /// overrides of non-V methods.
4245 virtual BasicBlock *getSuccessorV(unsigned idx) const = 0;
4346 virtual unsigned getNumSuccessorsV() const = 0;
4447 virtual void setSuccessorV(unsigned idx, BasicBlock *B) = 0;
45
46 static void destroyThis(TerminatorInst* v) {
47 Instruction::destroyThis(v);
48 }
49 friend class Value;
5048 public:
5149
5250 virtual Instruction *clone() const = 0;
9593 UnaryInstruction(const Type *Ty, unsigned iType, Value *V, BasicBlock *IAE)
9694 : Instruction(Ty, iType, &Op, 1, IAE), Op(V, this_()) {
9795 }
98
99 static void destroyThis(UnaryInstruction* v) {
100 Instruction::destroyThis(v);
101 }
102 friend class Value;
10396 public:
97 // Out of line virtual method, so the vtable, etc has a home.
98 ~UnaryInstruction();
99
104100 // Transparently provide more efficient getOperand methods.
105101 Value *getOperand(unsigned i) const {
106102 assert(i == 0 && "getOperand() out of range!");
139135 const std::string &Name, Instruction *InsertBefore);
140136 BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
141137 const std::string &Name, BasicBlock *InsertAtEnd);
142
143 static void destroyThis(BinaryOperator* v) {
144 Instruction::destroyThis(v);
145 }
146 friend class Value;
147138 public:
148139
149140 /// Transparently provide more efficient getOperand methods.
280271 : UnaryInstruction(Ty, iType, S, InsertAtEnd) {
281272 setName(Name);
282273 }
283
284 protected:
285 static void destroyThis(CastInst* v) {
286 UnaryInstruction::destroyThis(v);
287 }
288 friend class Value;
289274 public:
290275 /// Provides a way to construct any of the CastInst subclasses using an
291276 /// opcode instead of the subclass's constructor. The opcode must be in the
507492
508493 Use Ops[2]; // CmpInst instructions always have 2 operands, optimize
509494
510 static void destroyThis(CmpInst* v) {
511 Instruction::destroyThis(v);
512 }
513 friend class Value;
514495 public:
515496 /// Construct a compare instruction, given the opcode, the predicate and
516497 /// the two operands. Optionally (if InstBefore is specified) insert the
4141 Instruction *InsertBefore = 0);
4242 Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
4343 BasicBlock *InsertAtEnd);
44
45 static void destroyThis(Instruction*v);
46 friend class Value;
4744 public:
45 // Out of line virtual method, so the vtable, etc has a home.
46 ~Instruction();
47
4848 /// mayWriteToMemory - Return true if this instruction may modify memory.
4949 ///
5050 bool mayWriteToMemory() const;
4646 AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align,
4747 const std::string &Name, BasicBlock *InsertAtEnd);
4848 public:
49 // Out of line virtual method, so the vtable, etc has a home.
50 virtual ~AllocationInst();
51
4952 /// isArrayAllocation - Return true if there is an allocation size parameter
5053 /// to the allocation instruction that is not 1.
5154 ///
186189 ///
187190 class FreeInst : public UnaryInstruction {
188191 void AssertOK();
189 protected:
190 static void destroyThis(FreeInst* v) {
191 UnaryInstruction::destroyThis(v);
192 }
193 friend class Value;
194192 public:
195193 explicit FreeInst(Value *Ptr, Instruction *InsertBefore = 0);
196194 FreeInst(Value *Ptr, BasicBlock *InsertAfter);
231229 #endif
232230 }
233231 void AssertOK();
234 protected:
235 static void destroyThis(LoadInst* v) {
236 UnaryInstruction::destroyThis(v);
237 }
238 friend class Value;
239232 public:
240233 LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBefore);
241234 LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAtEnd);
311304 #endif
312305 }
313306 void AssertOK();
314 protected:
315 static void destroyThis(StoreInst* v) {
316 Instruction::destroyThis(v);
317 }
318 friend class Value;
319307 public:
320308 StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore);
321309 StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd);
454442 }
455443 }
456444
457 protected:
458 static void destroyThis(GetElementPtrInst*v);
459 friend class Value;
460445 public:
461446 /// Constructors - Create a getelementptr instruction with a base pointer an
462447 /// list of indices. The first ctor can optionally insert before an existing
491476 const std::string &Name = "", Instruction *InsertBefore =0);
492477 GetElementPtrInst(Value *Ptr, Value *Idx,
493478 const std::string &Name, BasicBlock *InsertAtEnd);
479 ~GetElementPtrInst();
494480
495481 virtual GetElementPtrInst *clone() const;
496482
569555 /// vectors of integrals. The two operands must be the same type.
570556 /// @brief Represent an integer comparison operator.
571557 class ICmpInst: public CmpInst {
572 protected:
573 static void destroyThis(ICmpInst* v) {
574 CmpInst::destroyThis(v);
575 }
576 friend class Value;
577558 public:
578559 /// This enumeration lists the possible predicates for the ICmpInst. The
579560 /// values in the range 0-31 are reserved for FCmpInst while values in the
730711 /// vectors of floating point values. The operands must be identical types.
731712 /// @brief Represents a floating point comparison operator.
732713 class FCmpInst: public CmpInst {
733 protected:
734 static void destroyThis(FCmpInst* v) {
735 CmpInst::destroyThis(v);
736 }
737 friend class Value;
738714 public:
739715 /// This enumeration lists the possible predicates for the FCmpInst. Values
740716 /// in the range 0-31 are reserved for FCmpInst.
880856 setName(Name);
881857 }
882858
883 protected:
884 static void destroyThis(CallInst*v);
885 friend class Value;
886859 public:
887860 /// Construct a CallInst given a range of arguments. InputIterator
888861 /// must be a random-access iterator pointing to contiguous storage
923896 explicit CallInst(Value *F, const std::string &Name = "",
924897 Instruction *InsertBefore = 0);
925898 CallInst(Value *F, const std::string &Name, BasicBlock *InsertAtEnd);
899 ~CallInst();
926900
927901 virtual CallInst *clone() const;
928902
1014988 : Instruction(SI.getType(), SI.getOpcode(), Ops, 3) {
1015989 init(SI.Ops[0], SI.Ops[1], SI.Ops[2]);
1016990 }
1017 protected:
1018 static void destroyThis(SelectInst* v) {
1019 Instruction::destroyThis(v);
1020 }
1021 friend class Value;
1022991 public:
1023992 SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "",
1024993 Instruction *InsertBefore = 0)
10741043 class VAArgInst : public UnaryInstruction {
10751044 VAArgInst(const VAArgInst &VAA)
10761045 : UnaryInstruction(VAA.getType(), VAArg, VAA.getOperand(0)) {}
1077 protected:
1078 static void destroyThis(VAArgInst* v) {
1079 UnaryInstruction::destroyThis(v);
1080 }
1081 friend class Value;
10821046 public:
10831047 VAArgInst(Value *List, const Type *Ty, const std::string &Name = "",
10841048 Instruction *InsertBefore = 0)
11181082 Ops[1].init(EE.Ops[1], this);
11191083 }
11201084
1121 protected:
1122 static void destroyThis(ExtractElementInst* v) {
1123 Instruction::destroyThis(v);
1124 }
1125 friend class Value;
11261085 public:
11271086 ExtractElementInst(Value *Vec, Value *Idx, const std::string &Name = "",
11281087 Instruction *InsertBefore = 0);
11701129 class InsertElementInst : public Instruction {
11711130 Use Ops[3];
11721131 InsertElementInst(const InsertElementInst &IE);
1173 protected:
1174 static void destroyThis(InsertElementInst* v) {
1175 Instruction::destroyThis(v);
1176 }
1177 friend class Value;
11781132 public:
11791133 InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
11801134 const std::string &Name = "",Instruction *InsertBefore = 0);
12291183 class ShuffleVectorInst : public Instruction {
12301184 Use Ops[3];
12311185 ShuffleVectorInst(const ShuffleVectorInst &IE);
1232 protected:
1233 static void destroyThis(ShuffleVectorInst* v) {
1234 Instruction::destroyThis(v);
1235 }
1236 friend class Value;
12371186 public:
12381187 ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
12391188 const std::string &Name = "", Instruction *InsertBefor = 0);
12881237 /// the number actually in use.
12891238 unsigned ReservedSpace;
12901239 PHINode(const PHINode &PN);
1291 protected:
1292 static void destroyThis(PHINode*);
1293 friend class Value;
12941240 public:
12951241 explicit PHINode(const Type *Ty, const std::string &Name = "",
12961242 Instruction *InsertBefore = 0)
13041250 ReservedSpace(0) {
13051251 setName(Name);
13061252 }
1253
1254 ~PHINode();
13071255
13081256 /// reserveOperandSpace - This method can be used to avoid repeated
13091257 /// reallocation of PHI operand lists by reserving space for the correct
15731521 SwitchInst(const SwitchInst &RI);
15741522 void init(Value *Value, BasicBlock *Default, unsigned NumCases);
15751523 void resizeOperands(unsigned No);
1576 protected:
1577 static void destroyThis(SwitchInst*v);
1578 friend class Value;
15791524 public:
15801525 /// SwitchInst ctor - Create a new switch instruction, specifying a value to
15811526 /// switch on and a default destination. The number of additional cases can
15901535 /// constructor also autoinserts at the end of the specified BasicBlock.
15911536 SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
15921537 BasicBlock *InsertAtEnd);
1538 ~SwitchInst();
15931539
15941540
15951541 // Accessor Methods for Switch stmt
17171663 setName(Name);
17181664 }
17191665
1720 protected:
1721 static void destroyThis(InvokeInst*v);
1722 friend class Value;
17231666 public:
17241667 /// Construct an InvokeInst given a range of arguments.
17251668 /// InputIterator must be a random-access iterator pointing to
17571700 typename std::iterator_traits::iterator_category());
17581701 }
17591702
1703 ~InvokeInst();
1704
17601705 virtual InvokeInst *clone() const;
17611706
17621707 /// getCallingConv/setCallingConv - Get or set the calling convention of this
19261871 TruncInst(const TruncInst &CI)
19271872 : CastInst(CI.getType(), Trunc, CI.getOperand(0)) {
19281873 }
1929 protected:
1930 static void destroyThis(TruncInst* v) {
1931 CastInst::destroyThis(v);
1932 }
1933 friend class Value;
19341874 public:
19351875 /// @brief Constructor with insert-before-instruction semantics
19361876 TruncInst(
19711911 ZExtInst(const ZExtInst &CI)
19721912 : CastInst(CI.getType(), ZExt, CI.getOperand(0)) {
19731913 }
1974 protected:
1975 static void destroyThis(ZExtInst* v) {
1976 CastInst::destroyThis(v);
1977 }
1978 friend class Value;
19791914 public:
19801915 /// @brief Constructor with insert-before-instruction semantics
19811916 ZExtInst(
20161951 SExtInst(const SExtInst &CI)
20171952 : CastInst(CI.getType(), SExt, CI.getOperand(0)) {
20181953 }
2019 protected:
2020 static void destroyThis(SExtInst* v) {
2021 CastInst::destroyThis(v);
2022 }
2023 friend class Value;
20241954 public:
20251955 /// @brief Constructor with insert-before-instruction semantics
20261956 SExtInst(
20601990 FPTruncInst(const FPTruncInst &CI)
20611991 : CastInst(CI.getType(), FPTrunc, CI.getOperand(0)) {
20621992 }
2063 protected:
2064 static void destroyThis(FPTruncInst* v) {
2065 CastInst::destroyThis(v);
2066 }
2067 friend class Value;
20681993 public:
20691994 /// @brief Constructor with insert-before-instruction semantics
20701995 FPTruncInst(
21042029 FPExtInst(const FPExtInst &CI)
21052030 : CastInst(CI.getType(), FPExt, CI.getOperand(0)) {
21062031 }
2107 protected:
2108 static void destroyThis(FPExtInst* v) {
2109 CastInst::destroyThis(v);
2110 }
2111 friend class Value;
21122032 public:
21132033 /// @brief Constructor with insert-before-instruction semantics
21142034 FPExtInst(
21482068 UIToFPInst(const UIToFPInst &CI)
21492069 : CastInst(CI.getType(), UIToFP, CI.getOperand(0)) {
21502070 }
2151 protected:
2152 static void destroyThis(UIToFPInst* v) {
2153 CastInst::destroyThis(v);
2154 }
2155 friend class Value;
21562071 public:
21572072 /// @brief Constructor with insert-before-instruction semantics
21582073 UIToFPInst(
21922107 SIToFPInst(const SIToFPInst &CI)
21932108 : CastInst(CI.getType(), SIToFP, CI.getOperand(0)) {
21942109 }
2195 protected:
2196 static void destroyThis(SIToFPInst* v) {
2197 CastInst::destroyThis(v);
2198 }
2199 friend class Value;
22002110 public:
22012111 /// @brief Constructor with insert-before-instruction semantics
22022112 SIToFPInst(
22362146 FPToUIInst(const FPToUIInst &CI)
22372147 : CastInst(CI.getType(), FPToUI, CI.getOperand(0)) {
22382148 }
2239 protected:
2240 static void destroyThis(FPToUIInst* v) {
2241 CastInst::destroyThis(v);
2242 }
2243 friend class Value;
22442149 public:
22452150 /// @brief Constructor with insert-before-instruction semantics
22462151 FPToUIInst(
22802185 FPToSIInst(const FPToSIInst &CI)
22812186 : CastInst(CI.getType(), FPToSI, CI.getOperand(0)) {
22822187 }
2283 protected:
2284 static void destroyThis(FPToSIInst* v) {
2285 CastInst::destroyThis(v);
2286 }
2287 friend class Value;
22882188 public:
22892189 /// @brief Constructor with insert-before-instruction semantics
22902190 FPToSIInst(
23242224 IntToPtrInst(const IntToPtrInst &CI)
23252225 : CastInst(CI.getType(), IntToPtr, CI.getOperand(0)) {
23262226 }
2327 protected:
2328 static void destroyThis(IntToPtrInst* v) {
2329 CastInst::destroyThis(v);
2330 }
2331 friend class Value;
23322227 public:
23332228 /// @brief Constructor with insert-before-instruction semantics
23342229 IntToPtrInst(
23682263 PtrToIntInst(const PtrToIntInst &CI)
23692264 : CastInst(CI.getType(), PtrToInt, CI.getOperand(0)) {
23702265 }
2371 protected:
2372 static void destroyThis(PtrToIntInst* v) {
2373 CastInst::destroyThis(v);
2374 }
2375 friend class Value;
23762266 public:
23772267 /// @brief Constructor with insert-before-instruction semantics
23782268 PtrToIntInst(
24122302 BitCastInst(const BitCastInst &CI)
24132303 : CastInst(CI.getType(), BitCast, CI.getOperand(0)) {
24142304 }
2415 protected:
2416 static void destroyThis(BitCastInst* v) {
2417 CastInst::destroyThis(v);
2418 }
2419 friend class Value;
24202305 public:
24212306 /// @brief Constructor with insert-before-instruction semantics
24222307 BitCastInst(
3636 ///
3737 unsigned NumOperands;
3838
39 static void destroyThis(User*v) {
40 Value::destroyThis(v);
41 }
42 friend class Value;
4339 public:
4440 User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps)
4541 : Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {}
6565 friend class SymbolTable; // Allow SymbolTable to directly poke Name.
6666 ValueName *Name;
6767
68 private:
6968 void operator=(const Value &); // Do not implement
7069 Value(const Value &); // Do not implement
71 protected:
72 static void destroyThis(Value*);
7370
7471 public:
7572 Value(const Type *Ty, unsigned scid);
2929 return 0;
3030 }
3131
32 DummyInst::DummyInst() : Instruction(Type::VoidTy, OtherOpsEnd, 0, 0) {
33 // This should not be garbage monitored.
34 LeakDetector::removeGarbageObject(this);
32
33 namespace {
34 /// DummyInst - An instance of this class is used to mark the end of the
35 /// instruction list. This is not a real instruction.
36 struct VISIBILITY_HIDDEN DummyInst : public Instruction {
37 DummyInst() : Instruction(Type::VoidTy, OtherOpsEnd, 0, 0) {
38 // This should not be garbage monitored.
39 LeakDetector::removeGarbageObject(this);
40 }
41
42 Instruction *clone() const {
43 assert(0 && "Cannot clone EOL");abort();
44 return 0;
45 }
46 const char *getOpcodeName() const { return "*end-of-list-inst*"; }
47
48 // Methods for support type inquiry through isa, cast, and dyn_cast...
49 static inline bool classof(const DummyInst *) { return true; }
50 static inline bool classof(const Instruction *I) {
51 return I->getOpcode() == OtherOpsEnd;
52 }
53 static inline bool classof(const Value *V) {
54 return isa(V) && classof(cast(V));
55 }
56 };
3557 }
3658
3759 Instruction *ilist_traits::createSentinel() {
6587 }
6688
6789
68 void BasicBlock::destroyThis(BasicBlock*v)
69 {
70 assert(v->getParent() == 0 && "BasicBlock still linked into the program!");
71 v->dropAllReferences();
72 v->InstList.clear();
73 Value::destroyThis(v);
90 BasicBlock::~BasicBlock() {
91 assert(getParent() == 0 && "BasicBlock still linked into the program!");
92 dropAllReferences();
93 InstList.clear();
7494 }
7595
7696 void BasicBlock::setParent(Function *parent) {
355355 }
356356 }
357357
358 void ConstantArray::destroyThis(ConstantArray*v) {
359 delete [] v->OperandList;
360 Constant::destroyThis(v);
358 ConstantArray::~ConstantArray() {
359 delete [] OperandList;
361360 }
362361
363362 ConstantStruct::ConstantStruct(const StructType *T,
379378 }
380379 }
381380
382 void ConstantStruct::destroyThis(ConstantStruct*v) {
383 delete [] v->OperandList;
384 Constant::destroyThis(v);
381 ConstantStruct::~ConstantStruct() {
382 delete [] OperandList;
385383 }
386384
387385
400398 }
401399 }
402400
403 void ConstantVector::destroyThis(ConstantVector*v) {
404 delete [] v->OperandList;
405 Constant::destroyThis(v);
406 }
407
408 UnaryConstantExpr::UnaryConstantExpr(unsigned Opcode,
409 Constant *C, const Type *Ty)
410 : ConstantExpr(Ty, Opcode, &Op, 1), Op(C, this) {
411 }
412
413 SelectConstantExpr::SelectConstantExpr(Constant *C1,
414 Constant *C2, Constant *C3)
415 : ConstantExpr(C2->getType(), Instruction::Select, Ops, 3) {
416 Ops[0].init(C1, this);
417 Ops[1].init(C2, this);
418 Ops[2].init(C3, this);
419 }
420
421 ExtractElementConstantExpr::ExtractElementConstantExpr(Constant *C1,
422 Constant *C2)
423 : ConstantExpr(cast(C1->getType())->getElementType(),
424 Instruction::ExtractElement, Ops, 2) {
425 Ops[0].init(C1, this);
426 Ops[1].init(C2, this);
427 }
428
429 InsertElementConstantExpr::InsertElementConstantExpr(Constant *C1,
430 Constant *C2,
431 Constant *C3)
432 : ConstantExpr(C1->getType(), Instruction::InsertElement, Ops, 3) {
433 Ops[0].init(C1, this);
434 Ops[1].init(C2, this);
435 Ops[2].init(C3, this);
436 }
437
438 ShuffleVectorConstantExpr::ShuffleVectorConstantExpr(Constant *C1,
439 Constant *C2,
440 Constant *C3)
441 : ConstantExpr(C1->getType(), Instruction::ShuffleVector, Ops, 3) {
442 Ops[0].init(C1, this);
443 Ops[1].init(C2, this);
444 Ops[2].init(C3, this);
445 }
446
447 CompareConstantExpr::CompareConstantExpr(unsigned opc, unsigned short pred,
448 Constant* LHS, Constant* RHS)
449 : ConstantExpr(Type::Int1Ty, opc, Ops, 2), predicate(pred) {
450 OperandList[0].init(LHS, this);
451 OperandList[1].init(RHS, this);
452 }
453
454 GetElementPtrConstantExpr::GetElementPtrConstantExpr(Constant *C,
455 const std::vector
456 &IdxList, const Type *DestTy)
457 : ConstantExpr(DestTy, Instruction::GetElementPtr,
458 new Use[IdxList.size()+1], IdxList.size()+1)
459 {
460 OperandList[0].init(C, this);
461 for (unsigned i = 0, E = IdxList.size(); i != E; ++i)
462 OperandList[i+1].init(IdxList[i], this);
463 }
401 ConstantVector::~ConstantVector() {
402 delete [] OperandList;
403 }
404
405 // We declare several classes private to this file, so use an anonymous
406 // namespace
407 namespace {
408
409 /// UnaryConstantExpr - This class is private to Constants.cpp, and is used
410 /// behind the scenes to implement unary constant exprs.
411 class VISIBILITY_HIDDEN UnaryConstantExpr : public ConstantExpr {
412 Use Op;
413 public:
414 UnaryConstantExpr(unsigned Opcode, Constant *C, const Type *Ty)
415 : ConstantExpr(Ty, Opcode, &Op, 1), Op(C, this) {}
416 };
417
418 /// BinaryConstantExpr - This class is private to Constants.cpp, and is used
419 /// behind the scenes to implement binary constant exprs.
420 class VISIBILITY_HIDDEN BinaryConstantExpr : public ConstantExpr {
421 Use Ops[2];
422 public:
423 BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2)
424 : ConstantExpr(C1->getType(), Opcode, Ops, 2) {
425 Ops[0].init(C1, this);
426 Ops[1].init(C2, this);
427 }
428 };
429
430 /// SelectConstantExpr - This class is private to Constants.cpp, and is used
431 /// behind the scenes to implement select constant exprs.
432 class VISIBILITY_HIDDEN SelectConstantExpr : public ConstantExpr {
433 Use Ops[3];
434 public:
435 SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3)
436 : ConstantExpr(C2->getType(), Instruction::Select, Ops, 3) {
437 Ops[0].init(C1, this);
438 Ops[1].init(C2, this);
439 Ops[2].init(C3, this);
440 }
441 };
442
443 /// ExtractElementConstantExpr - This class is private to
444 /// Constants.cpp, and is used behind the scenes to implement
445 /// extractelement constant exprs.
446 class VISIBILITY_HIDDEN ExtractElementConstantExpr : public ConstantExpr {
447 Use Ops[2];
448 public:
449 ExtractElementConstantExpr(Constant *C1, Constant *C2)
450 : ConstantExpr(cast(C1->getType())->getElementType(),
451 Instruction::ExtractElement, Ops, 2) {
452 Ops[0].init(C1, this);
453 Ops[1].init(C2, this);
454 }
455 };
456
457 /// InsertElementConstantExpr - This class is private to
458 /// Constants.cpp, and is used behind the scenes to implement
459 /// insertelement constant exprs.
460 class VISIBILITY_HIDDEN InsertElementConstantExpr : public ConstantExpr {
461 Use Ops[3];
462 public:
463 InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3)
464 : ConstantExpr(C1->getType(), Instruction::InsertElement,
465 Ops, 3) {
466 Ops[0].init(C1, this);
467 Ops[1].init(C2, this);
468 Ops[2].init(C3, this);
469 }
470 };
471
472 /// ShuffleVectorConstantExpr - This class is private to
473 /// Constants.cpp, and is used behind the scenes to implement
474 /// shufflevector constant exprs.
475 class VISIBILITY_HIDDEN ShuffleVectorConstantExpr : public ConstantExpr {
476 Use Ops[3];
477 public:
478 ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3)
479 : ConstantExpr(C1->getType(), Instruction::ShuffleVector,
480 Ops, 3) {
481 Ops[0].init(C1, this);
482 Ops[1].init(C2, this);
483 Ops[2].init(C3, this);
484 }
485 };
486
487 /// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is
488 /// used behind the scenes to implement getelementpr constant exprs.
489 struct VISIBILITY_HIDDEN GetElementPtrConstantExpr : public ConstantExpr {
490 GetElementPtrConstantExpr(Constant *C, const std::vector &IdxList,
491 const Type *DestTy)
492 : ConstantExpr(DestTy, Instruction::GetElementPtr,
493 new Use[IdxList.size()+1], IdxList.size()+1) {
494 OperandList[0].init(C, this);
495 for (unsigned i = 0, E = IdxList.size(); i != E; ++i)
496 OperandList[i+1].init(IdxList[i], this);
497 }
498 ~GetElementPtrConstantExpr() {
499 delete [] OperandList;
500 }
501 };
502
503 // CompareConstantExpr - This class is private to Constants.cpp, and is used
504 // behind the scenes to implement ICmp and FCmp constant expressions. This is
505 // needed in order to store the predicate value for these instructions.
506 struct VISIBILITY_HIDDEN CompareConstantExpr : public ConstantExpr {
507 unsigned short predicate;
508 Use Ops[2];
509 CompareConstantExpr(Instruction::OtherOps opc, unsigned short pred,
510 Constant* LHS, Constant* RHS)
511 : ConstantExpr(Type::Int1Ty, opc, Ops, 2), predicate(pred) {
512 OperandList[0].init(LHS, this);
513 OperandList[1].init(RHS, this);
514 }
515 };
516
517 } // end anonymous namespace
518
464519
465520 // Utility function for determining if a ConstantExpr is a CastOp or not. This
466521 // can't be inline because we don't want to #include Instruction.h into
286286 ParentModule->getFunctionList().push_back(this);
287287 }
288288
289 void Function::destroyThis(Function*v) {
290 v->dropAllReferences(); // After this it is safe to delete instructions.
289 Function::~Function() {
290 dropAllReferences(); // After this it is safe to delete instructions.
291291
292292 // Delete all of the method arguments and unlink from symbol table...
293 v->ArgumentList.clear();
294 delete v->SymTab;
293 ArgumentList.clear();
294 delete SymTab;
295295
296296 // Drop our reference to the parameter attributes, if any.
297 if (v->ParamAttrs)
298 v->ParamAttrs->dropRef();
299 GlobalValue::destroyThis(v);
297 if (ParamAttrs)
298 ParamAttrs->dropRef();
300299 }
301300
302301 void Function::BuildLazyArguments() const {
1515 #include
1616 #include
1717 using namespace llvm;
18
19 // Implement the first virtual method in this class in this file so the
20 // InlineAsm vtable is emitted here.
21 InlineAsm::~InlineAsm() {
22 }
23
1824
1925 // NOTE: when memoizing the function type, we have to be careful to handle the
2026 // case when the type gets refined.
4545
4646
4747 // Out of line virtual method, so the vtable, etc has a home.
48 void Instruction::destroyThis(Instruction*v) {
49 assert(v->Parent == 0 && "Instruction still linked in the program!");
48 Instruction::~Instruction() {
49 assert(Parent == 0 && "Instruction still linked in the program!");
5050 }
5151
5252
6666 }
6767
6868
69
70 //===----------------------------------------------------------------------===//
71 // TerminatorInst Class
72 //===----------------------------------------------------------------------===//
73
74 // Out of line virtual method, so the vtable, etc has a home.
75 TerminatorInst::~TerminatorInst() {
76 }
77
78 // Out of line virtual method, so the vtable, etc has a home.
79 UnaryInstruction::~UnaryInstruction() {
80 }
81
82
6983 //===----------------------------------------------------------------------===//
7084 // PHINode Class
7185 //===----------------------------------------------------------------------===//
8195 }
8296 }
8397
84 void PHINode::destroyThis(PHINode*v) {
85 delete [] v->OperandList;
86 Instruction::destroyThis(v);
98 PHINode::~PHINode() {
99 delete [] OperandList;
87100 }
88101
89102 // removeIncomingValue - Remove an incoming value. This is useful if a
200213 // CallInst Implementation
201214 //===----------------------------------------------------------------------===//
202215
203 void CallInst::destroyThis(CallInst*v) {
204 delete [] v->OperandList;
205 if (v->ParamAttrs)
206 v->ParamAttrs->dropRef();
207 Instruction::destroyThis(v);
216 CallInst::~CallInst() {
217 delete [] OperandList;
218 if (ParamAttrs)
219 ParamAttrs->dropRef();
208220 }
209221
210222 void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) {
393405 // InvokeInst Implementation
394406 //===----------------------------------------------------------------------===//
395407
396 void InvokeInst::destroyThis(InvokeInst*v) {
397 delete [] v->OperandList;
398 if (v->ParamAttrs)
399 v->ParamAttrs->dropRef();
400 TerminatorInst::destroyThis(v);
408 InvokeInst::~InvokeInst() {
409 delete [] OperandList;
410 if (ParamAttrs)
411 ParamAttrs->dropRef();
401412 }
402413
403414 void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
671682 setName(Name);
672683 }
673684
685 // Out of line virtual method, so the vtable, etc has a home.
686 AllocationInst::~AllocationInst() {
687 }
688
674689 bool AllocationInst::isArrayAllocation() const {
675690 if (ConstantInt *CI = dyn_cast(getOperand(0)))
676691 return CI->getZExtValue() != 1;
935950 setName(Name);
936951 }
937952
938 void GetElementPtrInst::destroyThis(GetElementPtrInst*v) {
939 delete[] v->OperandList;
953 GetElementPtrInst::~GetElementPtrInst() {
954 delete[] OperandList;
940955 }
941956
942957 // getIndexedType - Returns the type of the element that would be loaded with
24532468 }
24542469 }
24552470
2456 void SwitchInst::destroyThis(SwitchInst*v) {
2457 delete [] v->OperandList;
2458 TerminatorInst::destroyThis(v);
2471 SwitchInst::~SwitchInst() {
2472 delete [] OperandList;
24592473 }
24602474
24612475
1717 #include "llvm/ValueSymbolTable.h"
1818 #include "llvm/Support/Debug.h"
1919 #include "llvm/Support/LeakDetector.h"
20 #include "llvm/Constants.h"
21 #include "llvm/InlineAsm.h"
22 #include "llvm/Instructions.h"
23 #include "llvm/IntrinsicInst.h"
24 #include "llvm/InstrTypes.h"
2520 #include
2621 using namespace llvm;
2722
4338 "Cannot create non-first-class values except for constants!");
4439 }
4540
46 Value::~Value()
47 {
48 switch(SubclassID)
49 {
50 case ArgumentVal:
51 Argument::destroyThis(cast(this));
52 break;
53 case BasicBlockVal:
54 BasicBlock::destroyThis(cast(this));
55 break;
56 case FunctionVal:
57 Function::destroyThis(cast(this));
58 break;
59 case GlobalAliasVal:
60 GlobalAlias::destroyThis(cast(this));
61 break;
62 case GlobalVariableVal:
63 GlobalVariable::destroyThis(cast(this));
64 break;
65 case UndefValueVal:
66 UndefValue::destroyThis(cast(this));
67 break;
68 case ConstantExprVal:
69 {
70 ConstantExpr* CE = dyn_cast(this);
71 if(CE->getOpcode() == Instruction::GetElementPtr)
72 {
73 GetElementPtrConstantExpr* GECE =
74 dyn_cast(CE);
75 GetElementPtrConstantExpr::destroyThis(GECE);
76 }
77 else if(CE->getOpcode() == Instruction::ExtractElement)
78 {
79 ExtractElementConstantExpr* EECE =
80 dyn_cast(CE);
81 ExtractElementConstantExpr::destroyThis(EECE);
82 }
83 else if(CE->getOpcode() == Instruction::InsertElement)
84 {
85 InsertElementConstantExpr* IECE =
86 dyn_cast(CE);
87 InsertElementConstantExpr::destroyThis(IECE);
88 }
89 else if(CE->getOpcode() == Instruction::Select)
90 {
91 SelectConstantExpr* SCE = dyn_cast(CE);
92 SelectConstantExpr::destroyThis(SCE);
93 }
94 else if(CE->getOpcode() == Instruction::ShuffleVector)
95 {
96 ShuffleVectorConstantExpr* SVCE =
97 dyn_cast(CE);
98 ShuffleVectorConstantExpr::destroyThis(SVCE);
99 }
100 else if(BinaryConstantExpr* BCE = dyn_cast(this))
101 BinaryConstantExpr::destroyThis(BCE);
102 else if(UnaryConstantExpr* UCE = dyn_cast(this))
103 UnaryConstantExpr::destroyThis(UCE);
104 else if(CompareConstantExpr* CCE = dyn_cast(this))
105 CompareConstantExpr::destroyThis(CCE);
106 else
107 assert(0 && "Unknown ConstantExpr-inherited class in ~Value.");
108 }
109 break;
110 case ConstantAggregateZeroVal:
111 ConstantAggregateZero::destroyThis(cast(this));
112 break;
113 case ConstantIntVal:
114 ConstantInt::destroyThis(cast(this));
115 break;
116 case ConstantFPVal:
117 ConstantFP::destroyThis(cast(this));
118 break;
119 case ConstantArrayVal:
120 ConstantArray::destroyThis(cast(this));
121 break;
122 case ConstantStructVal:
123 ConstantStruct::destroyThis(cast(this));
124 break;
125 case ConstantVectorVal:
126 ConstantVector::destroyThis(cast(this));
127 break;
128 case ConstantPointerNullVal:
129 ConstantPointerNull::destroyThis(cast(this));
130 break;
131 case InlineAsmVal:
132 InlineAsm::destroyThis(cast(this));
133 break;
134
135 default:
136 if (BinaryOperator *BO = dyn_cast(this))
137 BinaryOperator::destroyThis(BO);
138 else if (CallInst *CI = dyn_cast(this))
139 CallInst::destroyThis(CI);
140 else if (CmpInst *CI = dyn_cast(this))
141 {
142 if (FCmpInst *FCI = dyn_cast(CI))
143 FCmpInst::destroyThis(FCI);
144 else if (ICmpInst *ICI = dyn_cast(CI))
145 ICmpInst::destroyThis(ICI);
146 else
147 assert(0 && "Unknown CmpInst-inherited class in ~Value.");
148 }
149 else if (ExtractElementInst *EEI = dyn_cast(this))
150 ExtractElementInst::destroyThis(EEI);
151 else if (GetElementPtrInst *GEP = dyn_cast(this))
152 GetElementPtrInst::destroyThis(GEP);
153 else if (InsertElementInst* IE = dyn_cast(this))
154 InsertElementInst::destroyThis(IE);
155 else if (PHINode *PN = dyn_cast(this))
156 PHINode::destroyThis(PN);
157 else if (SelectInst *SI = dyn_cast(this))
158 SelectInst::destroyThis(SI);
159 else if (ShuffleVectorInst *SVI = dyn_cast(this))
160 ShuffleVectorInst::destroyThis(SVI);
161 else if (StoreInst *SI = dyn_cast(this))
162 StoreInst::destroyThis(SI);
163 else if (TerminatorInst *TI = dyn_cast(this))
164 {
165 if (BranchInst* BI = dyn_cast(TI))
166 BranchInst::destroyThis(BI);
167 else if (InvokeInst* II = dyn_cast(TI))
168 InvokeInst::destroyThis(II);
169 else if (ReturnInst* RI = dyn_cast(TI))
170 ReturnInst::destroyThis(RI);
171 else if (SwitchInst *SI = dyn_cast(TI))
172 SwitchInst::destroyThis(SI);
173 else if (UnreachableInst *UI = dyn_cast(TI))
174 UnreachableInst::destroyThis(UI);
175 else if (UnwindInst *UI = dyn_cast(TI))
176 UnwindInst::destroyThis(UI);
177 else
178 assert(0 && "Unknown TerminatorInst-inherited class in ~Value.");
179 } else if(UnaryInstruction* UI = dyn_cast(this)) {
180 if(AllocationInst* AI = dyn_cast(UI)) {
181 if(AllocaInst* AI = dyn_cast(UI))
182 AllocaInst::destroyThis(AI);
183 else if(MallocInst* MI = dyn_cast(UI))
184 MallocInst::destroyThis(MI);
185 else
186 assert(0 && "Unknown AllocationInst-inherited class in ~Value.");
187 } else if(CastInst* CI = dyn_cast(this)) {
188 if(BitCastInst* BCI = dyn_cast(CI))
189 BitCastInst::destroyThis(BCI);
190 else if(FPExtInst* FPEI = dyn_cast(CI))
191 FPExtInst::destroyThis(FPEI);
192 else if(FPToSIInst* FPSII = dyn_cast(CI))
193 FPToSIInst::destroyThis(FPSII);
194 else if(FPToUIInst* FPUII = dyn_cast(CI))
195 FPToUIInst::destroyThis(FPUII);
196 else if(FPTruncInst* FPTI = dyn_cast(CI))
197 FPTruncInst::destroyThis(FPTI);
198 else if(IntToPtrInst* I2PI = dyn_cast(CI))
199 IntToPtrInst::destroyThis(I2PI);
200 else if(PtrToIntInst* P2II = dyn_cast(CI))
201 PtrToIntInst::destroyThis(P2II);
202 else if(SExtInst* SEI = dyn_cast(CI))
203 SExtInst::destroyThis(SEI);
204 else if(SIToFPInst* SIFPI = dyn_cast(CI))
205 SIToFPInst::destroyThis(SIFPI);
206 else if(TruncInst* TI = dyn_cast(CI))
207 TruncInst::destroyThis(TI);
208 else if(UIToFPInst* UIFPI = dyn_cast(CI))
209 UIToFPInst::destroyThis(UIFPI);
210 else if(ZExtInst* ZEI = dyn_cast(CI))
211 ZExtInst::destroyThis(ZEI);
212 else
213 assert(0 && "Unknown CastInst-inherited class in ~Value.");
214 }
215 else if(FreeInst* FI = dyn_cast(this))
216 FreeInst::destroyThis(FI);
217 else if(LoadInst* LI = dyn_cast(this))
218 LoadInst::destroyThis(LI);
219 else if(VAArgInst* VAI = dyn_cast(this))
220 VAArgInst::destroyThis(VAI);
221 else
222 assert(0 && "Unknown UnaryInstruction-inherited class in ~Value.");
223 }
224 else if (DummyInst *DI = dyn_cast(this))
225 DummyInst::destroyThis(DI);
226 else
227 assert(0 && "Unknown Instruction-inherited class in ~Value.");
228 break;
229 }
230 }
231
232 void Value::destroyThis(Value*v)
233 {
41 Value::~Value() {
23442 #ifndef NDEBUG // Only in -g mode...
23543 // Check to make sure that there are no uses of this value that are still
23644 // around when the value is destroyed. If there are, then we have a dangling
23846 // still being referenced. The value in question should be printed as
23947 // a
24048 //
241 if (!v->use_empty()) {
242 DOUT << "While deleting: " << *v->Ty << " %" << v->Name << "\n";
243 for (use_iterator I = v->use_begin(), E = v->use_end(); I != E; ++I)
49 if (!use_empty()) {
50 DOUT << "While deleting: " << *Ty << " %" << Name << "\n";
51 for (use_iterator I = use_begin(), E = use_end(); I != E; ++I)
24452 DOUT << "Use still stuck around after Def is destroyed:"
24553 << **I << "\n";
24654 }
24755 #endif
248 assert(v->use_empty() && "Uses remain when a value is destroyed!");
56 assert(use_empty() && "Uses remain when a value is destroyed!");
24957
25058 // If this value is named, destroy the name. This should not be in a symtab
25159 // at this point.
252 if (v->Name)
253 v->Name->Destroy();
60 if (Name)
61 Name->Destroy();
25462
25563 // There should be no uses of this object anymore, remove it.
256 LeakDetector::removeGarbageObject(v);
64 LeakDetector::removeGarbageObject(this);
25765 }
25866
25967 /// hasNUses - Return true if this Value has exactly N users.