[llvm] [memprof] std::move matchings (NFC) (PR #128933)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 26 12:04:30 PST 2025
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/128933
>From 3b1c5854a034aa5ff1e2b40339d84fddf3f64898 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 26 Feb 2025 11:00:36 -0800
Subject: [PATCH 1/2] [memprof] std::move matchings (NFC)
We do not modify Matchings after we call try_emplace, so we can just
std::move Matchings.
---
llvm/lib/Transforms/Instrumentation/MemProfiler.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
index 7d8bc3aa4c589..8149f55b46274 100644
--- a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
@@ -929,7 +929,8 @@ memprof::computeUndriftMap(Module &M, IndexedInstrProfReader *MemProfReader,
longestCommonSequence<LineLocation, GlobalValue::GUID>(
ProfileAnchors, IRAnchors, std::equal_to<GlobalValue::GUID>(),
[&](LineLocation A, LineLocation B) { Matchings.try_emplace(A, B); });
- bool Inserted = UndriftMaps.try_emplace(CallerGUID, Matchings).second;
+ bool Inserted =
+ UndriftMaps.try_emplace(CallerGUID, std::move(Matchings)).second;
// The insertion must succeed because we visit each GUID exactly once.
assert(Inserted);
>From 49a3b18035aa36941c5db80fdae62b288df4c132 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 26 Feb 2025 12:04:15 -0800
Subject: [PATCH 2/2] Address a comment.
---
llvm/lib/Transforms/Instrumentation/MemProfiler.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
index 8149f55b46274..c6352df39bba5 100644
--- a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
@@ -929,12 +929,11 @@ memprof::computeUndriftMap(Module &M, IndexedInstrProfReader *MemProfReader,
longestCommonSequence<LineLocation, GlobalValue::GUID>(
ProfileAnchors, IRAnchors, std::equal_to<GlobalValue::GUID>(),
[&](LineLocation A, LineLocation B) { Matchings.try_emplace(A, B); });
- bool Inserted =
+ [[maybe_unused]] bool Inserted =
UndriftMaps.try_emplace(CallerGUID, std::move(Matchings)).second;
// The insertion must succeed because we visit each GUID exactly once.
assert(Inserted);
- (void)Inserted;
}
return UndriftMaps;
More information about the llvm-commits
mailing list