Chapter 9: Code generation

Flow graphs

. add control flow information to basic blocks

. nodes are the basic blocks

. there is a directed edge from B1 to B2 if B 2can follow B1 in some execution sequence

- there is a jump from the last statement of B1 to the first statement of B2

- B2 follows B 1 in natural order of execution

. initial node: block with first statement as leader

We can add flow control information to the set of basic blocks making up a program by constructing a directed graph called a flow graph. The nodes of a flow graph are the basic nodes. One node is distinguished as initial; it is the block whose leader is the first statement. There is a directed edge from block B1 to block B2 if B2 can immediately follow B1 in some execution sequence; that is, if

. There is conditional or unconditional jump from the last statement of B1 to the first statement of B2 , or

. B2 immediately follows B1 in the order of the program, and B1 does not end in an unconditional jump. We say that B1 is the predecessor of B 2 , and B 2 is a successor of B 1 .