This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: printing cfg
- From: Diego Novillo <dnovillo at google dot com>
- To: gcc at gcc dot gnu dot org, bob_rossi at cox dot net
- Date: Wed, 01 Aug 2007 15:17:36 -0400
- Subject: Re: printing cfg
- References: <20070801190303.GU11737@cox.net>
On 8/1/07 3:03 PM, Bob Rossi wrote:
> Is there a way to make it show the actual expressions in the code
> instead?
Other than changing the code in tree-cfg.c:tree_cfg2vcg(), not really.
Also, this dump is fairly static in that it only happens right after the
CFG is built for the first time (before any optimizations).
> Also, is there a native way to display this information using
> dot instead?
Perhaps it would be easier to post-process the dumps that contain basic
block information (-fdump-tree-all-blocks). I generally use the
attached script to get the CFG out of an arbitrary pass. It's very
simplistic, but it could be adapted to do what you want.
#!/bin/sh
#
# (C) 2005 Free Software Foundation
# Contributed by Diego Novillo <dnovillo@redhat.com>.
#
# This script is Free Software, and it can be copied, distributed and
# modified as defined in the GNU General Public License. A copy of
# its license can be downloaded from http://www.gnu.org/copyleft/gpl.html
if [ "$1" = "" ] ; then
echo "usage: $0 file"
echo
echo "Generates a GraphViz .dot graph file from 'file'."
echo "It assumes that 'file' has been generated with -fdump-tree-...-blocks"
echo
exit 1
fi
file=$1
out=$file.dot
echo "digraph cfg {" > $out
echo " node [shape=box]" >>$out
echo ' size="11,8.5"' >>$out
echo >>$out
(grep -E '# BLOCK|# PRED:|# SUCC:' $file | \
sed -e 's:\[\([0-9\.%]*\)*\]::g;s:([a-z_,]*)::g' | \
awk '{ #print $0; \
if ($2 == "BLOCK") \
{ \
bb = $3; \
print "\t", bb, "[label=\"", bb, "\", style=filled, color=gray]"; \
} \
else if ($2 == "PRED:") \
{ \
for (i = 3; i <= NF; i++) \
print "\t", $i, "->", bb, ";"; \
} \
}') >> $out
echo "}" >> $out