Skip to content

Commit 276283d

Browse files
[LLD] [MinGW] Implement the -lto-sample-profile option (#85841)
This has been a supported option for ELF and is added to the COFF Linker in #85701
1 parent 0aa6d57 commit 276283d

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

lld/MinGW/Driver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,8 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
455455
add("-lldemit:llvm");
456456
if (args.hasArg(OPT_lto_emit_asm))
457457
add("-lldemit:asm");
458+
if (auto *arg = args.getLastArg(OPT_lto_sample_profile))
459+
add("-lto-sample-profile:" + StringRef(arg->getValue()));
458460

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

lld/MinGW/Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ def lto_cs_profile_file: JJ<"lto-cs-profile-file=">,
160160
HelpText<"Context sensitive profile file path">;
161161
def lto_emit_asm: FF<"lto-emit-asm">,
162162
HelpText<"Emit assembly code">;
163+
def lto_sample_profile: JJ<"lto-sample-profile=">,
164+
HelpText<"Sample profile file path">;
163165

164166
def thinlto_cache_dir: JJ<"thinlto-cache-dir=">,
165167
HelpText<"Path to ThinLTO cached object file directory">;

lld/test/MinGW/driver.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,9 @@ LTO_EMIT_ASM: -lldemit:asm
422422
RUN: ld.lld -### foo.o -m i386pe -plugin-opt=emit-llvm 2>&1 | FileCheck -check-prefix=LTO_EMIT_LLVM %s
423423
LTO_EMIT_LLVM: -lldemit:llvm
424424

425+
RUN: ld.lld -### foo.o -m i386pep --lto-sample-profile=foo 2>&1 | FileCheck -check-prefix=LTO_SAMPLE_PROFILE %s
426+
LTO_SAMPLE_PROFILE: -lto-sample-profile:foo
427+
425428
Test GCC specific LTO options that GCC passes unconditionally, that we ignore.
426429

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