[PATCH] D23681: [LTO] Add the ability to test -thinlto-emit-imports-files through llvm-lto2

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 18 11:10:14 PDT 2016


mehdi_amini created this revision.
mehdi_amini added a reviewer: tejohnson.
mehdi_amini added a subscriber: llvm-commits.
Herald added a subscriber: mehdi_amini.

Start bringing llvm-lto2 to a level where we can test the LTO API
a bit deeper.

https://reviews.llvm.org/D23681

Files:
  test/tools/llvm-lto2/Inputs/thinlto_emit_imports.ll
  test/tools/llvm-lto2/thinlto_emit_imports.ll
  tools/llvm-lto2/llvm-lto2.cpp

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<bool> SaveTemps("save-temps", cl::desc("Save temporary files"));
 
+static cl::opt<bool> EmitImportFiles("thinlto-emit-imports-files",
+                                     cl::init(false),
+                                     cl::desc("Emit import files for the "
+                                              "distributed backend case"));
+
+static cl::opt<int> Threads("-thinlto-threads",
+                            cl::init(thread::hardware_concurrency()));
+
 static cl::list<std::string> 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) {
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: 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
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23681.68575.patch
Type: text/x-patch
Size: 2644 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160818/a5a76a82/attachment.bin>


More information about the llvm-commits mailing list