Skip to content

Commit 3749e0d

Browse files
[memprof] Use structured binding (NFC) (llvm#88363)
1 parent f135d22 commit 3749e0d

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

llvm/lib/ProfileData/MemProfReader.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ CallStackMap readStackInfo(const char *Ptr) {
142142
// any stack ids observed previously map to a different set of program counter
143143
// addresses.
144144
bool mergeStackMap(const CallStackMap &From, CallStackMap &To) {
145-
for (const auto &IdStack : From) {
146-
auto I = To.find(IdStack.first);
145+
for (const auto &[Id, Stack] : From) {
146+
auto I = To.find(Id);
147147
if (I == To.end()) {
148-
To[IdStack.first] = IdStack.second;
148+
To[Id] = Stack;
149149
} else {
150150
// Check that the PCs are the same (in order).
151-
if (IdStack.second != I->second)
151+
if (Stack != I->second)
152152
return true;
153153
}
154154
}
@@ -275,10 +275,10 @@ void RawMemProfReader::printYAML(raw_ostream &OS) {
275275
}
276276
// Print out the merged contents of the profiles.
277277
OS << " Records:\n";
278-
for (const auto &Entry : *this) {
278+
for (const auto &[GUID, Record] : *this) {
279279
OS << " -\n";
280-
OS << " FunctionGUID: " << Entry.first << "\n";
281-
Entry.second.print(OS);
280+
OS << " FunctionGUID: " << GUID << "\n";
281+
Record.print(OS);
282282
}
283283
}
284284

@@ -405,9 +405,7 @@ Error RawMemProfReader::mapRawProfileToRecords() {
405405

406406
// Convert the raw profile callstack data into memprof records. While doing so
407407
// keep track of related contexts so that we can fill these in later.
408-
for (const auto &Entry : CallstackProfileData) {
409-
const uint64_t StackId = Entry.first;
410-
408+
for (const auto &[StackId, MIB] : CallstackProfileData) {
411409
auto It = StackMap.find(StackId);
412410
if (It == StackMap.end())
413411
return make_error<InstrProfError>(
@@ -455,7 +453,7 @@ Error RawMemProfReader::mapRawProfileToRecords() {
455453
auto Result =
456454
FunctionProfileData.insert({F.Function, IndexedMemProfRecord()});
457455
IndexedMemProfRecord &Record = Result.first->second;
458-
Record.AllocSites.emplace_back(Callstack, CSId, Entry.second);
456+
Record.AllocSites.emplace_back(Callstack, CSId, MIB);
459457

460458
if (!F.IsInlineFrame)
461459
break;

llvm/tools/llvm-profdata/llvm-profdata.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,8 @@ static void loadInput(const WeightedFile &Input, SymbolRemapper *Remapper,
679679
}
680680
const auto &FunctionProfileData = Reader->getProfileData();
681681
// Add the memprof records into the writer context.
682-
for (const auto &I : FunctionProfileData) {
683-
WC->Writer.addMemProfRecord(/*Id=*/I.first, /*Record=*/I.second);
682+
for (const auto &[GUID, Record] : FunctionProfileData) {
683+
WC->Writer.addMemProfRecord(GUID, Record);
684684
}
685685
return;
686686
}

0 commit comments

Comments
 (0)