[llvm] [memprof] Don't use Frame::hash() (NFC) (PR #119828)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 12 23:09:39 PST 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/119828
In these tests, we just want to add one instance of
IndexedMemProfRecord to MemProfData.Records and retrieve it from
MemProfReader. There is no particular reason to associate F1.hash()
with the IndexedMemProfRecord instance. A fake value suffices.
While I am at it, I'm switching to try_emplace so that I can move
FakeRecord.
>From 4fe9621b8fef2fec1213bc3685d4b87b774c0304 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 12 Dec 2024 22:54:37 -0800
Subject: [PATCH] [memprof] Don't use Frame::hash() (NFC)
In these tests, we just want to add one instance of
IndexedMemProfRecord to MemProfData.Records and retrieve it from
MemProfReader. There is no particular reason to associate F1.hash()
with the IndexedMemProfRecord instance. A fake value suffices.
While I am at it, I'm switching to try_emplace so that I can move
FakeRecord.
---
llvm/unittests/ProfileData/MemProfTest.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp
index af801d0ff5e1e2..2cb4725ab89e38 100644
--- a/llvm/unittests/ProfileData/MemProfTest.cpp
+++ b/llvm/unittests/ProfileData/MemProfTest.cpp
@@ -422,7 +422,7 @@ TEST(MemProf, BaseMemProfReader) {
Block.AllocCount = 1U, Block.TotalAccessDensity = 4,
Block.TotalLifetime = 200001;
FakeRecord.AllocSites.emplace_back(/*CSId=*/CSId, /*MB=*/Block);
- MemProfData.Records.insert({F1.hash(), FakeRecord});
+ MemProfData.Records.try_emplace(0x1234, std::move(FakeRecord));
MemProfReader Reader(std::move(MemProfData));
@@ -454,7 +454,7 @@ TEST(MemProf, BaseMemProfReaderWithCSIdMap) {
Block.AllocCount = 1U, Block.TotalAccessDensity = 4,
Block.TotalLifetime = 200001;
FakeRecord.AllocSites.emplace_back(/*CSId=*/CSId, /*MB=*/Block);
- MemProfData.Records.insert({F1.hash(), FakeRecord});
+ MemProfData.Records.try_emplace(0x1234, std::move(FakeRecord));
MemProfReader Reader(std::move(MemProfData));
More information about the llvm-commits
mailing list