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)?
- A. {a, b, c}
- B. {a, b, c, d}
- C. {b, c}
- 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
- Let L = { w ∈ {a,b} : the 4th symbol from the right end of w is 'a' }. The minimal DFA for L has how many states (including any dead/trap…
- Procedure P(x, y) { x = x + 1; y = x + y; } is called as P(a, a) with a = 3. What is a after the call under call-by-reference, and under…
- Grammar: S → L = R | R; L → R | id; R → L (augmented with S' → S). How many states do the LR(0) automaton and the canonical LR(1)…
- Grammar: S → a A d | b B d | a B e | b A e; A → c; B → c. How many states does the canonical LR(1) collection contain, how many does…
- For the standard expression grammar E → E + T | T; T → T F | F; F → ( E ) | id (augmented), how many states does the canonical LR(1)…
- For S → C C; C → c C | d (augmented), the canonical LR(1) collection has some states that share an LR(0) core. By how many states does…