Pointers Class ReferencePointer analyzer.
More...
#include <pointers.h>
List of all members.
|
Public Types |
typedef set< string > | string_set |
typedef string_set::iterator | string_set_p |
typedef pair< int, double > | count_accuracy_pair |
typedef map< stmtLocation *,
count_accuracy_pair > | accuracy_map |
typedef accuracy_map::iterator | accuracy_map_p |
Public Member Functions |
| Pointers (procNode *root, Linker &l, unitNode *unit) |
| Constructor.
|
virtual | ~Pointers () |
| Destructor.
|
Linker & | getLinker () const |
virtual void | run_unification () |
| Create and run unification, if in unification mode.
|
UnificationBasedPtr * | unification_analyzer () const |
| Get the unification analyzer.
|
void | use_unification_analyzer (UnificationBasedPtr *u) |
void | analyze () |
| Run the analyzer.
|
void | analyze (analysisProblem *problem) |
virtual void | initialize () |
| Initialize.
|
constantAnalyzer & | get_constants () |
| Constants.
|
void | clear () |
| Clear pointer information after a program change.
|
void | show_progress () |
| Turn on progress meter.
|
void | hide_progress () |
| Turn off progress meter.
|
void | turn_on_multiplicity () |
| Turn on multiplicity analysis.
|
void | turn_off_multiplicity () |
| Turn off multiplicity analysis.
|
void | analyze_procedure (procLocation *current, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes) |
| Analyze one procedure.
|
virtual void | procedure_call (procedureInfo *caller, stmtLocation *current, operandNode *call, operand_list &args, pointerValue &call_target, memoryBlock *target_mb, pointervalue_list &arguments, memoryblock_set &external_defs, memoryuse_set &external_uses, memoryblock_set &external_changes, pointerValue &return_val, bool &never_returns) |
| Process a procedure call.
|
void | analyze_procedure_at (procedureInfo *callee, stmtLocation *callsite, pointervalue_list &arguments, memoryblock_set &external_defs, memoryuse_set &external_uses, memoryblock_set &external_changes, pointerValue &return_val) |
| Analyze a procedure at a call.
|
void | pass_parameters (procedureInfo *info, stmtLocation *callsite, pointervalue_list &arguments, memoryblock_set ¶meters, memoryblock_set &changed_inputs) |
| Pass parameters.
|
void | pass_return_value (procedureInfo *info, stmtLocation *current_callsite, pointerValue &return_val, memoryblock_set &changes) |
| Pass return value.
|
void | process_merge_point (procedureInfo *info, basicblockLocation *current_block, pointerValue &result, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes) |
| Process a merge point.
|
void | process_local_changes (procedureInfo *info, basicblockLocation *current_block, memoryblock_set &local_changes, memoryblock_set &changes) |
| Process local changes.
|
void | pass_external_inputs (procedureInfo *info, stmtLocation *current_callsite, memoryuse_set &external_uses, memoryblock_set &changed_inputs) |
| Process external inputs.
|
void | pass_one_external_input (procedureInfo *callee, procedureInfo *caller, stmtLocation *current_callsite, memoryBlock *block_to_pass, memoryblock_set &changed_inputs) |
| Pass one external input.
|
void | pass_external_outputs (procedureInfo *info, stmtLocation *current_callsite) |
| Process external outputs.
|
void | pass_one_external_output (procedureInfo *info, stmtLocation *current_callsite, memoryBlock *block_to_pass, bool is_return_val) |
| Pass one external output.
|
void | record_external_inputs_and_outputs (procedureInfo *callee, procLocation *current, pointervalue_list &arguments, memoryblock_set ¶meters, memoryblock_set &defs, memoryblock_set &external_defs, memoryuse_set &uses, memoryuse_set &external_uses, memoryblock_set &changes, memoryblock_set &external_changes) |
| Record external inputs and outputs.
|
virtual 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.
|
void | eval (procedureInfo *info, stmtLocation *current, exprNode *E, stmtNode *cur_stmt, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes, pointerValue &result, bool &never_returns) |
| Expression evaluator.
|
void | eval (procedureInfo *info, stmtLocation *current, threeAddrNode *threeAddr, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes, pointerValue &result, bool &never_returns) |
void | star_operator (procedureInfo *info, Location *current, pointerValue &operand, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes, pointerValue &result) |
| Star "*" operator.
|
void | dot_operator (Location *current, const string &field_name, declNode *field_decl, pointerValue &operand, memoryuse_set &uses, pointerValue &result) |
| Dot "." operator.
|
void | struct_union_assignment (procedureInfo *info, stmtLocation *current, threeAddrNode *threeaddr, sueNode *suetype, pointerValue &left_hand_side, pointerValue &right_hand_side, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes) |
| Struct/union assignment.
|
virtual void | assignment_operator (procedureInfo *info, Location *current, stmtLocation *parameter_callsite, pointerValue &left_hand_side, pointerValue &right_hand_side, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes) |
| Assignment "=" operator.
|
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.
|
void | self_assignment (Location *from, Location *to, memoryBlock *block, memoryblock_set &changes) |
| Self-assignment.
|
void | call_operator (procedureInfo *caller, stmtLocation *current, operandNode *call, operand_list &args, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes, pointerValue &result, pointerValue &call_targets, bool &never_returns) |
| Function call operator.
|
void | determine_call_targets (procedureInfo *caller, stmtLocation *current, operandNode *call, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes, pointerValue &targets) |
| Determine call targets.
|
void | generate_uses (procedureInfo *info, Location *where, memoryuse_set &uses, pointerValue &pointer) |
| Generate memoryUses.
|
memoryDef * | nearest_def_at (procedureInfo *info, memoryBlock *block, Location *where) |
| Reaching def.
|
void | reachable_blocks (Location *where, memoryblock_list &worklist, memoryblock_set &already_seen) |
| Reachable blocks.
|
procedureInfo * | lookup_procedure (procNode *proc) |
| Lookup a procedure.
|
bool | is_pointer_expression (operandNode *operand) |
| Return true if the expression involves pointers.
|
void | stats (ostream &out) |
| Print some statistics.
|
void | uses_and_defs () |
| Print all uses and defs.
|
void | show_accuracy () |
| Compute accuracy.
|
void | progress_meter (procedureInfo *info, bool skipped) |
| Progress meter.
|
double | compute_accuracy (accuracy_map &accuracy_data) |
| Compute accuracy.
|
proc_info_map | procedures () const |
| Return all the procedures.
|
Static Public Member Functions |
static void | merge (const memoryblock_set &source, memoryblock_set &dest) |
| Useful utilities.
|
static void | print_memoryblock_set (const string &label, const memoryblock_set &the_set, ostream &o) |
static void | print_memoryblock_def_set (const string &label, const memoryblock_set &the_set, ostream &o) |
static void | print_memorydef_set (const string &label, const memorydef_set &the_set, ostream &o) |
Static Public Attributes |
static long int | call_counter |
| Counter for call invocations.
|
Protected Member Functions |
memoryBlock * | at_allocation (const string &name, procedureInfo *info, stmtLocation *current, stmtNode *allocation_stmt, declNode *decl, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes, pointerValue &result) |
| At allocation site.
|
void | at_deallocation (procedureInfo *info, Location *current, pointerValue &to_deallocate, memoryblock_set &defs, memoryuse_set &uses, memoryblock_set &changes) |
| At deallocation site.
|
Multiplicity | current_multiplicity (procedureInfo *info, Location *current, memoryBlock *block, memoryuse_set &uses) |
| Current multiplicity.
|
void | mark_as_indexed (memoryblock_set &blocks) |
| Mark as indexed.
|
void | setup_va_list_variables (procedureInfo *info, procLocation *callee_path, stmtLocation *parameter_callsite, procNode *callee, memoryBlock *ellipsis) |
| Var args.
|
Static Protected Member Functions |
static bool | is_allocation (pointerValue &call_targets) |
static bool | is_deallocation (pointerValue &call_targets) |
static bool | is_reallocation (pointerValue &call_targets) |
static bool | is_va_list (declNode *decl) |
static bool | is_va_list (exprNode *expr) |
static bool | is_va_arg (pointerValue &call_targets) |
static bool | is_va_start (pointerValue &call_targets) |
static bool | is_va_end (pointerValue &call_targets) |
static bool | is_exit (pointerValue &call_targets) |
| Exit procedures.
|
Protected Attributes |
memoryModel | Memory |
| Memory model.
|
heap_map | HeapMap |
| Heap decl map.
|
procNode * | Root |
| Analysis starting point.
|
procLocation * | root_location |
| Starting point in the location representation.
|
Linker & | linker |
| Linker.
|
procedureDB | Procedures |
| Procedure database.
|
constantAnalyzer | _constants |
| Constants.
|
analysisProblem * | Problem |
| Use-defined analysis problem.
|
bool | computePointers |
| Analysis mode switch.
|
Direction | _direction |
| Analysis direction.
|
int | _procedureCount |
| Progress counter.
|
int | _skipCount |
| Number of procedures skipped.
|
bool | _show_progress |
| Show progress counter.
|
bool | _use_multiplicity |
| Use multiplicity analysis.
|
string_set | _unknown_procedures |
| Unknown procedures.
|
accuracy_map | _def_accuracy |
| Accuracy at defs.
|
accuracy_map | _star_accuracy |
| Accuracy at star.
|
UnificationBasedPtr * | _unification_based |
| Unification-based analyzer.
|
Detailed Description
Pointer analyzer.
This class is the main pointer analyzer engine.
Definition at line 62 of file pointers.h.
Member Typedef Documentation
Constructor & Destructor Documentation
virtual Pointers::~Pointers |
( |
|
) |
[virtual] |
|
Member Function Documentation
void Pointers::analyze |
( |
|
) |
|
|
|
Analyze a procedure at a call.
This method provides the interface between procedure_call() and analyze(). It handles all of the parameter passing, as well as context sensitivity. |
|
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. |
|
At allocation site.
Process a memory allocation. This method performs two important tasks: (1) it creates a representation of the heap object, and (2) it manages the multiplicity analysis. Allocation is considered a def of the newly allocated space. |
|
At deallocation site.
Process a deallocation. The main job of this method is to handle the multiplicity analysis. Deallocation bumps the multiplicity down for objects that are in the Single state. |
|
Function call operator.
Evaluate the actual parameters, determine the call target and then call procedure_call(). |
|
Clear pointer information after a program change.
|
double Pointers::compute_accuracy |
( |
accuracy_map & |
accuracy_data |
) |
|
|
|
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. |
|
Current multiplicity.
Get the allocation object for the given memoryBlock and use it to determine the current multiplicity value. |
|
Determine call targets.
Evaluate the callNode subexpression that indicates which procedure we're calling. In most cases, this is just a single identifier. However, for calls through a function pointer, we need to evaluate the pointer expression to determine the target or targets. |
|
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. |
|
Constants.
Return a reference to the constant propagation information. Be careful with this!
Definition at line 219 of file pointers.h.
References _constants. |
Linker& Pointers::getLinker |
( |
|
) |
const [inline] |
|
void Pointers::hide_progress |
( |
|
) |
[inline] |
|
virtual void Pointers::initialize |
( |
|
) |
[inline, virtual] |
|
|
Initialize.
Override this method in subclasses to do some initialization. The Broadway analyzer needs this to initialize some of the analyses.
Definition at line 212 of file pointers.h. |
static bool Pointers::is_allocation |
( |
pointerValue & |
call_targets |
) |
[static, protected] |
|
static bool Pointers::is_deallocation |
( |
pointerValue & |
call_targets |
) |
[static, protected] |
|
static bool Pointers::is_exit |
( |
pointerValue & |
call_targets |
) |
[static, protected] |
|
|
Exit procedures.
Return true if the given call if to one of the system calls that never returns, such as exit() or abort(). |
bool Pointers::is_pointer_expression |
( |
operandNode * |
operand |
) |
|
|
|
Return true if the expression involves pointers.
|
static bool Pointers::is_reallocation |
( |
pointerValue & |
call_targets |
) |
[static, protected] |
|
static bool Pointers::is_va_arg |
( |
pointerValue & |
call_targets |
) |
[static, protected] |
|
static bool Pointers::is_va_end |
( |
pointerValue & |
call_targets |
) |
[static, protected] |
|
static bool Pointers::is_va_list |
( |
exprNode * |
expr |
) |
[static, protected] |
|
static bool Pointers::is_va_list |
( |
declNode * |
decl |
) |
[static, protected] |
|
static bool Pointers::is_va_start |
( |
pointerValue & |
call_targets |
) |
[static, protected] |
|
|
Mark as indexed.
Mark all of the given objects as indexed, meaning that they conceptually represent many objects (as in an array). This is necessary when we discover that an object is being treated like an array (for example, the index operator is applied, or pointer arithmetic is used to access it). |
|
Process a control-flow merge.
|
|
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. |
|
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. |
|
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. |
|
Pass one external input.
This method is used right before entering a procedure to make sure that external inputs are fresh, and also during analysis when we discover a new external input during the Pointers::nearest_def_at() method. |
|
Pass one external output.
Called by the above routine and by the pass_return_value() routine. It propagates the last value of the given memoryBlock from the callee procedure back to all of the places it's called. It does this by creating a use at the last statement of the procedure that holds the last reaching def in the procedure. It then assigns this use to a def at each target callsite. That way, the def will contain the right value, and dominate any uses of the object that follow. If any changes occur, they are stored in the pending_changes set of the caller. |
static void Pointers::print_memoryblock_def_set |
( |
const string & |
label, |
|
|
const memoryblock_set & |
the_set, |
|
|
ostream & |
o |
|
) |
[static] |
|
static void Pointers::print_memoryblock_set |
( |
const string & |
label, |
|
|
const memoryblock_set & |
the_set, |
|
|
ostream & |
o |
|
) |
[static] |
|
static void Pointers::print_memorydef_set |
( |
const string & |
label, |
|
|
const memorydef_set & |
the_set, |
|
|
ostream & |
o |
|
) |
[static] |
|
virtual void Pointers::procedure_call |
( |
procedureInfo * |
caller, |
|
|
stmtLocation * |
current, |
|
|
operandNode * |
call, |
|
|
operand_list & |
args, |
|
|
pointerValue & |
call_target, |
|
|
memoryBlock * |
target_mb, |
|
|
pointervalue_list & |
arguments, |
|
|
memoryblock_set & |
external_defs, |
|
|
memoryuse_set & |
external_uses, |
|
|
memoryblock_set & |
external_changes, |
|
|
pointerValue & |
return_val, |
|
|
bool & |
never_returns |
|
) |
[virtual] |
|
|
Process a procedure call.
|
|
Process local changes.
After analyzing a particular basic block, we process the blocks that have changed by inserting merge-points for those blocks. |
void Pointers::progress_meter |
( |
procedureInfo * |
info, |
|
|
bool |
skipped |
|
) |
|
|
|
Reachable blocks.
Given a set of memoryBlocks, compute the set of all blocks reachable by following pointer or structure-field relationships. |
|
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. |
virtual void Pointers::run_unification |
( |
|
) |
[virtual] |
|
|
Create and run unification, if in unification mode.
|
|
Self-assignment.
This method is used to pass an external input or output. It works like a hybrid of the assignment operator and the merge operator, except that it allows the use to be at a different location from the def. |
void Pointers::show_accuracy |
( |
|
) |
|
|
void Pointers::show_progress |
( |
|
) |
[inline] |
|
void Pointers::stats |
( |
ostream & |
out |
) |
|
|
|
Struct/union assignment.
Direct assignments between structs and unions are allowed, so here we recursively descend through the fields assigning them in a pairwise fashion. NOTE: Here we are relying on having the correct types. |
void Pointers::turn_off_multiplicity |
( |
|
) |
[inline] |
|
void Pointers::turn_on_multiplicity |
( |
|
) |
[inline] |
|
void Pointers::uses_and_defs |
( |
|
) |
|
|
Member Data Documentation
|
Constants.
Constant propagation is now built in. The most significant aspect of this change is that memoryDef and pointerValue contain an explicit pointer for holding the constant value.
Definition at line 122 of file pointers.h.
Referenced by get_constants(). |
|
Accuracy at defs.
Store the size of the points-to set at each def.
Definition at line 169 of file pointers.h. |
|
Analysis direction.
During pointer analysis, this is always set to "Forward". Otherwise, it is determined by the corresponding value on the analysisProblem object.
Definition at line 143 of file pointers.h. |
|
Number of procedures skipped.
Definition at line 151 of file pointers.h. |
|
Accuracy at star.
Store the size of the points-to set at every star operator.
Definition at line 175 of file pointers.h. |
|
Counter for call invocations.
Definition at line 690 of file pointers.h. |
|
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.
Definition at line 135 of file pointers.h. |
|
Heap decl map.
Our pointer analysis keeps one heap object for each allocation site. This field maintains the mapping from allocation sites to synthetic declarations for those heap objects.
Definition at line 88 of file pointers.h. |
|
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.
NOTE: the adaptive algorithm needs the linker to be the same for all iterations, that way the synthetic declNodes stay the same.
Definition at line 107 of file pointers.h.
Referenced by getLinker(). |
|
Memory model.
This object holds all of the memoryBlocks, and is responsible for their creation, indexing and deletion.
Definition at line 80 of file pointers.h.
Referenced by use_unification_analyzer(). |
|
Use-defined analysis problem.
Definition at line 126 of file pointers.h. |
|
Procedure database.
This object holds per-procedure information used during analysis. In particular, each entry holds the worklist for that procedure.
Definition at line 114 of file pointers.h.
Referenced by procedures(). |
|
Analysis starting point.
Definition at line 92 of file pointers.h. |
|
Starting point in the location representation.
Definition at line 96 of file pointers.h. |
The documentation for this class was generated from the following file:
|