[llvm] r311822 - Add options to dump block frequency/branch probability info in text.
Hiroshi Yamauchi via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 25 17:31:00 PDT 2017
Author: yamauchi
Date: Fri Aug 25 17:31:00 2017
New Revision: 311822
URL: http://llvm.org/viewvc/llvm-project?rev=311822&view=rev
Log:
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
Modified:
llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp
llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp
Modified: llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp?rev=311822&r1=311821&r2=311822&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp Fri Aug 25 17:31:00 2017
@@ -75,6 +75,15 @@ cl::opt<bool>
"display to only one function, use filtering option "
"-view-bfi-func-name."));
+static cl::opt<bool> PrintBlockFreq(
+ "print-bfi", cl::init(false), cl::Hidden,
+ cl::desc("Print the block frequency info."));
+
+cl::opt<std::string> PrintBlockFreqFuncName(
+ "print-bfi-func-name", cl::Hidden,
+ cl::desc("The option to specify the name of the function "
+ "whose block frequency info is printed."));
+
namespace llvm {
static GVDAGType getGVDT() {
@@ -180,6 +189,11 @@ void BlockFrequencyInfo::calculate(const
F.getName().equals(ViewBlockFreqFuncName))) {
view();
}
+ if (PrintBlockFreq &&
+ (PrintBlockFreqFuncName.empty() ||
+ F.getName().equals(PrintBlockFreqFuncName))) {
+ print(dbgs());
+ }
}
BlockFrequency BlockFrequencyInfo::getBlockFreq(const BasicBlock *BB) const {
Modified: llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp?rev=311822&r1=311821&r2=311822&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp Fri Aug 25 17:31:00 2017
@@ -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(co
PostDominatedByUnreachable.clear();
PostDominatedByColdCall.clear();
+
+ if (PrintBranchProb &&
+ (PrintBranchProbFuncName.empty() ||
+ F.getName().equals(PrintBranchProbFuncName))) {
+ print(dbgs());
+ }
}
void BranchProbabilityInfoWrapperPass::getAnalysisUsage(
Modified: llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp?rev=311822&r1=311821&r2=311822&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp Fri Aug 25 17:31:00 2017
@@ -68,6 +68,14 @@ extern cl::opt<std::string> ViewBlockFre
// Defined in Analysis/BlockFrequencyInfo.cpp: -view-hot-freq-perc=
extern cl::opt<unsigned> ViewHotFreqPercent;
+static cl::opt<bool> PrintMachineBlockFreq(
+ "print-machine-bfi", cl::init(false), cl::Hidden,
+ cl::desc("Print the machine block frequency info."));
+
+// Command line option to specify the name of the function for block frequency
+// dump. Defined in Analysis/BlockFrequencyInfo.cpp.
+extern cl::opt<std::string> PrintBlockFreqFuncName;
+
static GVDAGType getGVDT() {
if (ViewBlockLayoutWithBFI != GVDT_None)
return ViewBlockLayoutWithBFI;
@@ -185,6 +193,11 @@ void MachineBlockFrequencyInfo::calculat
F.getName().equals(ViewBlockFreqFuncName))) {
view("MachineBlockFrequencyDAGS." + F.getName());
}
+ if (PrintMachineBlockFreq &&
+ (PrintBlockFreqFuncName.empty() ||
+ F.getName().equals(PrintBlockFreqFuncName))) {
+ MBFI->print(dbgs());
+ }
}
bool MachineBlockFrequencyInfo::runOnMachineFunction(MachineFunction &F) {
More information about the llvm-commits
mailing list