You are on page 1of 1

CSC 333/633 Fall 2011 Live Variable Analysis Denition: The value of variable x is live at point p in a program if and

only if that value is used along some path in the ow graph starting at p. Otherwise, x is dead at point p. Analysis: For each basic block, we compute the variables that are live on entrance to the block, and those that are live on exit from the block. Given the live-variable information at the end of each basic block, we can compute the live-variable information at each point of each basic block by a backward scan through the basic block.1 Purpose: Live variable analysis enables dead code elimination. More Denitions: Let B denote a basic block. def[B ] is the set of variables that are unambiguously assigned a value in B prior to any use in B. use[B ] is the set of variables that may be used in block B prior to any denition in B. in[B ] is set of variables that are live at the point immediately before entry into block B. out[B ] is set of variables that are live at the point immediately following block B. Note: Live variable analysis propagates information (regarding liveness) in the opposite direction of the control ow. Data Flow Equations: in[B] = use[B] ( out[B] def[B] ) out[B] =
S

in[S]
is a successor of
B

Solution Method: for each block B do in[B] = ; while changes to in[B] occur for any block B do { for each block B do { in[S] out[B] =
S

is a successor of

in[B] = use[B] ( out[B] def[B] ) } }

See section 9.5 of Aho, Sethi, and Ullman.

You might also like