[llvm] [memprof] Use structured binding (NFC) (PR #88363)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 11 01:01:29 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/88363
None
>From a085d62179796c7d596025cafe5634f7966b7c7b Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 9 Apr 2024 19:09:15 -0700
Subject: [PATCH] [memprof] Use structured binding (NFC)
---
llvm/lib/ProfileData/MemProfReader.cpp | 20 +++++++++-----------
llvm/tools/llvm-profdata/llvm-profdata.cpp | 4 ++--
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/llvm/lib/ProfileData/MemProfReader.cpp b/llvm/lib/ProfileData/MemProfReader.cpp
index 4ccec26597c098..580867a9083fde 100644
--- a/llvm/lib/ProfileData/MemProfReader.cpp
+++ b/llvm/lib/ProfileData/MemProfReader.cpp
@@ -142,13 +142,13 @@ CallStackMap readStackInfo(const char *Ptr) {
// any stack ids observed previously map to a different set of program counter
// addresses.
bool mergeStackMap(const CallStackMap &From, CallStackMap &To) {
- for (const auto &IdStack : From) {
- auto I = To.find(IdStack.first);
+ for (const auto &[Id, Stack] : From) {
+ auto I = To.find(Id);
if (I == To.end()) {
- To[IdStack.first] = IdStack.second;
+ To[Id] = Stack;
} else {
// Check that the PCs are the same (in order).
- if (IdStack.second != I->second)
+ if (Stack != I->second)
return true;
}
}
@@ -275,10 +275,10 @@ void RawMemProfReader::printYAML(raw_ostream &OS) {
}
// Print out the merged contents of the profiles.
OS << " Records:\n";
- for (const auto &Entry : *this) {
+ for (const auto &[GUID, Record] : *this) {
OS << " -\n";
- OS << " FunctionGUID: " << Entry.first << "\n";
- Entry.second.print(OS);
+ OS << " FunctionGUID: " << GUID << "\n";
+ Record.print(OS);
}
}
@@ -405,9 +405,7 @@ Error RawMemProfReader::mapRawProfileToRecords() {
// Convert the raw profile callstack data into memprof records. While doing so
// keep track of related contexts so that we can fill these in later.
- for (const auto &Entry : CallstackProfileData) {
- const uint64_t StackId = Entry.first;
-
+ for (const auto &[StackId, MIB] : CallstackProfileData) {
auto It = StackMap.find(StackId);
if (It == StackMap.end())
return make_error<InstrProfError>(
@@ -455,7 +453,7 @@ Error RawMemProfReader::mapRawProfileToRecords() {
auto Result =
FunctionProfileData.insert({F.Function, IndexedMemProfRecord()});
IndexedMemProfRecord &Record = Result.first->second;
- Record.AllocSites.emplace_back(Callstack, CSId, Entry.second);
+ Record.AllocSites.emplace_back(Callstack, CSId, MIB);
if (!F.IsInlineFrame)
break;
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 6a70773613b7f3..66a4cea0353479 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -679,8 +679,8 @@ static void loadInput(const WeightedFile &Input, SymbolRemapper *Remapper,
}
const auto &FunctionProfileData = Reader->getProfileData();
// Add the memprof records into the writer context.
- for (const auto &I : FunctionProfileData) {
- WC->Writer.addMemProfRecord(/*Id=*/I.first, /*Record=*/I.second);
+ for (const auto &[GUID, Record] : FunctionProfileData) {
+ WC->Writer.addMemProfRecord(GUID, Record);
}
return;
}
More information about the llvm-commits
mailing list