summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2017-05-11 21:14:29 +0000
committerReid Kleckner <rnk@google.com>2017-05-11 21:14:29 +0000
commite7c7854cb1094df582586e2321e18aaebd754b08 (patch)
treecef0648927350653a52daadcb97572163d72d49a /llvm/include
parentaeffffdb44a43a92380052e158b550dfa194414f (diff)
downloadbcm5719-llvm-e7c7854cb1094df582586e2321e18aaebd754b08.tar.gz
bcm5719-llvm-e7c7854cb1094df582586e2321e18aaebd754b08.zip
De-virtualize GlobalValue
The erase/remove from parent methods now use a switch table to remove themselves from their appropriate parent ilist. The copyAttributesFrom method is now completely non-virtual, since we only ever copy attributes from a global of the appropriate type. Pre-requisite to de-virtualizing Value to save a vptr (https://reviews.llvm.org/D31261). NFC llvm-svn: 302823
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/IR/Function.h6
-rw-r--r--llvm/include/llvm/IR/GlobalAlias.h8
-rw-r--r--llvm/include/llvm/IR/GlobalIFunc.h8
-rw-r--r--llvm/include/llvm/IR/GlobalObject.h4
-rw-r--r--llvm/include/llvm/IR/GlobalValue.h8
-rw-r--r--llvm/include/llvm/IR/GlobalVariable.h6
6 files changed, 26 insertions, 14 deletions
diff --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h
index 4e4128138cb..8a2a6ed87eb 100644
--- a/llvm/include/llvm/IR/Function.h
+++ b/llvm/include/llvm/IR/Function.h
@@ -494,7 +494,7 @@ public:
/// copyAttributesFrom - copy all additional attributes (those not needed to
/// create a Function) from the Function Src to this one.
- void copyAttributesFrom(const GlobalValue *Src) override;
+ void copyAttributesFrom(const Function *Src);
/// deleteBody - This method deletes the body of the function, and converts
/// the linkage to external.
@@ -507,12 +507,12 @@ public:
/// removeFromParent - This method unlinks 'this' from the containing module,
/// but does not delete it.
///
- void removeFromParent() override;
+ void removeFromParent();
/// eraseFromParent - This method unlinks 'this' from the containing module
/// and deletes it.
///
- void eraseFromParent() override;
+ void eraseFromParent();
/// Steal arguments from another function.
///
diff --git a/llvm/include/llvm/IR/GlobalAlias.h b/llvm/include/llvm/IR/GlobalAlias.h
index 37a291dfeb7..d4bf0d7e1ed 100644
--- a/llvm/include/llvm/IR/GlobalAlias.h
+++ b/llvm/include/llvm/IR/GlobalAlias.h
@@ -59,15 +59,19 @@ public:
// Linkage, Type, Parent and AddressSpace taken from the Aliasee.
static GlobalAlias *create(const Twine &Name, GlobalValue *Aliasee);
+ void copyAttributesFrom(const GlobalValue *Src) {
+ GlobalValue::copyAttributesFrom(Src);
+ }
+
/// removeFromParent - This method unlinks 'this' from the containing module,
/// but does not delete it.
///
- void removeFromParent() override;
+ void removeFromParent();
/// eraseFromParent - This method unlinks 'this' from the containing module
/// and deletes it.
///
- void eraseFromParent() override;
+ void eraseFromParent();
/// These methods retrieve and set alias target.
void setAliasee(Constant *Aliasee);
diff --git a/llvm/include/llvm/IR/GlobalIFunc.h b/llvm/include/llvm/IR/GlobalIFunc.h
index bfaa9960cb1..d90c7c78ed2 100644
--- a/llvm/include/llvm/IR/GlobalIFunc.h
+++ b/llvm/include/llvm/IR/GlobalIFunc.h
@@ -47,12 +47,16 @@ public:
LinkageTypes Linkage, const Twine &Name,
Constant *Resolver, Module *Parent);
+ void copyAttributesFrom(const GlobalIFunc *Src) {
+ GlobalValue::copyAttributesFrom(Src);
+ }
+
/// This method unlinks 'this' from the containing module, but does not
/// delete it.
- void removeFromParent() final;
+ void removeFromParent();
/// This method unlinks 'this' from the containing module and deletes it.
- void eraseFromParent() final;
+ void eraseFromParent();
/// These methods retrieve and set ifunc resolver function.
void setResolver(Constant *Resolver) {
diff --git a/llvm/include/llvm/IR/GlobalObject.h b/llvm/include/llvm/IR/GlobalObject.h
index f3789bafefe..fc38f698027 100644
--- a/llvm/include/llvm/IR/GlobalObject.h
+++ b/llvm/include/llvm/IR/GlobalObject.h
@@ -150,8 +150,10 @@ public:
void addTypeMetadata(unsigned Offset, Metadata *TypeID);
- void copyAttributesFrom(const GlobalValue *Src) override;
+protected:
+ void copyAttributesFrom(const GlobalObject *Src);
+public:
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const Value *V) {
return V->getValueID() == Value::FunctionVal ||
diff --git a/llvm/include/llvm/IR/GlobalValue.h b/llvm/include/llvm/IR/GlobalValue.h
index bb30fa8be86..b595c225ce8 100644
--- a/llvm/include/llvm/IR/GlobalValue.h
+++ b/llvm/include/llvm/IR/GlobalValue.h
@@ -435,10 +435,12 @@ public:
bool isWeakForLinker() const { return isWeakForLinker(getLinkage()); }
+protected:
/// Copy all additional attributes (those not needed to create a GlobalValue)
/// from the GlobalValue Src to this one.
- virtual void copyAttributesFrom(const GlobalValue *Src);
+ void copyAttributesFrom(const GlobalValue *Src);
+public:
/// If special LLVM prefix that is used to inform the asm printer to not emit
/// usual symbol prefix before the symbol name is used then return linkage
/// name after skipping this special LLVM prefix.
@@ -530,10 +532,10 @@ public:
/// This method unlinks 'this' from the containing module, but does not delete
/// it.
- virtual void removeFromParent() = 0;
+ void removeFromParent();
/// This method unlinks 'this' from the containing module and deletes it.
- virtual void eraseFromParent() = 0;
+ void eraseFromParent();
/// Get the module that this global value is contained inside of...
Module *getParent() { return Parent; }
diff --git a/llvm/include/llvm/IR/GlobalVariable.h b/llvm/include/llvm/IR/GlobalVariable.h
index c25e08059ce..21d334c8f01 100644
--- a/llvm/include/llvm/IR/GlobalVariable.h
+++ b/llvm/include/llvm/IR/GlobalVariable.h
@@ -158,17 +158,17 @@ public:
/// copyAttributesFrom - copy all additional attributes (those not needed to
/// create a GlobalVariable) from the GlobalVariable Src to this one.
- void copyAttributesFrom(const GlobalValue *Src) override;
+ void copyAttributesFrom(const GlobalVariable *Src);
/// removeFromParent - This method unlinks 'this' from the containing module,
/// but does not delete it.
///
- void removeFromParent() override;
+ void removeFromParent();
/// eraseFromParent - This method unlinks 'this' from the containing module
/// and deletes it.
///
- void eraseFromParent() override;
+ void eraseFromParent();
/// Drop all references in preparation to destroy the GlobalVariable. This
/// drops not only the reference to the initializer but also to any metadata.
OpenPOWER on IntegriCloud