Skip to content

Commit a4e1a3d

Browse files
[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.
1 parent e0b522d commit a4e1a3d

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

llvm/include/llvm/ProfileData/MemProf.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,15 @@ struct IndexedAllocationInfo {
354354
PortableMemInfoBlock Info;
355355

356356
IndexedAllocationInfo() = default;
357+
// This constructor is soft deprecated. It will be removed once we remove all
358+
// users of the CallStack field.
357359
IndexedAllocationInfo(ArrayRef<FrameId> CS, CallStackId CSId,
358360
const MemInfoBlock &MB,
359361
const MemProfSchema &Schema = getFullSchema())
360362
: CallStack(CS), CSId(CSId), Info(MB, Schema) {}
363+
IndexedAllocationInfo(CallStackId CSId, const MemInfoBlock &MB,
364+
const MemProfSchema &Schema = getFullSchema())
365+
: CSId(CSId), Info(MB, Schema) {}
361366

362367
// Returns the size in bytes when this allocation info struct is serialized.
363368
size_t serializedSize(const MemProfSchema &Schema,

llvm/unittests/ProfileData/InstrProfTest.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,7 @@ makeRecordV2(std::initializer_list<::llvm::memprof::CallStackId> AllocFrames,
415415
for (const auto &CSId : AllocFrames)
416416
// We don't populate IndexedAllocationInfo::CallStack because we use it only
417417
// in Version1.
418-
MR.AllocSites.emplace_back(::llvm::SmallVector<memprof::FrameId>(), CSId,
419-
Block, Schema);
418+
MR.AllocSites.emplace_back(CSId, Block, Schema);
420419
for (const auto &CSId : CallSiteFrames)
421420
MR.CallSiteIds.push_back(CSId);
422421
return MR;

llvm/unittests/ProfileData/MemProfTest.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ TEST(MemProf, RecordSerializationRoundTripVerion2) {
315315
IndexedMemProfRecord Record;
316316
for (const auto &CSId : CallStackIds) {
317317
// Use the same info block for both allocation sites.
318-
Record.AllocSites.emplace_back(llvm::SmallVector<FrameId>(), CSId, Info);
318+
Record.AllocSites.emplace_back(CSId, Info);
319319
}
320320
Record.CallSiteIds.assign(CallSiteIds);
321321

@@ -346,8 +346,7 @@ TEST(MemProf, RecordSerializationRoundTripVersion2HotColdSchema) {
346346
IndexedMemProfRecord Record;
347347
for (const auto &CSId : CallStackIds) {
348348
// Use the same info block for both allocation sites.
349-
Record.AllocSites.emplace_back(llvm::SmallVector<FrameId>(), CSId, Info,
350-
Schema);
349+
Record.AllocSites.emplace_back(CSId, Info, Schema);
351350
}
352351
Record.CallSiteIds.assign(CallSiteIds);
353352

@@ -510,7 +509,6 @@ TEST(MemProf, BaseMemProfReaderWithCSIdMap) {
510509
Block.AllocCount = 1U, Block.TotalAccessDensity = 4,
511510
Block.TotalLifetime = 200001;
512511
FakeRecord.AllocSites.emplace_back(
513-
/*CS=*/llvm::SmallVector<FrameId>(),
514512
/*CSId=*/llvm::memprof::hashCallStack(CallStack),
515513
/*MB=*/Block);
516514
ProfData.insert({F1.hash(), FakeRecord});
@@ -610,7 +608,7 @@ MemInfoBlock makePartialMIB() {
610608
TEST(MemProf, MissingCallStackId) {
611609
// Use a non-existent CallStackId to trigger a mapping error in
612610
// toMemProfRecord.
613-
llvm::memprof::IndexedAllocationInfo AI({}, 0xdeadbeefU, makePartialMIB(),
611+
llvm::memprof::IndexedAllocationInfo AI(0xdeadbeefU, makePartialMIB(),
614612
llvm::memprof::getHotColdSchema());
615613

616614
IndexedMemProfRecord IndexedMR;
@@ -633,7 +631,7 @@ TEST(MemProf, MissingCallStackId) {
633631
}
634632

635633
TEST(MemProf, MissingFrameId) {
636-
llvm::memprof::IndexedAllocationInfo AI({}, 0x222, makePartialMIB(),
634+
llvm::memprof::IndexedAllocationInfo AI(0x222, makePartialMIB(),
637635
llvm::memprof::getHotColdSchema());
638636

639637
IndexedMemProfRecord IndexedMR;

0 commit comments

Comments
 (0)