diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-05-06 14:51:36 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-05-06 14:51:36 +0000 |
commit | a7d9c69cc86c563e6b47fea749b6af1d77a3b129 (patch) | |
tree | 552c298ff293d00c51e5ada9bfaa53361a7a2cbe /llvm/lib/Linker/LinkModules.cpp | |
parent | 484033b188c8a5fc245e3f522133038b6a6cb635 (diff) | |
download | bcm5719-llvm-a7d9c69cc86c563e6b47fea749b6af1d77a3b129.tar.gz bcm5719-llvm-a7d9c69cc86c563e6b47fea749b6af1d77a3b129.zip |
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.
llvm-svn: 208094
Diffstat (limited to 'llvm/lib/Linker/LinkModules.cpp')
-rw-r--r-- | llvm/lib/Linker/LinkModules.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index 581e8217dee..55654ac25d6 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/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()); } |