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,16 +1055,10 @@ bool ShouldLink = shouldLink(DGV, *SGV); - // just missing from map - 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); - } + /// First verify if the value hasn't been alreay linked. + auto I = ValueMap.find(SGV); + if (I != ValueMap.end()) + return cast(I->second); if (!ShouldLink && ForAlias) DGV = nullptr; @@ -1196,7 +1189,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 +1548,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());