Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit d6ac1b4

Browse files
[ThinLTOCodeGenerator] Avoid Rehash StringMap in ThreadPool
Summary: During threaded thinLTO, it is possible that the entry for current module doesn't exist in StringMaps (like ExportLists, ResolvedODR, etc.). Using operator[] might trigger a rehash for the StringMap, which might happen on multiple threads at the same time. rdar://problem/43846199 Reviewers: tejohnson, mehdi_amini, kromanova, pcc Reviewed By: tejohnson Subscribers: dang, inglorion, eraman, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D52049 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342263 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent adbef70 commit d6ac1b4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/LTO/ThinLTOCodeGenerator.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -958,11 +958,15 @@ void ThinLTOCodeGenerator::run() {
958958
// Changes are made in the index, consumed in the ThinLTO backends.
959959
internalizeAndPromoteInIndex(ExportLists, GUIDPreservedSymbols, *Index);
960960

961-
// Make sure that every module has an entry in the ExportLists and
962-
// ResolvedODR maps to enable threaded access to these maps below.
963-
for (auto &DefinedGVSummaries : ModuleToDefinedGVSummaries) {
964-
ExportLists[DefinedGVSummaries.first()];
965-
ResolvedODR[DefinedGVSummaries.first()];
961+
// Make sure that every module has an entry in the ExportLists, ImportList,
962+
// GVSummary and ResolvedODR maps to enable threaded access to these maps
963+
// below.
964+
for (auto &Module : Modules) {
965+
auto ModuleIdentifier = Module.getBufferIdentifier();
966+
ExportLists[ModuleIdentifier];
967+
ImportLists[ModuleIdentifier];
968+
ResolvedODR[ModuleIdentifier];
969+
ModuleToDefinedGVSummaries[ModuleIdentifier];
966970
}
967971

968972
// Compute the ordering we will process the inputs: the rough heuristic here

0 commit comments

Comments
 (0)