[llvm] 300663a - [memprof] Use std::move in toMemProfRecord (#93133)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 23 12:27:42 PDT 2024


Author: Kazu Hirata
Date: 2024-05-23T12:27:38-07:00
New Revision: 300663a190537cfd2692003dc4af0aebb904bde0

URL: https://github.com/llvm/llvm-project/commit/300663a190537cfd2692003dc4af0aebb904bde0
DIFF: https://github.com/llvm/llvm-project/commit/300663a190537cfd2692003dc4af0aebb904bde0.diff

LOG: [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%.

Added: 
    

Modified: 
    llvm/lib/ProfileData/MemProf.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ProfileData/MemProf.cpp b/llvm/lib/ProfileData/MemProf.cpp
index f5789186094c6..5c86c0d9c7bbb 100644
--- a/llvm/lib/ProfileData/MemProf.cpp
+++ b/llvm/lib/ProfileData/MemProf.cpp
@@ -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));
 


        


More information about the llvm-commits mailing list