[PATCH] D52049: [ThinLTOCodeGenerator] Avoid Rehash StringMap in ThreadPool
Steven Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 13 11:08:51 PDT 2018
steven_wu created this revision.
steven_wu added reviewers: tejohnson, mehdi_amini, kromanova, pcc.
Herald added subscribers: dexonsmith, eraman, inglorion.
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
Repository:
rL LLVM
https://reviews.llvm.org/D52049
Files:
lib/LTO/ThinLTOCodeGenerator.cpp
Index: lib/LTO/ThinLTOCodeGenerator.cpp
===================================================================
--- lib/LTO/ThinLTOCodeGenerator.cpp
+++ lib/LTO/ThinLTOCodeGenerator.cpp
@@ -972,6 +972,15 @@
// Parallel optimizer + codegen
{
+ // Populate the StringMaps to avoid Rehashing in threads.
+ for (auto IndexCount : ModulesOrdering) {
+ auto &ModuleBuffer = Modules[IndexCount];
+ auto ModuleIdentifier = ModuleBuffer.getBufferIdentifier();
+ ExportLists.try_emplace(ModuleIdentifier);
+ ImportLists.try_emplace(ModuleIdentifier);
+ ResolvedODR.try_emplace(ModuleIdentifier);
+ ModuleToDefinedGVSummaries.try_emplace(ModuleIdentifier);
+ }
ThreadPool Pool(ThreadCount);
for (auto IndexCount : ModulesOrdering) {
auto &ModuleBuffer = Modules[IndexCount];
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52049.165335.patch
Type: text/x-patch
Size: 824 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180913/dbf049d0/attachment.bin>
More information about the llvm-commits
mailing list