mirror of https://github.com/microsoft/clang.git
[PS4][Profile] add "--dependent-lib=libclang_rt.profile-x86_64.a" to
the CC1 command line when enabling code coverage. Patch by Ying Yi! Differential Revision: http://reviews.llvm.org/D15222 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255784 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7e2c203014
commit
8d64ddfb20
|
@ -3198,6 +3198,23 @@ static void addPGOAndCoverageFlags(Compilation &C, const Driver &D,
|
|||
}
|
||||
}
|
||||
|
||||
static void addPS4ProfileRTArgs(const ToolChain &TC, const ArgList &Args,
|
||||
ArgStringList &CmdArgs) {
|
||||
if ((Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
|
||||
false) ||
|
||||
Args.hasFlag(options::OPT_fprofile_generate,
|
||||
options::OPT_fno_profile_instr_generate, false) ||
|
||||
Args.hasFlag(options::OPT_fprofile_generate_EQ,
|
||||
options::OPT_fno_profile_instr_generate, false) ||
|
||||
Args.hasFlag(options::OPT_fprofile_instr_generate,
|
||||
options::OPT_fno_profile_instr_generate, false) ||
|
||||
Args.hasFlag(options::OPT_fprofile_instr_generate_EQ,
|
||||
options::OPT_fno_profile_instr_generate, false) ||
|
||||
Args.hasArg(options::OPT_fcreate_profile) ||
|
||||
Args.hasArg(options::OPT_coverage)))
|
||||
CmdArgs.push_back("--dependent-lib=libclang_rt.profile-x86_64.a");
|
||||
}
|
||||
|
||||
/// Parses the various -fpic/-fPIC/-fpie/-fPIE arguments. Then,
|
||||
/// smooshes them together with platform defaults, to decide whether
|
||||
/// this compile should be using PIC mode or not. Returns a tuple of
|
||||
|
@ -4133,6 +4150,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
|
||||
addPGOAndCoverageFlags(C, D, Output, Args, CmdArgs);
|
||||
|
||||
// Add runtime flag for PS4 when PGO or Coverage are enabled.
|
||||
if (getToolChain().getTriple().isPS4CPU())
|
||||
addPS4ProfileRTArgs(getToolChain(), Args, CmdArgs);
|
||||
|
||||
// Pass options for controlling the default header search paths.
|
||||
if (Args.hasArg(options::OPT_nostdinc)) {
|
||||
CmdArgs.push_back("-nostdsysteminc");
|
||||
|
@ -10182,21 +10203,6 @@ void PS4cpu::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
|
||||
}
|
||||
|
||||
static void AddPS4ProfileRT(const ToolChain &TC, const ArgList &Args,
|
||||
ArgStringList &CmdArgs) {
|
||||
if (!(Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
|
||||
false) ||
|
||||
Args.hasArg(options::OPT_fprofile_generate) ||
|
||||
Args.hasArg(options::OPT_fprofile_instr_generate) ||
|
||||
Args.hasArg(options::OPT_fcreate_profile) ||
|
||||
Args.hasArg(options::OPT_coverage)))
|
||||
return;
|
||||
|
||||
assert(TC.getTriple().isPS4CPU() &&
|
||||
"Profiling libraries are only implemented for the PS4 CPU");
|
||||
CmdArgs.push_back("-lclang_rt.profile-x86_64");
|
||||
}
|
||||
|
||||
static void AddPS4SanitizerArgs(const ToolChain &TC, ArgStringList &CmdArgs) {
|
||||
const SanitizerArgs &SanArgs = TC.getSanitizerArgs();
|
||||
if (SanArgs.needsUbsanRt()) {
|
||||
|
@ -10261,8 +10267,6 @@ static void ConstructPS4LinkJob(const Tool &T, Compilation &C,
|
|||
CmdArgs.push_back("-lpthread");
|
||||
}
|
||||
|
||||
AddPS4ProfileRT(ToolChain, Args, CmdArgs);
|
||||
|
||||
const char *Exec = Args.MakeArgString(ToolChain.GetProgramPath("ps4-ld"));
|
||||
|
||||
C.addCommand(llvm::make_unique<Command>(JA, T, Exec, CmdArgs, Inputs));
|
||||
|
@ -10434,8 +10438,6 @@ static void ConstructGoldLinkJob(const Tool &T, Compilation &C,
|
|||
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
|
||||
}
|
||||
|
||||
AddPS4ProfileRT(ToolChain, Args, CmdArgs);
|
||||
|
||||
const char *Exec =
|
||||
#ifdef LLVM_ON_WIN32
|
||||
Args.MakeArgString(ToolChain.GetProgramPath("ps4-ld.gold.exe"));
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// REQUIRES: x86-registered-target
|
||||
//
|
||||
// Test the profile runtime library to be linked for PS4 compiler.
|
||||
// Check PS4 runtime flag --dependent-lib which does not append the default library search path.
|
||||
//
|
||||
// RUN: %clang -target x86_64-scei-ps4 --coverage %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
|
||||
// RUN: %clang -target x86_64-scei-ps4 -fprofile-arcs %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
|
||||
// RUN: %clang -target x86_64-scei-ps4 -fno-profile-arcs -fprofile-arcs %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
|
||||
// RUN: %clang -target x86_64-scei-ps4 -fno-profile-arcs %s -### 2>&1 | FileCheck -check-prefix=CHECK-PS4-NO-PROFILE %s
|
||||
// RUN: %clang -target x86_64-scei-ps4 -fprofile-arcs -fno-profile-arcs %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
|
||||
// RUN: %clang -target x86_64-scei-ps4 -fprofile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
|
||||
// RUN: %clang -target x86_64-scei-ps4 -fno-profile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
|
||||
// RUN: %clang -target x86_64-scei-ps4 -fprofile-generate=dir %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
|
||||
// RUN: %clang -target x86_64-scei-ps4 -fprofile-instr-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
|
||||
// RUN: %clang -target x86_64-scei-ps4 -fno-profile-instr-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
|
||||
// RUN: %clang -target x86_64-scei-ps4 -fprofile-instr-generate=somefile.profraw %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
|
||||
//
|
||||
// CHECK-PS4-PROFILE: "--dependent-lib=libclang_rt.profile-x86_64.a"
|
||||
// CHECK-PS4-NO-PROFILE-NOT: "--dependent-lib=libclang_rt.profile-x86_64.a"
|
Loading…
Reference in New Issue