Skip to content

Commit ad4d285

Browse files
committed
[SPGO][Driver] Add lto-sample-profile option for lld-link
SPGO in lto mode, linker needs -lto-sample-profile option to set sample profile file. Linux adds this option by transfering fprofile-sample-use but lld-link on Windows misses the transfering. So add it now.
1 parent ecb7f5a commit ad4d285

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

clang/lib/Driver/ToolChains/MSVC.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
232232
}
233233
}
234234

235+
if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ))
236+
CmdArgs.push_back(Args.MakeArgString(std::string("-lto-sample-profile:") +
237+
A->getValue()));
235238
Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link);
236239

237240
// Control Flow Guard checks

clang/test/Driver/cl-link.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,6 @@
7171
// RUN: %clang_cl -m32 -arch:IA32 --target=i386-pc-win32 /Tc%s -fuse-ld=lld -### -fsanitize=address 2>&1 | FileCheck --check-prefix=INFER-LLD %s
7272
// INFER-LLD: lld-link
7373
// INFER-LLD-NOT: INFERASANLIBS
74+
75+
// RUN: %clang_cl --target=x86_64-unknown-windows-msvc -fuse-ld=lld -### -S -fprofile-sample-use=%S/Inputs/file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-SAMPLE-PROFILE %s
76+
// CHECK-SAMPLE-PROFILE: "-lto-sample-profile:{{.*}}/file.prof"

0 commit comments

Comments
 (0)