[PATCH] D136846: [Driver] Add -fsample-profile-use-profi
Zhang Haoyu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 30 20:01:50 PDT 2022
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>,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136846.471894.patch
Type: text/x-patch
Size: 2521 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221031/b208d4dd/attachment-0001.bin>
More information about the cfe-commits
mailing list