• edited by
560 views
0 0 votes

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?

  1. $\text{B1: {a, b, c, e, f}, B2: {d, e}, B3: { }, B4: {b, c, e, f}}$
     
  2. $\text{B1: {a, b, c}, B2: {d, e}, B3: { }, B4: {b, c, e, f}}$
     
  3. $\text{B1: {a, b, c, e, f}, B2: {d, e}, B3: { }, B4: {e, f}}$
     
  4. $\text{B1: {a, b, c}, B2: {d, e}, B3: { }, B4: {b, e, f}}$

2 Answers

0 0 votes
In  this question we have to check   a path from exit  point where read of that variable happen without any write before it .

Block B1 Live variable = { a , b , c, e,f}

Block B2 Live variable = {d,e}

Block B3  Live variable = {}

Bolck B4 Live variable = {b,c,e,f}

So option A
0 0 votes

Source: Ullman

Available variables = {a,b,c,d,e,f,g}

At the exit of B1

  • a is first used before defined => LIVE {B1 -> B2 OR B1 -> B4}

  • b is first used before defined => LIVE {B1 -> B4 -> B1}

  • c is first used before defined => LIVE {B1 -> B4 -> B1}

  • d is first defined before used => DEAD {B1 -> B2}

  • e is first used before defined => LIVE {B1 -> B2}

  • f is first used before defined => LIVE {B1 -> B4}

  • g is first defined before used => DEAD {B1 -> B2 -> B3}

Live at exit of B1 = {a,b,c,e,f}

At the exit of B2

  • d is first used before defined => LIVE {B2 -> B3}

  • e is first used before defined => LIVE {B2 -> B3}

  • g is first defined before used => DEAD {B2 -> B3}

Live at exit of B2 = {d,e}

At the exit of B3

  • NO variable is LIVE

Live at exit of B3 = { }

At the exit of B4

  • a is first defined before used => DEAD {B4 -> B1}

  • b is first used before defined => LIVE {B4 -> B1}

  • c is first used before defined => LIVE {B4 -> B1}

  • d is first defined before use => DEAD {B4 -> B1 -> B2}

  • e is first used before defined => LIVE {B4 -> B1 -> B2}

  • f is first used before defined => LIVE {B4 -> B1 -> B4}

  • g is first defined before used => DEAD {B4 -> B1 -> B2 -> B3}

Live at exit of B4 = {b,c,e,f}

Answer: Option A

For better understanding of Method 1: Liveness Analysis - GATE PYQs & Practice Questions | CFG with Loop | Live Variable | Compiler Design

• edited by
Answer:
Position:
Show:

Related questions

1 1 vote
2 2 answers
500
500 views
GO Classes asked Feb 11
500 views
Consider the given grammer $: $$$\begin{aligned}& \mathrm{S} \rightarrow \mathrm{ACB} \\& \mathrm{A} \rightarrow \mathrm{aA} \mid \epsilon \\& \mathrm{C} \rightarrow \mat...
2 2 votes
1 1 answer
634
634 views
GO Classes asked Feb 11
634 views
Consider a lexical analyzer with the following token specifications:\[\begin{aligned}\texttt{letter} &\rightarrow \texttt{[A-Z a-z]} \\\texttt{digit} &\rightarrow \textt...
1 1 vote
1 1 answer
371
371 views
GO Classes asked Feb 11
371 views
Which of the following is ambiguous grammar?$\mathrm{S} \rightarrow \mathrm{aSb} \mid \in$ $\mathrm{S} \rightarrow \mathrm{aS} \mid \in$ $\mathrm{S} \rightarrow \mathrm{a...
6 6 votes
3 3 answers
2.0k
2.0k views
GO Classes asked Feb 13
2,031 views
Given that Maximum Segment size is $2 ~\mathrm{KB}$ and the slow start threshold (ssthresh) is $16 ~\mathrm{KB}$, how many transmission round is required to reach in cong...