Index: test/tools/llvm-lto2/Inputs/thinlto_emit_imports.ll =================================================================== --- /dev/null +++ test/tools/llvm-lto2/Inputs/thinlto_emit_imports.ll @@ -0,0 +1,6 @@ +target triple = "x86_64-apple-macosx10.11.0" + +define void @g() { +entry: + ret void +} Index: test/tools/llvm-lto2/thinlto_emit_imports.ll =================================================================== --- /dev/null +++ test/tools/llvm-lto2/thinlto_emit_imports.ll @@ -0,0 +1,28 @@ +; Generate summary sections and test gold handling. +; RUN: opt -module-summary %s -o %t.o +; RUN: opt -module-summary %p/Inputs/thinlto_emit_imports.ll -o %t2.o + +; Generate imports files for distributed backends. +; RUN: llvm-lto2 -thinlto-emit-imports-files %t.o %t2.o -o %t3 \ +; RUN: -r %t.o,f,plx \ +; RUN: -r %t.o,g,lx \ +; RUN: -r %t2.o,g,plx + +; The imports file for this module contains the bitcode file for +; Inputs/thinlto.ll +; RUN: cat %t.o.imports | count 1 +; RUN: cat %t.o.imports | FileCheck %s --check-prefix=IMPORTS1 +; IMPORTS1: test/tools/llvm-lto2/Output/thinlto_emit_imports.ll.tmp2.o + +; The imports file for Input/thinlto.ll is empty as it does not import anything. +; RUN: cat %t2.o.imports | count 0 + +target triple = "x86_64-apple-macosx10.11.0" + +declare void @g(...) + +define void @f() { +entry: + call void (...) @g() + ret void +} Index: tools/llvm-lto2/llvm-lto2.cpp =================================================================== --- tools/llvm-lto2/llvm-lto2.cpp +++ tools/llvm-lto2/llvm-lto2.cpp @@ -37,6 +37,14 @@ static cl::opt SaveTemps("save-temps", cl::desc("Save temporary files")); +static cl::opt EmitImportFiles("thinlto-emit-imports-files", + cl::init(false), + cl::desc("Emit import files for the " + "distributed backend case")); + +static cl::opt Threads("-thinlto-threads", + cl::init(thread::hardware_concurrency())); + static cl::list SymbolResolutions( "r", cl::desc("Specify a symbol resolution: filename,symbolname,resolution\n" @@ -139,7 +147,12 @@ check(Conf.addSaveTemps(OutputFilename + "."), "Config::addSaveTemps failed"); - LTO Lto(std::move(Conf)); + ThinBackend Backend; + if (EmitImportFiles) + Backend = createWriteIndexesThinBackend("", "", true, ""); + else + Backend = createInProcessThinBackend(Threads); + LTO Lto(std::move(Conf), std::move(Backend)); bool HasErrors = false; for (std::string F : InputFilenames) {