8.5.2 Building a Flow Graph

A flow graph shows all possible execution paths. We will use this information to perform optimizations.

Formally, a flow graph is a directed graph G, with N nodes and E edges. (Remember that a directed graph is a connected set of nodes where every node is reachable from the initial node.) Example 3 shows the control flow graph for Example 2. The rules for building such a graph follow.

More formally, we create nodes and arcs as shown in Figure 5. Successors and predecessors are defined as in Figure 5.

These are all the edges in a flow graph. (Convince yourself of this.)

Send questions and comments to: Karen Lemone