forked from OSchip/llvm-project
Add support for -fno-auto-profile and -fno-profile-sample-use
Summary: We need to be able to disable samplepgo for specific files by supporting -fno-auto-profile and -fno-profile-sample-use Reviewers: davidxl, dnovillo, echristo Reviewed By: echristo Subscribers: echristo, cfe-commits Differential Revision: https://reviews.llvm.org/D31213 llvm-svn: 298446
This commit is contained in:
parent
f93ed4de2e
commit
ea4b78fcb3
|
@ -613,9 +613,17 @@ def fno_gnu_inline_asm : Flag<["-"], "fno-gnu-inline-asm">, Group<f_Group>,
|
|||
Flags<[DriverOption, CC1Option]>,
|
||||
HelpText<"Disable GNU style inline asm">;
|
||||
|
||||
def fprofile_sample_use : Flag<["-"], "fprofile-sample-use">, Group<f_Group>,
|
||||
Flags<[CoreOption]>;
|
||||
def fno_profile_sample_use : Flag<["-"], "fno-profile-sample-use">, Group<f_Group>,
|
||||
Flags<[CoreOption]>;
|
||||
def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">,
|
||||
Group<f_Group>, Flags<[DriverOption, CC1Option]>,
|
||||
HelpText<"Enable sample-based profile guided optimizations">;
|
||||
def fauto_profile : Flag<["-"], "fauto-profile">, Group<f_Group>,
|
||||
Alias<fprofile_sample_use>;
|
||||
def fno_auto_profile : Flag<["-"], "fno-auto-profile">, Group<f_Group>,
|
||||
Alias<fno_profile_sample_use>;
|
||||
def fauto_profile_EQ : Joined<["-"], "fauto-profile=">,
|
||||
Alias<fprofile_sample_use_EQ>;
|
||||
def fdebug_info_for_profiling : Flag<["-"], "fdebug-info-for-profiling">, Group<f_Group>,
|
||||
|
|
|
@ -3431,7 +3431,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
|
||||
// Forward -f options with positive and negative forms; we translate
|
||||
// these by hand.
|
||||
if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
|
||||
if (Arg *A = getLastProfileSampleUseArg(Args)) {
|
||||
StringRef fname = A->getValue();
|
||||
if (!llvm::sys::fs::exists(fname))
|
||||
D.Diag(diag::err_drv_no_such_file) << fname;
|
||||
|
|
|
@ -407,7 +407,7 @@ void tools::AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
|
|||
CmdArgs.push_back("-plugin-opt=-data-sections");
|
||||
}
|
||||
|
||||
if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
|
||||
if (Arg *A = getLastProfileSampleUseArg(Args)) {
|
||||
StringRef FName = A->getValue();
|
||||
if (!llvm::sys::fs::exists(FName))
|
||||
D.Diag(diag::err_drv_no_such_file) << FName;
|
||||
|
@ -673,6 +673,22 @@ Arg *tools::getLastProfileUseArg(const ArgList &Args) {
|
|||
return ProfileUseArg;
|
||||
}
|
||||
|
||||
Arg *tools::getLastProfileSampleUseArg(const ArgList &Args) {
|
||||
auto *ProfileSampleUseArg = Args.getLastArg(
|
||||
options::OPT_fprofile_sample_use, options::OPT_fprofile_sample_use_EQ,
|
||||
options::OPT_fauto_profile, options::OPT_fauto_profile_EQ,
|
||||
options::OPT_fno_profile_sample_use, options::OPT_fno_auto_profile);
|
||||
|
||||
if (ProfileSampleUseArg &&
|
||||
(ProfileSampleUseArg->getOption().matches(
|
||||
options::OPT_fno_profile_sample_use) ||
|
||||
ProfileSampleUseArg->getOption().matches(options::OPT_fno_auto_profile)))
|
||||
return nullptr;
|
||||
|
||||
return Args.getLastArg(options::OPT_fprofile_sample_use_EQ,
|
||||
options::OPT_fauto_profile_EQ);
|
||||
}
|
||||
|
||||
/// 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
|
||||
|
|
|
@ -63,6 +63,7 @@ void addOpenMPRuntime(llvm::opt::ArgStringList &CmdArgs, const ToolChain &TC,
|
|||
const llvm::opt::ArgList &Args);
|
||||
|
||||
llvm::opt::Arg *getLastProfileUseArg(const llvm::opt::ArgList &Args);
|
||||
llvm::opt::Arg *getLastProfileSampleUseArg(const llvm::opt::ArgList &Args);
|
||||
|
||||
bool isObjCAutoRefCount(const llvm::opt::ArgList &Args);
|
||||
|
||||
|
|
|
@ -59,6 +59,13 @@
|
|||
// RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-AUTO-PROFILE %s
|
||||
// CHECK-AUTO-PROFILE: "-fprofile-sample-use={{.*}}/file.prof"
|
||||
|
||||
// RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-profile-sample-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-AUTO-PROFILE %s
|
||||
// RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-auto-profile %s 2>&1 | FileCheck -check-prefix=CHECK-NO-AUTO-PROFILE %s
|
||||
// CHECK-NO-AUTO-PROFILE-NOT: "-fprofile-sample-use={{.*}}/file.prof"
|
||||
|
||||
// RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-profile-sample-use -fauto-profile %s 2>&1 | FileCheck -check-prefix=CHECK-AUTO-PROFILE %s
|
||||
// RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-auto-profile -fprofile-sample-use %s 2>&1 | FileCheck -check-prefix=CHECK-AUTO-PROFILE %s
|
||||
|
||||
// RUN: %clang -### -S -fprofile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-ARCS %s
|
||||
// RUN: %clang -### -S -fno-profile-arcs -fprofile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-ARCS %s
|
||||
// RUN: %clang -### -S -fno-profile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-NO-PROFILE-ARCS %s
|
||||
|
|
Loading…
Reference in New Issue