1 //===-- SelectionDAGPrinter.cpp - Implement SelectionDAG::viewGraph() -----===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This implements the SelectionDAG::viewGraph method.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/CodeGen/SelectionDAG.h"
15 #include "llvm/CodeGen/MachineFunction.h"
16 #include "llvm/Function.h"
17 #include "llvm/Support/GraphWriter.h"
21 /// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
22 /// rendered using 'dot'.
24 void SelectionDAG::viewGraph() {
25 std::string Filename = "/tmp/dag." +
26 getMachineFunction().getFunction()->getName() + ".dot";
27 std::cerr << "Writing '" << Filename << "'... ";
28 std::ofstream F(Filename.c_str());
31 std::cerr << " error opening file for writing!\n";
39 std::cerr << "Running 'dot' program... " << std::flush;
40 if (system(("dot -Tps -Nfontname=Courier -Gsize=7.5,10 " + Filename
41 + " > /tmp/dag.tempgraph.ps").c_str())) {
42 std::cerr << "Error running dot: 'dot' not in path?\n";
45 system("gv /tmp/dag.tempgraph.ps");
47 system(("rm " + Filename + " /tmp/dag.tempgraph.ps").c_str());