Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 0 additions & 4 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -1729,8 +1729,6 @@ defm gnu_inline_asm : BoolFOption<"gnu-inline-asm",
"Disable GNU style inline asm">,
PosFlag<SetTrue>>;

def fprofile_sample_use : Flag<["-"], "fprofile-sample-use">, Group<f_Group>,
Visibility<[ClangOption, CLOption]>;
def fno_profile_sample_use : Flag<["-"], "fno-profile-sample-use">, Group<f_Group>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't also remove -fno-profile-sample-use and just leave -fprofile-sample-use=.
Is there any scenario to use -fno-profile-sample-use?

Copy link
Member Author

Choose a reason for hiding this comment

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

If -fprofile-sample-use= is added as a default option, -fno-profile-sample-use= can be used to cancel it. For example, it could be used as a debugging tool when you think one TU triggers a compiler bug.

Visibility<[ClangOption, CLOption]>;
def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">,
Expand All @@ -1756,8 +1754,6 @@ def fsample_profile_use_profi : Flag<["-"], "fsample-profile-use-profi">,
basic block counts to branch probabilites to fix them by extended
and re-engineered classic MCMF (min-cost max-flow) approach.}]>;
def fno_profile_sample_accurate : Flag<["-"], "fno-profile-sample-accurate">, Group<f_Group>;
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=">,
Expand Down
15 changes: 5 additions & 10 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1758,18 +1758,13 @@ Arg *tools::getLastProfileUseArg(const ArgList &Args) {

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)))
options::OPT_fprofile_sample_use_EQ, options::OPT_fno_profile_sample_use);

if (ProfileSampleUseArg && (ProfileSampleUseArg->getOption().matches(
options::OPT_fno_profile_sample_use)))
return nullptr;

return Args.getLastArg(options::OPT_fprofile_sample_use_EQ,
options::OPT_fauto_profile_EQ);
return Args.getLastArg(options::OPT_fprofile_sample_use_EQ);
}

const char *tools::RelocationModelName(llvm::Reloc::Model Model) {
Expand Down
3 changes: 0 additions & 3 deletions clang/test/Driver/clang_f_opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@
// 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-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-LLVM %s
// RUN: %clang -### -S -fprofile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
// RUN: %clang -### -S -fprofile-generate=/some/dir %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-DIR %s
Expand Down
5 changes: 5 additions & 0 deletions clang/test/Driver/fprofile-sample-use.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// GCC -fauto-profile (without =) is rejected.
/// -fprofile-sample-use without = is rejected as well.
// RUN: not %clang -### -S -fauto-profile -fprofile-sample-use %s 2>&1 | FileCheck %s --check-prefix=ERR
// ERR: error: unknown argument: '-fauto-profile'
// ERR: error: unknown argument: '-fprofile-sample-use'
Loading