[PATCH] D154120: [BOLT][NFC] Use formatv in DataAggregator/DataReader prints
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 29 10:52:11 PDT 2023
Amir created this revision.
Amir added a reviewer: bolt.
Herald added a reviewer: rafauler.
Herald added subscribers: treapster, ayermolo.
Herald added a reviewer: maksfb.
Herald added a project: All.
Amir requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D154120
Files:
bolt/lib/Profile/DataAggregator.cpp
bolt/lib/Profile/DataReader.cpp
Index: bolt/lib/Profile/DataReader.cpp
===================================================================
--- bolt/lib/Profile/DataReader.cpp
+++ bolt/lib/Profile/DataReader.cpp
@@ -785,9 +785,8 @@
FTBI.MispredictedCount += Mispreds;
ToBB = FTSuccessor;
} else {
- LLVM_DEBUG(dbgs() << "invalid branch in " << BF << '\n'
- << Twine::utohexstr(From) << " -> "
- << Twine::utohexstr(To) << '\n');
+ LLVM_DEBUG(dbgs() << "invalid branch in " << BF
+ << formatv(": {0:x} -> {1:x}\n", From, To));
return false;
}
}
Index: bolt/lib/Profile/DataAggregator.cpp
===================================================================
--- bolt/lib/Profile/DataAggregator.cpp
+++ bolt/lib/Profile/DataAggregator.cpp
@@ -397,28 +397,20 @@
};
OutFile << FallthroughLBRs.size() << "\n";
- for (const auto &AggrLBR : FallthroughLBRs) {
- const Trace &Trace = AggrLBR.first;
- const FTInfo &Info = AggrLBR.second;
- OutFile << Twine::utohexstr(filterAddress(Trace.From)) << "-"
- << Twine::utohexstr(filterAddress(Trace.To)) << ":"
- << (Info.InternCount + Info.ExternCount) << "\n";
+ for (const auto &[Trace, Info]: FallthroughLBRs) {
+ OutFile << formatv("{0:x}-{1:x}:{2}\n", filterAddress(Trace.From),
+ filterAddress(Trace.To),
+ Info.InternCount + Info.ExternCount);
}
OutFile << BasicSamples.size() << "\n";
- for (const auto &Sample : BasicSamples) {
- uint64_t PC = Sample.first;
- uint64_t HitCount = Sample.second;
- OutFile << Twine::utohexstr(filterAddress(PC)) << ":" << HitCount << "\n";
- }
+ for (const auto [PC, HitCount]: BasicSamples)
+ OutFile << formatv("{0:x}:{1}\n", filterAddress(PC), HitCount);
OutFile << BranchLBRs.size() << "\n";
- for (const auto &AggrLBR : BranchLBRs) {
- const Trace &Trace = AggrLBR.first;
- const BranchInfo &Info = AggrLBR.second;
- OutFile << Twine::utohexstr(filterAddress(Trace.From)) << "->"
- << Twine::utohexstr(filterAddress(Trace.To)) << ":"
- << Info.TakenCount << "\n";
+ for (const auto &[Trace, Info] : BranchLBRs) {
+ OutFile << formatv("{0:x}->{1:x}:{2}\n", filterAddress(Trace.From),
+ filterAddress(Trace.To), Info.TakenCount);
}
outs() << "PERF2BOLT: wrote " << FallthroughLBRs.size() << " unique traces, "
@@ -1989,12 +1981,11 @@
}
LLVM_DEBUG({
- dbgs() << "FileName -> mmap info:\n";
- for (const std::pair<const StringRef, MMapInfo> &Pair : GlobalMMapInfo)
- dbgs() << " " << Pair.first << " : " << Pair.second.PID << " [0x"
- << Twine::utohexstr(Pair.second.MMapAddress) << ", "
- << Twine::utohexstr(Pair.second.Size) << " @ "
- << Twine::utohexstr(Pair.second.Offset) << "]\n";
+ dbgs() << "FileName -> mmap info:\n"
+ << " Filename : PID [MMapAddr, Size, Offset]\n";
+ for (const auto &[Name, MMap] : GlobalMMapInfo)
+ dbgs() << formatv(" {0} : {1} [{2:x}, {3:x} @ {4:x}]\n", Name, MMap.PID,
+ MMap.MMapAddress, MMap.Size, MMap.Offset);
});
StringRef NameToUse = llvm::sys::path::filename(BC->getFilename());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154120.535902.patch
Type: text/x-patch
Size: 3273 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230629/6f05c2ac/attachment.bin>
More information about the llvm-commits
mailing list