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)?
- A. 5
- B. 2
- C. 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
- A flow graph has blocks (definitions d1…d7): B1: d1: i=0; d2: j=0. B2: d3: i=i+1. B3: d4: j=j+i. B4: d5: i=j; d6: k=i. B5: d7: j=k. Edges…
- In register allocation by graph colouring, variables v0…v6 have interference edges: the 5-cycle v0–v1–v2–v3–v4–v0, v5 interfering with…
- With Sethi–Ullman numbering (left leaf = 1, right leaf = 0, internal node = max(l,r) if l ≠ r else l+1), what is the label of the root of…
- Syntax-directed definition: E → E1 T { E.val = E1.val 2 + T.val }; E → T { E.val = T.val }; T → num { T.val = num.lexval }. For the input…
- Grammar: E → E + T | T; T → T F | F; F → id. An SLR(1) parser parses id + id id + id id (followed by ). Counting each shift and each…
- Grammar: S → A B C; A → a | ε; B → a | b | ε; C → a | c | ε. How many cells of the LL(1) table contain more than one production?