aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/InstrProfWriter.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-06-18 14:23:59 -0700
committerGitHub <noreply@github.com>2024-06-18 14:23:59 -0700
commit773ee62e16b859f41104c53bc3b80fb318d13eb2 (patch)
tree69b050749e4798db4c0c8f009679150107d4152c /llvm/lib/ProfileData/InstrProfWriter.cpp
parent66df7657c83a3650312699163e4dce085bd2a160 (diff)
downloadllvm-773ee62e16b859f41104c53bc3b80fb318d13eb2.zip
llvm-773ee62e16b859f41104c53bc3b80fb318d13eb2.tar.gz
llvm-773ee62e16b859f41104c53bc3b80fb318d13eb2.tar.bz2
[memprof] Rename the members of IndexedMemProfData (NFC) (#94873)
I'm planning to use IndexedMemProfData in MemProfReader and beyond. Before I do so, this patch renames the members of IndexedMemProfData as MemProfData.FrameData is a bit mouthful with "Data" repeated twice. Note that MemProfReader currently has a trio -- IdToFrame, CSIdToCallStack, and FunctionProfileData. Replacing them with an instance of IndexedMemProfData allows us to use the move semantics from the reader to the writer context. More importantly, treating the profile data as one package makes the maintenance easier. In the past, forgetting to update a place dealing with the trio has resulted in a bug where we totally forgot to emit call stacks into the indexed profile.
Diffstat (limited to 'llvm/lib/ProfileData/InstrProfWriter.cpp')
-rw-r--r--llvm/lib/ProfileData/InstrProfWriter.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index eac59ea..1ba2291 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -274,7 +274,7 @@ void InstrProfWriter::addRecord(StringRef Name, uint64_t Hash,
void InstrProfWriter::addMemProfRecord(
const Function::GUID Id, const memprof::IndexedMemProfRecord &Record) {
- auto [Iter, Inserted] = MemProfData.RecordData.insert({Id, Record});
+ auto [Iter, Inserted] = MemProfData.Records.insert({Id, Record});
// If we inserted a new record then we are done.
if (Inserted) {
return;
@@ -286,7 +286,7 @@ void InstrProfWriter::addMemProfRecord(
bool InstrProfWriter::addMemProfFrame(const memprof::FrameId Id,
const memprof::Frame &Frame,
function_ref<void(Error)> Warn) {
- auto [Iter, Inserted] = MemProfData.FrameData.insert({Id, Frame});
+ auto [Iter, Inserted] = MemProfData.Frames.insert({Id, Frame});
// If a mapping already exists for the current frame id and it does not
// match the new mapping provided then reset the existing contents and bail
// out. We don't support the merging of memprof data whose Frame -> Id
@@ -303,7 +303,7 @@ bool InstrProfWriter::addMemProfCallStack(
const memprof::CallStackId CSId,
const llvm::SmallVector<memprof::FrameId> &CallStack,
function_ref<void(Error)> Warn) {
- auto [Iter, Inserted] = MemProfData.CallStackData.insert({CSId, CallStack});
+ auto [Iter, Inserted] = MemProfData.CallStacks.insert({CSId, CallStack});
// If a mapping already exists for the current call stack id and it does not
// match the new mapping provided then reset the existing contents and bail
// out. We don't support the merging of memprof data whose CallStack -> Id
@@ -390,22 +390,22 @@ void InstrProfWriter::mergeRecordsFromWriter(InstrProfWriter &&IPW,
addTemporalProfileTraces(IPW.TemporalProfTraces,
IPW.TemporalProfTraceStreamSize);
- MemProfData.FrameData.reserve(IPW.MemProfData.FrameData.size());
- for (auto &[FrameId, Frame] : IPW.MemProfData.FrameData) {
+ MemProfData.Frames.reserve(IPW.MemProfData.Frames.size());
+ for (auto &[FrameId, Frame] : IPW.MemProfData.Frames) {
// If we weren't able to add the frame mappings then it doesn't make sense
// to try to merge the records from this profile.
if (!addMemProfFrame(FrameId, Frame, Warn))
return;
}
- MemProfData.CallStackData.reserve(IPW.MemProfData.CallStackData.size());
- for (auto &[CSId, CallStack] : IPW.MemProfData.CallStackData) {
+ MemProfData.CallStacks.reserve(IPW.MemProfData.CallStacks.size());
+ for (auto &[CSId, CallStack] : IPW.MemProfData.CallStacks) {
if (!addMemProfCallStack(CSId, CallStack, Warn))
return;
}
- MemProfData.RecordData.reserve(IPW.MemProfData.RecordData.size());
- for (auto &[GUID, Record] : IPW.MemProfData.RecordData) {
+ MemProfData.Records.reserve(IPW.MemProfData.Records.size());
+ for (auto &[GUID, Record] : IPW.MemProfData.Records) {
addMemProfRecord(GUID, Record);
}
}
@@ -605,11 +605,11 @@ static Error writeMemProfV0(ProfOStream &OS,
auto Schema = memprof::getFullSchema();
writeMemProfSchema(OS, Schema);
- uint64_t RecordTableOffset = writeMemProfRecords(OS, MemProfData.RecordData,
- &Schema, memprof::Version0);
+ uint64_t RecordTableOffset =
+ writeMemProfRecords(OS, MemProfData.Records, &Schema, memprof::Version0);
uint64_t FramePayloadOffset = OS.tell();
- uint64_t FrameTableOffset = writeMemProfFrames(OS, MemProfData.FrameData);
+ uint64_t FrameTableOffset = writeMemProfFrames(OS, MemProfData.Frames);
uint64_t Header[] = {RecordTableOffset, FramePayloadOffset, FrameTableOffset};
OS.patch({{HeaderUpdatePos, Header, std::size(Header)}});
@@ -640,11 +640,11 @@ static Error writeMemProfV1(ProfOStream &OS,
auto Schema = memprof::getFullSchema();
writeMemProfSchema(OS, Schema);
- uint64_t RecordTableOffset = writeMemProfRecords(OS, MemProfData.RecordData,
- &Schema, memprof::Version1);
+ uint64_t RecordTableOffset =
+ writeMemProfRecords(OS, MemProfData.Records, &Schema, memprof::Version1);
uint64_t FramePayloadOffset = OS.tell();
- uint64_t FrameTableOffset = writeMemProfFrames(OS, MemProfData.FrameData);
+ uint64_t FrameTableOffset = writeMemProfFrames(OS, MemProfData.Frames);
uint64_t Header[] = {RecordTableOffset, FramePayloadOffset, FrameTableOffset};
OS.patch({{HeaderUpdatePos, Header, std::size(Header)}});
@@ -683,15 +683,15 @@ static Error writeMemProfV2(ProfOStream &OS,
Schema = memprof::getFullSchema();
writeMemProfSchema(OS, Schema);
- uint64_t RecordTableOffset = writeMemProfRecords(OS, MemProfData.RecordData,
- &Schema, memprof::Version2);
+ uint64_t RecordTableOffset =
+ writeMemProfRecords(OS, MemProfData.Records, &Schema, memprof::Version2);
uint64_t FramePayloadOffset = OS.tell();
- uint64_t FrameTableOffset = writeMemProfFrames(OS, MemProfData.FrameData);
+ uint64_t FrameTableOffset = writeMemProfFrames(OS, MemProfData.Frames);
uint64_t CallStackPayloadOffset = OS.tell();
uint64_t CallStackTableOffset =
- writeMemProfCallStacks(OS, MemProfData.CallStackData);
+ writeMemProfCallStacks(OS, MemProfData.CallStacks);
uint64_t Header[] = {
RecordTableOffset, FramePayloadOffset, FrameTableOffset,
@@ -730,21 +730,21 @@ static Error writeMemProfV3(ProfOStream &OS,
writeMemProfSchema(OS, Schema);
llvm::DenseMap<memprof::FrameId, memprof::FrameStat> FrameHistogram =
- memprof::computeFrameHistogram(MemProfData.CallStackData);
- assert(MemProfData.FrameData.size() == FrameHistogram.size());
+ memprof::computeFrameHistogram(MemProfData.CallStacks);
+ assert(MemProfData.Frames.size() == FrameHistogram.size());
llvm::DenseMap<memprof::FrameId, memprof::LinearFrameId> MemProfFrameIndexes =
- writeMemProfFrameArray(OS, MemProfData.FrameData, FrameHistogram);
+ writeMemProfFrameArray(OS, MemProfData.Frames, FrameHistogram);
uint64_t CallStackPayloadOffset = OS.tell();
llvm::DenseMap<memprof::CallStackId, memprof::LinearCallStackId>
MemProfCallStackIndexes = writeMemProfCallStackArray(
- OS, MemProfData.CallStackData, MemProfFrameIndexes, FrameHistogram);
+ OS, MemProfData.CallStacks, MemProfFrameIndexes, FrameHistogram);
uint64_t RecordPayloadOffset = OS.tell();
uint64_t RecordTableOffset =
- writeMemProfRecords(OS, MemProfData.RecordData, &Schema,
- memprof::Version3, &MemProfCallStackIndexes);
+ writeMemProfRecords(OS, MemProfData.Records, &Schema, memprof::Version3,
+ &MemProfCallStackIndexes);
uint64_t Header[] = {
CallStackPayloadOffset,