[llvm] [memprof] Use std::move in toMemProfRecord (PR #93133)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu May 23 12:24:59 PDT 2024
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/93133
>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 1/2] [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)
>From 8ca87706cb8b2c1e9e6bea78260c71c65fb24469 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 23 May 2024 12:23:12 -0700
Subject: [PATCH 2/2] Add calls to reserve.
---
llvm/lib/ProfileData/MemProf.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/llvm/lib/ProfileData/MemProf.cpp b/llvm/lib/ProfileData/MemProf.cpp
index 01957f4eb1c1a..5c86c0d9c7bbb 100644
--- a/llvm/lib/ProfileData/MemProf.cpp
+++ b/llvm/lib/ProfileData/MemProf.cpp
@@ -247,6 +247,7 @@ 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;
@@ -254,6 +255,7 @@ MemProfRecord IndexedMemProfRecord::toMemProfRecord(
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