Make the SelectionDAG graph printer use SDNode::PersistentId labels.
authorJames Y Knight <jyknight@google.com>
Tue, 27 Oct 2015 23:09:03 +0000 (23:09 +0000)
committerJames Y Knight <jyknight@google.com>
Tue, 27 Oct 2015 23:09:03 +0000 (23:09 +0000)
r248010 changed the -debug output to use short ids, but did not
similarly modify the graph printer. Change to be consistent, for ease of
cross-reference.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251465 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/DOTGraphTraits.h
include/llvm/Support/GraphWriter.h
lib/CodeGen/MachineScheduler.cpp
lib/CodeGen/ScheduleDAGPrinter.cpp
lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp

index 95e37c01d7d54128a2ee709f49f9dfa91a0de534..4381b5bf163345c32d6dce539db60a9274a9e0e4 100644 (file)
@@ -72,11 +72,12 @@ public:
     return "";
   }
 
-  /// hasNodeAddressLabel - If this method returns true, the address of the node
-  /// is added to the label of the node.
-  template<typename GraphType>
-  static bool hasNodeAddressLabel(const void *, const GraphType &) {
-    return false;
+  // getNodeIdentifierLabel - Returns a string representing the
+  // address or other unique identifier of the node. (Only used if
+  // non-empty.)
+  template <typename GraphType>
+  static std::string getNodeIdentifierLabel(const void *, const GraphType &) {
+    return "";
   }
 
   template<typename GraphType>
index b1af3d7c2632bec3c79538d46334ed13cbf86c48..86985c5694649cf1f90442bad62d129cf4768ee3 100644 (file)
@@ -175,8 +175,9 @@ public:
       O << DOT::EscapeString(DTraits.getNodeLabel(Node, G));
 
       // If we should include the address of the node in the label, do so now.
-      if (DTraits.hasNodeAddressLabel(Node, G))
-        O << "|" << static_cast<const void*>(Node);
+      std::string Id = DTraits.getNodeIdentifierLabel(Node, G);
+      if (!Id.empty())
+        O << "|" << DOT::EscapeString(Id);
 
       std::string NodeDesc = DTraits.getNodeDescription(Node, G);
       if (!NodeDesc.empty())
@@ -199,8 +200,9 @@ public:
       O << DOT::EscapeString(DTraits.getNodeLabel(Node, G));
 
       // If we should include the address of the node in the label, do so now.
-      if (DTraits.hasNodeAddressLabel(Node, G))
-        O << "|" << static_cast<const void*>(Node);
+      std::string Id = DTraits.getNodeIdentifierLabel(Node, G);
+      if (!Id.empty())
+        O << "|" << DOT::EscapeString(Id);
 
       std::string NodeDesc = DTraits.getNodeDescription(Node, G);
       if (!NodeDesc.empty())
index ee2dbc86bf1f760d1a543abe71b5a9b51069dc99..ae92445bfd9c38b803d5af015d31a1239dfed418 100644 (file)
@@ -3310,11 +3310,6 @@ struct DOTGraphTraits<ScheduleDAGMI*> : public DefaultDOTGraphTraits {
          || Node->Succs.size() > ViewMISchedCutoff);
   }
 
-  static bool hasNodeAddressLabel(const SUnit *Node,
-                                  const ScheduleDAG *Graph) {
-    return false;
-  }
-
   /// If you want to override the dot attributes printed for a particular
   /// edge, override this method.
   static std::string getEdgeAttributes(const SUnit *Node,
index b2e4617720ff53f3bb100aa0d1dbd719fad4a042..1150d26e559b0ee8f683c3999fa8a7fbfaaa24fa 100644 (file)
@@ -43,9 +43,12 @@ namespace llvm {
       return (Node->NumPreds > 10 || Node->NumSuccs > 10);
     }
 
-    static bool hasNodeAddressLabel(const SUnit *Node,
-                                    const ScheduleDAG *Graph) {
-      return true;
+    static std::string getNodeIdentifierLabel(const SUnit *Node,
+                                              const ScheduleDAG *Graph) {
+      std::string R;
+      raw_string_ostream OS(R);
+      OS << static_cast<const void *>(Node);
+      return R;
     }
 
     /// If you want to override the dot attributes printed for a particular
index 4df5ede388fc6aed6269ad3d67fcf025da02bc62..2764688518c2b00a94fbc83eba88fa452afbd039 100644 (file)
@@ -80,9 +80,16 @@ namespace llvm {
       return true;
     }
 
-    static bool hasNodeAddressLabel(const SDNode *Node,
-                                    const SelectionDAG *Graph) {
-      return true;
+    static std::string getNodeIdentifierLabel(const SDNode *Node,
+                                              const SelectionDAG *Graph) {
+      std::string R;
+      raw_string_ostream OS(R);
+#ifndef NDEBUG
+      OS << 't' << Node->PersistentId;
+#else
+      OS << static_cast<const void *>(Node);
+#endif
+      return R;
     }
 
     /// If you want to override the dot attributes printed for a particular