[Prev][Next][Index]

Re: Question




>I would like to know if Sage++ builds a control-flow graph of the
>program that I can access.

Well, yes and no. There are two tools of which I am aware, none of them
appropriate for serious compiler work.

First, if you want a static procedure call graph, look in
Sage++/extentions/sgCallGraph.C, which extracts such a graph (and in
instr/cgm.C for an example of how this module can be used).

Second, if you want a procedure-wise control-flow graph, there is a
prototypical implementation of a program which creates such a graph to
be found in instr/cfg.C.  However, it may be unsuitable for you for
three reasons: it is largely unused at this time, hence relatively
untested; it works only for C++ right now (from your previous messages I
get the impression that you are working with Fortran); and it creates
graphs which do not contain actual basic blocks but some which are a
little extended: for example, if we have

	a = (c ? 1 : 2);

this statement will be treated as a non-terminating statement for the
block, even though it is clearly a decision point in the flow graph. In
brief, the graph operates on a statement level, and control-flow within
a statement (conditional expressions, short-circuit boolean evaluation)
is ignored.  The reason why the graph is coarse is because of its
intended use: it is to be used for displaying source graphs to the user
for manual insertion of profiling points.

That said, it may be straightforward to make it work for Fortran, and
perhaps it meets your needs.

--lars



Reference(s):