[llvm] a4e1a3d - [memprof] Add another constructor to IndexedAllocationInfo (NFC) (#116684)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 18 14:09:25 PST 2024
Author: Kazu Hirata
Date: 2024-11-18T14:09:21-08:00
New Revision: a4e1a3dc8bc9bb971d8a38130254b4570f8b7a03
URL: https://github.com/llvm/llvm-project/commit/a4e1a3dc8bc9bb971d8a38130254b4570f8b7a03
DIFF: https://github.com/llvm/llvm-project/commit/a4e1a3dc8bc9bb971d8a38130254b4570f8b7a03.diff
LOG: [memprof] Add another constructor to IndexedAllocationInfo (NFC) (#116684)
This patch adds another constructor to IndexedAllocationInfo that is
identical to the existing constructor except that the new one leaves
the CallStack field empty.
I'm planning to remove MemProf format Version 1. Then we will migrate
the users of the existing constructor to the new one as nobody will be
using the CallStack field anymore.
Adding the new constructor now allows us to migrate a few existing
users of the old constructor even before we remove the CallStack
field. In turn, that simplifies the patch to actually remove the
field.
Added:
Modified:
llvm/include/llvm/ProfileData/MemProf.h
llvm/unittests/ProfileData/InstrProfTest.cpp
llvm/unittests/ProfileData/MemProfTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ProfileData/MemProf.h b/llvm/include/llvm/ProfileData/MemProf.h
index 6a29e3df9629bc..9415e554bcc0ab 100644
--- a/llvm/include/llvm/ProfileData/MemProf.h
+++ b/llvm/include/llvm/ProfileData/MemProf.h
@@ -354,10 +354,15 @@ struct IndexedAllocationInfo {
PortableMemInfoBlock Info;
IndexedAllocationInfo() = default;
+ // This constructor is soft deprecated. It will be removed once we remove all
+ // users of the CallStack field.
IndexedAllocationInfo(ArrayRef<FrameId> CS, CallStackId CSId,
const MemInfoBlock &MB,
const MemProfSchema &Schema = getFullSchema())
: CallStack(CS), CSId(CSId), Info(MB, Schema) {}
+ IndexedAllocationInfo(CallStackId CSId, const MemInfoBlock &MB,
+ const MemProfSchema &Schema = getFullSchema())
+ : CSId(CSId), Info(MB, Schema) {}
// Returns the size in bytes when this allocation info struct is serialized.
size_t serializedSize(const MemProfSchema &Schema,
diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp
index b9f244104c65cf..5a313aa4182a54 100644
--- a/llvm/unittests/ProfileData/InstrProfTest.cpp
+++ b/llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -415,8 +415,7 @@ makeRecordV2(std::initializer_list<::llvm::memprof::CallStackId> AllocFrames,
for (const auto &CSId : AllocFrames)
// We don't populate IndexedAllocationInfo::CallStack because we use it only
// in Version1.
- MR.AllocSites.emplace_back(::llvm::SmallVector<memprof::FrameId>(), CSId,
- Block, Schema);
+ MR.AllocSites.emplace_back(CSId, Block, Schema);
for (const auto &CSId : CallSiteFrames)
MR.CallSiteIds.push_back(CSId);
return MR;
diff --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp
index c90669811e60ae..5097dbdd6c3915 100644
--- a/llvm/unittests/ProfileData/MemProfTest.cpp
+++ b/llvm/unittests/ProfileData/MemProfTest.cpp
@@ -315,7 +315,7 @@ TEST(MemProf, RecordSerializationRoundTripVerion2) {
IndexedMemProfRecord Record;
for (const auto &CSId : CallStackIds) {
// Use the same info block for both allocation sites.
- Record.AllocSites.emplace_back(llvm::SmallVector<FrameId>(), CSId, Info);
+ Record.AllocSites.emplace_back(CSId, Info);
}
Record.CallSiteIds.assign(CallSiteIds);
@@ -346,8 +346,7 @@ TEST(MemProf, RecordSerializationRoundTripVersion2HotColdSchema) {
IndexedMemProfRecord Record;
for (const auto &CSId : CallStackIds) {
// Use the same info block for both allocation sites.
- Record.AllocSites.emplace_back(llvm::SmallVector<FrameId>(), CSId, Info,
- Schema);
+ Record.AllocSites.emplace_back(CSId, Info, Schema);
}
Record.CallSiteIds.assign(CallSiteIds);
@@ -510,7 +509,6 @@ TEST(MemProf, BaseMemProfReaderWithCSIdMap) {
Block.AllocCount = 1U, Block.TotalAccessDensity = 4,
Block.TotalLifetime = 200001;
FakeRecord.AllocSites.emplace_back(
- /*CS=*/llvm::SmallVector<FrameId>(),
/*CSId=*/llvm::memprof::hashCallStack(CallStack),
/*MB=*/Block);
ProfData.insert({F1.hash(), FakeRecord});
@@ -610,7 +608,7 @@ MemInfoBlock makePartialMIB() {
TEST(MemProf, MissingCallStackId) {
// Use a non-existent CallStackId to trigger a mapping error in
// toMemProfRecord.
- llvm::memprof::IndexedAllocationInfo AI({}, 0xdeadbeefU, makePartialMIB(),
+ llvm::memprof::IndexedAllocationInfo AI(0xdeadbeefU, makePartialMIB(),
llvm::memprof::getHotColdSchema());
IndexedMemProfRecord IndexedMR;
@@ -633,7 +631,7 @@ TEST(MemProf, MissingCallStackId) {
}
TEST(MemProf, MissingFrameId) {
- llvm::memprof::IndexedAllocationInfo AI({}, 0x222, makePartialMIB(),
+ llvm::memprof::IndexedAllocationInfo AI(0x222, makePartialMIB(),
llvm::memprof::getHotColdSchema());
IndexedMemProfRecord IndexedMR;
More information about the llvm-commits
mailing list