[PATCH] D29474: [PGO] display select instruction raw profile data in graph dump

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 3 14:09:19 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL294055: [PGO] Add select instr profile in graph dump (authored by davidxl).

Changed prior to commit:
  https://reviews.llvm.org/D29474?vs=86885&id=87022#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29474

Files:
  llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp


Index: llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -1331,6 +1331,16 @@
   }
 };
 
+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 @@
   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;
   }
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29474.87022.patch
Type: text/x-patch
Size: 1741 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170203/8319fd33/attachment.bin>


More information about the llvm-commits mailing list