For a statement S in a program, in the context of liveness analysis, the…

2021

For a statement S in a program, in the context of liveness analysis, the following sets are defined:

USE(S): the set of variables used in S

IN(S): the set of variables that are live at the entry of S

OUT(S): the set of variables that are live at the exit of S

Consider a basic block that consists of two statements, S₁ followed by S₂. Which one of the following statements is correct?

  1. A.

    OUT(S₁) = IN(S₂)

  2. B.

    OUT(S₁) = IN(S₁) ∪ USE(S₁)

  3. C.

    OUT(S₁) = IN(S₂) ∪ OUT(S₂)

  4. D.

    OUT(S₁) = USE(S₁) ∪ IN(S₂)

Attempted by 27 students.

Show answer & explanation

Correct answer: A

In liveness analysis within a basic block, control flow flows sequentially from statement to statement. Variables live at the exit of S1 must be identical to those live at the entry of S2. This property establishes that OUT(S1) equals IN(S2).

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir