[lld] 93e0ffa - [lld] Add `--lto-emit-asm` and alias `--plugin-opt=emit-llvm` to it (#97469)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 2 13:35:55 PDT 2024


Author: Joseph Huber
Date: 2024-07-02T15:35:51-05:00
New Revision: 93e0ffa790c5f738171ed90004ab2b9e46f8d387

URL: https://github.com/llvm/llvm-project/commit/93e0ffa790c5f738171ed90004ab2b9e46f8d387
DIFF: https://github.com/llvm/llvm-project/commit/93e0ffa790c5f738171ed90004ab2b9e46f8d387.diff

LOG: [lld] Add `--lto-emit-asm` and alias `--plugin-opt=emit-llvm` to it (#97469)

Summary:
The LTO pass currently supporting emitting LTO via the
`--plugin-opt=emit-llvm` option. However, there is a very similar option
called `--lto-emit-asm`. This patch just makes the usage more
consistent and more obvious that emitting LLVM-IR is supported.

Added: 
    

Modified: 
    lld/ELF/Driver.cpp
    lld/ELF/Options.td
    lld/test/ELF/lto/emit-llvm.ll

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 73e260073da0c..a4863d6717efb 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1269,7 +1269,7 @@ static void readConfigs(opt::InputArgList &args) {
   config->dynamicLinker = getDynamicLinker(args);
   config->ehFrameHdr =
       args.hasFlag(OPT_eh_frame_hdr, OPT_no_eh_frame_hdr, false);
-  config->emitLLVM = args.hasArg(OPT_plugin_opt_emit_llvm, false);
+  config->emitLLVM = args.hasArg(OPT_lto_emit_llvm);
   config->emitRelocs = args.hasArg(OPT_emit_relocs);
   config->enableNewDtags =
       args.hasFlag(OPT_enable_new_dtags, OPT_disable_new_dtags, true);

diff  --git a/lld/ELF/Options.td b/lld/ELF/Options.td
index 7d91b02b51079..74733efb28ff5 100644
--- a/lld/ELF/Options.td
+++ b/lld/ELF/Options.td
@@ -614,6 +614,8 @@ def lto_debug_pass_manager: FF<"lto-debug-pass-manager">,
   HelpText<"Debug new pass manager">;
 def lto_emit_asm: FF<"lto-emit-asm">,
   HelpText<"Emit assembly code">;
+def lto_emit_llvm: FF<"lto-emit-llvm">,
+  HelpText<"Emit LLVM-IR bitcode">;
 def lto_newpm_passes: JJ<"lto-newpm-passes=">,
   HelpText<"Passes to run during LTO">;
 def lto_O: JJ<"lto-O">, MetaVarName<"<opt-level>">,
@@ -695,7 +697,8 @@ 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 plugin_opt_emit_asm: F<"plugin-opt=emit-asm">,
   Alias<lto_emit_asm>, HelpText<"Alias for --lto-emit-asm">;
-def plugin_opt_emit_llvm: F<"plugin-opt=emit-llvm">;
+def plugin_opt_emit_llvm: F<"plugin-opt=emit-llvm">,
+  Alias<lto_emit_llvm>, HelpText<"Alias for --lto-emit-llvm">;
 def: J<"plugin-opt=jobs=">, Alias<thinlto_jobs_eq>, 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=">;

diff  --git a/lld/test/ELF/lto/emit-llvm.ll b/lld/test/ELF/lto/emit-llvm.ll
index e80ef570b4e81..01f5a056e0c0d 100644
--- a/lld/test/ELF/lto/emit-llvm.ll
+++ b/lld/test/ELF/lto/emit-llvm.ll
@@ -7,6 +7,7 @@
 ;; Regression test for D112297: bitcode writer used to crash when
 ;; --plugin-opt=emit-llvmis enabled and the output is /dev/null.
 ; RUN: ld.lld --plugin-opt=emit-llvm -mllvm -bitcode-flush-threshold=0 -o /dev/null %t.o
+; RUN: ld.lld --lto-emit-llvm -mllvm -bitcode-flush-threshold=0 -o /dev/null %t.o
 
 ; CHECK: define internal void @main()
 


        


More information about the llvm-commits mailing list