GATE CS 2023 · Question 37 · Compiler Design · Multiple choice (MCQ) · 2 marks · −2/3 for a wrong answer

Consider the control flow graph shown.
Which one of the following choices correctly lists the set of live variables at the exit point of each basic block?

Control flow graph with four basic blocks. ENTRY has an arrow into block B1. B1 contains: i = m - 1; j = n; a = 10. B1 has an arrow to block B2. B2 contains: i = i + 1; j = j - 1. B2 has two outgoing arrows: one to block B3 and one directly down to block B4. B3 contains: a = 20. B3 has an arrow to B4. B4 contains: i = a + 1. B4 has two outgoing arrows: one down to EXIT, and one curved back-edge looping around the right side up into B2.
  1. (A) B1: {}, B2: {a}, B3: {a}, B4: {a}
  2. (B) B1: {i, j}, B2: {a}, B3: {a}, B4: {i}
  3. (C) B1: {a, i, j}, B2: {a, i, j}, B3: {a, i}, B4: {a}
  4. (D) B1: {a, i, j}, B2: {a, j}, B3: {a, j}, B4: {a, i, j}
Answer

Answer (D)

Answer from the official GATE CS 2023 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes