[llvm] [LTO] Avoid repeated hash lookups (NFC) (PR #112470)
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 15 21:48:11 PDT 2024
================
@@ -635,11 +635,12 @@ void LTO::addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms,
SymbolResolution Res = *ResI++;
StringRef SymbolName = Sym.getName();
+ auto [It, Inserted] = GlobalResolutions->try_emplace(SymbolName);
// Keep copies of symbols if the client of LTO says so.
- if (GlobalResolutionSymbolSaver && !GlobalResolutions->contains(SymbolName))
+ if (GlobalResolutionSymbolSaver && Inserted)
SymbolName = GlobalResolutionSymbolSaver->save(SymbolName);
- auto &GlobalRes = (*GlobalResolutions)[SymbolName];
+ auto &GlobalRes = It->second;
----------------
teresajohnson wrote:
Is this functionally equivalent? Previously if the GlobalResolutions map didn't contain SymbolName then we got a new SymbolName from the symbol saver and created an entry in GlobalResolutions with that. Now we are only indexing GlobalResolutions with the old SymbolName.
https://github.com/llvm/llvm-project/pull/112470
More information about the llvm-commits
mailing list