Equations for Live Variable Analysis

Algorithm for Computing Live Variables

Data Structures for Live Variables

9.4.2 Algorithm for Computing Live Variables

This time, we once again want the smallest solution -- we don't say a variable is live unless we actually find a path along which it is used before being redefined.

Thus, we start by assuming nothing is live on exit from any block. The process stops because we are only adding variables to the sets (and there are a finite number of variables).

    Algorithm

    Live Variable analysis

     FOR all blocks B DO
       IN(B) = Gen(B)
     ENDFOR
     WHILE there aer changes DO
       FOR each block B DO
         Out(B) =  In(S)
             S  Succ(B)
         In(B) = (Out(B) - Kill(B))  Gen(B)
       ENDFOR
     ENDWHILE