[llvm] [MemProf][NFC] Hoist size computation out of the loop for v3 (PR #137479)

Snehasish Kumar via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 26 15:48:38 PDT 2025


https://github.com/snehasish created https://github.com/llvm/llvm-project/pull/137479

None

>From 869af98580cdf71069394f9c853b63afa6dfa185 Mon Sep 17 00:00:00 2001
From: Snehasish Kumar <snehasishk at google.com>
Date: Sat, 26 Apr 2025 15:47:00 -0700
Subject: [PATCH] [MemProf][NFC] Hoist size computation out of the loop for v3

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

diff --git a/llvm/lib/ProfileData/MemProf.cpp b/llvm/lib/ProfileData/MemProf.cpp
index 0af08ca51481f..1e956250e5b84 100644
--- a/llvm/lib/ProfileData/MemProf.cpp
+++ b/llvm/lib/ProfileData/MemProf.cpp
@@ -190,12 +190,13 @@ static IndexedMemProfRecord deserializeV3(const MemProfSchema &Schema,
   const uint64_t NumNodes =
       endian::readNext<uint64_t, llvm::endianness::little>(Ptr);
   Record.AllocSites.reserve(NumNodes);
+  const size_t SerializedSize = PortableMemInfoBlock::serializedSize(Schema);
   for (uint64_t I = 0; I < NumNodes; I++) {
     IndexedAllocationInfo Node;
     Node.CSId =
         endian::readNext<LinearCallStackId, llvm::endianness::little>(Ptr);
     Node.Info.deserialize(Schema, Ptr);
-    Ptr += PortableMemInfoBlock::serializedSize(Schema);
+    Ptr += SerializedSize;
     Record.AllocSites.push_back(Node);
   }
 



More information about the llvm-commits mailing list