Skip to content

Commit

Permalink
[lld] Add --lto-emit-asm and alias --plugin-opt=emit-llvm to it (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
jhuber6 authored Jul 2, 2024
1 parent 59f4267 commit 93e0ffa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lld/ELF/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion lld/ELF/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -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>">,
Expand Down Expand Up @@ -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=">;
Expand Down
1 change: 1 addition & 0 deletions lld/test/ELF/lto/emit-llvm.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 93e0ffa

Please sign in to comment.