https://github.com/mingmingl-llvm updated 
https://github.com/llvm/llvm-project/pull/175872

>From beb2e598b56ce8e09e7bc8f630c6cdf61c9b77bd Mon Sep 17 00:00:00 2001
From: mingmingl <[email protected]>
Date: Tue, 13 Jan 2026 16:30:58 -0800
Subject: [PATCH 1/2] [docs][MemProf]Update compiler options for static data
 partitioning

---
 llvm/docs/MemProf.rst | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/llvm/docs/MemProf.rst b/llvm/docs/MemProf.rst
index a1a6d51ee6d2a..16b7a08174866 100644
--- a/llvm/docs/MemProf.rst
+++ b/llvm/docs/MemProf.rst
@@ -140,18 +140,29 @@ This feature uses a hybrid approach:
 
 To enable this feature, pass the following flags to the compiler:
 
-*   ``-memprof-annotate-static-data-prefix``: Enables annotation of global 
variables in IR.
-*   ``-split-static-data``: Enables partitioning of other data (like jump 
tables) in the backend.
-*   ``-Wl,-z,keep-data-section-prefix``: Instructs the linker (LLD) to group 
hot and cold data sections together.
+*   ``-fpartition-static-data-sections``: Instructs the compiler to generate 
`.hot` and `.unlikely` section prefixes for hot and cold static data 
respectively in the relocatable object files.
+*   ``-Wl,-z,keep-data-section-prefix``: Informs the LLD linker that 
`.data.rel.ro.hot` and `.data.rel.ro.unlikely` as relro sections. LLD requires 
all relro sections to be contiguous and this flag allows us to interleave the 
hotness-suffixed `.data.rel.ro` sections with other relro sections.
+*   ``-Wl,-script=<linker_script>``: Group hot and/or cold data sections, and 
order the data sections.
 
 .. code-block:: bash
 
-    clang++ -fmemory-profile-use=memprof.memprofdata -mllvm 
-memprof-annotate-static-data-prefix -mllvm -split-static-data -fuse-ld=lld 
-Wl,-z,keep-data-section-prefix -O2 source.cpp -o optimized_app
+    clang++ -fmemory-profile-use=memprof.memprofdata 
-fpartition-static-data-sections -fuse-ld=lld -Wl,-z,keep-data-section-prefix 
-O2 source.cpp -o optimized_app
 
 The optimized layout clusters hot static data, improving dTLB and cache 
efficiency.
 
 .. note::
-   For an LTO build -split-static-data needs to be passed to the LTO backend 
via the linker using ``-Wl,-mllvm,-split-static-data``.
+   When both PGO profiles and memory profiles are provided (using
+   ``-fprofile-use`` and ``-fmemory-profile-use``), global variable hotness are
+   inferred from a combination of PGO profile and data access profile:
+
+   * For data covered by both profiles (e.g., module-internal data with symbols
+     in the executable), the hotness is the max of PGO profile hotness and data
+     access profile hotness.
+
+   * For data covered by only one profile, the hotness is inferred from that
+     profile. Most notably, symbolizable data with external linkage is only
+     covered by data access profile, and module-internal unsymbolizable data is
+     only covered by PGO profile.
 
 Developer Manual
 ================

>From b3f2b19324522c08690760b4e6f7e9f467c14f35 Mon Sep 17 00:00:00 2001
From: mingmingl <[email protected]>
Date: Wed, 14 Jan 2026 13:45:23 -0800
Subject: [PATCH 2/2] Update the comment for -fpartition-static-data-sections

---
 clang/include/clang/Options/Options.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Options/Options.td 
b/clang/include/clang/Options/Options.td
index 2f57a5b13b917..d4dd71b9d1bea 100644
--- a/clang/include/clang/Options/Options.td
+++ b/clang/include/clang/Options/Options.td
@@ -4684,7 +4684,7 @@ defm partition_static_data_sections: 
BoolFOption<"partition-static-data-sections
   CodeGenOpts<"PartitionStaticDataSections">, DefaultFalse,
   PosFlag<SetTrue, [], [ClangOption, CC1Option], "Enable">,
   NegFlag<SetFalse, [], [ClangOption], "Disable">,
-  BothFlags<[], [ClangOption], " partition static data sections using profile 
information (x86 and aarch64 ELF)">>;
+  BothFlags<[], [ClangOption], " partition static data sections using PGO 
profile information and MemProf (x86 and aarch64 ELF). See LLVM MemProf doc for 
usage.">>;
 
 defm strict_return : BoolFOption<"strict-return",
   CodeGenOpts<"StrictReturn">, DefaultTrue,

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to