[BFI/MBFI]: cfg graph view with color scheme
This patch enhances dot graph viewer to show hot regions
with hot bbs/edges displayed in red. The ratio of the bb
freq to the max freq of the function needs to be no less
than the value specified by view-hot-freq-percent option.
The default value is 10 (i.e. 10%).
llvm-svn: 273996
diff --git a/llvm/lib/Analysis/BlockFrequencyInfo.cpp b/llvm/lib/Analysis/BlockFrequencyInfo.cpp
index f470d3c..de1c855 100644
--- a/llvm/lib/Analysis/BlockFrequencyInfo.cpp
+++ b/llvm/lib/Analysis/BlockFrequencyInfo.cpp
@@ -42,7 +42,19 @@
"profile count if available."),
clEnumValEnd));
-cl::opt<std::string> ViewBlockFreqFuncName("view-bfi-func-name", cl::Hidden);
+cl::opt<std::string>
+ ViewBlockFreqFuncName("view-bfi-func-name", cl::Hidden,
+ cl::desc("The option to specify "
+ "the name of the function "
+ "whose CFG will be displayed."));
+
+cl::opt<unsigned>
+ ViewHotFreqPercent("view-hot-freq-percent", cl::init(10), cl::Hidden,
+ cl::desc("An integer in percent used to specify "
+ "the hot blocks/edges to be displayed "
+ "in red: a block or edge whose frequency "
+ "is no less than the max frequency of the "
+ "function multiplied by this percent."));
namespace llvm {
@@ -84,9 +96,16 @@
ViewBlockFreqPropagationDAG);
}
+ std::string getNodeAttributes(const BasicBlock *Node,
+ const BlockFrequencyInfo *Graph) {
+ return BFIDOTGTraitsBase::getNodeAttributes(Node, Graph,
+ ViewHotFreqPercent);
+ }
+
std::string getEdgeAttributes(const BasicBlock *Node, EdgeIter EI,
const BlockFrequencyInfo *BFI) {
- return BFIDOTGTraitsBase::getEdgeAttributes(Node, EI, BFI->getBPI());
+ return BFIDOTGTraitsBase::getEdgeAttributes(Node, EI, BFI, BFI->getBPI(),
+ ViewHotFreqPercent);
}
};
diff --git a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp b/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
index 7e05ebe..4353ec4 100644
--- a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
+++ b/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
@@ -47,6 +47,7 @@
clEnumValEnd));
extern cl::opt<std::string> ViewBlockFreqFuncName;
+extern cl::opt<uint64_t> ViewHotFreqPercent;
namespace llvm {
@@ -92,9 +93,16 @@
Node, Graph, ViewMachineBlockFreqPropagationDAG);
}
+ std::string getNodeAttributes(const MachineBasicBlock *Node,
+ const MachineBlockFrequencyInfo *Graph) {
+ return MBFIDOTGraphTraitsBase::getNodeAttributes(Node, Graph,
+ ViewHotFreqPercent);
+ }
+
std::string getEdgeAttributes(const MachineBasicBlock *Node, EdgeIter EI,
const MachineBlockFrequencyInfo *MBFI) {
- return MBFIDOTGraphTraitsBase::getEdgeAttributes(Node, EI, MBFI->getMBPI());
+ return MBFIDOTGraphTraitsBase::getEdgeAttributes(
+ Node, EI, MBFI, MBFI->getMBPI(), ViewHotFreqPercent);
}
};