<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 31, 2018 at 11:54 AM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><br><div class="gmail_quote"><div><div class="gmail-h5"><div dir="ltr">On Thu, May 31, 2018 at 11:20 AM Peter Collingbourne via Phabricator <<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">pcc created this revision.<br>
pcc added reviewers: tejohnson, dblaikie.<br>
Herald added subscribers: JDevlieghere, hiraditya, eraman, inglorion, mehdi_amini.<br>
<br>
<a href="https://reviews.llvm.org/D47597" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D47597</a><br>
<br>
Files:<br>
  clang/lib/CodeGen/BackendUtil.<wbr>cpp<br>
  clang/test/CodeGen/thinlto-<wbr>split-dwarf.c<br>
  llvm/include/llvm/LTO/Config.h<br>
  llvm/lib/LTO/LTOBackend.cpp<br>
<br>
<br>
Index: llvm/lib/LTO/LTOBackend.cpp<br>
==============================<wbr>==============================<wbr>=======<br>
--- llvm/lib/LTO/LTOBackend.cpp<br>
+++ llvm/lib/LTO/LTOBackend.cpp<br>
@@ -291,14 +291,19 @@<br>
     return;<br>
<br>
   std::unique_ptr<<wbr>ToolOutputFile> DwoOut;<br>
+  SmallString<1024> DwoFile(Conf.DwoPath);<br>
   if (!Conf.DwoDir.empty()) {<br>
     std::error_code EC;<br>
     if (auto EC = llvm::sys::fs::create_<wbr>directories(Conf.DwoDir))<br>
       report_fatal_error("Failed to create directory " + Conf.DwoDir + ": " +<br>
                          EC.message());<br>
<br>
-    SmallString<1024> DwoFile(Conf.DwoDir);<br>
+    DwoFile = Conf.DwoDir;<br>
     sys::path::append(DwoFile, std::to_string(Task) + ".dwo");<br>
+  }<br>
+<br>
+  if (!DwoFile.empty()) {<br>
+    std::error_code EC;<br>
     TM->Options.MCOptions.<wbr>SplitDwarfFile = DwoFile.str().str();<br>
     DwoOut = llvm::make_unique<<wbr>ToolOutputFile>(DwoFile, EC, sys::fs::F_None);<br>
     if (EC)<br>
Index: llvm/include/llvm/LTO/Config.h<br>
==============================<wbr>==============================<wbr>=======<br>
--- llvm/include/llvm/LTO/Config.h<br>
+++ llvm/include/llvm/LTO/Config.h<br>
@@ -76,6 +76,11 @@<br>
   /// The directory to store .dwo files.<br>
   std::string DwoDir;<br>
<br>
+  /// The path to write a .dwo file to. This should generally only be used when<br>
+  /// running an individual backend directly via thinBackend(), as otherwise<br>
+  /// all .dwo files will be written to the same path.<br>
+  std::string DwoPath;<br>
+<br>
   /// Optimization remarks file path.<br>
   std::string RemarksFilename = "";<br>
<br>
Index: clang/test/CodeGen/thinlto-<wbr>split-dwarf.c<br>
==============================<wbr>==============================<wbr>=======<br>
--- /dev/null<br>
+++ clang/test/CodeGen/thinlto-<wbr>split-dwarf.c<br>
@@ -0,0 +1,21 @@<br>
+// REQUIRES: x86-registered-target<br>
+<br>
+// RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux-gnu \<br>
+// RUN:   -flto=thin -emit-llvm-bc \<br>
+// RUN:   -o %t.o %s<br>
+<br>
+// RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \<br>
+// RUN:   -o %t2.index \<br>
+// RUN:   -r=%t.o,main,px<br>
+<br>
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \<br>
+// RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.<wbr>bc \<br>
+// RUN:   -o %t.native.o -split-dwarf-file %t.native.dwo -x ir %t.o<br></blockquote></div></div><div><br>Can this be written in a single IR file yet (rather than frontend compiling, indexing, then backend compiling), now that Teresa's implemented some of the summary IR syntax?<br></div></div></div></blockquote><div><br></div><div>I think the parsing part isn't implemented yet, so that wouldn't work. Besides, we would need two separate files anyway: the bitcode file (%t.o) and the combined summary (%t.o.thinlto.bc).</div><div><br></div><div>Peter</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div> </div><span class="gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+// RUN: llvm-readobj -sections %t.native.o | FileCheck --check-prefix=O %s<br>
+// RUN: llvm-readobj -sections %t.native.dwo | FileCheck --check-prefix=DWO %s<br>
+<br>
+// O-NOT: .dwo<br>
+// DWO: .dwo<br>
+<br>
+int main() {}<br>
Index: clang/lib/CodeGen/BackendUtil.<wbr>cpp<br>
==============================<wbr>==============================<wbr>=======<br>
--- clang/lib/CodeGen/BackendUtil.<wbr>cpp<br>
+++ clang/lib/CodeGen/BackendUtil.<wbr>cpp<br>
@@ -1161,6 +1161,7 @@<br>
   Conf.DebugPassManager = CGOpts.DebugPassManager;<br>
   Conf.RemarksWithHotness = CGOpts.DiagnosticsWithHotness;<br>
   Conf.RemarksFilename = CGOpts.OptRecordFile;<br>
+  Conf.DwoPath = CGOpts.SplitDwarfFile;<br>
   switch (Action) {<br>
   case Backend_EmitNothing:<br>
     Conf.PreCodeGenModuleHook = [](size_t Task, const Module &Mod) {<br>
<br>
<br>
</blockquote></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div></div>