[llvm] [memprof] Use std::move in toMemProfRecord (PR #93133)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed May 22 21:28:13 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/93133

std::move here results in a measurable speed-up in llvm-profdata
modified to deserialize all MemProfRecords.  The cycle count goes down
by 6.1% while the instruction count goes down by 20%.

>From e8d005cc7c9b9c784d9d0aa9fde4ea2dea16f04d Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 22 May 2024 00:03:00 -0700
Subject: [PATCH] [memprof] Use std::move in toMemProfRecord

std::move here results in a measurable speed-up in llvm-profdata
modified to deserialize all MemProfRecords.  The cycle count goes down
by 6.1% while the instruction count goes down by 20%.
---
 llvm/lib/ProfileData/MemProf.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/ProfileData/MemProf.cpp b/llvm/lib/ProfileData/MemProf.cpp
index f5789186094c6..01957f4eb1c1a 100644
--- a/llvm/lib/ProfileData/MemProf.cpp
+++ b/llvm/lib/ProfileData/MemProf.cpp
@@ -251,7 +251,7 @@ MemProfRecord IndexedMemProfRecord::toMemProfRecord(
     memprof::AllocationInfo AI;
     AI.Info = IndexedAI.Info;
     AI.CallStack = Callback(IndexedAI.CSId);
-    Record.AllocSites.push_back(AI);
+    Record.AllocSites.push_back(std::move(AI));
   }
 
   for (memprof::CallStackId CSId : CallSiteIds)



More information about the llvm-commits mailing list