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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51118 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index 3db5b09..cf4ceaa 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -410,10 +410,12 @@
"': 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 @@
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 @@
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 @@
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())