Question
For a statement in a program, in the context of liveness analysis, the following sets are defined:
Consider a basic block that consists of two statements, followed by . Which one of the following statements is correct?
Official answer and solution
- Official answer
- A
- From
- Official GATE 2021 answer key
Solution
Recall the fundamental dataflow equations for backward liveness analysis within a sequential basic block.
In compiler liveness analysis, analysis is performed in the backward direction:
- A variable is live at a point if there is an execution path from along which its value is used before being redefined.
Within a basic block consisting of statement followed immediately by statement , execution proceeds unconditionally and sequentially from to . There are no intervening statements or branch points between the exit of and the entry of .
Consequently, a variable is live immediately after executing (at the exit of ) if and only if it is live immediately before executing (at the entry of ):
This matches option A.
A
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2021 Computer Science and Information Technology - Session 2 (CS2)
- Question
- 48 of 65, printed as CS Q.38
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.