Skip to content

Commit 991154d

Browse files
authored
[LTO] Use .at instead of .lookup to avoid copies. (NFC) (#117888)
`DenseMap::lookup` returns by value (because it default-creates the returned value if the key isn't present in the map), which means that we do a lot of copying here. Since we assert that something is present in the returned value two lines below this call, it's safe to use `.at` here instead. Copying and then destroying dense maps here is responsible for 60% of the time spent in LTO indexing in a large internal build.
1 parent c29e895 commit 991154d

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

llvm/lib/Transforms/IPO/FunctionImport.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,8 +1540,7 @@ void llvm::gatherImportedSummariesForModule(
15401540
auto &SummariesForIndex =
15411541
LookupOrCreate(ModuleToSummariesForIndex, FromModule);
15421542

1543-
const auto &DefinedGVSummaries =
1544-
ModuleToDefinedGVSummaries.lookup(FromModule);
1543+
const auto &DefinedGVSummaries = ModuleToDefinedGVSummaries.at(FromModule);
15451544
const auto &DS = DefinedGVSummaries.find(GUID);
15461545
assert(DS != DefinedGVSummaries.end() &&
15471546
"Expected a defined summary for imported global value");

0 commit comments

Comments
 (0)