Add -plugin-opt=sample-profile for thinLTO build.

Summary: ThinLTO needs to pass down the sample profile file path to linker.

Reviewers: tejohnson, davidxl, mehdi_amini

Subscribers: bruno, cfe-commits

Differential Revision: https://reviews.llvm.org/D27832

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290919 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dehao Chen 2017-01-04 00:33:23 +00:00
parent d49e17b411
commit ae1bed598a
2 changed files with 16 additions and 0 deletions

View File

@ -2235,6 +2235,15 @@ static void AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
UseSeparateSections)) {
CmdArgs.push_back("-plugin-opt=-data-sections");
}
if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
StringRef FName = A->getValue();
if (!llvm::sys::fs::exists(FName))
D.Diag(diag::err_drv_no_such_file) << FName;
else
CmdArgs.push_back(
Args.MakeArgString(Twine("-plugin-opt=sample-profile=") + FName));
}
}
/// This is a helper function for validating the optional refinement step

View File

@ -0,0 +1,7 @@
// RUN: touch %t.o
//
// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
// RUN: -Wl,-plugin-opt=foo -O3 \
// RUN: -fprofile-sample-use=%s \
// RUN: | FileCheck %s
// CHECK: -plugin-opt=sample-profile=