[llvm-branch-commits] [llvm-branch] r134471 - /llvm/branches/type-system-rewrite/lib/Linker/LinkModules.cpp
Chris Lattner
sabre at nondot.org
Tue Jul 5 23:06:58 PDT 2011
Author: lattner
Date: Wed Jul 6 01:06:58 2011
New Revision: 134471
URL: http://llvm.org/viewvc/llvm-project?rev=134471&view=rev
Log:
instead of explictly having the linker manage the unnamed_addr bit, just
let copyAttributesFrom do it. Change linkFromSource to respect the
unnamed_addr bit of the source, eliminate some explicit visibility processing
that we handle by copyAttributesFrom already.
Modified:
llvm/branches/type-system-rewrite/lib/Linker/LinkModules.cpp
Modified: llvm/branches/type-system-rewrite/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/type-system-rewrite/lib/Linker/LinkModules.cpp?rev=134471&r1=134470&r2=134471&view=diff
==============================================================================
--- llvm/branches/type-system-rewrite/lib/Linker/LinkModules.cpp (original)
+++ llvm/branches/type-system-rewrite/lib/Linker/LinkModules.cpp Wed Jul 6 01:06:58 2011
@@ -589,11 +589,11 @@
GlobalVariable *NewDGV =
new GlobalVariable(*DstM, TypeMap.get(SGV->getType()->getElementType()),
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
- SGV->getName(), 0, SGV->isThreadLocal(),
+ SGV->getName(), /*insertbefore*/0,
+ SGV->isThreadLocal(),
SGV->getType()->getAddressSpace());
// Propagate alignment, visibility and section info.
CopyGVAttributes(NewDGV, SGV);
- NewDGV->setUnnamedAddr(SGV->hasUnnamedAddr());
// If the LLVM runtime renamed the global, but it is an externally visible
// symbol, DGV must be an existing global with internal linkage. Rename
@@ -611,16 +611,9 @@
if (getLinkageResult(DGV, SGV, NewLinkage, LinkFromSrc))
return true;
- // If the visibilities of the symbols disagree and the destination is a
- // prototype, take the visibility of its input.
- if (DGV->isDeclaration())
- DGV->setVisibility(SGV->getVisibility());
-
if (DGV->hasAppendingLinkage())
return linkAppendingVars(cast<GlobalVariable>(DGV), SGV);
- bool HasUnnamedAddr = SGV->hasUnnamedAddr() && DGV->hasUnnamedAddr();
-
if (LinkFromSrc) {
if (isa<GlobalAlias>(DGV))
return emitError("Global alias collision on '" + SGV->getName() +
@@ -636,11 +629,9 @@
DGV->getName(), 0, false,
SGV->getType()->getAddressSpace());
- // Set the unnamed_addr.
- NewDGV->setUnnamedAddr(HasUnnamedAddr);
-
- // Propagate alignment, section, and visibility info.
+ // Propagate alignment, section, visibility info, unnamed_addr, etc.
CopyGVAttributes(NewDGV, SGV);
+
DGV->replaceAllUsesWith(ConstantExpr::getBitCast(NewDGV, DGV->getType()));
// DGV will conflict with NewDGV because they both had the same
@@ -681,9 +672,8 @@
"': symbol multiple defined");
}
- // Set calculated linkage and unnamed_addr
+ // Set calculated linkage and unnamed_addr.
DGV->setLinkage(NewLinkage);
- DGV->setUnnamedAddr(HasUnnamedAddr);
// Make sure to remember this mapping...
ValueMap[SGV] = ConstantExpr::getBitCast(DGV, SGV->getType());
More information about the llvm-branch-commits
mailing list