GATE Computer ScienceHardGATE CS (PYQ pattern)
A web of a variable is a maximal union of def-use chains that share a definition or a use; a register allocator gives each web its own live range. How many webs does x have in 1: x = a; 2: if p > 0 goto L1; 3: x = b; 4: L1: y = x + 1; 5: x = y * 2; 6: if q > 0 goto L2; 7: x = 0; 8: L2: z = x + y; 9: x = z; 10: return x?
- A. 3
- B. 5
- C. 2
- D. 4
Correct answer: A. 3
x is defined at 1, 3, 5, 7, 9 and used at 4, 8, 10. The use at 4 is reached by 1 and 3, so {1, 3, 4} is one web; the use at 8 is reached by 5 and 7: {5, 7, 8}; the use at 10 only by 9: {9, 10}. Five definitions but only three webs.
More Compiler Design questions
- In 1: x = 1; 2: y = 0; 3: L1: if y > n goto L3; 4: if x > 5 goto L2; 5: x = x 2; 6: L2: y = y + x; 7: x = y - 1; 8: if y < m goto L1; 9: x…
- Using the standard backpatching scheme (each relational test yields 'if a<b goto ' followed by 'goto ', with no fall-through optimisation…
- For S → a A | A b; A → c | ε (augmented), how many non-blank ACTION entries does the initial state I0 have in the SLR(1) table, and in the…
- For S → a S | a S b S | c (augmented), how many states does the canonical LR(1) automaton have, and how many ACTION cells of the canonical…
- For G: S → A | B; A → a A b | ε; B → a B b b | ε, which of these statements are true? I. Exactly two cells of the LL(1) table, M[S, a] and…
- The grammar S → i S | i S e S | a is ambiguous. How many distinct parse trees does the string "i i i a e a e a" have?