Add the support to LLVM's Context Sensitive FDO
LLVM recently implemented Context Sensitive FDO/PGO (CSFDO/CSPGO) which uses a
post-inline instrumentation to record more accurate profile information for the
inlined code. It improves the effectiveness of post-inline optimizations.
This CL adds the support to CSFDO:
(1) Add new options:
--cs_fdo_instrument=<csfdo_instru_path>,
--cs_profile=<csfdo_label>
(2) Add two features: CS_FDO_INSTRUMENT and CS_FDO_OPTIMIZE.
(2) Add a new BranchFdoMode: LLVM_CS_FDO.
(3) Merge CSFDO profile and regular FDO profile.
(4) Pass CSFDO options to the back-end invocations.
(5) Distribute the profile to build hosts in LLVM_CS_FDO optimize build. This is
not needed for regular FDO as the profile is read in during pre-LTO passes. We
need this step in CSFDO because the profile is read-in and used in the back-end.
RELNOTES: Add new options --cs_fdo_instrument and --cs_profile to support
LLVM's context-sensitive FDO (CSFDO).
PiperOrigin-RevId: 242685802
diff --git a/site/docs/cc-toolchain-config-reference.md b/site/docs/cc-toolchain-config-reference.md
index 5e8b05e..bef1804 100644
--- a/site/docs/cc-toolchain-config-reference.md
+++ b/site/docs/cc-toolchain-config-reference.md
@@ -976,6 +976,35 @@
of <code>.o</code> files and the compiler and linker need to know this.
</td>
</tr>
+ <tr>
+ <td><strong><code>fdo_instrument_path</code></strong>
+ </td>
+ <td>compile, link</td>
+ <td> Path to the directory that stores FDO instrumentation profile.
+ </td>
+ </tr>
+ <tr>
+ <td><strong><code>fdo_profile_path</code></strong>
+ </td>
+ <td>compile</td>
+ <td> Path to FDO profile.
+ </td>
+ </tr>
+ <tr>
+ <td><strong><code>fdo_prefetch_hints_path</code></strong>
+ </td>
+ <td>compile</td>
+ <td> Path to the cache prefetch profile.
+ </td>
+ </tr>
+ <tr>
+ <td><strong><code>csfdo_instrument_path</code></strong>
+ </td>
+ <td>compile, link</td>
+ <td> Path to the directory that stores context sensitive FDO
+ instrumentation profile.
+ </td>
+ </tr>
</table>
@@ -1094,6 +1123,8 @@
<li>Adds <code>include_paths</code> (if not present) feature to the top of the toolchain</li>
<li>Adds <code>fdo_instrument</code> (if not present) feature to the top of the toolchain</li>
<li>Adds <code>fdo_optimize</code> (if not present) feature to the top of the toolchain</li>
+ <li>Adds <code>cs_fdo_instrument</code> (if not present) feature to the top of the toolchain</li>
+ <li>Adds <code>cs_fdo_optimize</code> (if not present) feature to the top of the toolchain</li>
<li>Adds <code>fdo_prefetch_hints</code> (if not present) feature to the top of the toolchain</li>
<li>Adds <code>autofdo</code> (if not present) feature to the top of the toolchain</li>
<li>Adds <code>build_interface_libraries</code> (if not present) feature to the top of the toolchain</li>