Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang/lib/Driver/ToolChains/MSVC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
}
}

if (C.getDriver().isUsingLTO()) {
if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use getLastProfileSampleUseArg

CmdArgs.push_back(Args.MakeArgString(std::string("-lto-sample-profile:") +
A->getValue()));
}
Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link);

// Control Flow Guard checks
Expand Down
3 changes: 3 additions & 0 deletions clang/test/Driver/cl-link.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 -flto -fuse-ld=lld -### -S -fprofile-sample-use=%S/Inputs/file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-SAMPLE-PROFILE %s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use /Tc%s?
-S should be removed.
It's option for linker. I suggest first compile it to .obj then check it when using clang_cl to invoke linker.

// CHECK-SAMPLE-PROFILE: "-lto-sample-profile:{{.*}}/file.prof"