Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2024

Conversation

kazutakahirata
Copy link
Contributor

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

This patch introduces memprof::LinearFrameId, which is a frame version
of memprof::LinearCallStackId.
@llvmbot llvmbot added the PGO Profile Guided Optimizations label May 31, 2024
@llvmbot
Copy link
Member

llvmbot commented May 31, 2024

@llvm/pr-subscribers-pgo

Author: Kazu Hirata (kazutakahirata)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/94057.diff

2 Files Affected:

  • (modified) llvm/include/llvm/ProfileData/MemProf.h (+2)
  • (modified) llvm/lib/ProfileData/InstrProfWriter.cpp (+6-4)
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();

@kazutakahirata kazutakahirata merged commit bba5ee4 into llvm:main May 31, 2024
@kazutakahirata kazutakahirata deleted the memprof_v3_linear_frame_id branch May 31, 2024 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants