summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-12-02 20:03:17 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-12-02 20:03:17 +0000
commit769efe621ab318cb9e245c613dad5da695316557 (patch)
tree028a3cef6851a8883fa19402ccebb8cf347b6304 /llvm/lib/IR
parent00f2f91af4c7693e10cf70ef271b6cec89696e86 (diff)
downloadbcm5719-llvm-769efe621ab318cb9e245c613dad5da695316557.tar.gz
bcm5719-llvm-769efe621ab318cb9e245c613dad5da695316557.zip
Don't copy information from aliasee to alias.
They are independent. llvm-svn: 254541
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/Function.cpp10
-rw-r--r--llvm/lib/IR/Globals.cpp21
2 files changed, 17 insertions, 14 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 97e2a84a5ce..5e4d2d2054e 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -411,12 +411,14 @@ void Function::clearGC() {
}
}
-/// copyAttributesFrom - copy all additional attributes (those not needed to
-/// create a Function) from the Function Src to this one.
+/// Copy all additional attributes (those not needed to create a Function) from
+/// the Function Src to this one.
void Function::copyAttributesFrom(const GlobalValue *Src) {
- assert(isa<Function>(Src) && "Expected a Function!");
GlobalObject::copyAttributesFrom(Src);
- const Function *SrcF = cast<Function>(Src);
+ const Function *SrcF = dyn_cast<Function>(Src);
+ if (!SrcF)
+ return;
+
setCallingConv(SrcF->getCallingConv());
setAttributes(SrcF->getAttributes());
if (SrcF->hasGC())
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 8fde4b8e9d7..c538c7baa1f 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -97,10 +97,11 @@ void GlobalObject::setGlobalObjectSubClassData(unsigned Val) {
}
void GlobalObject::copyAttributesFrom(const GlobalValue *Src) {
- const auto *GV = cast<GlobalObject>(Src);
- GlobalValue::copyAttributesFrom(GV);
- setAlignment(GV->getAlignment());
- setSection(GV->getSection());
+ GlobalValue::copyAttributesFrom(Src);
+ if (const auto *GV = dyn_cast<GlobalObject>(Src)) {
+ setAlignment(GV->getAlignment());
+ setSection(GV->getSection());
+ }
}
const char *GlobalValue::getSection() const {
@@ -216,14 +217,14 @@ void GlobalVariable::setInitializer(Constant *InitVal) {
}
}
-/// copyAttributesFrom - copy all additional attributes (those not needed to
-/// create a GlobalVariable) from the GlobalVariable Src to this one.
+/// Copy all additional attributes (those not needed to create a GlobalVariable)
+/// from the GlobalVariable Src to this one.
void GlobalVariable::copyAttributesFrom(const GlobalValue *Src) {
- assert(isa<GlobalVariable>(Src) && "Expected a GlobalVariable!");
GlobalObject::copyAttributesFrom(Src);
- const GlobalVariable *SrcVar = cast<GlobalVariable>(Src);
- setThreadLocalMode(SrcVar->getThreadLocalMode());
- setExternallyInitialized(SrcVar->isExternallyInitialized());
+ if (const GlobalVariable *SrcVar = dyn_cast<GlobalVariable>(Src)) {
+ setThreadLocalMode(SrcVar->getThreadLocalMode());
+ setExternallyInitialized(SrcVar->isExternallyInitialized());
+ }
}
OpenPOWER on IntegriCloud