[llvm] [memprof] Fix typos in serializedSizeV0 and serializedSizeV2 (PR #88629)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 15 10:00:00 PDT 2024


https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/88629

>From 26278c7306793a468cc49331e4ab0a72bcf55ef2 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 13 Apr 2024 10:23:04 -0700
Subject: [PATCH 1/2] [memprof] Fix typos in serializedSizeV0 and
 serializedSizeV2

The first field to serialize is the size of
IndexedMemProfRecord::AllocSites.  It has nothing to do with
GlobalValue::GUID.  This happens to work because of:

  using GUID = uint64_t;
---
 llvm/lib/ProfileData/MemProf.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/ProfileData/MemProf.cpp b/llvm/lib/ProfileData/MemProf.cpp
index 96aeedf2e6913e..d856868ed2a461 100644
--- a/llvm/lib/ProfileData/MemProf.cpp
+++ b/llvm/lib/ProfileData/MemProf.cpp
@@ -42,7 +42,7 @@ size_t IndexedAllocationInfo::serializedSize(IndexedVersion Version) const {
 }
 
 static size_t serializedSizeV0(const IndexedMemProfRecord &Record) {
-  size_t Result = sizeof(GlobalValue::GUID);
+  size_t Result = sizeof(uint64_t);
   for (const IndexedAllocationInfo &N : Record.AllocSites)
     Result += N.serializedSize(Version0);
 
@@ -57,7 +57,7 @@ static size_t serializedSizeV0(const IndexedMemProfRecord &Record) {
 }
 
 static size_t serializedSizeV2(const IndexedMemProfRecord &Record) {
-  size_t Result = sizeof(GlobalValue::GUID);
+  size_t Result = sizeof(uint64_t);
   for (const IndexedAllocationInfo &N : Record.AllocSites)
     Result += N.serializedSize(Version2);
 

>From db4bde2b1e0c397c98b606f759def13104c26e95 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 15 Apr 2024 09:58:39 -0700
Subject: [PATCH 2/2] Add comments as suggested.

---
 llvm/lib/ProfileData/MemProf.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/ProfileData/MemProf.cpp b/llvm/lib/ProfileData/MemProf.cpp
index d856868ed2a461..97414505f1c134 100644
--- a/llvm/lib/ProfileData/MemProf.cpp
+++ b/llvm/lib/ProfileData/MemProf.cpp
@@ -42,6 +42,7 @@ size_t IndexedAllocationInfo::serializedSize(IndexedVersion Version) const {
 }
 
 static size_t serializedSizeV0(const IndexedMemProfRecord &Record) {
+  // The number of alloc sites to serialize.
   size_t Result = sizeof(uint64_t);
   for (const IndexedAllocationInfo &N : Record.AllocSites)
     Result += N.serializedSize(Version0);
@@ -57,6 +58,7 @@ static size_t serializedSizeV0(const IndexedMemProfRecord &Record) {
 }
 
 static size_t serializedSizeV2(const IndexedMemProfRecord &Record) {
+  // The number of alloc sites to serialize.
   size_t Result = sizeof(uint64_t);
   for (const IndexedAllocationInfo &N : Record.AllocSites)
     Result += N.serializedSize(Version2);



More information about the llvm-commits mailing list