[LLVMdev] Graphviz and LLVM-TV

Tobias Grosser grosser at fim.uni-passau.de
Thu Aug 13 10:19:24 PDT 2009


On Thu, 2009-08-13 at 17:17 +0100, Ioannis Nousias wrote:
> Chris Lattner wrote:
> 
> On Aug 13, 2009, at 8:56 AM, Ioannis Nousias wrote:
> 
> > Hi
> >
> > I'm trying to get a graphviz output (DOT) of a code I'm compiling. I
> > want to see the DFG/CFG of the LLVM assembly, how the operations are
> > chained together. The documentation mentions something about calling
> > certain methods from within gdb, but isn't there some option when
> > invoking the compiler (I've seen some -print-cfg and -dot-cfg options
> > mentioned in some source files, but I can't find which tool supports 
> > them)
> >
> > This should help:
> > http://llvm.org/docs/ProgrammersManual.html#ViewGraph
> >
> Hey Chris. Thanks for the prompt response.
> That's what I was referring to before. If I'm getting this right, I 
> should do a debug build of LLVM and the run it from gdb? So say, I run 
> llvmc from gdb, pass on the code I want to compile and then what? Should 
> I do a break point somewhere first, or wait for the program to finish 
> and then call the methods?(which I don't think it would work). I'm 
> confused. I was hoping for some CLI option or a separate tool that just 
> parses in LLVM assembly and spits out DOT.

The flags for dot output work as any other optimization or analysis
pass. So you can specify them at any tool that allows to pass
optimization flags.
You can use e.g. the "opt" binary and run it on any code that is already
in llvm intermediate code.

Use:

opt -dot-cfg file.bc

Any other tool that passes the flags to opt should also work.

Tobi






More information about the llvm-dev mailing list