Skip to content

Commit 32ff507

Browse files
[LTO] Avoid repeated hash lookups (NFC)
1 parent 4cc6a08 commit 32ff507

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm/lib/LTO/LTO.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,11 +635,12 @@ void LTO::addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms,
635635
SymbolResolution Res = *ResI++;
636636

637637
StringRef SymbolName = Sym.getName();
638+
auto [It, Inserted] = GlobalResolutions->try_emplace(SymbolName);
638639
// Keep copies of symbols if the client of LTO says so.
639-
if (GlobalResolutionSymbolSaver && !GlobalResolutions->contains(SymbolName))
640+
if (GlobalResolutionSymbolSaver && Inserted)
640641
SymbolName = GlobalResolutionSymbolSaver->save(SymbolName);
641642

642-
auto &GlobalRes = (*GlobalResolutions)[SymbolName];
643+
auto &GlobalRes = It->second;
643644
GlobalRes.UnnamedAddr &= Sym.isUnnamedAddr();
644645
if (Res.Prevailing) {
645646
assert(!GlobalRes.Prevailing &&

0 commit comments

Comments
 (0)