[llvm] [LTO] Avoid repeated hash lookups (NFC) (PR #112470)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 15 23:36:33 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;
----------------
kazutakahirata 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.
Thank you for catching this. You are right. I missed the update to `SymbolName`.
https://github.com/llvm/llvm-project/pull/112470
More information about the llvm-commits
mailing list