summaryrefslogtreecommitdiff
path: root/lib/Linker
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-09-04 14:05:09 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-09-04 14:05:09 +0000
commit3acfb58b178d25b0671cbfb4fb20194e62b01a98 (patch)
tree1b6ba566a1add527ad299539e8c7d08b018eaa7a /lib/Linker
parent0415b1810bbf93f434f1c561e172bf24c1cb37dc (diff)
downloadllvm-3acfb58b178d25b0671cbfb4fb20194e62b01a98.tar.gz
llvm-3acfb58b178d25b0671cbfb4fb20194e62b01a98.tar.bz2
llvm-3acfb58b178d25b0671cbfb4fb20194e62b01a98.tar.xz
Fix linking of unnamed_addr.
This was regression from r134829. When linking we have to be conservative. If one of the symbols has a significant address, then the result should have it too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189935 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker')
-rw-r--r--lib/Linker/LinkModules.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index f32211245f..ab37b8b12f 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -746,6 +746,7 @@ bool ModuleLinker::linkAppendingVarProto(GlobalVariable *DstGV,
bool ModuleLinker::linkGlobalProto(GlobalVariable *SGV) {
GlobalValue *DGV = getLinkedToGlobal(SGV);
llvm::Optional<GlobalValue::VisibilityTypes> NewVisibility;
+ bool HasUnnamedAddr = SGV->hasUnnamedAddr();
if (DGV) {
// Concatenation of appending linkage variables is magic and handled later.
@@ -755,6 +756,7 @@ bool ModuleLinker::linkGlobalProto(GlobalVariable *SGV) {
// Determine whether linkage of these two globals follows the source
// module's definition or the destination module's definition.
GlobalValue::LinkageTypes NewLinkage = GlobalValue::InternalLinkage;
+ HasUnnamedAddr = HasUnnamedAddr && DGV->hasUnnamedAddr();
GlobalValue::VisibilityTypes NV;
bool LinkFromSrc = false;
if (getLinkageResult(DGV, SGV, NewLinkage, NV, LinkFromSrc))
@@ -768,10 +770,11 @@ bool ModuleLinker::linkGlobalProto(GlobalVariable *SGV) {
if (GlobalVariable *DGVar = dyn_cast<GlobalVariable>(DGV))
if (DGVar->isDeclaration() && SGV->isConstant() && !DGVar->isConstant())
DGVar->setConstant(true);
-
- // Set calculated linkage and visibility.
+
+ // Set calculated linkage, visibility and unnamed_addr.
DGV->setLinkage(NewLinkage);
DGV->setVisibility(*NewVisibility);
+ DGV->setUnnamedAddr(HasUnnamedAddr);
// Make sure to remember this mapping.
ValueMap[SGV] = ConstantExpr::getBitCast(DGV,TypeMap.get(SGV->getType()));
@@ -797,6 +800,7 @@ bool ModuleLinker::linkGlobalProto(GlobalVariable *SGV) {
copyGVAttributes(NewDGV, SGV);
if (NewVisibility)
NewDGV->setVisibility(*NewVisibility);
+ NewDGV->setUnnamedAddr(HasUnnamedAddr);
if (DGV) {
DGV->replaceAllUsesWith(ConstantExpr::getBitCast(NewDGV, DGV->getType()));