forked from OSchip/llvm-project
Allow globals to be of different const'nesses when we link.
This finally resolves PR502, PR450, and test/Regression/Linker/2005-02-12-ConstantGlobals{,-2}.ll correctly llvm-svn: 20135
This commit is contained in:
parent
36f3eb82a1
commit
16277c1775
|
@ -517,18 +517,12 @@ static bool LinkGlobals(Module *Dest, Module *Src,
|
|||
DGV->setLinkage(NewLinkage);
|
||||
|
||||
if (LinkFromSrc) {
|
||||
if (DGV->isConstant() && !SGV->isConstant())
|
||||
return Error(Err, "Global Variable Collision on global '" +
|
||||
SGV->getName() + "': variables differ in const'ness");
|
||||
// Inherit const as appropriate
|
||||
if (SGV->isConstant()) DGV->setConstant(true);
|
||||
DGV->setConstant(SGV->isConstant());
|
||||
DGV->setInitializer(0);
|
||||
} else {
|
||||
if (SGV->isConstant() && !DGV->isConstant()) {
|
||||
if (!DGV->isExternal())
|
||||
return Error(Err, "Global Variable Collision on global '" +
|
||||
SGV->getName() + "': variables differ in const'ness");
|
||||
else
|
||||
if (DGV->isExternal())
|
||||
DGV->setConstant(true);
|
||||
}
|
||||
SGV->setLinkage(GlobalValue::ExternalLinkage);
|
||||
|
|
Loading…
Reference in New Issue