Live-variable analysis: Difference between revisions

Content deleted Content added
m Example: -<code>
Line 19:
== Expression in terms of dataflow equations ==
 
Liveness analysis is a "backwards may"{{Elucidate|date=May 2015}} analysis. The analysis is done in a backwards order, and the dataflow [[confluence operator]] is [[set union]]. In otherwords, if applying liveness analysis to a function with a particular number of logical branches within it, the analysis is performed starting from the beginning of the function working towards the beginning (hence "backwards"), and a variable is considered live if any of the branches moving forward within the function might potentially (hence "may") need the variables current value. This is in contrast to a "backwards must" analysis which would instead enforces this condition on all branches moving forward.
 
The dataflow equations used for a given basic block ''s'' and exiting block ''f'' in live variable analysis are the following:
Line 48:
 
The in-state of a block is the set of variables that are live at the start of the block. Its out-state is the set of variables that are live at the end of it. The out-state is the union of the in-states of the block's successors. The transfer function of a statement is applied by making the variables that are written dead, then making the variables that are read live.
 
 
== Second example ==