[llvm] bba5ee4 - [memprof] Introduce memprof::LinearFrameId (NFC) (#94057)

via llvm-commits llvm-commits at lists.llvm.org
Fri May 31 15:31:08 PDT 2024


Author: Kazu Hirata
Date: 2024-05-31T15:29:44-07:00
New Revision: bba5ee47e63298d61f6ea441a140144ce370ba92

URL: https://github.com/llvm/llvm-project/commit/bba5ee47e63298d61f6ea441a140144ce370ba92
DIFF: https://github.com/llvm/llvm-project/commit/bba5ee47e63298d61f6ea441a140144ce370ba92.diff

LOG: [memprof] Introduce memprof::LinearFrameId (NFC) (#94057)

This patch introduces memprof::LinearFrameId, which is a frame version
of memprof::LinearCallStackId.

Added: 
    

Modified: 
    llvm/include/llvm/ProfileData/MemProf.h
    llvm/lib/ProfileData/InstrProfWriter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ProfileData/MemProf.h b/llvm/include/llvm/ProfileData/MemProf.h
index 2a7c853cade66..5b0d1c867b202 100644
--- a/llvm/include/llvm/ProfileData/MemProf.h
+++ b/llvm/include/llvm/ProfileData/MemProf.h
@@ -188,6 +188,8 @@ struct PortableMemInfoBlock {
 
 // A type representing the id generated by hashing the contents of the Frame.
 using FrameId = uint64_t;
+// A type representing the id to index into the frame array.
+using LinearFrameId = uint32_t;
 // Describes a call frame for a dynamic allocation context. The contents of
 // the frame are populated by symbolizing the stack depot call frame from the
 // compiler runtime.

diff  --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index 9b12922427779..e58e6b8acfc81 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -491,11 +491,12 @@ static uint64_t writeMemProfFrames(
 
 // Serialize MemProfFrameData.  Return the mapping from FrameIds to their
 // indexes within the frame array.
-static llvm::DenseMap<memprof::FrameId, uint32_t> writeMemProfFrameArray(
+static llvm::DenseMap<memprof::FrameId, memprof::LinearFrameId>
+writeMemProfFrameArray(
     ProfOStream &OS,
     llvm::MapVector<memprof::FrameId, memprof::Frame> &MemProfFrameData) {
   // Mappings from FrameIds to array indexes.
-  llvm::DenseMap<memprof::FrameId, uint32_t> MemProfFrameIndexes;
+  llvm::DenseMap<memprof::FrameId, memprof::LinearFrameId> MemProfFrameIndexes;
 
   // Sort the FrameIDs for stability.
   std::vector<std::pair<memprof::FrameId, const memprof::Frame *>> FrameIdOrder;
@@ -541,7 +542,8 @@ writeMemProfCallStackArray(
     ProfOStream &OS,
     llvm::MapVector<memprof::CallStackId, llvm::SmallVector<memprof::FrameId>>
         &MemProfCallStackData,
-    llvm::DenseMap<memprof::FrameId, uint32_t> &MemProfFrameIndexes) {
+    llvm::DenseMap<memprof::FrameId, memprof::LinearFrameId>
+        &MemProfFrameIndexes) {
   llvm::DenseMap<memprof::CallStackId, memprof::LinearCallStackId>
       MemProfCallStackIndexes;
 
@@ -710,7 +712,7 @@ static Error writeMemProfV3(ProfOStream &OS,
     Schema = memprof::getFullSchema();
   writeMemProfSchema(OS, Schema);
 
-  llvm::DenseMap<memprof::FrameId, uint32_t> MemProfFrameIndexes =
+  llvm::DenseMap<memprof::FrameId, memprof::LinearFrameId> MemProfFrameIndexes =
       writeMemProfFrameArray(OS, MemProfData.FrameData);
 
   uint64_t CallStackPayloadOffset = OS.tell();


        


More information about the llvm-commits mailing list