C-Breeze
C Compiler Infrastructure

[ Project home page]

livenessAnalyzer Class Reference

Liveness analyzer. More...

#include <liveness.h>

Inheritance diagram for livenessAnalyzer:

analysisProblem List of all members.

Public Member Functions

 livenessAnalyzer ()
 Create a liveness analysis object.
virtual string name ()
 Name of the analysis.
void clear ()
 Reset liveness information.
bool isLive (stmtNode *stmt)
 Is a particular statement live.
const procedure_setvisited_procedures () const
virtual void at_index (stmtLocation *current, operandNode *operand, pointerValue &left, pointerValue &right, pointerValue &result)
virtual void at_call (stmtLocation *current, operandNode *call, pointerValue &call_target, procNode *callee, pointervalue_list &arguments, pointerValue &return_val)
virtual void at_assignment (stmtLocation *current, pointerValue &left, pointerValue &right, pointerValue &result, memoryblock_set &changes)
virtual void at_return (stmtLocation *stmt, returnNode *ret, pointerValue &result, pointerValue &return_val)
virtual void at_threeAddr (stmtLocation *stmt, threeAddrNode *threeaddr, pointerValue &result)
virtual void at_conditiongoto (stmtLocation *stmt, conditiongotoNode *c, pointerValue &left, pointerValue &right, pointerValue &result)
virtual void at_merge (Location *where, memoryBlock *block, memoryuse_list &phi_uses, pointerValue &result, memoryblock_set &changes)
virtual void at_allocation (stmtLocation *stmt, pointervalue_list &arguments, memoryBlock *block, memoryblock_set &changes)
virtual void at_deallocation (stmtLocation *stmt, pointerValue &to_deallocate, memoryblock_set &changes)
virtual void at_stmt_exit (stmtLocation *stmt, pointerValue &result)
virtual void at_basicblock_entry (basicblockLocation *block, procedureInfo *info, pointerValue &initial)
virtual void at_procedure_entry (procLocation *proc, procedureInfo *info, pointerValue &return_val)
virtual void at_procedure_exit (procLocation *proc, procedureInfo *info, pointerValue &return_val)
Direction direction () const
 Get the direction.
virtual bool compare_property_value (Location *where, memoryBlock *property_block, procedureInfo *callee)
 Compare current property value against the last input to callee.
virtual void record_input_to_value (procedureInfo *callee, memoryBlock *property_block, stmtLocation *callsite)
 Record the value of a property when it is used as an input_to/external_input value to a call to callee at a call site.
Transfer functions
The rest of these functions are hooks for the pointer analyzer to call at various points in the analysis. They serve as the transfer functions for the dataflow analysis problem.

virtual void at_id (stmtLocation *current, idNode *id, pointerValue &result)
virtual void at_unary (stmtLocation *current, threeAddrNode *r, pointerValue &operand, pointerValue &result)
virtual void at_sizeof (stmtLocation *current, threeAddrNode *r, pointerValue &operand, pointerValue &result)
virtual void at_binary (stmtLocation *current, stmtNode *r, pointerValue &left, pointerValue &right, pointerValue &result)
virtual void at_cast (stmtLocation *current, operandNode *operand, pointerValue &operand_value, pointerValue &result)
virtual void at_const (stmtLocation *current, constNode *cons, pointerValue &result)
virtual void at_field_access (stmtLocation *current, operandNode *operand, pointerValue &operand_value, pointerValue &result)
virtual void at_dereference (stmtLocation *current, operandNode *operand, pointerValue &operand_value, pointerValue &result)
virtual void at_address (stmtLocation *current, operandNode *operand, pointerValue &operand_value, pointerValue &result)
virtual void at_parameter_pass (Location *current, stmtLocation *parameter_callsite, pointerValue &left, pointerValue &right, memoryblock_set &changes)
virtual void at_self_assignment (Location *source, Location *target, memoryBlock *block, memoryblock_set &changes, bool is_input)
virtual void at_return (Location *current, pointerValue &left, pointerValue &right, memoryblock_set &changes)
virtual void at_stmt_entry (stmtLocation *stmt, pointerValue &result)
virtual void at_basicblock_exit (basicblockLocation *block, procedureInfo *info, pointerValue &final)
virtual void at_conservative_procedure_call (stmtLocation *current, operandNode *call, operand_list &args, pointerValue &call_target, pointervalue_list &arguments, memoryblock_set &reachable_blocks, pointerValue &return_val, memoryblock_set &changes)

Protected Member Functions

void collectDefs (pointerValue &pointer)
 Collect defs.
void addDef (memoryDef *def)
 Add one def.
bool determineLiveness ()
 Determine liveness.
bool isLive (memoryUse *use, memoryBlock *owner)
 Look up liveness.
void setLive (stmtLocation *where)
 Set live for statements.
void setLive (Location *where, memoryBlock *block)
 Set live for merge-points.

Protected Attributes

Direction _direction

Private Types

typedef set< stmtNode * > stmt_liveness_set
typedef stmt_liveness_set::iterator stmt_liveness_set_p
typedef set< stmtLocation * > stmtlocation_liveness_set
typedef stmtlocation_liveness_set::iterator stmtlocation_liveness_set_p
typedef pair< Location *,
memoryBlock * > 
mergepoint_pair
typedef set< mergepoint_pairmergepoint_liveness_set
typedef mergepoint_liveness_set::iterator mergepoint_liveness_set_p
typedef list< bool > change_stack
typedef change_stack::iterator change_stack_p

Private Attributes

stmt_liveness_set _live_stmts
 Live statements.
stmtlocation_liveness_set _live_stmtlocations
 Live statement locations.
mergepoint_liveness_set _live_mergepoints
 Live merge points.
memorydef_set _defs
 Collect defs.
bool _change
 Record changes.
change_stack _change_stack
 Change stack.
procedure_set _visited_procedures
 Set of visited procedures.

Detailed Description

Liveness analyzer.

Liveness is a property of statements in the program. A statement is live if any of the defs created by the statement are live. A def is live if it has uses, and at least one of it's uses is live. A use is live if the statement in which it occurs is live.

Definition at line 56 of file liveness.h.


Member Typedef Documentation

typedef list< bool > livenessAnalyzer::change_stack [private]
 

Definition at line 70 of file liveness.h.

typedef change_stack::iterator livenessAnalyzer::change_stack_p [private]
 

Definition at line 71 of file liveness.h.

typedef set< mergepoint_pair > livenessAnalyzer::mergepoint_liveness_set [private]
 

Definition at line 67 of file liveness.h.

typedef mergepoint_liveness_set::iterator livenessAnalyzer::mergepoint_liveness_set_p [private]
 

Definition at line 68 of file liveness.h.

typedef pair< Location *, memoryBlock * > livenessAnalyzer::mergepoint_pair [private]
 

Definition at line 66 of file liveness.h.

typedef set< stmtNode * > livenessAnalyzer::stmt_liveness_set [private]
 

Definition at line 60 of file liveness.h.

typedef stmt_liveness_set::iterator livenessAnalyzer::stmt_liveness_set_p [private]
 

Definition at line 61 of file liveness.h.

typedef set< stmtLocation * > livenessAnalyzer::stmtlocation_liveness_set [private]
 

Definition at line 63 of file liveness.h.

typedef stmtlocation_liveness_set::iterator livenessAnalyzer::stmtlocation_liveness_set_p [private]
 

Definition at line 64 of file liveness.h.


Constructor & Destructor Documentation

livenessAnalyzer::livenessAnalyzer  ) 
 

Create a liveness analysis object.


Member Function Documentation

void livenessAnalyzer::addDef memoryDef def  )  [protected]
 

Add one def.

virtual void analysisProblem::at_address stmtLocation current,
operandNode operand,
pointerValue operand_value,
pointerValue result
[inline, virtual, inherited]
 

Definition at line 151 of file ipanalysis.h.

virtual void livenessAnalyzer::at_allocation stmtLocation stmt,
pointervalue_list arguments,
memoryBlock block,
memoryblock_set changes
[virtual]
 

Reimplemented from analysisProblem.

virtual void livenessAnalyzer::at_assignment stmtLocation current,
pointerValue left,
pointerValue right,
pointerValue result,
memoryblock_set changes
[virtual]
 

Reimplemented from analysisProblem.

virtual void livenessAnalyzer::at_basicblock_entry basicblockLocation block,
procedureInfo info,
pointerValue initial
[virtual]
 

Reimplemented from analysisProblem.

virtual void analysisProblem::at_basicblock_exit basicblockLocation block,
procedureInfo info,
pointerValue final
[inline, virtual, inherited]
 

Definition at line 243 of file ipanalysis.h.

virtual void analysisProblem::at_binary stmtLocation current,
stmtNode r,
pointerValue left,
pointerValue right,
pointerValue result
[inline, virtual, inherited]
 

Definition at line 112 of file ipanalysis.h.

virtual void livenessAnalyzer::at_call stmtLocation current,
operandNode call,
pointerValue call_target,
procNode callee,
pointervalue_list arguments,
pointerValue return_val
[virtual]
 

Reimplemented from analysisProblem.

virtual void analysisProblem::at_cast stmtLocation current,
operandNode operand,
pointerValue operand_value,
pointerValue result
[inline, virtual, inherited]
 

Definition at line 119 of file ipanalysis.h.

virtual void livenessAnalyzer::at_conditiongoto stmtLocation stmt,
conditiongotoNode c,
pointerValue left,
pointerValue right,
pointerValue result
[virtual]
 

Reimplemented from analysisProblem.

virtual void analysisProblem::at_conservative_procedure_call stmtLocation current,
operandNode call,
operand_list args,
pointerValue call_target,
pointervalue_list arguments,
memoryblock_set reachable_blocks,
pointerValue return_val,
memoryblock_set changes
[inline, virtual, inherited]
 

Definition at line 250 of file ipanalysis.h.

virtual void analysisProblem::at_const stmtLocation current,
constNode cons,
pointerValue result
[inline, virtual, inherited]
 

Definition at line 124 of file ipanalysis.h.

virtual void livenessAnalyzer::at_deallocation stmtLocation stmt,
pointerValue to_deallocate,
memoryblock_set changes
[virtual]
 

Reimplemented from analysisProblem.

virtual void analysisProblem::at_dereference stmtLocation current,
operandNode operand,
pointerValue operand_value,
pointerValue result
[inline, virtual, inherited]
 

Reimplemented in precisionAnalyzer.

Definition at line 145 of file ipanalysis.h.

virtual void analysisProblem::at_field_access stmtLocation current,
operandNode operand,
pointerValue operand_value,
pointerValue result
[inline, virtual, inherited]
 

Reimplemented in precisionAnalyzer.

Definition at line 139 of file ipanalysis.h.

virtual void analysisProblem::at_id stmtLocation current,
idNode id,
pointerValue result
[inline, virtual, inherited]
 

Definition at line 96 of file ipanalysis.h.

virtual void livenessAnalyzer::at_index stmtLocation current,
operandNode operand,
pointerValue left,
pointerValue right,
pointerValue result
[virtual]
 

Reimplemented from analysisProblem.

virtual void livenessAnalyzer::at_merge Location where,
memoryBlock block,
memoryuse_list phi_uses,
pointerValue result,
memoryblock_set changes
[virtual]
 

Reimplemented from analysisProblem.

virtual void analysisProblem::at_parameter_pass Location current,
stmtLocation parameter_callsite,
pointerValue left,
pointerValue right,
memoryblock_set changes
[inline, virtual, inherited]
 

Definition at line 173 of file ipanalysis.h.

virtual void livenessAnalyzer::at_procedure_entry procLocation proc,
procedureInfo info,
pointerValue return_val
[virtual]
 

Reimplemented from analysisProblem.

virtual void livenessAnalyzer::at_procedure_exit procLocation proc,
procedureInfo info,
pointerValue return_val
[virtual]
 

Reimplemented from analysisProblem.

virtual void analysisProblem::at_return Location current,
pointerValue left,
pointerValue right,
memoryblock_set changes
[inline, virtual, inherited]
 

Definition at line 189 of file ipanalysis.h.

virtual void livenessAnalyzer::at_return stmtLocation stmt,
returnNode ret,
pointerValue result,
pointerValue return_val
[virtual]
 

virtual void analysisProblem::at_self_assignment Location source,
Location target,
memoryBlock block,
memoryblock_set changes,
bool  is_input
[inline, virtual, inherited]
 

Definition at line 180 of file ipanalysis.h.

virtual void analysisProblem::at_sizeof stmtLocation current,
threeAddrNode r,
pointerValue operand,
pointerValue result
[inline, virtual, inherited]
 

Definition at line 106 of file ipanalysis.h.

virtual void analysisProblem::at_stmt_entry stmtLocation stmt,
pointerValue result
[inline, virtual, inherited]
 

Definition at line 235 of file ipanalysis.h.

virtual void livenessAnalyzer::at_stmt_exit stmtLocation stmt,
pointerValue result
[virtual]
 

Reimplemented from analysisProblem.

virtual void livenessAnalyzer::at_threeAddr stmtLocation stmt,
threeAddrNode threeaddr,
pointerValue result
[virtual]
 

Reimplemented from analysisProblem.

virtual void analysisProblem::at_unary stmtLocation current,
threeAddrNode r,
pointerValue operand,
pointerValue result
[inline, virtual, inherited]
 

Definition at line 100 of file ipanalysis.h.

void livenessAnalyzer::clear  ) 
 

Reset liveness information.

Allow the liveness analyzer to be run again.

void livenessAnalyzer::collectDefs pointerValue pointer  )  [protected]
 

Collect defs.

virtual bool analysisProblem::compare_property_value Location where,
memoryBlock property_block,
procedureInfo callee
[inline, virtual, inherited]
 

Compare current property value against the last input to callee.

Returns true if equal.

Definition at line 275 of file ipanalysis.h.

bool livenessAnalyzer::determineLiveness  )  [protected]
 

Determine liveness.

Given the set of defs collected earlier, visit each def and each use that it reaches to see if any of them are live.

Direction analysisProblem::direction  )  const [inline, inherited]
 

Get the direction.

Definition at line 78 of file ipanalysis.h.

References analysisProblem::_direction.

bool livenessAnalyzer::isLive memoryUse use,
memoryBlock owner
[protected]
 

Look up liveness.

Look up the liveness of a memoryUse. This depends on the kind of location it comes from. As a special case, procLocations are always considered live.

bool livenessAnalyzer::isLive stmtNode stmt  ) 
 

Is a particular statement live.

This is the context insensitive query

virtual string livenessAnalyzer::name  )  [inline, virtual]
 

Name of the analysis.

Just for debug purposes.

Implements analysisProblem.

Definition at line 132 of file liveness.h.

virtual void analysisProblem::record_input_to_value procedureInfo callee,
memoryBlock property_block,
stmtLocation callsite
[inline, virtual, inherited]
 

Record the value of a property when it is used as an input_to/external_input value to a call to callee at a call site.

Definition at line 282 of file ipanalysis.h.

void livenessAnalyzer::setLive Location where,
memoryBlock block
[protected]
 

Set live for merge-points.

Record the given merge-point as live. Since all blocks share a single merge-point location, we need to distinguish which ones are live by the specific block being merged.

void livenessAnalyzer::setLive stmtLocation where  )  [protected]
 

Set live for statements.

Record the given statement location as live.

const procedure_set& livenessAnalyzer::visited_procedures  )  const [inline]
 

Definition at line 188 of file liveness.h.

References _visited_procedures.


Member Data Documentation

bool livenessAnalyzer::_change [private]
 

Record changes.

Definition at line 106 of file liveness.h.

change_stack livenessAnalyzer::_change_stack [private]
 

Change stack.

We need to record the state of the change boolean in procedures above the current one.

Definition at line 113 of file liveness.h.

memorydef_set livenessAnalyzer::_defs [private]
 

Collect defs.

This set is used on a per-statement basis to collect memoryDef objects. Once we have the set of defs, we can decide whether or not the current statement is live.

Definition at line 102 of file liveness.h.

Direction analysisProblem::_direction [protected, inherited]
 

Definition at line 64 of file ipanalysis.h.

Referenced by analysisProblem::direction().

mergepoint_liveness_set livenessAnalyzer::_live_mergepoints [private]
 

Live merge points.

This set records which merge points are live. A merge point is specified by the basic block in which it occurs, and the memoryBlock being merged.

Definition at line 94 of file liveness.h.

stmtlocation_liveness_set livenessAnalyzer::_live_stmtlocations [private]
 

Live statement locations.

Set of live statements. Note that some kinds of statements are automatically live (for example, the return statement and all if statements.

Definition at line 86 of file liveness.h.

stmt_liveness_set livenessAnalyzer::_live_stmts [private]
 

Live statements.

This set records which statements are live. It is really context-insensitive summary of the live statement locations.

Definition at line 78 of file liveness.h.

procedure_set livenessAnalyzer::_visited_procedures [private]
 

Set of visited procedures.

We record the visited procedures so that we don't remove dead code from uncalled procedures.

Definition at line 120 of file liveness.h.

Referenced by visited_procedures().


The documentation for this class was generated from the following file:

Generated on February 1, 2006
Back to the C-Breeze home page