HaoyuZhang updated this revision to Diff 471894. HaoyuZhang added a comment.
[Driver] Add -fsample-profile-use-profi This patch enable -sample-profile-use-profi in Clang frontend as user-facing feature. By using this patch, we can use the cflag of -fsample-profile-use-profi instead of -mllvm -sample-profile-use-profi. 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/CodeGen/Inputs/pgo-sample-use-profi.prof clang/test/CodeGen/pgo-sample-use-profi.c Index: clang/test/CodeGen/pgo-sample-use-profi.c =================================================================== --- /dev/null +++ clang/test/CodeGen/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 -### %s 2>&1 | FileCheck %s + +//CHECK: "-mllvm" "-sample-profile-use-profi" \ No newline at end of file Index: clang/test/CodeGen/Inputs/pgo-sample-use-profi.prof =================================================================== --- /dev/null +++ clang/test/CodeGen/Inputs/pgo-sample-use-profi.prof @@ -0,0 +1,8 @@ +_Z11bubble_sortPii:965211:0 + 0: 0 + 2: 4 + 4: 19852 + 5: 20401 + 7: 4556 + 8: 4556 + 13: 0 Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -5760,6 +5760,11 @@ Args.AddLastArg(CmdArgs, options::OPT_fclang_abi_compat_EQ); + if (Args.hasArg(options::OPT_fsample_profile_use_profi)) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-sample-profile-use-profi"); + } + // 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,14 @@ 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<[{Profi - a flow-based profile inference algorithm is an extended + and significantly re-engineered classic MCMF (min-cost max-flow) + approach. It models profile inference as an optimization problem + on a control-flow graph with the objectives and constraints + capturing the desired properties on profile data.}]>; 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/CodeGen/pgo-sample-use-profi.c =================================================================== --- /dev/null +++ clang/test/CodeGen/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 -### %s 2>&1 | FileCheck %s + +//CHECK: "-mllvm" "-sample-profile-use-profi" \ No newline at end of file Index: clang/test/CodeGen/Inputs/pgo-sample-use-profi.prof =================================================================== --- /dev/null +++ clang/test/CodeGen/Inputs/pgo-sample-use-profi.prof @@ -0,0 +1,8 @@ +_Z11bubble_sortPii:965211:0 + 0: 0 + 2: 4 + 4: 19852 + 5: 20401 + 7: 4556 + 8: 4556 + 13: 0 Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -5760,6 +5760,11 @@ Args.AddLastArg(CmdArgs, options::OPT_fclang_abi_compat_EQ); + if (Args.hasArg(options::OPT_fsample_profile_use_profi)) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-sample-profile-use-profi"); + } + // 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,14 @@ 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<[{Profi - a flow-based profile inference algorithm is an extended + and significantly re-engineered classic MCMF (min-cost max-flow) + approach. It models profile inference as an optimization problem + on a control-flow graph with the objectives and constraints + capturing the desired properties on profile data.}]>; 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