[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:06:49 PDT 2022


HaoyuZhang updated this revision to Diff 471895.
HaoyuZhang added a comment.

Remove the prof file uploaded previous for test. No more need.


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/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"
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.471895.patch
Type: text/x-patch
Size: 2187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221031/b0615b59/attachment.bin>


More information about the cfe-commits mailing list