Skip to content

[memprof] Use structured binding (NFC) #89315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions llvm/lib/ProfileData/InstrProfWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,24 +272,24 @@ void InstrProfWriter::addRecord(StringRef Name, uint64_t Hash,

void InstrProfWriter::addMemProfRecord(
const Function::GUID Id, const memprof::IndexedMemProfRecord &Record) {
auto Result = MemProfRecordData.insert({Id, Record});
auto [Iter, Inserted] = MemProfRecordData.insert({Id, Record});
// If we inserted a new record then we are done.
if (Result.second) {
if (Inserted) {
return;
}
memprof::IndexedMemProfRecord &Existing = Result.first->second;
memprof::IndexedMemProfRecord &Existing = Iter->second;
Existing.merge(Record);
}

bool InstrProfWriter::addMemProfFrame(const memprof::FrameId Id,
const memprof::Frame &Frame,
function_ref<void(Error)> Warn) {
auto Result = MemProfFrameData.insert({Id, Frame});
auto [Iter, Inserted] = MemProfFrameData.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
// mapping across profiles is inconsistent.
if (!Result.second && Result.first->second != Frame) {
if (!Inserted && Iter->second != Frame) {
Warn(make_error<InstrProfError>(instrprof_error::malformed,
"frame to id mapping mismatch"));
return false;
Expand Down Expand Up @@ -388,10 +388,10 @@ void InstrProfWriter::mergeRecordsFromWriter(InstrProfWriter &&IPW,
IPW.TemporalProfTraceStreamSize);

MemProfFrameData.reserve(IPW.MemProfFrameData.size());
for (auto &I : IPW.MemProfFrameData) {
for (auto &[FrameId, Frame] : IPW.MemProfFrameData) {
// 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(I.first, I.second, Warn))
if (!addMemProfFrame(FrameId, Frame, Warn))
return;
}

Expand All @@ -402,8 +402,8 @@ void InstrProfWriter::mergeRecordsFromWriter(InstrProfWriter &&IPW,
}

MemProfRecordData.reserve(IPW.MemProfRecordData.size());
for (auto &I : IPW.MemProfRecordData) {
addMemProfRecord(I.first, I.second);
for (auto &[GUID, Record] : IPW.MemProfRecordData) {
addMemProfRecord(GUID, Record);
}
}

Expand Down