GATE Computer ScienceVery hardGATE CSE

A straight-line CFG B1→B2→B3→B4→B5 has: B1 defines x; B2 defines y; B3 uses y and defines z; B4 defines y; B5 uses x and z. Live-variable analysis (IN[B] = use ∪ (OUT[B] − def), OUT[B] = union of successors' IN) is run by round-robin iteration updating blocks in the order B1, B2, B3, B4, B5 in each pass, until a complete pass changes nothing. How many passes are executed in total (including the final pass that detects no change)?

  1. A. 5
  2. B. 2
  3. C. 4
  4. D. 6

Correct answer: A. 5

A backward problem visited in forward order propagates facts only one block per pass: the changes from B5 reach B1 over passes 1–4, and a fifth pass confirms stability (visiting in reverse order would need only 2).

More Compiler Design questions

Exams that ask this topic