[llvm] Add documentation for MemProf. (PR #172238)
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 16 09:16:53 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.
----------------
teresajohnson wrote:
Do we want to mention here that for now this requires tcmalloc? Or more generally, an allocator that supports the necessary interfaces?
https://github.com/llvm/llvm-project/pull/172238
More information about the llvm-commits
mailing list