Author: Fangrui Song Date: 2024-11-20T09:06:32-08:00 New Revision: ba7cc955662cfebb614c6a37a7341ba6072a0b70
URL: https://github.com/llvm/llvm-project/commit/ba7cc955662cfebb614c6a37a7341ba6072a0b70 DIFF: https://github.com/llvm/llvm-project/commit/ba7cc955662cfebb614c6a37a7341ba6072a0b70.diff LOG: [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: https://github.com/llvm/llvm-project/pull/113528 Added: clang/test/Driver/fprofile-sample-use.c Modified: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/CommonArgs.cpp clang/test/Driver/clang_f_opts.c Removed: ################################################################################ diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index f2f9c20c9bc264..5167c3c39e315a 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1732,8 +1732,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>, Visibility<[ClangOption, CLOption]>; def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">, @@ -1759,8 +1757,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=">, diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index cbba4289eb9450..8d977149e62485 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1763,18 +1763,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) { diff --git a/clang/test/Driver/clang_f_opts.c b/clang/test/Driver/clang_f_opts.c index 2cfbe256bc7456..ddbf1fd951c84e 100644 --- a/clang/test/Driver/clang_f_opts.c +++ b/clang/test/Driver/clang_f_opts.c @@ -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 diff --git a/clang/test/Driver/fprofile-sample-use.c b/clang/test/Driver/fprofile-sample-use.c new file mode 100644 index 00000000000000..7c8813a83785ce --- /dev/null +++ b/clang/test/Driver/fprofile-sample-use.c @@ -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' _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits