Skip to content

Commit 300663a

Browse files
[memprof] Use std::move in toMemProfRecord (#93133)
std::move and reserve here result in a measurable speed-up in llvm-profdata modified to deserialize all MemProfRecords. The cycle count goes down by 7.1% while the instruction count goes down by 21%.
1 parent f3d6db3 commit 300663a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llvm/lib/ProfileData/MemProf.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,15 @@ MemProfRecord IndexedMemProfRecord::toMemProfRecord(
247247
Callback) const {
248248
MemProfRecord Record;
249249

250+
Record.AllocSites.reserve(AllocSites.size());
250251
for (const memprof::IndexedAllocationInfo &IndexedAI : AllocSites) {
251252
memprof::AllocationInfo AI;
252253
AI.Info = IndexedAI.Info;
253254
AI.CallStack = Callback(IndexedAI.CSId);
254-
Record.AllocSites.push_back(AI);
255+
Record.AllocSites.push_back(std::move(AI));
255256
}
256257

258+
Record.CallSites.reserve(CallSiteIds.size());
257259
for (memprof::CallStackId CSId : CallSiteIds)
258260
Record.CallSites.push_back(Callback(CSId));
259261

0 commit comments

Comments
 (0)