summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2017-02-03 21:57:51 +0000
committerXinliang David Li <davidxl@google.com>2017-02-03 21:57:51 +0000
commit6144a59b7fe487154a97164c773effc4de98979d (patch)
treeaa5f215320ba86b855f098ab90a559b42c2fb5af
parentc06f54122ef56859d6e8e7467734d678a33adaab (diff)
downloadbcm5719-llvm-6144a59b7fe487154a97164c773effc4de98979d.tar.gz
bcm5719-llvm-6144a59b7fe487154a97164c773effc4de98979d.zip
[PGO] Add select instr profile in graph dump
Differential Revision: http://reviews.llvm.org/D29474 llvm-svn: 294055
-rw-r--r--llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp35
1 files changed, 32 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
index a146eaf0449..b81bb1b4955 100644
--- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -1331,6 +1331,16 @@ template <> struct GraphTraits<PGOUseFunc *> {
}
};
+static std::string getSimpleNodeName(const BasicBlock *Node) {
+ if (!Node->getName().empty())
+ return Node->getName();
+
+ std::string SimpleNodeName;
+ raw_string_ostream OS(SimpleNodeName);
+ Node->printAsOperand(OS, false);
+ return OS.str();
+}
+
template <> struct DOTGraphTraits<PGOUseFunc *> : DefaultDOTGraphTraits {
explicit DOTGraphTraits(bool isSimple = false)
: DefaultDOTGraphTraits(isSimple) {}
@@ -1342,12 +1352,31 @@ template <> struct DOTGraphTraits<PGOUseFunc *> : DefaultDOTGraphTraits {
std::string getNodeLabel(const BasicBlock *Node, const PGOUseFunc *Graph) {
std::string Result;
raw_string_ostream OS(Result);
- OS << Node->getName().str() << " : ";
+
+ OS << getSimpleNodeName(Node) << ":\\l";
UseBBInfo *BI = Graph->findBBInfo(Node);
+ OS << "Count : ";
if (BI && BI->CountValid)
- OS << BI->CountValue;
+ OS << BI->CountValue << "\\l";
else
- OS << "Unknown";
+ OS << "Unknown\\l";
+
+ if (!PGOInstrSelect)
+ return Result;
+
+ for (auto BI = Node->begin(); BI != Node->end(); ++BI) {
+ auto *I = &*BI;
+ if (!isa<SelectInst>(I))
+ continue;
+ // Display scaled counts for SELECT instruction:
+ OS << "SELECT : { T = ";
+ uint64_t TC, FC;
+ bool hasProf = I->extractProfMetadata(TC, FC);
+ if (!hasProf)
+ OS << "Unknown, F = Unknown }\\l";
+ else
+ OS << TC << ", F = " << FC << " }\\l";
+ }
return Result;
}
};
OpenPOWER on IntegriCloud