yunlian updated this revision to Diff 152120.
yunlian added a comment.

Removed redundant 'if' statement


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 -o a.out 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR < %t %s
+//
+// CHECK-LINK-DWO-DIR: "-plugin-opt=dwo_dir=DIR{{.*}}a.out_dwo"
+//
+
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -gsplit-dwarf 
-o a.out 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR-DEFAULT < %t %s
+//
+// CHECK-LINK-DWO-DIR-DEFAULT: "-plugin-opt=dwo_dir=a.out_dwo"
Index: lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -416,6 +416,20 @@
       CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt));
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_gsplit_dwarf_EQ)) {
+    StringRef Dwo_Dir = A->getValue();
+    SmallString<1024> DwoDir;
+    llvm::sys::path::native(Dwo_Dir, DwoDir);
+    llvm::sys::path::append(DwoDir, Twine(Output.getFilename()) + "_dwo");
+    CmdArgs.push_back(
+        Args.MakeArgString(Twine("-plugin-opt=dwo_dir=") + DwoDir));
+  }
+  else if (Args.hasArg(options::OPT_gsplit_dwarf)) {
+    CmdArgs.push_back(
+    Args.MakeArgString(Twine("-plugin-opt=dwo_dir=") +
+    Output.getFilename() + "_dwo"));
+  }
+
   if (IsThinLTO)
     CmdArgs.push_back("-plugin-opt=thinlto");
 
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1788,6 +1788,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>,


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 -o a.out 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR < %t %s
+//
+// CHECK-LINK-DWO-DIR: "-plugin-opt=dwo_dir=DIR{{.*}}a.out_dwo"
+//
+
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -gsplit-dwarf -o a.out 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR-DEFAULT < %t %s
+//
+// CHECK-LINK-DWO-DIR-DEFAULT: "-plugin-opt=dwo_dir=a.out_dwo"
Index: lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -416,6 +416,20 @@
       CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt));
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_gsplit_dwarf_EQ)) {
+    StringRef Dwo_Dir = A->getValue();
+    SmallString<1024> DwoDir;
+    llvm::sys::path::native(Dwo_Dir, DwoDir);
+    llvm::sys::path::append(DwoDir, Twine(Output.getFilename()) + "_dwo");
+    CmdArgs.push_back(
+        Args.MakeArgString(Twine("-plugin-opt=dwo_dir=") + DwoDir));
+  }
+  else if (Args.hasArg(options::OPT_gsplit_dwarf)) {
+    CmdArgs.push_back(
+    Args.MakeArgString(Twine("-plugin-opt=dwo_dir=") +
+    Output.getFilename() + "_dwo"));
+  }
+
   if (IsThinLTO)
     CmdArgs.push_back("-plugin-opt=thinlto");
 
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1788,6 +1788,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>,
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to