class documentation

class LivenessAnalysis(Analysis): (source)

View In Hierarchy

Liveness analysis by basic block.

In the liveness analysis, the in_value of a block is the set of variables that are live at the start of a block. "Live" means that the current value of the variable may be used later in the execution. The out_value of a block is the set of variable identifiers that are live at the end of the block.

Since this is a backward analysis, the "before_value" is the out_value and the "after_value" is the in_value.

Method __init__ Undocumented
Method aggregate_previous_after_values Computes the out_value (before_value) of a block.
Method compute_after_value Computes the liveness analysis gen and kill sets for a basic block.

Inherited from Analysis:

Method visit Visit the nodes of the control flow graph, performing the analysis.
Instance Variable after_label Either the in_label or out_label depending on the direction of the analysis. Marks the after_value on a node during an analysis.
Instance Variable before_label Either the in_label or out_label depending on the direction of the analysis. Marks the before_value on a node during an analysis.
Instance Variable forward (bool) True for forward analyses, False for backward analyses.
Instance Variable in_label The name of the analysis, suffixed with _in.
Instance Variable label The name of the analysis.
Instance Variable out_label The name of the analysis, suffixed with _out.
def __init__(self): (source)
def aggregate_previous_after_values(self, previous_after_values): (source)

Computes the out_value (before_value) of a block.

Parameters
previous_after_valuesA list of the sets of live variables at the start of each of the blocks following the current block.
Returns
The set of live variables at the end of the current block. This is the union of live variable sets at the start of each subsequent block.
def compute_after_value(self, block, before_value): (source)

Computes the liveness analysis gen and kill sets for a basic block.

The gen set is the set of variables read by the block before they are written to. The kill set is the set of variables written to by the basic block.

Parameters
blockThe BasicBlock to analyze.
before_valueThe out_value for block (the set of variables live at the end of the block.)
Returns
The in_value for block (the set of variables live at the start of the block).