Index: include/llvm/Transforms/IPO/FunctionImport.h =================================================================== --- include/llvm/Transforms/IPO/FunctionImport.h +++ include/llvm/Transforms/IPO/FunctionImport.h @@ -42,7 +42,7 @@ /// The map contains an entry for every module to import from, the key being /// the module identifier to pass to the ModuleLoader. The value is the set of /// functions to import. - using ImportMapTy = StringMap; + using ImportMapTy = std::map; /// The set contains an entry for every global value the module exports. using ExportSetTy = std::unordered_set; Index: lib/LTO/LTO.cpp =================================================================== --- lib/LTO/LTO.cpp +++ lib/LTO/LTO.cpp @@ -151,7 +151,7 @@ // imported symbols for each module may affect code generation and is // sensitive to link order, so include that as well. for (auto &Entry : ImportList) { - auto ModHash = Index.getModuleHash(Entry.first()); + auto ModHash = Index.getModuleHash(Entry.first); Hasher.update(ArrayRef((uint8_t *)&ModHash[0], sizeof(ModHash))); AddUint64(Entry.second.size()); @@ -221,7 +221,7 @@ // so we need to collect their used resolutions as well. for (auto &ImpM : ImportList) for (auto &ImpF : ImpM.second) - AddUsedThings(Index.findSummaryInModule(ImpF.first, ImpM.first())); + AddUsedThings(Index.findSummaryInModule(ImpF.first, ImpM.first)); auto AddTypeIdSummary = [&](StringRef TId, const TypeIdSummary &S) { AddString(TId); Index: lib/LTO/ThinLTOCodeGenerator.cpp =================================================================== --- lib/LTO/ThinLTOCodeGenerator.cpp +++ lib/LTO/ThinLTOCodeGenerator.cpp @@ -359,7 +359,7 @@ // Include the hash for every module we import functions from for (auto &Entry : ImportList) { - auto ModHash = Index.getModuleHash(Entry.first()); + auto ModHash = Index.getModuleHash(Entry.first); Hasher.update(ArrayRef((uint8_t *)&ModHash[0], sizeof(ModHash))); } Index: lib/Transforms/IPO/FunctionImport.cpp =================================================================== --- lib/Transforms/IPO/FunctionImport.cpp +++ lib/Transforms/IPO/FunctionImport.cpp @@ -510,7 +510,7 @@ << " vars. Imports from " << ModuleImports.second.size() << " modules.\n"); for (auto &Src : ModuleImports.second) { - auto SrcModName = Src.first(); + auto SrcModName = Src.first; unsigned NumGVSPerMod = numGlobalVarSummaries(Index, Src.second); LLVM_DEBUG(dbgs() << " - " << Src.second.size() - NumGVSPerMod << " functions imported from " << SrcModName << "\n"); @@ -528,7 +528,7 @@ LLVM_DEBUG(dbgs() << "* Module " << ModulePath << " imports from " << ImportList.size() << " modules.\n"); for (auto &Src : ImportList) { - auto SrcModName = Src.first(); + auto SrcModName = Src.first; unsigned NumGVSPerMod = numGlobalVarSummaries(Index, Src.second); LLVM_DEBUG(dbgs() << " - " << Src.second.size() - NumGVSPerMod << " functions imported from " << SrcModName << "\n"); @@ -694,9 +694,9 @@ ModuleToDefinedGVSummaries.lookup(ModulePath); // Include summaries for imports. for (auto &ILI : ImportList) { - auto &SummariesForIndex = ModuleToSummariesForIndex[ILI.first()]; + auto &SummariesForIndex = ModuleToSummariesForIndex[ILI.first]; const auto &DefinedGVSummaries = - ModuleToDefinedGVSummaries.lookup(ILI.first()); + ModuleToDefinedGVSummaries.lookup(ILI.first); for (auto &GI : ILI.second) { const auto &DS = DefinedGVSummaries.find(GI.first); assert(DS != DefinedGVSummaries.end() && @@ -715,7 +715,7 @@ if (EC) return EC; for (auto &ILI : ModuleImports) - ImportsOS << ILI.first() << "\n"; + ImportsOS << ILI.first << "\n"; return std::error_code(); } @@ -884,7 +884,7 @@ // Do the actual import of functions now, one Module at a time std::set ModuleNameOrderedList; for (auto &FunctionsToImportPerModule : ImportList) { - ModuleNameOrderedList.insert(FunctionsToImportPerModule.first()); + ModuleNameOrderedList.insert(FunctionsToImportPerModule.first); } for (auto &Name : ModuleNameOrderedList) { // Get the module for the import Index: test/ThinLTO/X86/Inputs/emit_imports2.ll =================================================================== --- /dev/null +++ test/ThinLTO/X86/Inputs/emit_imports2.ll @@ -0,0 +1,7 @@ +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define void @h() { +entry: + ret void +} Index: test/ThinLTO/X86/emit_imports.ll =================================================================== --- test/ThinLTO/X86/emit_imports.ll +++ test/ThinLTO/X86/emit_imports.ll @@ -1,17 +1,19 @@ ; RUN: opt -module-summary %s -o %t1.bc ; RUN: opt -module-summary %p/Inputs/emit_imports.ll -o %t2.bc +; RUN: opt -module-summary %p/Inputs/emit_imports2.ll -o %t2b.bc ; Include a file with an empty module summary index, to ensure that the expected ; output files are created regardless, for a distributed build system. ; RUN: opt -module-summary %p/Inputs/empty.ll -o %t3.bc ; RUN: rm -f %t3.bc.imports -; RUN: llvm-lto -thinlto-action=thinlink -o %t.index.bc %t1.bc %t2.bc %t3.bc -; RUN: llvm-lto -thinlto-action=emitimports -thinlto-index %t.index.bc %t1.bc %t2.bc %t3.bc +; RUN: llvm-lto -thinlto-action=thinlink -o %t.index.bc %t1.bc %t2.bc %t2b.bc %t3.bc +; RUN: llvm-lto -thinlto-action=emitimports -thinlto-index %t.index.bc %t1.bc %t2.bc %t2b.bc %t3.bc ; The imports file for this module contains the bitcode file for ; Inputs/emit_imports.ll -; RUN: cat %t1.bc.imports | count 1 +; RUN: cat %t1.bc.imports | count 2 ; RUN: cat %t1.bc.imports | FileCheck %s --check-prefix=IMPORTS1 ; IMPORTS1: emit_imports.ll.tmp2.bc +; IMPORTS1: emit_imports.ll.tmp2b.bc ; The imports file for Input/emit_imports.ll is empty as it does not import anything. ; RUN: cat %t2.bc.imports | count 0 @@ -22,13 +24,15 @@ ; RUN: rm -f %t1.thinlto.bc %t1.bc.imports ; RUN: rm -f %t2.thinlto.bc %t2.bc.imports ; RUN: rm -f %t3.bc.thinlto.bc %t3.bc.imports -; RUN: llvm-lto2 run %t1.bc %t2.bc %t3.bc -o %t.o -save-temps \ +; RUN: llvm-lto2 run %t1.bc %t2.bc %t2b.bc %t3.bc -o %t.o -save-temps \ ; RUN: -thinlto-distributed-indexes \ ; RUN: -r=%t1.bc,g, \ +; RUN: -r=%t1.bc,h, \ ; RUN: -r=%t1.bc,f,px \ -; RUN: -r=%t2.bc,g,px +; RUN: -r=%t2.bc,g,px \ +; RUN: -r=%t2b.bc,h,px -; RUN: cat %t1.bc.imports | count 1 +; RUN: cat %t1.bc.imports | count 2 ; RUN: cat %t1.bc.imports | FileCheck %s --check-prefix=IMPORTS1 ; The imports file for Input/emit_imports.ll is empty as it does not import anything. @@ -44,9 +48,11 @@ target triple = "x86_64-unknown-linux-gnu" declare void @g(...) +declare void @h(...) define void @f() { entry: call void (...) @g() + call void (...) @h() ret void }