summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2016-06-22 19:26:44 +0000
committerXinliang David Li <davidxl@google.com>2016-06-22 19:26:44 +0000
commit30c50f3cea27964f85b53358e38a60fd07642960 (patch)
tree5918a7aabb4a077d5081a6e7cb7ecda743801018 /llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
parenta06d98955245dc27fc1995192000f0f240f45d85 (diff)
downloadbcm5719-llvm-30c50f3cea27964f85b53358e38a60fd07642960.tar.gz
bcm5719-llvm-30c50f3cea27964f85b53358e38a60fd07642960.zip
[MBFI]: Add a new suboption for graph viewer
-view-machine-block-freq-propagation-dags currently support integer and fraction as the suboptions. This patch adds the 'count' suboption to display actual profile count if available. llvm-svn: 273460
Diffstat (limited to 'llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp b/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
index f83e7ff2fbf..689deb8c370 100644
--- a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
+++ b/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
@@ -29,7 +29,7 @@ using namespace llvm;
#define DEBUG_TYPE "block-freq"
#ifndef NDEBUG
-enum GVDAGType { GVDT_None, GVDT_Fraction, GVDT_Integer };
+enum GVDAGType { GVDT_None, GVDT_Fraction, GVDT_Integer, GVDT_Count };
static cl::opt<GVDAGType> ViewMachineBlockFreqPropagationDAG(
"view-machine-block-freq-propagation-dags", cl::Hidden,
@@ -42,6 +42,9 @@ static cl::opt<GVDAGType> ViewMachineBlockFreqPropagationDAG(
clEnumValN(GVDT_Integer, "integer",
"display a graph using the raw "
"integer fractional block frequency representation."),
+ clEnumValN(GVDT_Count, "count", "display a graph using the real "
+ "profile count if available."),
+
clEnumValEnd));
static cl::opt<std::string> ViewMachineBlockFreqFuncName("view-mbfi-func-name",
@@ -92,7 +95,7 @@ struct DOTGraphTraits<MachineBlockFrequencyInfo *>
std::string Result;
raw_string_ostream OS(Result);
- OS << Node->getName().str() << ":";
+ OS << Node->getName().str() << " : ";
switch (ViewMachineBlockFreqPropagationDAG) {
case GVDT_Fraction:
Graph->printBlockFreq(OS, Node);
@@ -100,11 +103,18 @@ struct DOTGraphTraits<MachineBlockFrequencyInfo *>
case GVDT_Integer:
OS << Graph->getBlockFreq(Node).getFrequency();
break;
+ case GVDT_Count: {
+ auto Count = Graph->getBlockProfileCount(Node);
+ if (Count)
+ OS << Count.getValue();
+ else
+ OS << "Unknown";
+ break;
+ }
case GVDT_None:
llvm_unreachable("If we are not supposed to render a graph we should "
"never reach this point.");
}
-
return Result;
}
static std::string getEdgeAttributes(const MachineBasicBlock *Node,
@@ -187,6 +197,12 @@ MachineBlockFrequencyInfo::getBlockFreq(const MachineBasicBlock *MBB) const {
return MBFI ? MBFI->getBlockFreq(MBB) : 0;
}
+Optional<uint64_t> MachineBlockFrequencyInfo::getBlockProfileCount(
+ const MachineBasicBlock *MBB) const {
+ const Function *F = MBFI->getFunction()->getFunction();
+ return MBFI ? MBFI->getBlockProfileCount(*F, MBB) : None;
+}
+
const MachineFunction *MachineBlockFrequencyInfo::getFunction() const {
return MBFI ? MBFI->getFunction() : nullptr;
}
OpenPOWER on IntegriCloud