Skip to content

Commit 3e4bc1d

Browse files
committed
Hoist serialized size computation outside the loop.
1 parent 6d756d6 commit 3e4bc1d

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
@@ -276,12 +276,13 @@ static IndexedMemProfRecord deserializeV4(const MemProfSchema &Schema,
276276
const uint64_t NumNodes =
277277
endian::readNext<uint64_t, llvm::endianness::little>(Ptr);
278278
Record.AllocSites.reserve(NumNodes);
279+
const size_t SerializedSize = PortableMemInfoBlock::serializedSize(Schema);
279280
for (uint64_t I = 0; I < NumNodes; I++) {
280281
IndexedAllocationInfo Node;
281282
Node.CSId =
282283
endian::readNext<LinearCallStackId, llvm::endianness::little>(Ptr);
283284
Node.Info.deserialize(Schema, Ptr);
284-
Ptr += PortableMemInfoBlock::serializedSize(Schema);
285+
Ptr += SerializedSize;
285286
Record.AllocSites.push_back(Node);
286287
}
287288

0 commit comments

Comments
 (0)