Which one of the following options is the set of live variables at the exit point of each basic block?
A
Step-by-Step Solution
Insight: Global liveness analysis in the presence of loops requires synthesizing backward data-flow equations with fixed-point iteration to resolve back-edge dependencies.
Exam route: Compute IN/OUT for each block backwards. OUT(B4) = \emptyset implies IN(B4) = \{d, e\}. Backtrack to B2, B3, and B1, testing the given options for consistency.
Learning route:
- This is a global data-flow question, recognizable by the CFG with a back edge and a request for live variables at block exits.
- The trigger is the loop (back edge B3 to B1), which requires solving a system of backward equations to a fixed point.
- Step 1: EXIT: OUT(B4) = \emptyset.
- Step 2: B4:
g = d + e. USE=\{d, e\}, DEF=\{g\}. IN(B4) = (OUT(B4) - \{g\}) \cup \{d, e\} = \{d, e\}. - Step 3: B2:
d = a + e. USE=\{a, e\}, DEF=\{d\}. Successor is B4. OUT(B2) = IN(B4) = \{d, e\}. IN(B2) = (OUT(B2) - \{d\}) \cup \{a, e\} = \{e\} \cup \{a, e\} = \{a, e\}. - Step 4: B3:
e = a + f. USE=\{a, f\}, DEF=\{e\}. Successor is B1 (back edge). OUT(B3) = IN(B1). IN(B3) = (OUT(B3) - \{e\}) \cup \{a, f\}. - Step 5: B1:
a = b + c. USE=\{b, c\}, DEF=\{a\}. Successors are B2 and B3. OUT(B1) = IN(B2) \cup IN(B3) = \{a, e\} \cup IN(B3). - Step 6: Solve fixed point. Assume IN(B1) initially \emptyset. Then OUT(B3) = \emptyset, IN(B3) = \{a, f\}. OUT(B1) = \{a, e\} \cup \{a, f\} = \{a, e, f\}. IN(B1) = (OUT(B1) - \{a\}) \cup \{b, c\} = \{e, f\} \cup \{b, c\} = \{b, c, e, f\}.
- Step 7: Iterate again with IN(B1) = \{b, c, e, f\}. OUT(B3) = \{b, c, e, f\}. IN(B3) = (\{b, c, e, f\} - \{e\}) \cup \{a, f\} = \{a, b, c, f\}. OUT(B1) = \{a, e\} \cup \{a, b, c, f\} = \{a, b, c, e, f\}. IN(B1) = (\{a, b, c, e, f\} - \{a\}) \cup \{b, c\} = \{b, c, e, f\}. Fixed point reached.
- Step 8: Final OUT sets: OUT(B1) = \{a, b, c, e, f\}, OUT(B2) = \{d, e\}, OUT(B3) = \{b, c, e, f\}, OUT(B4) = \emptyset. This matches Option A. My verified answer matches the current answer.