[llvm] r255538 - Add missing vtable anchor's.
Pete Cooper via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 14 12:29:16 PST 2015
Author: pete
Date: Mon Dec 14 14:29:16 2015
New Revision: 255538
URL: http://llvm.org/viewvc/llvm-project?rev=255538&view=rev
Log:
Add missing vtable anchor's.
The following description is from http://reviews.llvm.org/D15481:
ICmpInst, GetElementPtrInst and PHINode have no anchor functions. This causes the vtable and the type info (if RTTI is enabled in user code) to be emitted in multiple translation units.
Before 3.7, the destructors were the key functions for these nodes, but they have been removed.
There have been discussions about this here: http://lists.llvm.org/pipermail/llvm-dev/2015-August/089010.html and here: http://lists.llvm.org/pipermail/llvm-dev/2015-December/092921.html.
Patch by Visoiu Mistrih Francis
Modified:
llvm/trunk/include/llvm/IR/Instructions.h
llvm/trunk/lib/IR/Instructions.cpp
Modified: llvm/trunk/include/llvm/IR/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Instructions.h?rev=255538&r1=255537&r2=255538&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Instructions.h (original)
+++ llvm/trunk/include/llvm/IR/Instructions.h Mon Dec 14 14:29:16 2015
@@ -839,6 +839,8 @@ class GetElementPtrInst : public Instruc
Type *SourceElementType;
Type *ResultElementType;
+ void anchor() override;
+
GetElementPtrInst(const GetElementPtrInst &GEPI);
void init(Value *Ptr, ArrayRef<Value *> IdxList, const Twine &NameStr);
@@ -1097,6 +1099,8 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(Get
/// must be identical types.
/// \brief Represent an integer comparison operator.
class ICmpInst: public CmpInst {
+ void anchor() override;
+
void AssertOK() {
assert(getPredicate() >= CmpInst::FIRST_ICMP_PREDICATE &&
getPredicate() <= CmpInst::LAST_ICMP_PREDICATE &&
@@ -2426,6 +2430,8 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(Ins
// scientist's overactive imagination.
//
class PHINode : public Instruction {
+ void anchor() override;
+
void *operator new(size_t, unsigned) = delete;
/// ReservedSpace - The number of operands actually allocated. NumOperands is
/// the number actually in use.
Modified: llvm/trunk/lib/IR/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instructions.cpp?rev=255538&r1=255537&r2=255538&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instructions.cpp (original)
+++ llvm/trunk/lib/IR/Instructions.cpp Mon Dec 14 14:29:16 2015
@@ -87,6 +87,8 @@ const char *SelectInst::areInvalidOperan
// PHINode Class
//===----------------------------------------------------------------------===//
+void PHINode::anchor() {}
+
PHINode::PHINode(const PHINode &PN)
: Instruction(PN.getType(), Instruction::PHI, nullptr, PN.getNumOperands()),
ReservedSpace(PN.getNumOperands()) {
@@ -1503,6 +1505,8 @@ FenceInst::FenceInst(LLVMContext &C, Ato
// GetElementPtrInst Implementation
//===----------------------------------------------------------------------===//
+void GetElementPtrInst::anchor() {}
+
void GetElementPtrInst::init(Value *Ptr, ArrayRef<Value *> IdxList,
const Twine &Name) {
assert(getNumOperands() == 1 + IdxList.size() &&
@@ -3389,6 +3393,8 @@ CmpInst::Predicate CmpInst::getInversePr
}
}
+void ICmpInst::anchor() {}
+
ICmpInst::Predicate ICmpInst::getSignedPredicate(Predicate pred) {
switch (pred) {
default: llvm_unreachable("Unknown icmp predicate!");
More information about the llvm-commits
mailing list