summaryrefslogtreecommitdiff
path: root/lib/Linker
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-05-06 14:51:36 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-05-06 14:51:36 +0000
commit55ba6a126fbed4f7cce5e727b670bb41ec938321 (patch)
treeffafabd6f3244feae7f62496912ab2084080d913 /lib/Linker
parent3524723195be6132674ed6492355230e35cdfca0 (diff)
downloadllvm-55ba6a126fbed4f7cce5e727b670bb41ec938321.tar.gz
llvm-55ba6a126fbed4f7cce5e727b670bb41ec938321.tar.bz2
llvm-55ba6a126fbed4f7cce5e727b670bb41ec938321.tar.xz
Be more strict about not calling setAlignment on global aliases.
The fact that GlobalAlias::setAlignment exists at all is a side effect of how the classes are organized, it should never be used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208094 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker')
-rw-r--r--lib/Linker/LinkModules.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index 581e8217de..55654ac25d 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -495,10 +495,16 @@ static void forceRenaming(GlobalValue *GV, StringRef Name) {
/// a GlobalValue) from the SrcGV to the DestGV.
static void copyGVAttributes(GlobalValue *DestGV, const GlobalValue *SrcGV) {
// Use the maximum alignment, rather than just copying the alignment of SrcGV.
- unsigned Alignment = std::max(DestGV->getAlignment(), SrcGV->getAlignment());
+ unsigned Alignment;
+ bool IsAlias = isa<GlobalAlias>(DestGV);
+ if (!IsAlias)
+ Alignment = std::max(DestGV->getAlignment(), SrcGV->getAlignment());
+
DestGV->copyAttributesFrom(SrcGV);
- DestGV->setAlignment(Alignment);
-
+
+ if (!IsAlias)
+ DestGV->setAlignment(Alignment);
+
forceRenaming(DestGV, SrcGV->getName());
}