Skip to content

Commit 1a61846

Browse files
committed
Add flto condition for the option.
1 parent ad4d285 commit 1a61846

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

clang/lib/Driver/ToolChains/MSVC.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,11 @@ 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()));
235+
if (C.getDriver().isUsingLTO()) {
236+
if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ))
237+
CmdArgs.push_back(Args.MakeArgString(std::string("-lto-sample-profile:") +
238+
A->getValue()));
239+
}
238240
Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link);
239241

240242
// Control Flow Guard checks

clang/test/Driver/cl-link.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@
7272
// INFER-LLD: lld-link
7373
// INFER-LLD-NOT: INFERASANLIBS
7474

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
75+
// RUN: %clang_cl --target=x86_64-unknown-windows-msvc -flto -fuse-ld=lld -### -S -fprofile-sample-use=%S/Inputs/file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-SAMPLE-PROFILE %s
7676
// CHECK-SAMPLE-PROFILE: "-lto-sample-profile:{{.*}}/file.prof"

0 commit comments

Comments
 (0)