GATE Computer ScienceVery hardGATE CSE
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: B1→B2, B2→B3, B2→B4, B3→B5, B4→B5, B5→B2. How many definitions reach the entry of B2 (IN[B2])?
- A. 5
- B. 6
- C. 7
- D. 8
Correct answer: B. 6
Reaching-definitions fixpoint: IN[B2] = OUT[B1] ∪ OUT[B5] = {d1, d2, d3, d5, d6, d7}.
More Compiler Design questions
- 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?
- A lexer uses longest match, with ties broken in favour of the rule listed first. Rules in order: IF = "if"; ELSE = "else"; ID =…