+ DGV->setLinkage(SGV->getLinkage()); // Inherit linkage!
+ } 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() ||
+ SGV->getInitializer() != DGV->getInitializer())
+ return Error(Err, "Global Variable Collision on '" +
+ SGV->getType()->getDescription() + " %" + SGV->getName() +
+ "' - Global variables differ in const'ness");
+ ValueMap.insert(std::make_pair(SGV, DGV));
+ } else if (SGV->hasLinkOnceLinkage()) {
+ // If the global variable has a name, and that name is already in use in
+ // the Dest module, make sure that the name is a compatible global
+ // variable...
+ //
+ // Check to see if the two GV's have the same Const'ness...
+ if (SGV->isConstant() != DGV->isConstant())
+ return Error(Err, "Global Variable Collision on '" +
+ SGV->getType()->getDescription() + " %" + SGV->getName() +
+ "' - Global variables differ in const'ness");
+
+ // Okay, everything is cool, remember the mapping...
+ ValueMap.insert(std::make_pair(SGV, DGV));
+ } else if (SGV->hasAppendingLinkage()) {
+ assert(0 && "FIXME: Appending linkage unimplemented!");
+ } else {
+ assert(0 && "Unknown linkage!");