[PATCH] D47597: IRGen: Write .dwo files when -split-dwarf-file is used together with -fthinlto-index.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 31 11:31:03 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL333677: IRGen: Write .dwo files when -split-dwarf-file is used together with -fthinlto… (authored by pcc, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47597?vs=149323&id=149326#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47597

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/test/CodeGen/thinlto-split-dwarf.c
  llvm/trunk/include/llvm/LTO/Config.h
  llvm/trunk/lib/LTO/LTOBackend.cpp


Index: llvm/trunk/lib/LTO/LTOBackend.cpp
===================================================================
--- llvm/trunk/lib/LTO/LTOBackend.cpp
+++ llvm/trunk/lib/LTO/LTOBackend.cpp
@@ -291,14 +291,19 @@
     return;
 
   std::unique_ptr<ToolOutputFile> DwoOut;
+  SmallString<1024> DwoFile(Conf.DwoPath);
   if (!Conf.DwoDir.empty()) {
     std::error_code EC;
     if (auto EC = llvm::sys::fs::create_directories(Conf.DwoDir))
       report_fatal_error("Failed to create directory " + Conf.DwoDir + ": " +
                          EC.message());
 
-    SmallString<1024> DwoFile(Conf.DwoDir);
+    DwoFile = Conf.DwoDir;
     sys::path::append(DwoFile, std::to_string(Task) + ".dwo");
+  }
+
+  if (!DwoFile.empty()) {
+    std::error_code EC;
     TM->Options.MCOptions.SplitDwarfFile = DwoFile.str().str();
     DwoOut = llvm::make_unique<ToolOutputFile>(DwoFile, EC, sys::fs::F_None);
     if (EC)
Index: llvm/trunk/include/llvm/LTO/Config.h
===================================================================
--- llvm/trunk/include/llvm/LTO/Config.h
+++ llvm/trunk/include/llvm/LTO/Config.h
@@ -76,6 +76,11 @@
   /// The directory to store .dwo files.
   std::string DwoDir;
 
+  /// The path to write a .dwo file to. This should generally only be used when
+  /// running an individual backend directly via thinBackend(), as otherwise
+  /// all .dwo files will be written to the same path.
+  std::string DwoPath;
+
   /// Optimization remarks file path.
   std::string RemarksFilename = "";
 
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -1161,6 +1161,7 @@
   Conf.DebugPassManager = CGOpts.DebugPassManager;
   Conf.RemarksWithHotness = CGOpts.DiagnosticsWithHotness;
   Conf.RemarksFilename = CGOpts.OptRecordFile;
+  Conf.DwoPath = CGOpts.SplitDwarfFile;
   switch (Action) {
   case Backend_EmitNothing:
     Conf.PreCodeGenModuleHook = [](size_t Task, const Module &Mod) {
Index: cfe/trunk/test/CodeGen/thinlto-split-dwarf.c
===================================================================
--- cfe/trunk/test/CodeGen/thinlto-split-dwarf.c
+++ cfe/trunk/test/CodeGen/thinlto-split-dwarf.c
@@ -0,0 +1,21 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux-gnu \
+// RUN:   -flto=thin -emit-llvm-bc \
+// RUN:   -o %t.o %s
+
+// RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
+// RUN:   -o %t2.index \
+// RUN:   -r=%t.o,main,px
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \
+// RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc \
+// RUN:   -o %t.native.o -split-dwarf-file %t.native.dwo -x ir %t.o
+
+// RUN: llvm-readobj -sections %t.native.o | FileCheck --check-prefix=O %s
+// RUN: llvm-readobj -sections %t.native.dwo | FileCheck --check-prefix=DWO %s
+
+// O-NOT: .dwo
+// DWO: .dwo
+
+int main() {}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47597.149326.patch
Type: text/x-patch
Size: 2961 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180531/bf8bc64b/attachment.bin>


More information about the llvm-commits mailing list