[llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp Instructions.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Jun 21 09:54:02 PDT 2006



Changes in directory llvm/lib/VMCore:

Instruction.cpp updated: 1.51 -> 1.52
Instructions.cpp updated: 1.38 -> 1.39
---
Log message:

Add some out-of-line virtual dtors so that the class has a "home", preventing
vtables for (e.g.) Instruction from being emitted into every .o file.


---
Diffs of the changes:  (+19 -0)

 Instruction.cpp  |    6 ++++++
 Instructions.cpp |   13 +++++++++++++
 2 files changed, 19 insertions(+)


Index: llvm/lib/VMCore/Instruction.cpp
diff -u llvm/lib/VMCore/Instruction.cpp:1.51 llvm/lib/VMCore/Instruction.cpp:1.52
--- llvm/lib/VMCore/Instruction.cpp:1.51	Fri Apr  7 20:18:18 2006
+++ llvm/lib/VMCore/Instruction.cpp	Wed Jun 21 11:53:47 2006
@@ -43,6 +43,12 @@
   InsertAtEnd->getInstList().push_back(this);
 }
 
+// Out of line virtual method, so the vtable, etc has a home.
+Instruction::~Instruction() {
+  assert(Parent == 0 && "Instruction still linked in the program!");
+}
+
+
 void Instruction::setOpcode(unsigned opc) {
   setValueType(Value::InstructionVal + opc);
 }


Index: llvm/lib/VMCore/Instructions.cpp
diff -u llvm/lib/VMCore/Instructions.cpp:1.38 llvm/lib/VMCore/Instructions.cpp:1.39
--- llvm/lib/VMCore/Instructions.cpp:1.38	Sun May 14 13:34:36 2006
+++ llvm/lib/VMCore/Instructions.cpp	Wed Jun 21 11:53:47 2006
@@ -34,6 +34,8 @@
 }
 
 
+
+
 //===----------------------------------------------------------------------===//
 //                            TerminatorInst Class
 //===----------------------------------------------------------------------===//
@@ -48,6 +50,13 @@
   : Instruction(Type::VoidTy, iType, Ops, NumOps, "", IAE) {
 }
 
+// Out of line virtual method, so the vtable, etc has a home.
+TerminatorInst::~TerminatorInst() {
+}
+
+// Out of line virtual method, so the vtable, etc has a home.
+UnaryInstruction::~UnaryInstruction() {
+}
 
 
 //===----------------------------------------------------------------------===//
@@ -532,6 +541,10 @@
   assert(Ty != Type::VoidTy && "Cannot allocate void!");
 }
 
+// Out of line virtual method, so the vtable, etc has a home.
+AllocationInst::~AllocationInst() {
+}
+
 bool AllocationInst::isArrayAllocation() const {
   if (ConstantUInt *CUI = dyn_cast<ConstantUInt>(getOperand(0)))
     return CUI->getValue() != 1;






More information about the llvm-commits mailing list