Skip to content

Commit

Permalink
[memprof] Use std::move in toMemProfRecord (#93133)
Browse files Browse the repository at this point in the history
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%.
  • Loading branch information
kazutakahirata committed May 23, 2024
1 parent f3d6db3 commit 300663a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion llvm/lib/ProfileData/MemProf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,15 @@ MemProfRecord IndexedMemProfRecord::toMemProfRecord(
Callback) const {
MemProfRecord Record;

Record.AllocSites.reserve(AllocSites.size());
for (const memprof::IndexedAllocationInfo &IndexedAI : AllocSites) {
memprof::AllocationInfo AI;
AI.Info = IndexedAI.Info;
AI.CallStack = Callback(IndexedAI.CSId);
Record.AllocSites.push_back(AI);
Record.AllocSites.push_back(std::move(AI));
}

Record.CallSites.reserve(CallSiteIds.size());
for (memprof::CallStackId CSId : CallSiteIds)
Record.CallSites.push_back(Callback(CSId));

Expand Down

0 comments on commit 300663a

Please sign in to comment.