Skip to content

Commit 28be6f6

Browse files
mstorsjotstellar
authored andcommitted
[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. (cherry picked from commit d033366)
1 parent 5750be5 commit 28be6f6

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
@@ -448,6 +448,10 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
448448
add("-lto-cs-profile-generate");
449449
if (auto *arg = args.getLastArg(OPT_lto_cs_profile_file))
450450
add("-lto-cs-profile-file:" + StringRef(arg->getValue()));
451+
if (args.hasArg(OPT_plugin_opt_emit_llvm))
452+
add("-lldemit:llvm");
453+
if (args.hasArg(OPT_lto_emit_asm))
454+
add("-lldemit:asm");
451455

452456
if (auto *a = args.getLastArg(OPT_thinlto_cache_dir))
453457
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
@@ -409,6 +409,13 @@ LTO_OPTS: -mllvm:-mcpu=x86-64 -opt:lldlto=2 -dwodir:foo -lto-cs-profile-generate
409409
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
410410
LTO_OPTS2:-opt:lldlto=2 -opt:lldltocgo=1 -lto-cs-profile-generate -lto-cs-profile-file:foo
411411

412+
RUN: ld.lld -### foo.o -m i386pe -plugin-opt=emit-asm 2>&1 | FileCheck -check-prefix=LTO_EMIT_ASM %s
413+
RUN: ld.lld -### foo.o -m i386pe --lto-emit-asm 2>&1 | FileCheck -check-prefix=LTO_EMIT_ASM %s
414+
LTO_EMIT_ASM: -lldemit:asm
415+
416+
RUN: ld.lld -### foo.o -m i386pe -plugin-opt=emit-llvm 2>&1 | FileCheck -check-prefix=LTO_EMIT_LLVM %s
417+
LTO_EMIT_LLVM: -lldemit:llvm
418+
412419
Test GCC specific LTO options that GCC passes unconditionally, that we ignore.
413420

414421
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)