Naming as follows
Method-1:
Construct this table:
|
Gen |
Kill |
IN |
OUT |
Block-1 |
b,c,f |
a,d,e |
b,c,f |
d,e,c,f |
Block-2 |
e |
f |
e,c |
c,f |
Block-3 |
d,e |
b,e |
d,e,c,f |
c,f |
Block-4 |
f,c |
b |
c,f |
--- |
query-i = IN(Block-1) = {b,c,f}
query-ii = IN(Block-2) = {e,c}
query-iii = IN(Block-3) = {d,e,c,f}
query-iv = OUT(Block-2) = {c,f}
query-v = OUT(Block-2) = {c,f}
query-vi = OUT(Block-4) = NULL
Method-2:
Logic for query-i:
By identifying all those variables (from the point of query onwards to the end of the program via at least one path) which have been read by some statement before it has been over-written by some other statement, we can get the live variables at the point of query.
Similarly, using the same logic for all the queries, we’ll get the same answer as in method-1.
Please correct me if anything is wrong.