<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, May 31, 2018 at 12:00 PM Peter Collingbourne <<a href="mailto:peter@pcc.me.uk">peter@pcc.me.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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="m_1837013143587697986gmail-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/D47597</a><br>
<br>
Files:<br>
  clang/lib/CodeGen/BackendUtil.cpp<br>
  clang/test/CodeGen/thinlto-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>
===================================================================<br>
--- llvm/lib/LTO/LTOBackend.cpp<br>
+++ llvm/lib/LTO/LTOBackend.cpp<br>
@@ -291,14 +291,19 @@<br>
     return;<br>
<br>
   std::unique_ptr<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_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.SplitDwarfFile = DwoFile.str().str();<br>
     DwoOut = llvm::make_unique<ToolOutputFile>(DwoFile, EC, sys::fs::F_None);<br>
     if (EC)<br>
Index: llvm/include/llvm/LTO/Config.h<br>
===================================================================<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-split-dwarf.c<br>
===================================================================<br>
--- /dev/null<br>
+++ clang/test/CodeGen/thinlto-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.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.</div></div></div></div></blockquote><div><br></div><div>Regarding this - the parsing support is coming along, slowly but surely. I'd say I am about 75% done.</div><div>Teresa</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> 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="m_1837013143587697986gmail-"><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.cpp<br>
===================================================================<br>
--- clang/lib/CodeGen/BackendUtil.cpp<br>
+++ clang/lib/CodeGen/BackendUtil.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="m_1837013143587697986gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Teresa Johnson |</td><td style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"> 408-460-2413</td></tr></tbody></table></span></div></div>