[llvm] [llvm-profgen] Handle perf mmaps with page sizes larger than 4 KiB (PR #217887)

Jinjie Huang via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 23 09:09:19 PDT 2026


================
@@ -362,10 +362,11 @@ template <class ELFT>
 void ProfiledBinary::setPreferredTextSegmentAddresses(const ELFFile<ELFT> &Obj,
                                                       StringRef FileName) {
   const auto &PhdrRange = unwrapOrError(Obj.program_headers(), FileName);
-  // FIXME: This should be the page size of the system running profiling.
-  // However such info isn't available at post-processing time, assuming
-  // 4K page now. Note that we don't use EXEC_PAGESIZE from <linux/param.h>
-  // because we may build the tools on non-linux.
+  // The page size of the profiling system cannot be determined from the ELF
+  // binary alone, and using the page size of the post-processing system would
+  // be incorrect. Use 4 KiB as the binary-side baseline. PerfScriptReader
+  // reconciles executable mmap events whose mappings cover the segment start
+  // due to a larger runtime page size.
   uint64_t PageSize = 0x1000;
----------------
Jinjie-Huang wrote:

Alternatively, I think we could directly add an option to explicitly specify a page size. llvm-profgen would use this value directly for mmaps parsing(defaulting to 4 KB when not specified). What do you think?

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


More information about the llvm-commits mailing list