[Driver][MSVC] Pass profile file to lld-link via -lto-sample-profile option (#127442)
In SPGO lto mode, linker needs -lto-sample-profile option to set sample profile file. Linux adds this option by transferring fprofile-sample-use to -plugin-opt=sample-profile=, which is alias of lto-sample-profile. (in clang\lib\Driver\ToolChains\CommonArgs.cpp: tools::addLTOOptions()). But clang on Windows misses the transferring. So add it now.
This commit is contained in:
@@ -232,6 +232,11 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
}
|
||||
}
|
||||
|
||||
if (C.getDriver().isUsingLTO()) {
|
||||
if (Arg *A = tools::getLastProfileSampleUseArg(Args))
|
||||
CmdArgs.push_back(Args.MakeArgString(std::string("-lto-sample-profile:") +
|
||||
A->getValue()));
|
||||
}
|
||||
Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link);
|
||||
|
||||
// Control Flow Guard checks
|
||||
|
||||
@@ -71,3 +71,6 @@
|
||||
// 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
|
||||
// INFER-LLD: lld-link
|
||||
// INFER-LLD-NOT: INFERASANLIBS
|
||||
|
||||
// RUN: %clang_cl --target=x86_64-unknown-windows-msvc /Tc%s -flto -fuse-ld=lld -### -fprofile-sample-use=%S/Inputs/file.prof 2>&1 | FileCheck -check-prefix=CHECK-SAMPLE-PROFILE %s
|
||||
// CHECK-SAMPLE-PROFILE: "-lto-sample-profile:{{.*}}/file.prof"
|
||||
|
||||
Reference in New Issue
Block a user