summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Linker/LinkModules.cpp
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2008-05-14 20:12:51 +0000
committerDale Johannesen <dalej@apple.com>2008-05-14 20:12:51 +0000
commitce4396bc92640e84cb8aa55e424f11341a3f1e3b (patch)
treee49fb307951b1f7cfdf182eee611d01333dc00df /llvm/lib/Linker/LinkModules.cpp
parente94e0f66cdd503e02936f0705ddf74ed9bf44e0c (diff)
downloadbcm5719-llvm-ce4396bc92640e84cb8aa55e424f11341a3f1e3b.tar.gz
bcm5719-llvm-ce4396bc92640e84cb8aa55e424f11341a3f1e3b.zip
Add CommonLinkage; currently tentative definitions
are represented as "weak", but there are subtle differences in some cases on Darwin, so we need both. The intent is that "common" will behave identically to "weak" unless somebody changes their target to do something else. No functional change as yet. llvm-svn: 51118
Diffstat (limited to 'llvm/lib/Linker/LinkModules.cpp')
-rw-r--r--llvm/lib/Linker/LinkModules.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index 3db5b0927c3..cf4ceaac504 100644
--- a/llvm/lib/Linker/LinkModules.cpp
+++ b/llvm/lib/Linker/LinkModules.cpp
@@ -410,10 +410,12 @@ static bool GetLinkageResult(GlobalValue *Dest, const GlobalValue *Src,
"': can only link appending global with another appending global!");
LinkFromSrc = true; // Special cased.
LT = Src->getLinkage();
- } else if (Src->hasWeakLinkage() || Src->hasLinkOnceLinkage()) {
- // At this point we know that Dest has LinkOnce, External*, Weak, or
- // DLL* linkage.
- if ((Dest->hasLinkOnceLinkage() && Src->hasWeakLinkage()) ||
+ } else if (Src->hasWeakLinkage() || Src->hasLinkOnceLinkage() ||
+ Src->hasCommonLinkage()) {
+ // At this point we know that Dest has LinkOnce, External*, Weak, Common,
+ // or DLL* linkage.
+ if ((Dest->hasLinkOnceLinkage() &&
+ (Src->hasWeakLinkage() || Src->hasCommonLinkage())) ||
Dest->hasExternalWeakLinkage()) {
LinkFromSrc = true;
LT = Src->getLinkage();
@@ -421,7 +423,8 @@ static bool GetLinkageResult(GlobalValue *Dest, const GlobalValue *Src,
LinkFromSrc = false;
LT = Dest->getLinkage();
}
- } else if (Dest->hasWeakLinkage() || Dest->hasLinkOnceLinkage()) {
+ } else if (Dest->hasWeakLinkage() || Dest->hasLinkOnceLinkage() ||
+ Dest->hasCommonLinkage()) {
// At this point we know that Src has External* or DLL* linkage.
if (Src->hasExternalWeakLinkage()) {
LinkFromSrc = false;
@@ -792,10 +795,12 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src,
if (DGV->getInitializer() != SInit)
return Error(Err, "Global Variable Collision on '" + SGV->getName() +
"': global variables have different initializers");
- } else if (DGV->hasLinkOnceLinkage() || DGV->hasWeakLinkage()) {
+ } else if (DGV->hasLinkOnceLinkage() || DGV->hasWeakLinkage() ||
+ DGV->hasCommonLinkage()) {
// Nothing is required, mapped values will take the new global
// automatically.
- } else if (SGV->hasLinkOnceLinkage() || SGV->hasWeakLinkage()) {
+ } else if (SGV->hasLinkOnceLinkage() || SGV->hasWeakLinkage() ||
+ SGV->hasCommonLinkage()) {
// Nothing is required, mapped values will take the new global
// automatically.
} else if (DGV->hasAppendingLinkage()) {
@@ -916,16 +921,19 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
DF->setLinkage(SF->getLinkage());
// Visibility of prototype is overridden by vis of definition.
DF->setVisibility(SF->getVisibility());
- } else if (SF->hasWeakLinkage() || SF->hasLinkOnceLinkage()) {
+ } else if (SF->hasWeakLinkage() || SF->hasLinkOnceLinkage() ||
+ SF->hasCommonLinkage()) {
// At this point we know that DF has LinkOnce, Weak, or External* linkage.
ValueMap[SF] = DF;
// Linkonce+Weak = Weak
// *+External Weak = *
- if ((DF->hasLinkOnceLinkage() && SF->hasWeakLinkage()) ||
+ if ((DF->hasLinkOnceLinkage() &&
+ (SF->hasWeakLinkage() || SF->hasCommonLinkage())) ||
DF->hasExternalWeakLinkage())
DF->setLinkage(SF->getLinkage());
- } else if (DF->hasWeakLinkage() || DF->hasLinkOnceLinkage()) {
+ } else if (DF->hasWeakLinkage() || DF->hasLinkOnceLinkage() ||
+ DF->hasCommonLinkage()) {
// At this point we know that SF has LinkOnce or External* linkage.
ValueMap[SF] = DF;
if (!SF->hasLinkOnceLinkage() && !SF->hasExternalWeakLinkage())
OpenPOWER on IntegriCloud