-
- GlobalVariable *DGV =
- cast<GlobalVariable>(ValueMap[SGV]->stripPointerCasts());
- if (DGV->hasInitializer()) {
- if (SGV->hasExternalLinkage()) {
- if (DGV->getInitializer() != SInit)
- return Error(Err, "Global Variable Collision on '" + SGV->getName() +
- "': global variables have different initializers");
- } else if (DGV->mayBeOverridden()) {
- // Nothing is required, mapped values will take the new global
- // automatically.
- } else if (SGV->mayBeOverridden()) {
- // Nothing is required, mapped values will take the new global
- // automatically.
- } else if (DGV->hasAppendingLinkage()) {
- assert(0 && "Appending linkage unimplemented!");
+ // Grab destination global variable or alias.
+ GlobalValue *DGV = cast<GlobalValue>(ValueMap[SGV]->stripPointerCasts());
+
+ // If dest if global variable, check that initializers match.
+ if (GlobalVariable *DGVar = dyn_cast<GlobalVariable>(DGV)) {
+ if (DGVar->hasInitializer()) {
+ if (SGV->hasExternalLinkage()) {
+ if (DGVar->getInitializer() != SInit)
+ return Error(Err, "Global Variable Collision on '" +
+ SGV->getName() +
+ "': global variables have different initializers");
+ } else if (DGVar->mayBeOverridden()) {
+ // Nothing is required, mapped values will take the new global
+ // automatically.
+ } else if (SGV->mayBeOverridden()) {
+ // Nothing is required, mapped values will take the new global
+ // automatically.
+ } else if (DGVar->hasAppendingLinkage()) {
+ assert(0 && "Appending linkage unimplemented!");
+ } else {
+ assert(0 && "Unknown linkage!");
+ }