diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -172,6 +172,10 @@ cl::desc("print functions after each stage"), cl::Hidden, cl::cat(BoltCategory)); +cl::opt PrintProfile("print-profile", + cl::desc("print functions after attaching profile"), + cl::Hidden, cl::cat(BoltCategory)); + cl::opt PrintCFG("print-cfg", cl::desc("print functions after CFG construction"), cl::Hidden, cl::cat(BoltCategory)); @@ -3260,6 +3264,16 @@ 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);