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];