[PATCH] D47904: Support option -plugin-opt=dwo_dir=

Yunlian Jiang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 12 09:34:49 PDT 2018


yunlian updated this revision to Diff 155198.
yunlian added a comment.
Herald added a subscriber: eraman.

unittest added


https://reviews.llvm.org/D47904

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/LTO.cpp
  ELF/Options.td
  test/ELF/lto/thinlto-debug-fission.ll


Index: ELF/Options.td
===================================================================
--- ELF/Options.td
+++ ELF/Options.td
@@ -432,6 +432,8 @@
 def: F<"plugin-opt=debug-pass-manager">,
   Alias<lto_debug_pass_manager>, HelpText<"Alias for -lto-debug-pass-manager">;
 def: F<"plugin-opt=disable-verify">, Alias<disable_verify>, HelpText<"Alias for -disable-verify">;
+def plugin_opt_dwo_dir_eq: J<"plugin-opt=dwo_dir=">,
+  HelpText<"Directory to store .dwo files when LTO and debug fission are used">;
 def: J<"plugin-opt=jobs=">, Alias<thinlto_jobs>, HelpText<"Alias for -thinlto-jobs">;
 def: J<"plugin-opt=lto-partitions=">, Alias<lto_partitions>, HelpText<"Alias for -lto-partitions">;
 def plugin_opt_mcpu_eq: J<"plugin-opt=mcpu=">;
Index: ELF/LTO.cpp
===================================================================
--- ELF/LTO.cpp
+++ ELF/LTO.cpp
@@ -99,6 +99,7 @@
   C.SampleProfile = Config->LTOSampleProfile;
   C.UseNewPM = Config->LTONewPassManager;
   C.DebugPassManager = Config->LTODebugPassManager;
+  C.DwoDir = Config->DwoDir;
 
   if (Config->SaveTemps)
     checkError(C.addSaveTemps(Config->OutputFile.str() + ".",
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -727,6 +727,7 @@
   Config->Demangle = Args.hasFlag(OPT_demangle, OPT_no_demangle, true);
   Config->DisableVerify = Args.hasArg(OPT_disable_verify);
   Config->Discard = getDiscard(Args);
+  Config->DwoDir = Args.getLastArgValue(OPT_plugin_opt_dwo_dir_eq);
   Config->DynamicLinker = getDynamicLinker(Args);
   Config->EhFrameHdr =
       Args.hasFlag(OPT_eh_frame_hdr, OPT_no_eh_frame_hdr, false);
Index: ELF/Config.h
===================================================================
--- ELF/Config.h
+++ ELF/Config.h
@@ -80,6 +80,7 @@
   llvm::StringMap<uint64_t> SectionStartMap;
   llvm::StringRef Chroot;
   llvm::StringRef DynamicLinker;
+  llvm::StringRef DwoDir;
   llvm::StringRef Entry;
   llvm::StringRef Emulation;
   llvm::StringRef Fini;
Index: test/ELF/lto/thinlto-debug-fission.ll
===================================================================
--- /dev/null
+++ test/ELF/lto/thinlto-debug-fission.ll
@@ -0,0 +1,21 @@
+; REQUIRES: x86
+
+; RUN: pwd
+; RUN: opt  %s -o %t1.o
+
+; Test to ensure that --plugin-opt=dwo_dir=$DIR creates .dwo files under $DIR
+; RUN: ld.lld --plugin-opt=dwo_dir=%T/dwo -shared %t1.o -o %t2
+; RUN: llvm-readobj -h %T/dwo/0.dwo | FileCheck %s
+
+; CHECK: Format: ELF64-x86-64
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @g(...)
+
+define void @f() {
+entry:
+  call void (...) @g()
+  ret void
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47904.155198.patch
Type: text/x-patch
Size: 2702 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180712/7cd51ad4/attachment.bin>


More information about the llvm-commits mailing list