HaoyuZhang updated this revision to Diff 472219. HaoyuZhang added a comment.
1. Modify the DocBrief contents for fsample-profile-use-profi. 2. Add a checking for -fsample-profile-use-profi that this args only allowed with -fprofile-sample-use (has a profile). 3. Modify the test case and change the directory. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136846/new/ https://reviews.llvm.org/D136846 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/pgo-sample-use-profi.c Index: clang/test/Driver/pgo-sample-use-profi.c =================================================================== --- /dev/null +++ clang/test/Driver/pgo-sample-use-profi.c @@ -0,0 +1,5 @@ +// Test if profi flat is enabled in frontend as user-facing feature. +// +// RUN: %clang -c -fsample-profile-use-profi -fprofile-sample-use=%S/../CodeGen/Inputs/pgo-sample.prof -### %s 2>&1 | FileCheck %s + +// CHECK: "-mllvm" "-sample-profile-use-profi" Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -5760,6 +5760,17 @@ Args.AddLastArg(CmdArgs, options::OPT_fclang_abi_compat_EQ); + if (Args.hasArg(options::OPT_fsample_profile_use_profi)) { + if (Args.hasArg(options::OPT_fprofile_sample_use_EQ)) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-sample-profile-use-profi"); + } else { + D.Diag(diag::err_drv_argument_only_allowed_with) + << "-fsample-profile-use-profi" + << "fprofile-sample-use="; + } + } + // Add runtime flag for PS4/PS5 when PGO, coverage, or sanitizers are enabled. if (RawTriple.isPS() && !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -1248,6 +1248,13 @@ as cold. Otherwise, treat callsites without profile samples as if we have no profile}]>, MarshallingInfoFlag<CodeGenOpts<"ProfileSampleAccurate">>; +def fsample_profile_use_profi : Flag<["-"], "fsample-profile-use-profi">, + Flags<[NoXarchOption, CC1Option]>, Group<f_Group>, + HelpText<"Use profi to infer block and edge counts.">, + DocBrief<[{Infer block and edge counts. If the profiles have errors or missing + block caused by sampling, profile inference (profi) can converting + 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>, Flags<[NoXarchOption]>; def fauto_profile : Flag<["-"], "fauto-profile">, Group<f_Group>,
Index: clang/test/Driver/pgo-sample-use-profi.c =================================================================== --- /dev/null +++ clang/test/Driver/pgo-sample-use-profi.c @@ -0,0 +1,5 @@ +// Test if profi flat is enabled in frontend as user-facing feature. +// +// RUN: %clang -c -fsample-profile-use-profi -fprofile-sample-use=%S/../CodeGen/Inputs/pgo-sample.prof -### %s 2>&1 | FileCheck %s + +// CHECK: "-mllvm" "-sample-profile-use-profi" Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -5760,6 +5760,17 @@ Args.AddLastArg(CmdArgs, options::OPT_fclang_abi_compat_EQ); + if (Args.hasArg(options::OPT_fsample_profile_use_profi)) { + if (Args.hasArg(options::OPT_fprofile_sample_use_EQ)) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-sample-profile-use-profi"); + } else { + D.Diag(diag::err_drv_argument_only_allowed_with) + << "-fsample-profile-use-profi" + << "fprofile-sample-use="; + } + } + // Add runtime flag for PS4/PS5 when PGO, coverage, or sanitizers are enabled. if (RawTriple.isPS() && !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -1248,6 +1248,13 @@ as cold. Otherwise, treat callsites without profile samples as if we have no profile}]>, MarshallingInfoFlag<CodeGenOpts<"ProfileSampleAccurate">>; +def fsample_profile_use_profi : Flag<["-"], "fsample-profile-use-profi">, + Flags<[NoXarchOption, CC1Option]>, Group<f_Group>, + HelpText<"Use profi to infer block and edge counts.">, + DocBrief<[{Infer block and edge counts. If the profiles have errors or missing + block caused by sampling, profile inference (profi) can converting + 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>, Flags<[NoXarchOption]>; def fauto_profile : Flag<["-"], "fauto-profile">, Group<f_Group>,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits