diff options
author | Hiroshi Yamauchi <yamauchi@google.com> | 2017-08-26 00:31:00 +0000 |
---|---|---|
committer | Hiroshi Yamauchi <yamauchi@google.com> | 2017-08-26 00:31:00 +0000 |
commit | 63e17ebf8b8449932f57d334f25692515b36571a (patch) | |
tree | 43226126b74fc990067c3d50b44885d927f13f8c /llvm/lib/Analysis/BranchProbabilityInfo.cpp | |
parent | d27386a9edfa0d1c33bf6bb4ba704ba1e4bee7c7 (diff) | |
download | bcm5719-llvm-63e17ebf8b8449932f57d334f25692515b36571a.tar.gz bcm5719-llvm-63e17ebf8b8449932f57d334f25692515b36571a.zip |
Add options to dump block frequency/branch probability info in text.
Summary:
Add options -print-bfi/-print-bpi that dump block frequency and branch
probability info like -view-block-freq-propagation-dags and
-view-machine-block-freq-propagation-dags do but in text.
This is useful when the graph is very large and complex (the dot command
crashes, lines/edges too close to tell apart, hard to navigate without textual
search) or simply when text is preferred.
Reviewers: davidxl
Reviewed By: davidxl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D37165
llvm-svn: 311822
Diffstat (limited to 'llvm/lib/Analysis/BranchProbabilityInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/BranchProbabilityInfo.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp index 11f2bcc4703..c6d17d2936d 100644 --- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp +++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp @@ -44,6 +44,15 @@ using namespace llvm; #define DEBUG_TYPE "branch-prob" +static cl::opt<bool> PrintBranchProb( + "print-bpi", cl::init(false), cl::Hidden, + cl::desc("Print the branch probability info.")); + +cl::opt<std::string> PrintBranchProbFuncName( + "print-bpi-func-name", cl::Hidden, + cl::desc("The option to specify the name of the function " + "whose branch probability info is printed.")); + INITIALIZE_PASS_BEGIN(BranchProbabilityInfoWrapperPass, "branch-prob", "Branch Probability Analysis", false, true) INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass) @@ -790,6 +799,12 @@ void BranchProbabilityInfo::calculate(const Function &F, const LoopInfo &LI, PostDominatedByUnreachable.clear(); PostDominatedByColdCall.clear(); + + if (PrintBranchProb && + (PrintBranchProbFuncName.empty() || + F.getName().equals(PrintBranchProbFuncName))) { + print(dbgs()); + } } void BranchProbabilityInfoWrapperPass::getAnalysisUsage( |