Consider the control flow graph given below.

Which one of the following options is the set of live variables at the exit point of each basic block?
View worked solution
Answer: A
Live variable analysis is a backward data-flow analysis. A variable is said to be live at a given point if there is a path from that point to a use of the variable along which the variable is not redefined.
The data-flow equations for any basic block are:
Applying these equations backward from the exit block:
- Block B4: Since B4 is the exit block of the program, no variables are live at its exit. Thus, .
- Block B2: The variables and are propagated from its successors, giving .
- Block B3: Due to the loop back to the preceding blocks where is used before being redefined, the variable remains live at the exit of B3 along with . Thus, .
- Block B1: The union of the live-in variables of its successors B2 and B3 gives .
This matches the sets given in Option A.
Free practice · Your answers on this page are not saved.
