mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-17 18:24:34 +00:00
Added graphviz/gv support for MF.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23700 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
#include "llvm/Support/LeakDetector.h"
|
#include "llvm/Support/LeakDetector.h"
|
||||||
#include "llvm/Support/GraphWriter.h"
|
#include "llvm/Support/GraphWriter.h"
|
||||||
|
#include "llvm/Config/config.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -206,6 +207,7 @@ namespace llvm {
|
|||||||
|
|
||||||
void MachineFunction::viewCFG() const
|
void MachineFunction::viewCFG() const
|
||||||
{
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
std::string Filename = "/tmp/cfg." + getFunction()->getName() + ".dot";
|
std::string Filename = "/tmp/cfg." + getFunction()->getName() + ".dot";
|
||||||
std::cerr << "Writing '" << Filename << "'... ";
|
std::cerr << "Writing '" << Filename << "'... ";
|
||||||
std::ofstream F(Filename.c_str());
|
std::ofstream F(Filename.c_str());
|
||||||
@@ -219,6 +221,17 @@ void MachineFunction::viewCFG() const
|
|||||||
F.close();
|
F.close();
|
||||||
std::cerr << "\n";
|
std::cerr << "\n";
|
||||||
|
|
||||||
|
#ifdef HAVE_GRAPHVIZ
|
||||||
|
std::cerr << "Running 'Graphviz' program... " << std::flush;
|
||||||
|
if (system((LLVM_PATH_GRAPHVIZ " " + Filename).c_str())) {
|
||||||
|
std::cerr << "Error viewing graph: 'Graphviz' not in path?\n";
|
||||||
|
} else {
|
||||||
|
system(("rm " + Filename).c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif // HAVE_GRAPHVIZ
|
||||||
|
|
||||||
|
#ifdef HAVE_GV
|
||||||
std::cerr << "Running 'dot' program... " << std::flush;
|
std::cerr << "Running 'dot' program... " << std::flush;
|
||||||
if (system(("dot -Tps -Nfontname=Courier -Gsize=7.5,10 " + Filename
|
if (system(("dot -Tps -Nfontname=Courier -Gsize=7.5,10 " + Filename
|
||||||
+ " > /tmp/cfg.tempgraph.ps").c_str())) {
|
+ " > /tmp/cfg.tempgraph.ps").c_str())) {
|
||||||
@@ -228,6 +241,15 @@ void MachineFunction::viewCFG() const
|
|||||||
system("gv /tmp/cfg.tempgraph.ps");
|
system("gv /tmp/cfg.tempgraph.ps");
|
||||||
}
|
}
|
||||||
system(("rm " + Filename + " /tmp/cfg.tempgraph.ps").c_str());
|
system(("rm " + Filename + " /tmp/cfg.tempgraph.ps").c_str());
|
||||||
|
return;
|
||||||
|
#endif // HAVE_GV
|
||||||
|
#endif // NDEBUG
|
||||||
|
std::cerr << "MachineFunction::viewCFG is only available in debug builds on "
|
||||||
|
<< "systems with Graphviz or gv!\n";
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
system(("rm " + Filename).c_str());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MachineFunction::viewCFGOnly() const
|
void MachineFunction::viewCFGOnly() const
|
||||||
|
Reference in New Issue
Block a user