1,128 views
0 votes
0 votes

A variable v is live at a program point p if some path from p to program exit contains an r-value occurrence of v which is not preceded by an l-value occurrence of v . That is, the variable should be referenced before redefinition along any path up to the exit code. https://www.cse.iitb.ac.in/~uday/fp-2019-pune/live-vars.pdf

This is the given question, the number of variables “live” at the “exit” point is asked. Shouldn't the answer be zero as from the exit point there are no such definitions, to begin with?

This is the solution they have provided :
 

 

1 Answer

Best answer
5 votes
5 votes

In this question in first line it is written that a,b,c,d,e,f are live at entry point. Which is wrong, as e is not live at entry point.

Variables live at exit point ={}=phi. ( Because this is the end of program , all variable will be dead here.)

Variables live at path 1 of entry point = {a,b}

Variables live at path 2 of entry point = {c,d,f}

Variables live at path 3 of entry point = {b,c}

Variables live at entry point = Variables live at path 1 of entry point Union Variables live at path 2 of entry point Union Variables live at path 3 of entry point. = {a,b} U {c,d,f} U {b,c} = {a,b,c,d,f}


May be they want to ask the number of variable live at entry point. Anyhow you are right.

selected by

Related questions

1 votes
1 votes
1 answer
1
Na462 asked Jun 11, 2018
1,785 views
Need to tell the Variables live at the Shown points. And Please explain because I know how to identify but I am little confused in applying the concept.Thank you
1 votes
1 votes
1 answer
2
santhoshdevulapally asked Jan 4, 2017
680 views
What is live variable and dead code elimination.please explain with example each