From a0e9c6ff437124cd701828e2b380a2febb2996b9 Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Tue, 27 Oct 2015 23:09:03 +0000 Subject: [PATCH] Make the SelectionDAG graph printer use SDNode::PersistentId labels. 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 | 11 ++++++----- include/llvm/Support/GraphWriter.h | 10 ++++++---- lib/CodeGen/MachineScheduler.cpp | 5 ----- lib/CodeGen/ScheduleDAGPrinter.cpp | 9 ++++++--- lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp | 13 ++++++++++--- 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/include/llvm/Support/DOTGraphTraits.h b/include/llvm/Support/DOTGraphTraits.h index 95e37c01d7d..4381b5bf163 100644 --- a/include/llvm/Support/DOTGraphTraits.h +++ b/include/llvm/Support/DOTGraphTraits.h @@ -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 - 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 + static std::string getNodeIdentifierLabel(const void *, const GraphType &) { + return ""; } template diff --git a/include/llvm/Support/GraphWriter.h b/include/llvm/Support/GraphWriter.h index b1af3d7c263..86985c56946 100644 --- a/include/llvm/Support/GraphWriter.h +++ b/include/llvm/Support/GraphWriter.h @@ -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(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(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()) diff --git a/lib/CodeGen/MachineScheduler.cpp b/lib/CodeGen/MachineScheduler.cpp index ee2dbc86bf1..ae92445bfd9 100644 --- a/lib/CodeGen/MachineScheduler.cpp +++ b/lib/CodeGen/MachineScheduler.cpp @@ -3310,11 +3310,6 @@ struct DOTGraphTraits : 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, diff --git a/lib/CodeGen/ScheduleDAGPrinter.cpp b/lib/CodeGen/ScheduleDAGPrinter.cpp index b2e4617720f..1150d26e559 100644 --- a/lib/CodeGen/ScheduleDAGPrinter.cpp +++ b/lib/CodeGen/ScheduleDAGPrinter.cpp @@ -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(Node); + return R; } /// If you want to override the dot attributes printed for a particular diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp index 4df5ede388f..2764688518c 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp @@ -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(Node); +#endif + return R; } /// If you want to override the dot attributes printed for a particular -- 2.34.1