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

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 22:20:57 PDT 2026


================
@@ -594,30 +594,48 @@ void PerfScriptReader::updateBinaryAddress(const MMapEvent &Event) {
   if (PIDFilter && Event.PID != *PIDFilter)
     return;
 
-  // Drop the event if its image is loaded at the same address
-  if (Event.Address == Binary->getBaseAddress()) {
+  auto MMapContainsFileOffset = [&](uint64_t FileOffset) {
+    return Event.Offset == FileOffset ||
+           (Event.MemProtectionFlag.contains("x") &&
+            Event.Offset < FileOffset &&
+            FileOffset - Event.Offset < Event.Size);
+  };
+  const bool MMapContainsTextSegment =
+      MMapContainsFileOffset(Binary->getTextSegmentOffset());
+
+  // For user-space ELF, subtract the mmap file offset to get the runtime
+  // address corresponding to file offset zero. Kernel and COFF retain their
+  // existing mmap address semantics.
+  const uint64_t RuntimeBaseAddress = IsKernel || Binary->isCOFF()
----------------
HighW4y2H3ll wrote:

Why is COFF relevant? Windows doesn't have mmap event anyway

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


More information about the llvm-commits mailing list