[llvm] Add documentation for MemProf. (PR #172238)

Snehasish Kumar via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 22 23:16:42 PST 2025


================
@@ -0,0 +1,274 @@
+====================================
+MemProf: Memory Profiling for LLVM
+====================================
+
+.. contents::
+   :local:
+   :depth: 2
+
+Introduction
+============
+
+MemProf is a profile-guided optimization (PGO) feature for memory. It enables the compiler to optimize memory allocations and static data layout based on runtime profiling information. By understanding the "hotness", lifetime, and access frequency of memory, the compiler can make better decisions about where to place data (both heap and static), reducing fragmentation and improving cache locality.
+
+Motivation
+----------
+
+Traditional PGO focuses on control flow (hot vs. cold code). MemProf extends this concept to data. It answers questions like:
+
+*   Which allocation sites are "hot" (frequently accessed)?
+*   Which allocation sites are "cold" (rarely accessed)?
+*   What is the lifetime of an allocation?
+
+This information enables optimizations such as:
+
+*   **Heap Layout Optimization:** Grouping objects with similar lifetimes or access density.
+*   **Static Data Partitioning:** Segregating frequently accessed (hot) global variables and constants from rarely accessed (cold) ones to improve data locality and TLB utilization.
+
+User Manual
+===========
+
+This section describes how to use MemProf to profile and optimize your application.
+
+Building with MemProf
----------------
snehasish wrote:

Done.

https://github.com/llvm/llvm-project/pull/172238


More information about the llvm-commits mailing list