[llvm-branch-commits] [llvm] [llvm-profgen] Extend llvm-profgen to generate vtable profiles with data access events. (PR #148013)

Mingming Liu via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Jul 27 13:04:38 PDT 2025


================
@@ -603,6 +640,16 @@ class ProfiledBinary {
     return ProbeDecoder.getInlinerDescForProbe(Probe);
   }
 
+  void addMMapNonTextEvent(MMapEvent MMap) {
+    MMapNonTextEvents.push_back(MMap);
----------------
mingmingl-llvm wrote:

My understanding is that it's rare for the virtual address ranges (i.e., the intervals formed by `[MMapEvent.Address, MMapEvent.Address + MMap.Size)`) of mmap events to overlap with each other. Assuming this is true, I think there are two implementation options here:

1)  Make llvm-profgen to validate mmap events don't have overlapping virtual address (and report 'unimplemented error' otherwise). This way, the implementation can use a map to do efficient address canonicalization and handle the common case. The updated change implements this option.
  
2) llvm-profgen doesn't validate address interval and cannot assume non-overlapping address ranges. The implementation uses a vector to record the mmap events in the order they are added and reverse iterate the map to do data address canonicalization. While a linear reverse iteration is probably acceptable given the number of non-text mmap events is observed to be 3 in most cases, I think option 1) does the better trade-off. 

Let me know your thoughts and I'd be glad to follow up.


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


More information about the llvm-branch-commits mailing list