Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

Pointers Class Reference

Pointer analyzer. More...

#include <pointers.h>

List of all members.

Public Types

typedef set< string > string_set
typedef string_set::iterator string_set_p

Public Methods

 Pointers (procNode *root, unitNode *unit, bool debug=false)
 Constructor. More...

 ~Pointers ()
 Destructor. More...

void analyze ()
 Run the analyzer. More...

void analyze (analysisProblem *problem)
void reanalyze_at (procedureInfo *info, stmtLocation *callsite)
 Reanalyze a callsite. More...

void clear ()
 Clear pointer information after a program change. More...

void set_context_sensitivity_threshold (int threshold)
 Context-sensitivity. More...

void show_progress ()
 Turn on progress meter. More...

void hide_progress ()
 Turn off progress meter. More...

void analyze_procedure (procLocation *current, memoryblock_set &external_defs, memoryuse_set &external_uses, memoryblock_set &external_changes, pointerValue &return_val)
 Analyze one procedure. More...

virtual void procedure_call (procedureInfo *caller, stmtLocation *current, callNode *call, pointerValue &call_target, pointervalue_list &arguments, memoryblock_set &external_defs, memoryuse_set &external_uses, memoryblock_set &external_changes, pointerValue &return_val)
 Process a procedure call. More...

void pass_parameters (procedureInfo *info, procedureInfo *caller, procLocation *callee_path, procNode *callee, pointervalue_list &arguments, memoryblock_set &changed_inputs, pointerValue &return_val)
 Pass parameters. More...

void process_merge_point (procedureInfo *info, basicblockLocation *current_block, pointerValue &result, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes)
 Process a merge point. More...

void process_changes (procedureInfo *info, basicblockLocation *current_block, memoryblock_set &changes, memoryblock_set &external_changes)
 Process changes. More...

void pass_external_inputs (procedureInfo *info, memoryuse_set &external_uses, memoryblock_set &changed_inputs)
 Process external inputs. More...

void pass_external_outputs (procedureInfo *info, memoryblock_set &external_defs, memoryblock_set &external_changes)
 Process external outputs. More...

void record_external_inputs_and_outputs (procedureInfo *info, procLocation *current, memoryblock_set &defs, memoryblock_set &external_defs, memoryuse_set &uses, memoryuse_set &external_uses)
 Record external inputs and outputs. More...

void conservative_procedure_call (procedureInfo *info, stmtLocation *current, pointervalue_list &arguments, memoryblock_set &reachable, memoryblock_set &external_defs, memoryuse_set &external_uses, memoryblock_set &external_changes, pointerValue &return_val)
 Conservative procedure call. More...

void eval (procedureInfo *info, stmtLocation *current, exprNode *E, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes, pointerValue &result, bool result_is_a_use)
 Expression evaluator. More...

void star_operator (stmtLocation *current, pointerValue &operand, memoryuse_set &uses, pointerValue &result)
 Star "*" operator. More...

void dot_operator (stmtLocation *current, const string &field_name, declNode *field_decl, pointerValue &operand, memoryuse_set &uses, pointerValue &result)
 Dot "." operator. More...

void assignment_operator (procedureInfo *info, Location *current, pointerValue &left_hand_side, pointerValue &right_hand_side, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes, bool additive=false)
 Assignment "=" operator. More...

void merge_operator (procedureInfo *info, Location *current, memoryBlock *block_to_merge, memoryuse_list &phi_uses, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes)
 Process a control-flow merge. More...

void call_operator (procedureInfo *caller, stmtLocation *current, callNode *call, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes, pointerValue &result)
 Function call operator. More...

void determine_call_targets (procedureInfo *caller, stmtLocation *current, callNode *call, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes, pointerValue &targets)
void generate_uses (procedureInfo *info, Location *where, memoryuse_set &uses, pointerValue &pointer)
 Generate memoryUses. More...

memoryDef * nearest_def_at (procedureInfo *info, memoryBlock *block, Location *where)
 Reaching def. More...

void reachable_blocks (Location *where, memoryblock_list &worklist, memoryblock_set &already_seen)
 Reachable blocks. More...

memoryBlock * lookup_memoryblock (Location *location, declNode *decl)
 Lookup a memory block. More...

procedureInfo * lookup_procedure (procNode *proc)
 Lookup a procedure. More...

bool is_pointer_expression (exprNode *expr)
 Return true if the expression involves pointers. More...

void stats (ostream &out)
 Print some statistics. More...

void uses_and_defs ()
 Print all uses and defs. More...


Protected Methods

memoryBlock * lookup_heap_object (stmtLocation *current)
 Manage the heap. More...

memoryBlock * lookup_string_constant (stmtLocation *current, constant &value)
void setup_va_list_variables (procedureInfo *info, procLocation *callee_path, procNode *callee, memoryBlock *ellipsis, pointerValue &return_val)
 Var args. More...

void progress_meter (procedureInfo *info, bool skipped)
 Progress meter. More...


Static Protected Methods

bool is_allocation (pointerValue &call_targets)
bool is_deallocation (pointerValue &call_targets)
bool is_va_list (declNode *decl)
bool is_va_list (exprNode *expr)
bool is_va_start (pointerValue &call_targets)
bool is_va_end (pointerValue &call_targets)
void merge (const memoryblock_set &source, memoryblock_set &dest)
 Useful utilities. More...

void print_memoryblock_set (const string &label, const memoryblock_set &the_set, ostream &o)
void print_memoryblock_def_set (const string &label, const memoryblock_set &the_set, ostream &o)
void print_memorydef_set (const string &label, const memorydef_set &the_set, ostream &o)

Protected Attributes

memoryModel Memory
 Memory model. More...

heap_map HeapMap
 Heap index. More...

procNode * Root
 Analysis starting point. More...

procLocation * root_location
 Starting point in the location representation. More...

Linker linker
 Linker. More...

procedureDB Procedures
 Procedure database. More...

analysisProblem * Problem
 Use-defined analysis problem. More...

bool computePointers
 Analysis mode switch. More...

Direction _direction
 Analysis direction. More...

int _context_sensitivity_threshold
 Context-sensitivity threshold. More...

bool _debug
 Control debugging output. More...

int _procedureCount
 Progress counter. More...

int _skipCount
 Number of procedures skipped. More...

bool _show_progress
 Show progress counter. More...

string_set _unknown_procedures
 Unknown procedures. More...


Detailed Description

Pointer analyzer.

This class is the main pointer analyzer engine.


Member Typedef Documentation

typedef set< string > Pointers::string_set
 

typedef string_set::iterator Pointers::string_set_p
 


Constructor & Destructor Documentation

Pointers::Pointers (  procNode *    root,
unitNode *    unit,
bool    debug = false
) 
 

Constructor.

Pointers::~Pointers (    ) 
 

Destructor.


Member Function Documentation

void Pointers::analyze (  analysisProblem *    problem ) 
 

void Pointers::analyze (    ) 
 

Run the analyzer.

void Pointers::analyze_procedure (  procLocation *    current,
memoryblock_set &    external_defs,
memoryuse_set &    external_uses,
memoryblock_set &    external_changes,
pointerValue &    return_val
) 
 

Analyze one procedure.

void Pointers::assignment_operator (  procedureInfo *    info,
Location *    current,
pointerValue &    left_hand_side,
pointerValue &    right_hand_side,
memoryblock_set &    defs,
memoryuse_set &    uses,
memoryblock_set &    changes,
bool    additive = false
) 
 

Assignment "=" operator.

When the additive flag is set, the assignment will include the previous value of the pointer at this location. This allows us to say things like "p = &x and p = &y" without having to build a single pointerValue that contains both x and y.

void Pointers::call_operator (  procedureInfo *    caller,
stmtLocation *    current,
callNode *    call,
memoryblock_set &    defs,
memoryuse_set &    uses,
memoryblock_set &    changes,
pointerValue &    result
) 
 

Function call operator.

void Pointers::clear (    ) 
 

Clear pointer information after a program change.

void Pointers::conservative_procedure_call (  procedureInfo *    info,
stmtLocation *    current,
pointervalue_list &    arguments,
memoryblock_set &    reachable,
memoryblock_set &    external_defs,
memoryuse_set &    external_uses,
memoryblock_set &    external_changes,
pointerValue &    return_val
) 
 

Conservative procedure call.

This function is called when we encounter a procedure with no source code. It conservatively creates uses and defs for all blocks reachable from the input arguments.

void Pointers::determine_call_targets (  procedureInfo *    caller,
stmtLocation *    current,
callNode *    call,
memoryblock_set &    defs,
memoryuse_set &    uses,
memoryblock_set &    changes,
pointerValue &    call_targets
) 
 

void Pointers::dot_operator (  stmtLocation *    current,
const string &    field_name,
declNode *    field_decl,
pointerValue &    operand,
memoryuse_set &    uses,
pointerValue &    result
) 
 

Dot "." operator.

void Pointers::eval (  procedureInfo *    info,
stmtLocation *    current,
exprNode *    E,
memoryblock_set &    defs,
memoryuse_set &    uses,
memoryblock_set &    changes,
pointerValue &    result,
bool    result_is_a_use
) 
 

Expression evaluator.

void Pointers::generate_uses (  procedureInfo *    info,
Location *    where,
memoryuse_set &    uses,
pointerValue &    pointer
) 
 

Generate memoryUses.

For each block in the set, generate a use at the given location. This also sets the "current_use" field on each memoryBlock, so that it can be accessed during other computations.

void Pointers::hide_progress (    )  [inline]
 

Turn off progress meter.

bool Pointers::is_allocation (  pointerValue &    call_targets )  [static, protected]
 

bool Pointers::is_deallocation (  pointerValue &    call_targets )  [static, protected]
 

bool Pointers::is_pointer_expression (  exprNode *    expr ) 
 

Return true if the expression involves pointers.

bool Pointers::is_va_end (  pointerValue &    call_targets )  [static, protected]
 

bool Pointers::is_va_list (  exprNode *    expr )  [static, protected]
 

bool Pointers::is_va_list (  declNode *    decl )  [static, protected]
 

bool Pointers::is_va_start (  pointerValue &    call_targets )  [static, protected]
 

memoryBlock * Pointers::lookup_heap_object (  stmtLocation *    current )  [protected]
 

Manage the heap.

memoryBlock * Pointers::lookup_memoryblock (  Location *    location,
declNode *    decl
) 
 

Lookup a memory block.

procedureInfo * Pointers::lookup_procedure (  procNode *    proc ) 
 

Lookup a procedure.

memoryBlock * Pointers::lookup_string_constant (  stmtLocation *    current,
constant &    value
)  [protected]
 

void Pointers::merge (  const memoryblock_set &    source,
memoryblock_set &    dest
)  [static, protected]
 

Useful utilities.

void Pointers::merge_operator (  procedureInfo *    info,
Location *    merge_point,
memoryBlock *    block_to_merge,
memoryuse_list &    phi_uses,
memoryblock_set &    defs,
memoryuse_set &    uses,
memoryblock_set &    changes
) 
 

Process a control-flow merge.

memoryDef * Pointers::nearest_def_at (  procedureInfo *    info,
memoryBlock *    block,
Location *    where
) 
 

Reaching def.

This is a special version of "nearest dominating def" that works across context insensitive boundaries. It handles the case where we discover an "input" to the current context that wasn't in previous analyses of the procedure.

It should only be called when memoryBlock::nearest_def_at() fails.

void Pointers::pass_external_inputs (  procedureInfo *    info,
memoryuse_set &    external_uses,
memoryblock_set &    changed_inputs
) 
 

Process external inputs.

In context insensitive mode, this method visits all the external inputs from the given procedure. For each one, it merges together the reaching defs from all the calling contexts, and produces a single def that reaches the uses inside the procedure.

Each use is attached to the special procLocation at that calling context. The merged def itself is attach to basic block zero in the actual procedure.

Record any inputs that change so that we can decide whether to skip analyzing the procedure.

void Pointers::pass_external_outputs (  procedureInfo *    info,
memoryblock_set &    external_defs,
memoryblock_set &    external_changes
) 
 

Process external outputs.

In context insensitive mode, this method visits all the external outputs from the given procedure. For each one, it propagates the last value to all the call sites. It does this by creating a use at the callsite that is reached by the last def inside the procedure. This use is then assigned to a def at that location. That way, the def will contain the right value, and dominate any uses of the object that follow.

void Pointers::pass_parameters (  procedureInfo *    info,
procedureInfo *    caller,
procLocation *    callee_path,
procNode *    callee,
pointervalue_list &    arguments,
memoryblock_set &    changed_inputs,
pointerValue &    return_val
) 
 

Pass parameters.

void Pointers::print_memoryblock_def_set (  const string &    label,
const memoryblock_set &    the_set,
ostream &    o
)  [static, protected]
 

void Pointers::print_memoryblock_set (  const string &    label,
const memoryblock_set &    the_set,
ostream &    o
)  [static, protected]
 

void Pointers::print_memorydef_set (  const string &    label,
const memorydef_set &    the_set,
ostream &    o
)  [static, protected]
 

void Pointers::procedure_call (  procedureInfo *    caller,
stmtLocation *    current,
callNode *    call,
pointerValue &    call_target,
pointervalue_list &    arguments,
memoryblock_set &    external_defs,
memoryuse_set &    external_uses,
memoryblock_set &    external_changes,
pointerValue &    return_val
)  [virtual]
 

Process a procedure call.

void Pointers::process_changes (  procedureInfo *    info,
basicblockLocation *    current_block,
memoryblock_set &    changes,
memoryblock_set &    external_changes
) 
 

Process changes.

After analyzing a particular basic block, we process the blocks that have changed by inserting merge-points for those blocks. In addition, for blocks that are accessible outside this procedure, we pass the changes back up to the caller.

void Pointers::process_merge_point (  procedureInfo *    info,
basicblockLocation *    current_block,
pointerValue &    result,
memoryblock_set &    defs,
memoryuse_set &    uses,
memoryblock_set &    changes
) 
 

Process a merge point.

void Pointers::progress_meter (  procedureInfo *    info,
bool    skipped
)  [protected]
 

Progress meter.

void Pointers::reachable_blocks (  Location *    where,
memoryblock_list &    worklist,
memoryblock_set &    already_seen
) 
 

Reachable blocks.

Given a set of memoryBlocks, compute the set of all blocks reachable by following pointer or structure-field relationships.

void Pointers::reanalyze_at (  procedureInfo *    info,
stmtLocation *    callsite
) 
 

Reanalyze a callsite.

void Pointers::record_external_inputs_and_outputs (  procedureInfo *    info,
procLocation *    current,
memoryblock_set &    defs,
memoryblock_set &    external_defs,
memoryuse_set &    uses,
memoryuse_set &    external_uses
) 
 

Record external inputs and outputs.

After a procedure has been analyzed, go through the uses and defs and determine which are external. That is, which uses are reached by defs outside the procedure, and which defs could reach uses outside the procedure.

void Pointers::set_context_sensitivity_threshold (  int    threshold ) 
 

Context-sensitivity.

Set the threshold for context-sensitivity. Measured in the number of new defs created in a procedure, when the threshold is exceeded the procedure becomes context-insensitive. Pass -1 to turn this feature off completely.

void Pointers::setup_va_list_variables (  procedureInfo *    info,
procLocation *    callee_path,
procNode *    callee,
memoryBlock *    ellipsis,
pointerValue &    return_val
)  [protected]
 

Var args.

void Pointers::show_progress (    )  [inline]
 

Turn on progress meter.

void Pointers::star_operator (  stmtLocation *    current,
pointerValue &    operand,
memoryuse_set &    uses,
pointerValue &    result
) 
 

Star "*" operator.

void Pointers::stats (  ostream &    out ) 
 

Print some statistics.

void Pointers::uses_and_defs (    ) 
 

Print all uses and defs.


Member Data Documentation

int Pointers::_context_sensitivity_threshold [protected]
 

Context-sensitivity threshold.

This value indicates how many defs we will tolerate during the analysis of a particular function before marking it as "context insensitive". A value of -1 turns off this feature.

bool Pointers::_debug [protected]
 

Control debugging output.

Direction Pointers::_direction [protected]
 

Analysis direction.

During pointer analysis, this is always set to "Forward". Otherwise, it is determined by the corresponding value on the analysisProblem object.

int Pointers::_procedureCount [protected]
 

Progress counter.

bool Pointers::_show_progress [protected]
 

Show progress counter.

int Pointers::_skipCount [protected]
 

Number of procedures skipped.

string_set Pointers::_unknown_procedures [protected]
 

Unknown procedures.

bool Pointers::computePointers [protected]
 

Analysis mode switch.

This boolean is true during pointer analysis, which allows new defs and uses to be created. Once complete, the boolean is set false so that other analyses can call pointer methods without changing the dependence information.

heap_map Pointers::HeapMap [protected]
 

Heap index.

Our pointer analysis keeps one heap object for each allocation site. This object maintains the mapping from allocation sites to heap objects in the memory model.

Linker Pointers::linker [protected]
 

Linker.

The linker object is used to connect external declaration across translation units. We need this, for example, so that accesses to a global variable in different source files are properly connected.

memoryModel Pointers::Memory [protected]
 

Memory model.

This object holds all of the memoryBlocks, and is responsible for their creation, indexing and deletion.

analysisProblem* Pointers::Problem [protected]
 

Use-defined analysis problem.

procedureDB Pointers::Procedures [protected]
 

Procedure database.

This object holds per-procedure information used during analysis. In particular, each entry holds the worklist for that procedure.

procNode* Pointers::Root [protected]
 

Analysis starting point.

procLocation* Pointers::root_location [protected]
 

Starting point in the location representation.


The documentation for this class was generated from the following files:
Generated on Thu Jan 10 12:06:31 2002 for C-Breeze by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001