aboutsummaryrefslogtreecommitdiff
path: root/bolt
diff options
context:
space:
mode:
authorAmir Ayupov <aaupov@fb.com>2023-06-28 17:50:39 -0700
committerAmir Ayupov <aaupov@fb.com>2023-06-28 17:51:17 -0700
commitfd49cc87d0024c7d5c9f068bbf2f9a7e9a6ac0f3 (patch)
tree5dcfd98bb94454303a4187b2f73d191702cfabc0 /bolt
parentde19101e3302f4423f4946b1a916a4d19260d6ac (diff)
downloadllvm-fd49cc87d0024c7d5c9f068bbf2f9a7e9a6ac0f3.zip
llvm-fd49cc87d0024c7d5c9f068bbf2f9a7e9a6ac0f3.tar.gz
llvm-fd49cc87d0024c7d5c9f068bbf2f9a7e9a6ac0f3.tar.bz2
[BOLT][NFC] Print functions after attaching profile (-print-profile)
Add an extra point of dumping functions: immediately after attaching the profile information. This dumping is enabled by newly introduced `-print-profile` and `-print-all`. The reason is that in `aggregate-only`/perf2bolt mode BOLT may not reach the point of printing the function after CFG is constructed (`-print-cfg`), while we may still want to inspect the attached profile, especially for diff'ing purposes. Reviewed By: #bolt, rafauler Differential Revision: https://reviews.llvm.org/D153996
Diffstat (limited to 'bolt')
-rw-r--r--bolt/lib/Rewrite/RewriteInstance.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index d17a0f4..a4d8ab2 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -172,6 +172,10 @@ cl::opt<bool> PrintAll("print-all",
cl::desc("print functions after each stage"), cl::Hidden,
cl::cat(BoltCategory));
+cl::opt<bool> PrintProfile("print-profile",
+ cl::desc("print functions after attaching profile"),
+ cl::Hidden, cl::cat(BoltCategory));
+
cl::opt<bool> PrintCFG("print-cfg",
cl::desc("print functions after CFG construction"),
cl::Hidden, cl::cat(BoltCategory));
@@ -3260,6 +3264,16 @@ void RewriteInstance::processProfileData() {
if (Error E = ProfileReader->readProfile(*BC.get()))
report_error("cannot read profile", std::move(E));
+ if (opts::PrintProfile || opts::PrintAll) {
+ for (auto &BFI : BC->getBinaryFunctions()) {
+ BinaryFunction &Function = BFI.second;
+ if (Function.empty())
+ continue;
+
+ Function.print(outs(), "after attaching profile");
+ }
+ }
+
if (!opts::SaveProfile.empty()) {
YAMLProfileWriter PW(opts::SaveProfile);
PW.writeProfile(*this);