175 views

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 :

### Subscribe to GO Classes for GATE CSE 2022

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.

sounds good to me.
@palashbehra5 @raja11sep can you guys please suggest a source where i could learn about live variable analysis? that’d be really helpful. cheers!

You can start here.