Devirtualizing Value destructor (PR889). Patch by Pawel Kunio!

llvm-svn: 44747
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index 0df0466..84adc50 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -67,20 +67,6 @@
 }
 
 
-
-//===----------------------------------------------------------------------===//
-//                            TerminatorInst Class
-//===----------------------------------------------------------------------===//
-
-// 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() {
-}
-
-
 //===----------------------------------------------------------------------===//
 //                               PHINode Class
 //===----------------------------------------------------------------------===//
@@ -96,8 +82,9 @@
   }
 }
 
-PHINode::~PHINode() {
-  delete [] OperandList;
+void PHINode::destroyThis(PHINode*v) {
+  delete [] v->OperandList;
+  Instruction::destroyThis(v);
 }
 
 // removeIncomingValue - Remove an incoming value.  This is useful if a
@@ -214,10 +201,11 @@
 //                        CallInst Implementation
 //===----------------------------------------------------------------------===//
 
-CallInst::~CallInst() {
-  delete [] OperandList;
-  if (ParamAttrs)
-    ParamAttrs->dropRef();
+void CallInst::destroyThis(CallInst*v) {
+  delete [] v->OperandList;
+  if (v->ParamAttrs)
+    v->ParamAttrs->dropRef();
+  Instruction::destroyThis(v);
 }
 
 void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) {
@@ -406,10 +394,11 @@
 //                        InvokeInst Implementation
 //===----------------------------------------------------------------------===//
 
-InvokeInst::~InvokeInst() {
-  delete [] OperandList;
-  if (ParamAttrs)
-    ParamAttrs->dropRef();
+void InvokeInst::destroyThis(InvokeInst*v) {
+  delete [] v->OperandList;
+  if (v->ParamAttrs)
+    v->ParamAttrs->dropRef();
+  TerminatorInst::destroyThis(v);
 }
 
 void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
@@ -683,10 +672,6 @@
   setName(Name);
 }
 
-// Out of line virtual method, so the vtable, etc has a home.
-AllocationInst::~AllocationInst() {
-}
-
 bool AllocationInst::isArrayAllocation() const {
   if (ConstantInt *CI = dyn_cast<ConstantInt>(getOperand(0)))
     return CI->getZExtValue() != 1;
@@ -951,8 +936,8 @@
   setName(Name);
 }
 
-GetElementPtrInst::~GetElementPtrInst() {
-  delete[] OperandList;
+void GetElementPtrInst::destroyThis(GetElementPtrInst*v) {
+  delete[] v->OperandList;
 }
 
 // getIndexedType - Returns the type of the element that would be loaded with
@@ -2469,8 +2454,9 @@
   }
 }
 
-SwitchInst::~SwitchInst() {
-  delete [] OperandList;
+void SwitchInst::destroyThis(SwitchInst*v) {
+  delete [] v->OperandList;
+  TerminatorInst::destroyThis(v);
 }