next up previous
Next: extraction of the CFG Up: Analysis Previous: Introduction
Gasta Homepage: Home page

The control flow graph (CFG)

Figure 9 gives the CFG extract from the code on Figure 10. A node of the CFG contains to value which are its name and a link to an ASG node 1. By this way, all informations contain in the ASG is accessible from the CFG. If we are looking the node "IF_COND", we can see that expression corresponds to the node which has the number 36 in the ASG (which can be directly access using the hash table storing the ASG). Always on Figure 9 there is a representation of the node 36 of the ASG. As you can see, this node corresponds to the "if" condition (i > 10). We don't put all nodes but, it's exactly the same for each nodes. After that, we can use the differents hash tables used to store information about types, variables, parameters or what you need to access directly to relevant information 2. If we continue with the example given on Figure 9, from the line "op0: @23", using the key 23 you can find in the hash table which stores informations about variable that 23 corresponds to :

[Node 23]  source: sample2.c:4 | name: i 
           type: @6 | used: 1
        -> local variable
        -> not initialized
So, the complexity to access information from the CFG is constant. In the next section we will see how to construct the CFG using the visitor.

Figure 9: CFG and ASG link
\begin{figure}\center
\framebox{
\epsfysize=8cm
\epsfbox{figures/cfg.eps}
}\end{figure}

Figure 10: sample2.c basic if statement
\fbox{\begin{minipage}{11cm}
\begin{small}
\begin{tabbing}
t \=
tt \=
\kill
\\ ...
...j = -i;\\
\>\>return j;\\
\>\}\\
\par
\end{tabbing}\end{small}\end{minipage}}


next up previous
Next: extraction of the CFG Up: Analysis Previous: Introduction
Guillaume Thouvenin 2001-10-01