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(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(Ptr); Node.Info.deserialize(Schema, Ptr); - Ptr += PortableMemInfoBlock::serializedSize(Schema); + Ptr += SerializedSize; Record.AllocSites.push_back(Node); }