-
- } else if (SGV->isExternal()) {
- // If SGV is external or if both SGV & DGV are external.. Just link the
- // external globals, we aren't adding anything.
- ValueMap.insert(std::make_pair(SGV, DGV));
-
- } else if (DGV->isExternal()) { // If DGV is external but SGV is not...
- ValueMap.insert(std::make_pair(SGV, DGV));
- DGV->setLinkage(SGV->getLinkage()); // Inherit linkage!
- } else if (SGV->hasWeakLinkage() || SGV->hasLinkOnceLinkage()) {
- // At this point we know that DGV has LinkOnce, Appending, Weak, or
- // External linkage. If DGV is Appending, this is an error.
- if (DGV->hasAppendingLinkage())
- return Error(Err, "Linking globals named '" + SGV->getName() +
- " ' with 'weak' and 'appending' linkage is not allowed!");
-
- if (SGV->isConstant() != DGV->isConstant())
- return Error(Err, "Global Variable Collision on '" +
- SGV->getType()->getDescription() + " %" + SGV->getName() +
- "' - Global variables differ in const'ness");
-
- // Otherwise, just perform the link.
- ValueMap.insert(std::make_pair(SGV, DGV));
-
- // Linkonce+Weak = Weak
- if (DGV->hasLinkOnceLinkage() && SGV->hasWeakLinkage())
- DGV->setLinkage(SGV->getLinkage());
-
- } else if (DGV->hasWeakLinkage() || DGV->hasLinkOnceLinkage()) {
- // At this point we know that SGV has LinkOnce, Appending, or External
- // linkage. If SGV is Appending, this is an error.
- if (SGV->hasAppendingLinkage())
- return Error(Err, "Linking globals named '" + SGV->getName() +
- " ' with 'weak' and 'appending' linkage is not allowed!");
-
- if (SGV->isConstant() != DGV->isConstant())
- return Error(Err, "Global Variable Collision on '" +
- SGV->getType()->getDescription() + " %" + SGV->getName() +
- "' - Global variables differ in const'ness");
-
- if (!SGV->hasLinkOnceLinkage())
- DGV->setLinkage(SGV->getLinkage()); // Inherit linkage!
- ValueMap.insert(std::make_pair(SGV, DGV));
-
- } else if (SGV->getLinkage() != DGV->getLinkage()) {
- return Error(Err, "Global variables named '" + SGV->getName() +
- "' have different linkage specifiers!");
- } else if (SGV->hasExternalLinkage()) {
- // Allow linking two exactly identical external global variables...
- if (SGV->isConstant() != DGV->isConstant())
- return Error(Err, "Global Variable Collision on '" +
- SGV->getType()->getDescription() + " %" + SGV->getName() +
- "' - Global variables differ in const'ness");
-
- if (SGV->getInitializer() != DGV->getInitializer())
- return Error(Err, "Global Variable Collision on '" +
- SGV->getType()->getDescription() + " %" + SGV->getName() +
- "' - External linkage globals have different initializers");
-
- ValueMap.insert(std::make_pair(SGV, DGV));
- } else if (SGV->hasAppendingLinkage()) {