Skip to content

Commit d033366

Browse files
authored
[LLD] [MinGW] Implement the --lto-emit-asm and -plugin-opt=emit-llvm options (llvm#81475)
These were implemented in the COFF linker in 3923e61 and d12b99a. This matches the corresponding options in the ELF linker.
1 parent d7f59c8 commit d033366

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

lld/MinGW/Driver.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,10 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
451451
add("-lto-cs-profile-generate");
452452
if (auto *arg = args.getLastArg(OPT_lto_cs_profile_file))
453453
add("-lto-cs-profile-file:" + StringRef(arg->getValue()));
454+
if (args.hasArg(OPT_plugin_opt_emit_llvm))
455+
add("-lldemit:llvm");
456+
if (args.hasArg(OPT_lto_emit_asm))
457+
add("-lldemit:asm");
454458

455459
if (auto *a = args.getLastArg(OPT_thinlto_cache_dir))
456460
add("-lldltocache:" + StringRef(a->getValue()));

lld/MinGW/Options.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ def lto_cs_profile_generate: FF<"lto-cs-profile-generate">,
158158
HelpText<"Perform context sensitive PGO instrumentation">;
159159
def lto_cs_profile_file: JJ<"lto-cs-profile-file=">,
160160
HelpText<"Context sensitive profile file path">;
161+
def lto_emit_asm: FF<"lto-emit-asm">,
162+
HelpText<"Emit assembly code">;
161163

162164
def thinlto_cache_dir: JJ<"thinlto-cache-dir=">,
163165
HelpText<"Path to ThinLTO cached object file directory">;
@@ -181,6 +183,9 @@ def: J<"plugin-opt=cs-profile-path=">,
181183
Alias<lto_cs_profile_file>, HelpText<"Alias for --lto-cs-profile-file">;
182184
def plugin_opt_dwo_dir_eq: J<"plugin-opt=dwo_dir=">,
183185
HelpText<"Directory to store .dwo files when LTO and debug fission are used">;
186+
def plugin_opt_emit_asm: F<"plugin-opt=emit-asm">,
187+
Alias<lto_emit_asm>, HelpText<"Alias for --lto-emit-asm">;
188+
def plugin_opt_emit_llvm: F<"plugin-opt=emit-llvm">;
184189
def: J<"plugin-opt=jobs=">, Alias<thinlto_jobs_eq>, HelpText<"Alias for --thinlto-jobs=">;
185190
def plugin_opt_mcpu_eq: J<"plugin-opt=mcpu=">;
186191

lld/test/MinGW/driver.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,13 @@ LTO_OPTS: -mllvm:-mcpu=x86-64 -opt:lldlto=2 -dwodir:foo -lto-cs-profile-generate
415415
RUN: ld.lld -### foo.o -m i386pep --lto-O2 --lto-CGO1 --lto-cs-profile-generate --lto-cs-profile-file=foo 2>&1 | FileCheck -check-prefix=LTO_OPTS2 %s
416416
LTO_OPTS2:-opt:lldlto=2 -opt:lldltocgo=1 -lto-cs-profile-generate -lto-cs-profile-file:foo
417417

418+
RUN: ld.lld -### foo.o -m i386pe -plugin-opt=emit-asm 2>&1 | FileCheck -check-prefix=LTO_EMIT_ASM %s
419+
RUN: ld.lld -### foo.o -m i386pe --lto-emit-asm 2>&1 | FileCheck -check-prefix=LTO_EMIT_ASM %s
420+
LTO_EMIT_ASM: -lldemit:asm
421+
422+
RUN: ld.lld -### foo.o -m i386pe -plugin-opt=emit-llvm 2>&1 | FileCheck -check-prefix=LTO_EMIT_LLVM %s
423+
LTO_EMIT_LLVM: -lldemit:llvm
424+
418425
Test GCC specific LTO options that GCC passes unconditionally, that we ignore.
419426

420427
RUN: ld.lld -### foo.o -m i386pep -plugin /usr/lib/gcc/x86_64-w64-mingw32/10-posix/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-w64-mingw32/10-posix/lto-wrapper -plugin-opt=-fresolution=/tmp/ccM9d4fP.res -plugin-opt=-pass-through=-lmingw32 2> /dev/null

0 commit comments

Comments
 (0)