Question

There is -view-cfg option (doc) in llvm's opt program, which enables me to view the Control Flow Graph via dot program. But the CFG in too big to be rendered as postscript from dot. I know that there is the xvcg utiity capable of displaying complex graphs, including CFG (and its man says "VCG tool - visualization of compiler graphs").

So, how can I output llvm's CFG in xvcg format?

Was it helpful?

Solution

Directly generating .vcg files from LLVM will require heavy modifications to GraphWriter, which is very GraphViz-specific. Instead, it seems to me that the most straightforward solution will be to save a dot file (via -dot-cfg instead of -view-cfg) and then convert it, using something like Graph-Easy. From its documentation (emphasis mine):

It understands the following formats as input:

The output can be a dump of the graph in one of the following formats:

By the way, if you want to get a lot of graphs and prefer to see them before generating a lot of dot files, consider using a dot viewer which also allows you to save the file, such as my fork of xdot.py - or better yet, modify xdot.py so that it knows how to save in .vcg format itself, using Graph-Easy.

Another alternative to Graph-Easy appears to be dot2gdl.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top