Skip to content

Commit 507c2ee

Browse files
author
Snehasish Kumar
committed
Hoist serialized size computation outside the loop.
1 parent 1b0aafd commit 507c2ee

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/lib/ProfileData/IndexedMemProfData.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,7 @@ static Error writeMemProfRadixTreeBased(
249249

250250
uint64_t RecordPayloadOffset = OS.tell();
251251
uint64_t RecordTableOffset = writeMemProfRecords(
252-
OS, MemProfData.Records, &Schema, Version, // Pass Version
253-
&MemProfCallStackIndexes);
252+
OS, MemProfData.Records, &Schema, Version, &MemProfCallStackIndexes);
254253

255254
// Verify that the computation for the number of elements in the call stack
256255
// array works.

llvm/lib/ProfileData/MemProf.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,13 @@ static IndexedMemProfRecord deserializeV4(const MemProfSchema &Schema,
275275
const uint64_t NumNodes =
276276
endian::readNext<uint64_t, llvm::endianness::little>(Ptr);
277277
Record.AllocSites.reserve(NumNodes);
278+
const size_t SerializedSize = PortableMemInfoBlock::serializedSize(Schema);
278279
for (uint64_t I = 0; I < NumNodes; I++) {
279280
IndexedAllocationInfo Node;
280281
Node.CSId =
281282
endian::readNext<LinearCallStackId, llvm::endianness::little>(Ptr);
282283
Node.Info.deserialize(Schema, Ptr);
283-
Ptr += PortableMemInfoBlock::serializedSize(Schema);
284+
Ptr += SerializedSize;
284285
Record.AllocSites.push_back(Node);
285286
}
286287

0 commit comments

Comments
 (0)