aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-06-21 16:53:47 +0000
committerChris Lattner <sabre@nondot.org>2006-06-21 16:53:47 +0000
commit70aa33ee37fede7fb84de02daa38557ffd366458 (patch)
tree9f7faee50e86f0107e468ece963a7d71e8c3cbeb
parent0ad19703aef030ff92c7ccd28b741dc2da086e10 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28898 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/ADT/Statistic.h3
-rw-r--r--include/llvm/InstrTypes.h5
-rw-r--r--include/llvm/Instruction.h8
-rw-r--r--include/llvm/Instructions.h5
-rw-r--r--lib/Support/Statistic.cpp4
-rw-r--r--lib/VMCore/Instruction.cpp6
-rw-r--r--lib/VMCore/Instructions.cpp13
7 files changed, 36 insertions, 8 deletions
diff --git a/include/llvm/ADT/Statistic.h b/include/llvm/ADT/Statistic.h
index 69406ac385..dabacf41cf 100644
--- a/include/llvm/ADT/Statistic.h
+++ b/include/llvm/ADT/Statistic.h
@@ -37,7 +37,8 @@ protected:
StatisticBase(const char *name, const char *desc) : Name(name), Desc(desc) {
++NumStats; // Keep track of how many stats are created...
}
- virtual ~StatisticBase() {}
+ // Out of line virtual dtor, to give the vtable etc a home.
+ virtual ~StatisticBase();
// destroy - Called by subclass dtor so that we can still invoke virtual
// functions on the subclass.
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h
index 4f4b9373fc..095adcb3da 100644
--- a/include/llvm/InstrTypes.h
+++ b/include/llvm/InstrTypes.h
@@ -43,6 +43,9 @@ protected:
const std::string &Name, BasicBlock *InsertAtEnd)
: Instruction(Ty, iType, Ops, NumOps, Name, 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;
@@ -96,6 +99,8 @@ protected:
: Instruction(Ty, iType, &Op, 1, Name, IAE), Op(V, this) {
}
public:
+ // Out of line virtual method, so the vtable, etc has a home.
+ ~UnaryInstruction();
// Transparently provide more efficient getOperand methods.
Value *getOperand(unsigned i) const {
diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h
index a5df154740..dd73213878 100644
--- a/include/llvm/Instruction.h
+++ b/include/llvm/Instruction.h
@@ -52,11 +52,9 @@ protected:
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
const std::string &Name, BasicBlock *InsertAtEnd);
public:
-
- ~Instruction() {
- assert(Parent == 0 && "Instruction still linked in the program!");
- }
-
+ // Out of line virtual method, so the vtable, etc has a home.
+ ~Instruction();
+
/// mayWriteToMemory - Return true if this instruction may modify memory.
///
virtual bool mayWriteToMemory() const { return false; }
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h
index 0f92293f20..a3d70f8f14 100644
--- a/include/llvm/Instructions.h
+++ b/include/llvm/Instructions.h
@@ -40,9 +40,10 @@ protected:
const std::string &Name = "", Instruction *InsertBefore = 0);
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.
///
diff --git a/lib/Support/Statistic.cpp b/lib/Support/Statistic.cpp
index f94f246bae..d771f4dcfd 100644
--- a/lib/Support/Statistic.cpp
+++ b/lib/Support/Statistic.cpp
@@ -61,6 +61,10 @@ struct StatRecord {
static std::vector<StatRecord> *AccumStats = 0;
+// Out of line virtual dtor, to give the vtable etc a home.
+StatisticBase::~StatisticBase() {
+}
+
// Print information when destroyed, iff command line option is specified
void StatisticBase::destroy() const {
if (Enabled && hasSomeData()) {
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp
index fe4ba507c1..ab4aaac745 100644
--- a/lib/VMCore/Instruction.cpp
+++ b/lib/VMCore/Instruction.cpp
@@ -43,6 +43,12 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
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);
}
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index ea1008b376..c6730e14c5 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -34,6 +34,8 @@ void CallSite::setCallingConv(unsigned CC) {
}
+
+
//===----------------------------------------------------------------------===//
// TerminatorInst Class
//===----------------------------------------------------------------------===//
@@ -48,6 +50,13 @@ TerminatorInst::TerminatorInst(Instruction::TermOps iType,
: 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 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
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;