having weak or linkonce or common or extweak LLVM linkage.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53158
91177308-0d34-0410-b5e6-
96231b3b80d8
void setLinkage(LinkageTypes LT) { Linkage = LT; }
LinkageTypes getLinkage() const { return Linkage; }
void setLinkage(LinkageTypes LT) { Linkage = LT; }
LinkageTypes getLinkage() const { return Linkage; }
+ /// isWeakForLinker - Determines if symbol is weak for linker having weak or
+ /// linkonce or common or extweak LLVM linkage.
+ bool isWeakForLinker() const {
+ return (Linkage == WeakLinkage ||
+ Linkage == LinkOnceLinkage ||
+ Linkage == CommonLinkage ||
+ Linkage == ExternalWeakLinkage);
+ }
+
/// copyAttributesFrom - copy all additional attributes (those not needed to
/// create a GlobalValue) from the GlobalValue Src to this one.
virtual void copyAttributesFrom(const GlobalValue *Src);
/// copyAttributesFrom - copy all additional attributes (those not needed to
/// create a GlobalValue) from the GlobalValue Src to this one.
virtual void copyAttributesFrom(const GlobalValue *Src);
"': can only link appending global with another appending global!");
LinkFromSrc = true; // Special cased.
LT = Src->getLinkage();
"': can only link appending global with another appending global!");
LinkFromSrc = true; // Special cased.
LT = Src->getLinkage();
- } else if (Src->hasWeakLinkage() || Src->hasLinkOnceLinkage() ||
- Src->hasCommonLinkage()) {
+ } else if (Src->isWeakForLinker()) {
// At this point we know that Dest has LinkOnce, External*, Weak, Common,
// or DLL* linkage.
// At this point we know that Dest has LinkOnce, External*, Weak, Common,
// or DLL* linkage.
- if ((Dest->hasLinkOnceLinkage() &&
+ if ((Dest->hasLinkOnceLinkage() &&
(Src->hasWeakLinkage() || Src->hasCommonLinkage())) ||
Dest->hasExternalWeakLinkage()) {
LinkFromSrc = true;
(Src->hasWeakLinkage() || Src->hasCommonLinkage())) ||
Dest->hasExternalWeakLinkage()) {
LinkFromSrc = true;
LinkFromSrc = false;
LT = Dest->getLinkage();
}
LinkFromSrc = false;
LT = Dest->getLinkage();
}
- } else if (Dest->hasWeakLinkage() || Dest->hasLinkOnceLinkage() ||
- Dest->hasCommonLinkage()) {
+ } else if (Dest->isWeakForLinker()) {
// At this point we know that Src has External* or DLL* linkage.
if (Src->hasExternalWeakLinkage()) {
LinkFromSrc = false;
// At this point we know that Src has External* or DLL* linkage.
if (Src->hasExternalWeakLinkage()) {
LinkFromSrc = false;
} else if (GlobalVariable *DGVar = dyn_cast_or_null<GlobalVariable>(DGV)) {
// The only allowed way is to link alias with external declaration or weak
// symbol..
} else if (GlobalVariable *DGVar = dyn_cast_or_null<GlobalVariable>(DGV)) {
// The only allowed way is to link alias with external declaration or weak
// symbol..
- if (DGVar->isDeclaration() ||
- DGVar->hasWeakLinkage() ||
- DGVar->hasLinkOnceLinkage() ||
- DGVar->hasCommonLinkage()) {
+ if (DGVar->isDeclaration() || DGVar->isWeakForLinker()) {
// But only if aliasee is global too...
if (!isa<GlobalVariable>(DAliasee))
return Error(Err, "Global-Alias Collision on '" + SGA->getName() +
// But only if aliasee is global too...
if (!isa<GlobalVariable>(DAliasee))
return Error(Err, "Global-Alias Collision on '" + SGA->getName() +
} else if (Function *DF = dyn_cast_or_null<Function>(DGV)) {
// The only allowed way is to link alias with external declaration or weak
// symbol...
} else if (Function *DF = dyn_cast_or_null<Function>(DGV)) {
// The only allowed way is to link alias with external declaration or weak
// symbol...
- if (DF->isDeclaration() ||
- DF->hasWeakLinkage() ||
- DF->hasLinkOnceLinkage() ||
- DF->hasCommonLinkage()) {
+ if (DF->isDeclaration() || DF->isWeakForLinker()) {
// But only if aliasee is function too...
if (!isa<Function>(DAliasee))
return Error(Err, "Function-Alias Collision on '" + SGA->getName() +
// But only if aliasee is function too...
if (!isa<Function>(DAliasee))
return Error(Err, "Function-Alias Collision on '" + SGA->getName() +
if (DGV->getInitializer() != SInit)
return Error(Err, "Global Variable Collision on '" + SGV->getName() +
"': global variables have different initializers");
if (DGV->getInitializer() != SInit)
return Error(Err, "Global Variable Collision on '" + SGV->getName() +
"': global variables have different initializers");
- } else if (DGV->hasLinkOnceLinkage() || DGV->hasWeakLinkage() ||
- DGV->hasCommonLinkage()) {
+ } else if (DGV->isWeakForLinker()) {
// Nothing is required, mapped values will take the new global
// automatically.
// Nothing is required, mapped values will take the new global
// automatically.
- } else if (SGV->hasLinkOnceLinkage() || SGV->hasWeakLinkage() ||
- SGV->hasCommonLinkage()) {
+ } else if (SGV->isWeakForLinker()) {
// Nothing is required, mapped values will take the new global
// automatically.
} else if (DGV->hasAppendingLinkage()) {
// Nothing is required, mapped values will take the new global
// automatically.
} else if (DGV->hasAppendingLinkage()) {
// The only valid mappings are:
// - SF is external declaration, which is effectively a no-op.
// - SF is weak, when we just need to throw SF out.
// The only valid mappings are:
// - SF is external declaration, which is effectively a no-op.
// - SF is weak, when we just need to throw SF out.
- if (!SF->isDeclaration() &&
- !SF->hasWeakLinkage() &&
- !SF->hasLinkOnceLinkage() &&
- !SF->hasCommonLinkage())
+ if (!SF->isDeclaration() && !SF->isWeakForLinker())
return Error(Err, "Function-Alias Collision on '" + SF->getName() +
"': symbol multiple defined");
return Error(Err, "Function-Alias Collision on '" + SF->getName() +
"': symbol multiple defined");
}
// At this point we know that DF has LinkOnce, Weak, or External* linkage.
}
// At this point we know that DF has LinkOnce, Weak, or External* linkage.
- if (SF->hasWeakLinkage() || SF->hasLinkOnceLinkage() ||
- SF->hasCommonLinkage()) {
+ if (SF->isWeakForLinker()) {
ValueMap[SF] = MappedDF;
// Linkonce+Weak = Weak
// *+External Weak = *
ValueMap[SF] = MappedDF;
// Linkonce+Weak = Weak
// *+External Weak = *
- if ((DF->hasLinkOnceLinkage() &&
+ if ((DF->hasLinkOnceLinkage() &&
(SF->hasWeakLinkage() || SF->hasCommonLinkage())) ||
DF->hasExternalWeakLinkage())
DF->setLinkage(SF->getLinkage());
continue;
}
(SF->hasWeakLinkage() || SF->hasCommonLinkage())) ||
DF->hasExternalWeakLinkage())
DF->setLinkage(SF->getLinkage());
continue;
}
- if (DF->hasWeakLinkage() || DF->hasLinkOnceLinkage() ||
- DF->hasCommonLinkage()) {
+ if (DF->isWeakForLinker()) {
// At this point we know that SF has LinkOnce or External* linkage.
ValueMap[SF] = MappedDF;
// At this point we know that SF has LinkOnce or External* linkage.
ValueMap[SF] = MappedDF;