GATE Computer ScienceHardGATE CSE

Control-flow graph: B1: a=1; b=2; c=a+b; then B2: d=c+b; if d<10 goto B4 (else B3); B3: c=d+a; b=c; goto B2; B4: print(c+a). Edges: B1→B2, B2→B3, B2→B4, B3→B2. Which variables are live at the entry of B2 (live-in of B2)?

  1. A. {a, b, c}
  2. B. {a, b, c, d}
  3. C. {b, c}
  4. D. {a, b}

Correct answer: A. {a, b, c}

Backward fixpoint: B4 uses c,a; B3 needs d,a and defines c,b; live-in(B2) = use{c,b} ∪ (live-out − def{d}) = {a, b, c}.

More Compiler Design questions

Exams that ask this topic