From jlaskey at apple.com Mon Oct 2 07:27:11 2006
From: jlaskey at apple.com (Jim Laskey)
Date: Mon, 2 Oct 2006 07:27:11 -0500
Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Printer.cpp
Message-ID: <200610021227.k92CRBL0027136@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Analysis/DataStructure:
Printer.cpp updated: 1.85 -> 1.86
---
Log message:
Add ability to annotate (color) nodes in a viewGraph.
---
Diffs of the changes: (+1 -1)
Printer.cpp | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
Index: llvm/lib/Analysis/DataStructure/Printer.cpp
diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.85 llvm/lib/Analysis/DataStructure/Printer.cpp:1.86
--- llvm/lib/Analysis/DataStructure/Printer.cpp:1.85 Tue Jun 27 11:49:46 2006
+++ llvm/lib/Analysis/DataStructure/Printer.cpp Mon Oct 2 07:26:53 2006
@@ -112,7 +112,7 @@
return getCaption(Node, Graph);
}
- static std::string getNodeAttributes(const DSNode *N) {
+ static std::string getNodeAttributes(const DSNode *N, const DSGraph *Graph) {
return "shape=Mrecord";
}
From jlaskey at apple.com Mon Oct 2 07:27:09 2006
From: jlaskey at apple.com (Jim Laskey)
Date: Mon, 2 Oct 2006 07:27:09 -0500
Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAG.h
Message-ID: <200610021227.k92CR96C027131@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm/CodeGen:
SelectionDAG.h updated: 1.130 -> 1.131
---
Log message:
Add ability to annotate (color) nodes in a viewGraph.
---
Diffs of the changes: (+20 -1)
SelectionDAG.h | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletion(-)
Index: llvm/include/llvm/CodeGen/SelectionDAG.h
diff -u llvm/include/llvm/CodeGen/SelectionDAG.h:1.130 llvm/include/llvm/CodeGen/SelectionDAG.h:1.131
--- llvm/include/llvm/CodeGen/SelectionDAG.h:1.130 Tue Sep 12 15:59:22 2006
+++ llvm/include/llvm/CodeGen/SelectionDAG.h Mon Oct 2 07:26:53 2006
@@ -69,10 +69,29 @@
TargetLowering &getTargetLoweringInfo() const { return TLI; }
MachineDebugInfo *getMachineDebugInfo() const { return DI; }
- /// viewGraph - Pop up a ghostview window with the DAG rendered using 'dot'.
+ /// viewGraph - Pop up a GraphViz/gv window with the DAG rendered using 'dot'.
///
void viewGraph();
+
+#ifndef NDEBUG
+ std::map NodeGraphAttrs;
+#endif
+ /// clearGraphAttrs - Clear all previously defined node graph attributes.
+ /// Intended to be used from a debugging tool (eg. gdb).
+ void clearGraphAttrs();
+
+ /// setGraphAttrs - Set graph attributes for a node. (eg. "color=red".)
+ ///
+ void setGraphAttrs(const SDNode *N, const char *Attrs);
+
+ /// getGraphAttrs - Get graph attributes for a node. (eg. "color=red".)
+ /// Used from getNodeAttributes.
+ const std::string getGraphAttrs(const SDNode *N) const;
+
+ /// setGraphColor - Convenience for setting node color attribute.
+ ///
+ void setGraphColor(const SDNode *N, const char *Color);
typedef ilist::const_iterator allnodes_const_iterator;
allnodes_const_iterator allnodes_begin() const { return AllNodes.begin(); }
From jlaskey at apple.com Mon Oct 2 07:27:13 2006
From: jlaskey at apple.com (Jim Laskey)
Date: Mon, 2 Oct 2006 07:27:13 -0500
Subject: [llvm-commits] CVS: llvm/include/llvm/Support/DOTGraphTraits.h
GraphWriter.h
Message-ID: <200610021227.k92CRDjh027144@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm/Support:
DOTGraphTraits.h updated: 1.14 -> 1.15
GraphWriter.h updated: 1.29 -> 1.30
---
Log message:
Add ability to annotate (color) nodes in a viewGraph.
---
Diffs of the changes: (+4 -2)
DOTGraphTraits.h | 4 +++-
GraphWriter.h | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
Index: llvm/include/llvm/Support/DOTGraphTraits.h
diff -u llvm/include/llvm/Support/DOTGraphTraits.h:1.14 llvm/include/llvm/Support/DOTGraphTraits.h:1.15
--- llvm/include/llvm/Support/DOTGraphTraits.h:1.14 Fri Sep 30 19:17:07 2005
+++ llvm/include/llvm/Support/DOTGraphTraits.h Mon Oct 2 07:26:53 2006
@@ -60,7 +60,9 @@
/// If you want to specify custom node attributes, this is the place to do so
///
- static std::string getNodeAttributes(const void *Node) { return ""; }
+ static std::string getNodeAttributes(const void *Node, const void *Graph) {
+ return "";
+ }
/// If you want to override the dot attributes printed for a particular edge,
/// override this method.
Index: llvm/include/llvm/Support/GraphWriter.h
diff -u llvm/include/llvm/Support/GraphWriter.h:1.29 llvm/include/llvm/Support/GraphWriter.h:1.30
--- llvm/include/llvm/Support/GraphWriter.h:1.29 Wed Aug 23 15:34:57 2006
+++ llvm/include/llvm/Support/GraphWriter.h Mon Oct 2 07:26:53 2006
@@ -109,7 +109,7 @@
}
void writeNode(NodeType *Node) {
- std::string NodeAttributes = DOTTraits::getNodeAttributes(Node);
+ std::string NodeAttributes = DOTTraits::getNodeAttributes(Node, G);
O << "\tNode" << reinterpret_cast(Node) << " [shape=record,";
if (!NodeAttributes.empty()) O << NodeAttributes << ",";
From jlaskey at apple.com Mon Oct 2 07:27:13 2006
From: jlaskey at apple.com (Jim Laskey)
Date: Mon, 2 Oct 2006 07:27:13 -0500
Subject: [llvm-commits] CVS:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
Message-ID: <200610021227.k92CRDPi027149@zion.cs.uiuc.edu>
Changes in directory llvm/lib/CodeGen/SelectionDAG:
SelectionDAGPrinter.cpp updated: 1.34 -> 1.35
---
Log message:
Add ability to annotate (color) nodes in a viewGraph.
---
Diffs of the changes: (+69 -1)
SelectionDAGPrinter.cpp | 70 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 69 insertions(+), 1 deletion(-)
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp:1.34 llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp:1.35
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp:1.34 Tue Sep 12 16:00:35 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Mon Oct 2 07:26:53 2006
@@ -27,6 +27,9 @@
using namespace llvm;
namespace llvm {
+#ifndef NDEBUG
+ std::map DagNodeColor;
+#endif
template<>
struct DOTGraphTraits : public DefaultDOTGraphTraits {
static std::string getGraphName(const SelectionDAG *G) {
@@ -44,7 +47,17 @@
static std::string getNodeLabel(const SDNode *Node,
const SelectionDAG *Graph);
- static std::string getNodeAttributes(const SDNode *N) {
+ static std::string getNodeAttributes(const SDNode *N,
+ const SelectionDAG *Graph) {
+#ifndef NDEBUG
+ const std::string &Attrs = Graph->getGraphAttrs(N);
+ if (!Attrs.empty()) {
+ if (Attrs.find("shape=") == std::string::npos)
+ return std::string("shape=Mrecord,") + Attrs;
+ else
+ return Attrs;
+ }
+#endif
return "shape=Mrecord";
}
@@ -138,3 +151,58 @@
<< "systems with Graphviz or gv!\n";
#endif // NDEBUG
}
+
+
+/// clearGraphAttrs - Clear all previously defined node graph attributes.
+/// Intended to be used from a debugging tool (eg. gdb).
+void SelectionDAG::clearGraphAttrs() {
+#ifndef NDEBUG
+ NodeGraphAttrs.clear();
+#else
+ std::cerr << "SelectionDAG::clearGraphAttrs is only available in debug builds"
+ << " on systems with Graphviz or gv!\n";
+#endif
+}
+
+
+/// setGraphAttrs - Set graph attributes for a node. (eg. "color=red".)
+///
+void SelectionDAG::setGraphAttrs(const SDNode *N, const char *Attrs) {
+#ifndef NDEBUG
+ NodeGraphAttrs[N] = Attrs;
+#else
+ std::cerr << "SelectionDAG::setGraphAttrs is only available in debug builds"
+ << " on systems with Graphviz or gv!\n";
+#endif
+}
+
+
+/// getGraphAttrs - Get graph attributes for a node. (eg. "color=red".)
+/// Used from getNodeAttributes.
+const std::string SelectionDAG::getGraphAttrs(const SDNode *N) const {
+#ifndef NDEBUG
+ std::map::const_iterator I =
+ NodeGraphAttrs.find(N);
+
+ if (I != NodeGraphAttrs.end())
+ return I->second;
+ else
+ return "";
+#else
+ std::cerr << "SelectionDAG::getGraphAttrs is only available in debug builds"
+ << " on systems with Graphviz or gv!\n";
+ return std::string("");
+#endif
+}
+
+/// setGraphColor - Convenience for setting node color attribute.
+///
+void SelectionDAG::setGraphColor(const SDNode *N, const char *Color) {
+#ifndef NDEBUG
+ NodeGraphAttrs[N] = std::string("color=") + Color;
+#else
+ std::cerr << "SelectionDAG::setGraphColor is only available in debug builds"
+ << " on systems with Graphviz or gv!\n";
+#endif
+}
+
From jlaskey at apple.com Mon Oct 2 07:28:21 2006
From: jlaskey at apple.com (Jim Laskey)
Date: Mon, 2 Oct 2006 07:28:21 -0500
Subject: [llvm-commits] CVS: llvm/docs/ProgrammersManual.html
Message-ID: <200610021228.k92CSLO6027224@zion.cs.uiuc.edu>
Changes in directory llvm/docs:
ProgrammersManual.html updated: 1.91 -> 1.92
---
Log message:
Update documentaion of node annotation (coloring) in viewGraph.
---
Diffs of the changes: (+14 -2)
ProgrammersManual.html | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
Index: llvm/docs/ProgrammersManual.html
diff -u llvm/docs/ProgrammersManual.html:1.91 llvm/docs/ProgrammersManual.html:1.92
--- llvm/docs/ProgrammersManual.html:1.91 Fri Apr 14 09:11:48 2006
+++ llvm/docs/ProgrammersManual.html Mon Oct 2 07:28:07 2006
@@ -516,7 +516,7 @@
Function::viewCFGOnly() (does not include the instructions), the
MachineFunction::viewCFG() and MachineFunction::viewCFGOnly(),
and the SelectionDAG::viewGraph() methods. Within GDB, for example,
-you can usually use something like "call DAG.viewGraph()" to pop
+you can usually use something like call DAG.viewGraph() to pop
up a window. Alternatively, you can sprinkle calls to these functions in your
code in places you want to debug.
@@ -529,6 +529,18 @@
it) to your path. Once in your system and path are set up, rerun the LLVM
configure script and rebuild LLVM to enable this functionality.
+SelectionDAG has been extended to make it easier to locate
+interesting nodes in large complex graphs. From gdb, if you
+call DAG.setGraphColor(node, "color"), then the
+next call DAG.viewGraph() would hilight the node in the
+specified color (choices of colors can be found at Colors.) More
+complex node attributes can be provided with call
+DAG.setGraphAttrs(node, "attributes") (choices can be
+found at Graph
+Attributes.) If you want to restart and clear all the current graph
+attributes, then you can call DAG.clearGraphAttrs().
+
@@ -2281,7 +2293,7 @@
Dinakar Dhurjati and
Chris Lattner
The LLVM Compiler Infrastructure
- Last modified: $Date: 2006/04/14 14:11:48 $
+ Last modified: $Date: 2006/10/02 12:28:07 $