summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2015-12-14 20:29:16 +0000
committerPete Cooper <peter_cooper@apple.com>2015-12-14 20:29:16 +0000
commit1d07869c29b1631b74d9ee2b4e66e66ce35fd2e0 (patch)
tree462d2756d51c2eeaf190d926637b4dcacd0c5be7
parent8d73bdb316e518b4efc586f804ab7cd67b66ed3d (diff)
downloadbcm5719-llvm-1d07869c29b1631b74d9ee2b4e66e66ce35fd2e0.tar.gz
bcm5719-llvm-1d07869c29b1631b74d9ee2b4e66e66ce35fd2e0.zip
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 llvm-svn: 255538
-rw-r--r--llvm/include/llvm/IR/Instructions.h6
-rw-r--r--llvm/lib/IR/Instructions.cpp6
2 files changed, 12 insertions, 0 deletions
diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h
index 805a95ea473..d781c7af36d 100644
--- a/llvm/include/llvm/IR/Instructions.h
+++ b/llvm/include/llvm/IR/Instructions.h
@@ -839,6 +839,8 @@ class GetElementPtrInst : public Instruction {
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(GetElementPtrInst, Value)
/// 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(InsertValueInst, Value)
// 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.
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 5863456adfc..fb04aa52845 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -87,6 +87,8 @@ const char *SelectInst::areInvalidOperands(Value *Op0, Value *Op1, Value *Op2) {
// 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, AtomicOrdering Ordering,
// 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::getInversePredicate(Predicate pred) {
}
}
+void ICmpInst::anchor() {}
+
ICmpInst::Predicate ICmpInst::getSignedPredicate(Predicate pred) {
switch (pred) {
default: llvm_unreachable("Unknown icmp predicate!");
OpenPOWER on IntegriCloud