[PATCH] D44788: Add an option to support debug fission on implicit ThinLTO.

Yunlian Jiang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 5 12:48:59 PDT 2018


yunlian updated this revision to Diff 150028.

https://reviews.llvm.org/D44788

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/lto-dwo.c


Index: test/Driver/lto-dwo.c
===================================================================
--- /dev/null
+++ test/Driver/lto-dwo.c
@@ -0,0 +1,12 @@
+// Confirm that -gsplit-dwarf=DIR is passed to linker
+
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -gsplit-dwarf=DIR 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR < %t %s
+//
+// CHECK-LINK-DWO-DIR: "-plugin-opt=dwo_dir=DIR"
+//
+
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -gsplit-dwarf 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR-DEFAULT < %t %s
+//
+// CHECK-LINK-DWO-DIR-DEFAULT: "-plugin-opt=dwo_dir=."
Index: lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -417,6 +417,19 @@
   if (IsThinLTO)
     CmdArgs.push_back("-plugin-opt=thinlto");
 
+  if (Arg *A = Args.getLastArg(options::OPT_gsplit_dwarf_EQ)) {
+    StringRef DWO_Dir = A->getValue();
+    CmdArgs.push_back(
+        Args.MakeArgString(Twine("-plugin-opt=dwo_dir=") + DWO_Dir));
+  }
+
+  if (Args.hasArg(options::OPT_gsplit_dwarf)) {
+    if (!Args.getLastArg(options::OPT_gsplit_dwarf_EQ)) {
+      CmdArgs.push_back(
+          Args.MakeArgString(Twine("-plugin-opt=dwo_dir=.")));
+    }
+  }
+
   if (unsigned Parallelism = getLTOParallelism(Args, ToolChain.getDriver()))
     CmdArgs.push_back(
         Args.MakeArgString("-plugin-opt=jobs=" + Twine(Parallelism)));
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1762,6 +1762,7 @@
 def gcolumn_info : Flag<["-"], "gcolumn-info">, Group<g_flags_Group>, Flags<[CoreOption]>;
 def gno_column_info : Flag<["-"], "gno-column-info">, Group<g_flags_Group>, Flags<[CoreOption]>;
 def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group<g_flags_Group>;
+def gsplit_dwarf_EQ : Joined<["-"], "gsplit-dwarf=">, Group<g_flags_Group>;
 def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group<g_flags_Group>, Flags<[CC1Option]>;
 def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group<g_flags_Group>;
 def gmodules : Flag <["-"], "gmodules">, Group<gN_Group>,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44788.150028.patch
Type: text/x-patch
Size: 2272 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180605/63150d68/attachment.bin>


More information about the cfe-commits mailing list