Index: lib/Linker/IRMover.cpp =================================================================== --- lib/Linker/IRMover.cpp +++ lib/Linker/IRMover.cpp @@ -388,7 +388,6 @@ /// due to the use of Value handles which the Linker doesn't actually need, /// but this allows us to reuse the ValueMapper code. ValueToValueMapTy ValueMap; - ValueToValueMapTy AliasValueMap; DenseSet ValuesToLink; std::vector Worklist; @@ -1056,15 +1055,15 @@ bool ShouldLink = shouldLink(DGV, *SGV); - // just missing from map + /// First verify if the value hasn't been alreay linked, which should not be + /// possible without ShouldLink if (ShouldLink) { auto I = ValueMap.find(SGV); if (I != ValueMap.end()) return cast(I->second); - - I = AliasValueMap.find(SGV); - if (I != AliasValueMap.end()) - return cast(I->second); + } else { + assert(ValueMap.find(SGV) == ValueMap.end() && + "'!ShouldLink' GV shouldn't be in the ValueMap, broken invariant"); } if (!ShouldLink && ForAlias) @@ -1196,7 +1195,7 @@ void IRLinker::linkAliasBody(GlobalAlias &Dst, GlobalAlias &Src) { Constant *Aliasee = Src.getAliasee(); - Constant *Val = MapValue(Aliasee, AliasValueMap, ValueMapperFlags, &TypeMap, + Constant *Val = MapValue(Aliasee, ValueMap, ValueMapperFlags, &TypeMap, &LValMaterializer); Dst.setAliasee(Val); } @@ -1555,8 +1554,7 @@ Worklist.pop_back(); // Already mapped. - if (ValueMap.find(GV) != ValueMap.end() || - AliasValueMap.find(GV) != AliasValueMap.end()) + if (ValueMap.find(GV) != ValueMap.end()) continue; assert(!GV->isDeclaration());