2004-09-02 00:55:40 +02:00
|
|
|
//===-- llvm/Support/GraphWriter.h - Write graph to a .dot file -*- C++ -*-===//
|
2005-04-21 22:48:15 +02:00
|
|
|
//
|
2003-10-20 21:46:57 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:59:42 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 22:48:15 +02:00
|
|
|
//
|
2003-10-20 21:46:57 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-10-07 20:37:10 +02:00
|
|
|
//
|
|
|
|
// This file defines a simple interface that can be used to print out generic
|
|
|
|
// LLVM graphs to ".dot" files. "dot" is a tool that is part of the AT&T
|
|
|
|
// graphviz package (http://www.research.att.com/sw/tools/graphviz/) which can
|
|
|
|
// be used to turn the files output by this interface into a variety of
|
|
|
|
// different graphics formats.
|
|
|
|
//
|
|
|
|
// Graphs do not need to implement any interface past what is already required
|
|
|
|
// by the GraphTraits template, but they can choose to implement specializations
|
|
|
|
// of the DOTGraphTraits template if they want to customize the graphs output in
|
|
|
|
// any way.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2004-09-02 00:55:40 +02:00
|
|
|
#ifndef LLVM_SUPPORT_GRAPHWRITER_H
|
|
|
|
#define LLVM_SUPPORT_GRAPHWRITER_H
|
2002-10-07 20:37:10 +02:00
|
|
|
|
2004-09-02 00:55:40 +02:00
|
|
|
#include "llvm/Support/DOTGraphTraits.h"
|
2009-08-23 09:19:13 +02:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2004-09-02 00:55:40 +02:00
|
|
|
#include "llvm/ADT/GraphTraits.h"
|
2010-11-29 19:16:10 +01:00
|
|
|
#include "llvm/Support/Path.h"
|
2006-11-17 10:52:49 +01:00
|
|
|
#include <vector>
|
2009-07-08 23:53:41 +02:00
|
|
|
#include <cassert>
|
2002-10-07 20:37:10 +02:00
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
namespace llvm {
|
|
|
|
|
2002-10-07 20:37:10 +02:00
|
|
|
namespace DOT { // Private functions...
|
2009-08-23 09:19:13 +02:00
|
|
|
std::string EscapeString(const std::string &Label);
|
2002-10-07 20:37:10 +02:00
|
|
|
}
|
|
|
|
|
2009-07-09 19:06:18 +02:00
|
|
|
namespace GraphProgram {
|
|
|
|
enum Name {
|
|
|
|
DOT,
|
|
|
|
FDP,
|
|
|
|
NEATO,
|
|
|
|
TWOPI,
|
|
|
|
CIRCO
|
|
|
|
};
|
|
|
|
}
|
2009-09-20 06:03:25 +02:00
|
|
|
|
2009-07-09 19:06:18 +02:00
|
|
|
void DisplayGraph(const sys::Path& Filename, bool wait=true, GraphProgram::Name program = GraphProgram::DOT);
|
2009-02-20 23:51:36 +01:00
|
|
|
|
2002-10-07 20:37:10 +02:00
|
|
|
template<typename GraphType>
|
2002-10-16 03:34:18 +02:00
|
|
|
class GraphWriter {
|
2009-08-23 09:19:13 +02:00
|
|
|
raw_ostream &O;
|
2002-10-16 03:34:18 +02:00
|
|
|
const GraphType &G;
|
2002-10-07 20:37:10 +02:00
|
|
|
|
2002-10-16 03:34:18 +02:00
|
|
|
typedef DOTGraphTraits<GraphType> DOTTraits;
|
|
|
|
typedef GraphTraits<GraphType> GTraits;
|
|
|
|
typedef typename GTraits::NodeType NodeType;
|
|
|
|
typedef typename GTraits::nodes_iterator node_iterator;
|
|
|
|
typedef typename GTraits::ChildIteratorType child_iterator;
|
2009-11-30 13:38:13 +01:00
|
|
|
DOTTraits DTraits;
|
2009-11-30 13:24:40 +01:00
|
|
|
|
|
|
|
// Writes the edge labels of the node to O and returns true if there are any
|
|
|
|
// edge labels not equal to the empty string "".
|
|
|
|
bool getEdgeSourceLabels(raw_ostream &O, NodeType *Node) {
|
|
|
|
child_iterator EI = GTraits::child_begin(Node);
|
|
|
|
child_iterator EE = GTraits::child_end(Node);
|
|
|
|
bool hasEdgeSourceLabels = false;
|
|
|
|
|
|
|
|
for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) {
|
2009-11-30 13:38:13 +01:00
|
|
|
std::string label = DTraits.getEdgeSourceLabel(Node, EI);
|
2009-11-30 13:24:40 +01:00
|
|
|
|
2011-03-01 23:07:55 +01:00
|
|
|
if (label.empty())
|
2009-11-30 13:24:40 +01:00
|
|
|
continue;
|
|
|
|
|
|
|
|
hasEdgeSourceLabels = true;
|
|
|
|
|
|
|
|
if (i)
|
|
|
|
O << "|";
|
|
|
|
|
2011-03-01 23:12:24 +01:00
|
|
|
O << "<s" << i << ">" << DOT::EscapeString(label);
|
2009-11-30 13:24:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (EI != EE && hasEdgeSourceLabels)
|
|
|
|
O << "|<s64>truncated...";
|
|
|
|
|
|
|
|
return hasEdgeSourceLabels;
|
|
|
|
}
|
|
|
|
|
2002-10-16 03:34:18 +02:00
|
|
|
public:
|
2009-11-30 13:38:47 +01:00
|
|
|
GraphWriter(raw_ostream &o, const GraphType &g, bool SN) : O(o), G(g) {
|
2010-09-27 16:44:14 +02:00
|
|
|
DTraits = DOTTraits(SN);
|
|
|
|
}
|
2002-10-17 02:59:59 +02:00
|
|
|
|
2010-09-27 18:59:51 +02:00
|
|
|
void writeGraph(const std::string &Title = "") {
|
2010-09-27 18:44:11 +02:00
|
|
|
// Output the header for the graph...
|
2010-09-27 18:54:13 +02:00
|
|
|
writeHeader(Title);
|
2010-09-27 18:44:11 +02:00
|
|
|
|
|
|
|
// Emit all of the nodes in the graph...
|
2010-09-27 18:54:13 +02:00
|
|
|
writeNodes();
|
2010-09-27 18:44:11 +02:00
|
|
|
|
|
|
|
// Output any customizations on the graph
|
2010-09-27 18:54:13 +02:00
|
|
|
DOTGraphTraits<GraphType>::addCustomGraphFeatures(G, *this);
|
2010-09-27 18:44:11 +02:00
|
|
|
|
|
|
|
// Output the end of the graph
|
2010-09-27 18:54:13 +02:00
|
|
|
writeFooter();
|
2010-09-27 18:44:11 +02:00
|
|
|
}
|
|
|
|
|
2010-09-27 17:34:19 +02:00
|
|
|
void writeHeader(const std::string &Title) {
|
2009-11-30 13:38:13 +01:00
|
|
|
std::string GraphName = DTraits.getGraphName(G);
|
2008-07-09 01:33:46 +02:00
|
|
|
|
2010-09-27 17:34:19 +02:00
|
|
|
if (!Title.empty())
|
|
|
|
O << "digraph \"" << DOT::EscapeString(Title) << "\" {\n";
|
2008-07-09 01:33:46 +02:00
|
|
|
else if (!GraphName.empty())
|
2008-07-10 21:55:54 +02:00
|
|
|
O << "digraph \"" << DOT::EscapeString(GraphName) << "\" {\n";
|
2008-07-09 01:33:46 +02:00
|
|
|
else
|
|
|
|
O << "digraph unnamed {\n";
|
2002-10-07 20:37:10 +02:00
|
|
|
|
2009-11-30 13:38:13 +01:00
|
|
|
if (DTraits.renderGraphFromBottomUp())
|
2005-01-11 01:24:59 +01:00
|
|
|
O << "\trankdir=\"BT\";\n";
|
|
|
|
|
2010-09-27 17:34:19 +02:00
|
|
|
if (!Title.empty())
|
|
|
|
O << "\tlabel=\"" << DOT::EscapeString(Title) << "\";\n";
|
2008-07-21 21:57:57 +02:00
|
|
|
else if (!GraphName.empty())
|
2002-10-16 03:34:18 +02:00
|
|
|
O << "\tlabel=\"" << DOT::EscapeString(GraphName) << "\";\n";
|
2009-11-30 13:38:13 +01:00
|
|
|
O << DTraits.getGraphProperties(G);
|
2002-10-16 03:34:18 +02:00
|
|
|
O << "\n";
|
|
|
|
}
|
|
|
|
|
2002-10-17 02:59:59 +02:00
|
|
|
void writeFooter() {
|
2002-10-16 03:34:18 +02:00
|
|
|
// Finish off the graph
|
|
|
|
O << "}\n";
|
|
|
|
}
|
2002-10-07 20:37:10 +02:00
|
|
|
|
2002-10-16 03:34:18 +02:00
|
|
|
void writeNodes() {
|
|
|
|
// Loop over the graph, printing it out...
|
|
|
|
for (node_iterator I = GTraits::nodes_begin(G), E = GTraits::nodes_end(G);
|
|
|
|
I != E; ++I)
|
2010-05-14 17:29:31 +02:00
|
|
|
if (!isNodeHidden(*I))
|
|
|
|
writeNode(*I);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isNodeHidden(NodeType &Node) {
|
|
|
|
return isNodeHidden(&Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isNodeHidden(NodeType *const *Node) {
|
|
|
|
return isNodeHidden(*Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isNodeHidden(NodeType *Node) {
|
|
|
|
return DTraits.isNodeHidden(Node);
|
2007-09-19 23:26:49 +02:00
|
|
|
}
|
2009-02-20 23:51:36 +01:00
|
|
|
|
2007-09-19 23:26:49 +02:00
|
|
|
void writeNode(NodeType& Node) {
|
|
|
|
writeNode(&Node);
|
2002-10-16 03:34:18 +02:00
|
|
|
}
|
2005-04-21 22:48:15 +02:00
|
|
|
|
2005-01-11 00:05:07 +01:00
|
|
|
void writeNode(NodeType *const *Node) {
|
|
|
|
writeNode(*Node);
|
|
|
|
}
|
2005-04-21 22:48:15 +02:00
|
|
|
|
2002-10-16 03:34:18 +02:00
|
|
|
void writeNode(NodeType *Node) {
|
2009-11-30 13:38:13 +01:00
|
|
|
std::string NodeAttributes = DTraits.getNodeAttributes(Node, G);
|
2005-04-21 22:48:15 +02:00
|
|
|
|
2008-07-28 01:12:19 +02:00
|
|
|
O << "\tNode" << static_cast<const void*>(Node) << " [shape=record,";
|
2002-10-07 20:37:10 +02:00
|
|
|
if (!NodeAttributes.empty()) O << NodeAttributes << ",";
|
2005-01-11 01:24:59 +01:00
|
|
|
O << "label=\"{";
|
|
|
|
|
2009-11-30 13:38:13 +01:00
|
|
|
if (!DTraits.renderGraphFromBottomUp()) {
|
2009-11-30 13:38:47 +01:00
|
|
|
O << DOT::EscapeString(DTraits.getNodeLabel(Node, G));
|
2005-04-21 22:48:15 +02:00
|
|
|
|
2005-10-01 02:19:21 +02:00
|
|
|
// If we should include the address of the node in the label, do so now.
|
2009-11-30 13:38:13 +01:00
|
|
|
if (DTraits.hasNodeAddressLabel(Node, G))
|
2005-10-01 02:19:21 +02:00
|
|
|
O << "|" << (void*)Node;
|
|
|
|
}
|
|
|
|
|
2009-11-30 13:24:40 +01:00
|
|
|
std::string edgeSourceLabels;
|
2009-11-30 16:52:29 +01:00
|
|
|
raw_string_ostream EdgeSourceLabels(edgeSourceLabels);
|
2009-11-30 13:24:40 +01:00
|
|
|
bool hasEdgeSourceLabels = getEdgeSourceLabels(EdgeSourceLabels, Node);
|
|
|
|
|
|
|
|
if (hasEdgeSourceLabels) {
|
2009-11-30 13:38:13 +01:00
|
|
|
if (!DTraits.renderGraphFromBottomUp()) O << "|";
|
2005-04-21 22:48:15 +02:00
|
|
|
|
2009-11-30 13:24:40 +01:00
|
|
|
O << "{" << EdgeSourceLabels.str() << "}";
|
2005-04-21 22:48:15 +02:00
|
|
|
|
2009-11-30 13:38:13 +01:00
|
|
|
if (DTraits.renderGraphFromBottomUp()) O << "|";
|
2002-10-07 20:37:10 +02:00
|
|
|
}
|
2005-10-01 02:19:21 +02:00
|
|
|
|
2009-11-30 13:38:13 +01:00
|
|
|
if (DTraits.renderGraphFromBottomUp()) {
|
2009-11-30 13:38:47 +01:00
|
|
|
O << DOT::EscapeString(DTraits.getNodeLabel(Node, G));
|
2005-04-21 22:48:15 +02:00
|
|
|
|
2005-10-01 02:19:21 +02:00
|
|
|
// If we should include the address of the node in the label, do so now.
|
2009-11-30 13:38:13 +01:00
|
|
|
if (DTraits.hasNodeAddressLabel(Node, G))
|
2005-10-01 02:19:21 +02:00
|
|
|
O << "|" << (void*)Node;
|
|
|
|
}
|
|
|
|
|
2009-11-30 13:38:13 +01:00
|
|
|
if (DTraits.hasEdgeDestLabels()) {
|
2008-07-21 23:06:55 +02:00
|
|
|
O << "|{";
|
|
|
|
|
2009-11-30 13:38:13 +01:00
|
|
|
unsigned i = 0, e = DTraits.numEdgeDestLabels(Node);
|
2008-07-21 23:06:55 +02:00
|
|
|
for (; i != e && i != 64; ++i) {
|
|
|
|
if (i) O << "|";
|
2010-04-30 20:27:57 +02:00
|
|
|
O << "<d" << i << ">"
|
|
|
|
<< DOT::EscapeString(DTraits.getEdgeDestLabel(Node, i));
|
2008-07-21 23:06:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (i != e)
|
|
|
|
O << "|<d64>truncated...";
|
|
|
|
O << "}";
|
|
|
|
}
|
|
|
|
|
2005-09-30 21:33:41 +02:00
|
|
|
O << "}\"];\n"; // Finish printing the "node" line
|
2005-04-21 22:48:15 +02:00
|
|
|
|
2002-10-07 20:37:10 +02:00
|
|
|
// Output all of the edges now
|
2009-11-30 13:24:40 +01:00
|
|
|
child_iterator EI = GTraits::child_begin(Node);
|
|
|
|
child_iterator EE = GTraits::child_end(Node);
|
2002-10-16 03:34:18 +02:00
|
|
|
for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i)
|
2010-05-14 17:29:31 +02:00
|
|
|
if (!DTraits.isNodeHidden(*EI))
|
|
|
|
writeEdge(Node, i, EI);
|
2004-02-11 21:44:17 +01:00
|
|
|
for (; EI != EE; ++EI)
|
2010-05-14 17:29:31 +02:00
|
|
|
if (!DTraits.isNodeHidden(*EI))
|
|
|
|
writeEdge(Node, 64, EI);
|
2002-10-16 03:34:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void writeEdge(NodeType *Node, unsigned edgeidx, child_iterator EI) {
|
|
|
|
if (NodeType *TargetNode = *EI) {
|
2002-10-16 04:03:18 +02:00
|
|
|
int DestPort = -1;
|
2009-11-30 13:38:13 +01:00
|
|
|
if (DTraits.edgeTargetsEdgeSource(Node, EI)) {
|
|
|
|
child_iterator TargetIt = DTraits.getEdgeTarget(Node, EI);
|
2002-10-16 03:34:18 +02:00
|
|
|
|
|
|
|
// Figure out which edge this targets...
|
2008-05-05 20:30:58 +02:00
|
|
|
unsigned Offset =
|
|
|
|
(unsigned)std::distance(GTraits::child_begin(TargetNode), TargetIt);
|
2003-11-16 21:21:15 +01:00
|
|
|
DestPort = static_cast<int>(Offset);
|
2002-10-07 20:37:10 +02:00
|
|
|
}
|
2002-10-16 04:03:18 +02:00
|
|
|
|
2011-03-01 23:07:55 +01:00
|
|
|
if (DTraits.getEdgeSourceLabel(Node, EI).empty())
|
2009-11-30 13:24:40 +01:00
|
|
|
edgeidx = -1;
|
|
|
|
|
2008-07-28 01:12:19 +02:00
|
|
|
emitEdge(static_cast<const void*>(Node), edgeidx,
|
|
|
|
static_cast<const void*>(TargetNode), DestPort,
|
2011-02-27 05:11:03 +01:00
|
|
|
DTraits.getEdgeAttributes(Node, EI, G));
|
2002-10-07 20:37:10 +02:00
|
|
|
}
|
|
|
|
}
|
2002-10-16 04:03:18 +02:00
|
|
|
|
|
|
|
/// emitSimpleNode - Outputs a simple (non-record) node
|
2002-10-16 22:15:38 +02:00
|
|
|
void emitSimpleNode(const void *ID, const std::string &Attr,
|
2003-02-05 20:40:59 +01:00
|
|
|
const std::string &Label, unsigned NumEdgeSources = 0,
|
|
|
|
const std::vector<std::string> *EdgeSourceLabels = 0) {
|
2002-10-16 04:03:18 +02:00
|
|
|
O << "\tNode" << ID << "[ ";
|
|
|
|
if (!Attr.empty())
|
|
|
|
O << Attr << ",";
|
2002-10-18 16:55:44 +02:00
|
|
|
O << " label =\"";
|
|
|
|
if (NumEdgeSources) O << "{";
|
|
|
|
O << DOT::EscapeString(Label);
|
2002-10-16 22:15:38 +02:00
|
|
|
if (NumEdgeSources) {
|
|
|
|
O << "|{";
|
2005-04-21 22:48:15 +02:00
|
|
|
|
2002-10-16 22:15:38 +02:00
|
|
|
for (unsigned i = 0; i != NumEdgeSources; ++i) {
|
|
|
|
if (i) O << "|";
|
2009-07-23 17:24:38 +02:00
|
|
|
O << "<s" << i << ">";
|
2010-04-30 20:27:57 +02:00
|
|
|
if (EdgeSourceLabels) O << DOT::EscapeString((*EdgeSourceLabels)[i]);
|
2002-10-16 22:15:38 +02:00
|
|
|
}
|
2002-10-18 16:55:44 +02:00
|
|
|
O << "}}";
|
2002-10-16 22:15:38 +02:00
|
|
|
}
|
2002-10-18 16:55:44 +02:00
|
|
|
O << "\"];\n";
|
2002-10-16 04:03:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// emitEdge - Output an edge from a simple node into the graph...
|
2002-10-16 22:15:38 +02:00
|
|
|
void emitEdge(const void *SrcNodeID, int SrcNodePort,
|
|
|
|
const void *DestNodeID, int DestNodePort,
|
|
|
|
const std::string &Attrs) {
|
2002-11-10 07:47:03 +01:00
|
|
|
if (SrcNodePort > 64) return; // Eminating from truncated part?
|
2011-04-15 07:18:47 +02:00
|
|
|
if (DestNodePort > 64) DestNodePort = 64; // Targeting the truncated part?
|
2002-11-10 07:47:03 +01:00
|
|
|
|
2002-10-16 04:03:18 +02:00
|
|
|
O << "\tNode" << SrcNodeID;
|
|
|
|
if (SrcNodePort >= 0)
|
2008-07-21 23:06:55 +02:00
|
|
|
O << ":s" << SrcNodePort;
|
2008-07-28 01:12:19 +02:00
|
|
|
O << " -> Node" << DestNodeID;
|
2009-11-30 13:38:13 +01:00
|
|
|
if (DestNodePort >= 0 && DTraits.hasEdgeDestLabels())
|
2009-11-30 13:37:39 +01:00
|
|
|
O << ":d" << DestNodePort;
|
2002-10-16 04:03:18 +02:00
|
|
|
|
|
|
|
if (!Attrs.empty())
|
|
|
|
O << "[" << Attrs << "]";
|
|
|
|
O << ";\n";
|
|
|
|
}
|
2010-07-22 09:46:31 +02:00
|
|
|
|
|
|
|
/// getOStream - Get the raw output stream into the graph file. Useful to
|
|
|
|
/// write fancy things using addCustomGraphFeatures().
|
|
|
|
raw_ostream &getOStream() {
|
|
|
|
return O;
|
|
|
|
}
|
2002-10-16 03:34:18 +02:00
|
|
|
};
|
2002-10-07 20:37:10 +02:00
|
|
|
|
2002-10-16 03:34:18 +02:00
|
|
|
template<typename GraphType>
|
2009-08-23 09:19:13 +02:00
|
|
|
raw_ostream &WriteGraph(raw_ostream &O, const GraphType &G,
|
|
|
|
bool ShortNames = false,
|
2011-11-15 17:26:38 +01:00
|
|
|
const Twine &Title = "") {
|
2002-10-16 03:34:18 +02:00
|
|
|
// Start the graph emission process...
|
2009-06-24 19:37:09 +02:00
|
|
|
GraphWriter<GraphType> W(O, G, ShortNames);
|
2002-10-17 02:59:59 +02:00
|
|
|
|
2010-09-27 18:44:11 +02:00
|
|
|
// Emit the graph.
|
2011-11-15 17:26:38 +01:00
|
|
|
W.writeGraph(Title.str());
|
2002-10-17 02:59:59 +02:00
|
|
|
|
2002-10-07 20:37:10 +02:00
|
|
|
return O;
|
|
|
|
}
|
|
|
|
|
2006-06-27 18:49:46 +02:00
|
|
|
template<typename GraphType>
|
2011-11-15 17:26:38 +01:00
|
|
|
sys::Path WriteGraph(const GraphType &G, const Twine &Name,
|
|
|
|
bool ShortNames = false, const Twine &Title = "") {
|
2011-01-17 18:34:43 +01:00
|
|
|
std::string ErrMsg;
|
|
|
|
sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg);
|
|
|
|
if (Filename.isEmpty()) {
|
|
|
|
errs() << "Error: " << ErrMsg << "\n";
|
|
|
|
return Filename;
|
|
|
|
}
|
2011-11-15 17:26:38 +01:00
|
|
|
Filename.appendComponent((Name + ".dot").str());
|
2011-01-17 18:34:43 +01:00
|
|
|
if (Filename.makeUnique(true,&ErrMsg)) {
|
|
|
|
errs() << "Error: " << ErrMsg << "\n";
|
2006-08-23 22:34:57 +02:00
|
|
|
return sys::Path();
|
|
|
|
}
|
|
|
|
|
2011-01-17 18:34:43 +01:00
|
|
|
errs() << "Writing '" << Filename.str() << "'... ";
|
|
|
|
|
|
|
|
std::string ErrorInfo;
|
|
|
|
raw_fd_ostream O(Filename.c_str(), ErrorInfo);
|
|
|
|
|
|
|
|
if (ErrorInfo.empty()) {
|
|
|
|
llvm::WriteGraph(O, G, ShortNames, Title);
|
|
|
|
errs() << " done. \n";
|
|
|
|
} else {
|
|
|
|
errs() << "error opening file '" << Filename.str() << "' for writing!\n";
|
|
|
|
Filename.clear();
|
|
|
|
}
|
2009-02-20 23:51:36 +01:00
|
|
|
|
2011-01-17 18:34:43 +01:00
|
|
|
return Filename;
|
2006-06-27 18:49:46 +02:00
|
|
|
}
|
2009-02-20 23:51:36 +01:00
|
|
|
|
2006-06-27 18:49:46 +02:00
|
|
|
/// ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file,
|
|
|
|
/// then cleanup. For use from the debugger.
|
|
|
|
///
|
|
|
|
template<typename GraphType>
|
2011-11-15 17:26:38 +01:00
|
|
|
void ViewGraph(const GraphType &G, const Twine &Name,
|
|
|
|
bool ShortNames = false, const Twine &Title = "",
|
2009-07-09 19:06:18 +02:00
|
|
|
GraphProgram::Name Program = GraphProgram::DOT) {
|
2010-08-20 13:24:35 +02:00
|
|
|
sys::Path Filename = llvm::WriteGraph(G, Name, ShortNames, Title);
|
2006-06-27 18:49:46 +02:00
|
|
|
|
2009-08-24 00:45:37 +02:00
|
|
|
if (Filename.isEmpty())
|
2006-06-27 18:49:46 +02:00
|
|
|
return;
|
2009-02-20 23:51:36 +01:00
|
|
|
|
2009-07-09 19:06:18 +02:00
|
|
|
DisplayGraph(Filename, true, Program);
|
2006-06-27 18:49:46 +02:00
|
|
|
}
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2002-10-07 20:37:10 +02:00
|
|
|
#endif
|