practice final solutions question 4

10 views
Skip to first unread message

Joshua

unread,
Dec 14, 2011, 2:53:13 PM12/14/11
to CPSC410-2011, bsto...@gmail.com
Two things. When doing 4a and 4b, I noticed that you have the
declarations in line 1 listed as being live even though in the class
notes you have stated that you kill the set of declared variables. Can
you explain whats going on and your reasoning. Also in 4b you have
listed x,y,z as live at line 3 even though the intersection of
liveness at 7 and 4 cannot give a liveness in all 3 variables.Any
explanation would be great.

Jannus Meyburg

unread,
Dec 14, 2011, 5:46:15 PM12/14/11
to cpsc41...@googlegroups.com, bsto...@gmail.com
+1 for the second question.
Re: Q4b, intersection of 7 and 4 cannot give a liveness in all three variables.

Eric Wohlstadter

unread,
Dec 14, 2011, 6:44:15 PM12/14/11
to cpsc41...@googlegroups.com
Hi Joshua,

On Wed, Dec 14, 2011 at 11:53 AM, Joshua <joshuac...@gmail.com> wrote:
Two things. When doing 4a and 4b, I noticed that you have the
declarations in line 1 listed as being live even though in the class
notes you have stated that you kill the set of declared variables. Can
you explain whats going on and your reasoning.

I don't think it states "you kill the set of declared variables". That statement is too vague. Perhaps I said that if a variable is redefined then it kills a previous definition. 

Notice that the value of the parameter x passed in at line 1 might be used on line 4. 
For z, since it hasn't even been declared yet on line 1, any answer would be acceptable. 
 
 Also in 4b you have
listed x,y,z as live at line 3 even though the intersection of
liveness at 7 and 4 cannot give a liveness in all 3 variables.Any
explanation would be great.

This is because "x" and "z" are used at that statement. It was not clear in the practice question whether to consider liveness immediately before a statement or immediately after. I'll make sure it is clarified in the text of the exam.

Eric
Reply all
Reply to author
Forward
0 new messages