Skip to content

Commit ba7cc95

Browse files
authored
[Driver] Remove ignored Flag form of -fauto-profile/-fprofile-sample-use
The Flag form options are accepted and silently ignored, which can be surprising. The Eq form is supposed to be used instead, e.g. -fprofile-sample-use=a.afdo. Since we does not intend to support GCC's "fbaata.afdo" filename, just remove the two options. While here, clean up code as -fauto-profile= is an alias. Pull Request: #113528
1 parent ae023f3 commit ba7cc95

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,8 +1732,6 @@ defm gnu_inline_asm : BoolFOption<"gnu-inline-asm",
17321732
"Disable GNU style inline asm">,
17331733
PosFlag<SetTrue>>;
17341734

1735-
def fprofile_sample_use : Flag<["-"], "fprofile-sample-use">, Group<f_Group>,
1736-
Visibility<[ClangOption, CLOption]>;
17371735
def fno_profile_sample_use : Flag<["-"], "fno-profile-sample-use">, Group<f_Group>,
17381736
Visibility<[ClangOption, CLOption]>;
17391737
def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">,
@@ -1759,8 +1757,6 @@ def fsample_profile_use_profi : Flag<["-"], "fsample-profile-use-profi">,
17591757
basic block counts to branch probabilites to fix them by extended
17601758
and re-engineered classic MCMF (min-cost max-flow) approach.}]>;
17611759
def fno_profile_sample_accurate : Flag<["-"], "fno-profile-sample-accurate">, Group<f_Group>;
1762-
def fauto_profile : Flag<["-"], "fauto-profile">, Group<f_Group>,
1763-
Alias<fprofile_sample_use>;
17641760
def fno_auto_profile : Flag<["-"], "fno-auto-profile">, Group<f_Group>,
17651761
Alias<fno_profile_sample_use>;
17661762
def fauto_profile_EQ : Joined<["-"], "fauto-profile=">,

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,18 +1763,13 @@ Arg *tools::getLastProfileUseArg(const ArgList &Args) {
17631763

17641764
Arg *tools::getLastProfileSampleUseArg(const ArgList &Args) {
17651765
auto *ProfileSampleUseArg = Args.getLastArg(
1766-
options::OPT_fprofile_sample_use, options::OPT_fprofile_sample_use_EQ,
1767-
options::OPT_fauto_profile, options::OPT_fauto_profile_EQ,
1768-
options::OPT_fno_profile_sample_use, options::OPT_fno_auto_profile);
1769-
1770-
if (ProfileSampleUseArg &&
1771-
(ProfileSampleUseArg->getOption().matches(
1772-
options::OPT_fno_profile_sample_use) ||
1773-
ProfileSampleUseArg->getOption().matches(options::OPT_fno_auto_profile)))
1766+
options::OPT_fprofile_sample_use_EQ, options::OPT_fno_profile_sample_use);
1767+
1768+
if (ProfileSampleUseArg && (ProfileSampleUseArg->getOption().matches(
1769+
options::OPT_fno_profile_sample_use)))
17741770
return nullptr;
17751771

1776-
return Args.getLastArg(options::OPT_fprofile_sample_use_EQ,
1777-
options::OPT_fauto_profile_EQ);
1772+
return Args.getLastArg(options::OPT_fprofile_sample_use_EQ);
17781773
}
17791774

17801775
const char *tools::RelocationModelName(llvm::Reloc::Model Model) {

clang/test/Driver/clang_f_opts.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@
7171
// RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-auto-profile %s 2>&1 | FileCheck -check-prefix=CHECK-NO-AUTO-PROFILE %s
7272
// CHECK-NO-AUTO-PROFILE-NOT: "-fprofile-sample-use={{.*}}/file.prof"
7373

74-
// 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
75-
// 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
76-
7774
// RUN: %clang -### -S -fprofile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-LLVM %s
7875
// RUN: %clang -### -S -fprofile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
7976
// RUN: %clang -### -S -fprofile-generate=/some/dir %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-DIR %s
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// GCC -fauto-profile (without =) is rejected.
2+
/// -fprofile-sample-use without = is rejected as well.
3+
// RUN: not %clang -### -S -fauto-profile -fprofile-sample-use %s 2>&1 | FileCheck %s --check-prefix=ERR
4+
// ERR: error: unknown argument: '-fauto-profile'
5+
// ERR: error: unknown argument: '-fprofile-sample-use'

0 commit comments

Comments
 (0)