[PATCH] D52049: [ThinLTOCodeGenerator] Avoid Rehash StringMap in ThreadPool

Steven Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 13 12:06:02 PDT 2018


steven_wu updated this revision to Diff 165345.
steven_wu added a comment.

Fix up my previous patch.

It seems we have already done similar stuff but ModuleToDefinedGVSummaries
doesn't have all the modules so it cannot avoid rehashing.


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
@@ -950,13 +950,6 @@
   // Changes are made in the index, consumed in the ThinLTO backends.
   internalizeAndPromoteInIndex(ExportLists, GUIDPreservedSymbols, *Index);
 
-  // Make sure that every module has an entry in the ExportLists and
-  // ResolvedODR maps to enable threaded access to these maps below.
-  for (auto &DefinedGVSummaries : ModuleToDefinedGVSummaries) {
-    ExportLists[DefinedGVSummaries.first()];
-    ResolvedODR[DefinedGVSummaries.first()];
-  }
-
   // Compute the ordering we will process the inputs: the rough heuristic here
   // is to sort them per size so that the largest module get schedule as soon as
   // possible. This is purely a compile-time optimization.
@@ -972,6 +965,17 @@
 
   // Parallel optimizer + codegen
   {
+    // Make sure that every module has an entry in the ExportLists and
+    // ResolvedODR maps to enable threaded access to these maps below.
+    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.165345.patch
Type: text/x-patch
Size: 1603 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180913/384dc8e0/attachment.bin>


More information about the llvm-commits mailing list