in Compiler Design
447 views
0 votes
0 votes

in Compiler Design
by
447 views

3 Comments

This is a snippet from the stanford slide

You can access the slides from this link : http://openclassroom.stanford.edu/MainFolder/DocumentPage.php?course=Compilers&doc=docs/slides.html


Coming back to the question

The variable p is live at Basic block 1

  1. as statement 2 uses p
  2. There is a direct path from 1→ 2
  3. No intervening assignment to p is there

Hence option D is eliminated

The variable p is not live at BB 2 as there is a assignment to p in BB4

The variable p is live at Basic block 4

  1. as statement 5 uses p
  2. There is a direct path from 4→ 5
  3. No intervening assignment to p is there

The variable p is live at Basic block 5

  1. as statement 2 uses p
  2. There is a direct path from 5→2
  3. No intervening assignment to p is there

Hence option (C) is the answer

You can also use USE(),IN(),OUT() sets, but i find this way more easy to analyse

 

1
1
But ,at statement 1 there is a definition of P ,i.e there is a new definition of p from 1>2.So ,how can you say that p is live at statement 1?
0
0

I hope your doubt is clear why p is live from 1→ 2

0
0

Please log in or register to answer this question.

Related questions