procedureInfo Class ReferenceProcedure information.
More...
#include <proceduredb.h>
List of all members.
|
Public Types |
typedef map< basicblockNode *,
int > | worklist_order_map |
typedef worklist_order_map::iterator | worklist_order_map_p |
typedef map< stmtLocation *,
procedureInfo * > | callsite_map |
typedef callsite_map::iterator | callsite_map_p |
typedef callsite_map::const_iterator | callsite_map_cp |
typedef map< basicblockLocation *,
memoryblock_set > | mergepoint_map |
typedef mergepoint_map::iterator | mergepoint_map_p |
typedef map< stmtLocation *,
memoryblock_set > | callsite_changes_map |
typedef callsite_changes_map::iterator | callsite_changes_map_p |
typedef map< procedureInfo *,
int > | proc_int_map |
typedef proc_int_map::iterator | proc_int_map_p |
Public Member Functions |
DFPreds * | dominance_frontiers () const |
| Return the dominance frontiers.
|
| procedureInfo (procNode *the_proc) |
| Create a procedureInfo object for a procedure.
|
| ~procedureInfo () |
| Destroy a procedureInfo object.
|
void | add_one_ancestor (procedureInfo *ancestor) |
| Add one ancestor.
|
void | add_ancestor_set (procedureinfo_set &ancestors) |
| Add ancestor set.
|
void | setup_call_at (procedureInfo *caller, stmtLocation *callsite, bool is_recursive_call, bool multiple_target_call) |
| Call the procedure.
|
procNode * | proc () const |
| Return from the procedureGet the procedure.
|
string & | name () |
| Get the procedure name.
|
string | qualified_name () |
| Qualified name.
|
const procedureinfo_set & | ancestors () const |
| Set of ancestors.
|
const procedureinfo_set & | calls () const |
| Return the calls.
|
const callsite_map & | callsites () const |
| Return the set of callsites.
|
procedureInfo * | first_caller () const |
| Return the first caller.
|
bool | is_recursive () const |
| Is procedure recursive?
|
void | set_recursive () |
| Set recursive flag.
|
declNode * | return_variable () const |
| Return variable.
|
memoryBlock * | return_block () const |
| Return block.
|
void | return_block (memoryBlock *r) |
| Set return block.
|
returnNode * | return_stmt () const |
| Return statment.
|
bool | never_returns () const |
| Test never returns flag.
|
void | set_never_returns () |
| Set never returns flag.
|
void | set_pending_changes (stmtLocation *callsite, memoryblock_set &changes) |
| Set pending changes.
|
void | get_pending_changes (stmtLocation *callsite, memoryblock_set &changes) |
| Get pending changes.
|
procedureInfo * | caller_at (stmtLocation *callsite) |
| Return the current callsiteReturn the current callerReturn the caller.
|
bool | is_ancestor (procedureInfo *other) |
| Is ancestor?
|
procLocation * | procedure_location (stmtLocation *callsite) |
| Get the procedure location.
|
int | analysis_count () const |
| Get the analysis count.
|
void | incr_analysis_count () |
| Increment analysis count.
|
bool | is_verbose () const |
| Is verbose?
|
bool | is_library_routine () |
| Is library routine?
|
void | print (ostream &out) |
| Output.
|
void | stats (ostream &out) |
| Stats.
|
int | count_calling_contexts () |
| Count contexts.
|
int | procedure_size () |
| Procedure size.
|
void | start_self_timer () |
| Start the self timer.
|
void | stop_self_timer () |
| Stop the self timer.
|
double | self_timer () |
| Return the self time.
|
void | start_total_timer () |
| Start the total timer.
|
void | stop_total_timer () |
| Stop the total timer.
|
double | total_timer () |
| Return the total time.
|
void | update_cg_statistics_call (procedureInfo *callee) |
void | update_cg_statistics_return (procedureInfo *callee) |
void | get_cg_statistics (int &cg_depth_min, int &cg_depth_max, int &cg_height_min, int &cg_height_max) |
|
bool | is_context_insensitive () const |
| Is context-insensitive.
|
bool | prefer_context_sensitive () const |
| Do we prefer context sensitive?
|
void | set_prefer_context_sensitive () |
| Set context-sensitivity preference.
|
procLocation * | get_context () const |
| Get context-insensitive.
|
|
void | setup_merge_point (memoryBlock *block_to_merge, basicblockLocation *cur) |
| Set up merge points.
|
memoryblock_set * | lookup_merge_point (basicblockLocation *where) |
| Lookup a merge point.
|
void | check_merge_point (memoryBlock *block_to_merge, basicblockLocation *cur) |
| Check merge point.
|
|
Manage external inputs and outputs when working in context-insensitive mode.
|
const memoryblock_set & | external_inputs () const |
| Get external inputs.
|
const memoryblock_set & | external_outputs () const |
| Get external outputs.
|
bool | add_external_input (memoryBlock *block) |
| Add an external input.
|
bool | add_external_output (memoryBlock *block) |
| Add an external output.
|
void | record_input_to_value (memoryBlock *block, stmtLocation *loc, memoryblock_set points_to) |
| Record points-to set of input blocks to this procedure.
|
memoryblock_set | input_to_value (memoryBlock *block) const |
| Get recorded points-to set of input blocks to this procedure.
|
memoryblock_set | input_to_value (memoryBlock *block, stmtLocation *loc) const |
| Get recorded points-to set of input blocks to this procedure, for a particular site.
|
|
basicblockNode * | get_next_block (Direction dir) |
| Get the next block on the worklist.
|
void | add_block (basicblockNode *block, Direction dir) |
| Add a block to the worklist.
|
void | add_reachable_blocks (basicblockNode *block, Direction dir) |
| Add all reachable blocks to the worklist.
|
void | add_all_blocks () |
| Add all blocks.
|
void | add_start_block (Direction dir) |
| Add the start node.
|
bool | is_empty () const |
| Test for empty worklist.
|
void | remove_branch_blocks (basicblockNode *cond, basicblockNode *branch_taken, basicblockNode *branch_not_taken) |
| Remove branch.
|
void | update_conditional_worklist (basicblockNode *block, bool has_truth_value, bool which_branch) |
| Conditional worklist algorithm.
|
cfg_edge_set & | active_edges () |
| Active edges.
|
Private Types |
typedef pair< memoryBlock *,
stmtLocation * > | block_loc_pair |
typedef map< basicblockNode *,
basicblockNode * > | true_branch_map |
| True branches.
|
typedef true_branch_map::iterator | true_branch_map_p |
Private Member Functions |
int | count_calling_contexts_rec (proc_int_map &count, stmtNode *callsite) |
| Count contexts.
|
void | reverse_post_order (Direction dir, basicblockNode *cur, basicblock_set &visited, basicblock_list &order) |
| Compute a reverse post-ordering of the basic blocks.
|
void | dfs_dominators (Direction dir, basicblockNode *cur, basicblock_set &visited, basicblock_list &order, basicblock_list &rpo_order) |
| Alternative ordering.
|
int | block_position (basicblockNode *block, Direction dir) |
basicblockNode * | block_at (int position, Direction dir) |
void | add_reachable_blocks_rec (Direction dir, basicblockNode *cur, worklist_set &temp, bool first) |
Private Attributes |
procNode * | _proc |
| A pointer to the procedure definition.
|
workList | _worklist |
| The worklist of basic blocks.
|
worklist_order_map | _forward_worklist_order |
| The forward ordering of basic blocks in the worklist.
|
vector< basicblockNode * > | _forward_basicblock_order |
| The forward enumeration of basic blocks.
|
worklist_order_map | _backward_worklist_order |
| The backward ordering of basic blocks in the worklist.
|
vector< basicblockNode * > | _backward_basicblock_order |
| The backward enumeration of basic blocks.
|
mergepoint_map | _merge_points |
| Merge points.
|
DFPreds * | _dominance_frontiers |
| Dominance frontiers.
|
loopTree * | _loops |
| Loop tree.
|
callsite_map | _callsites |
| Call sites.
|
declNode * | _return_variable |
| Return value variable.
|
memoryBlock * | _return_block |
| Block for return value variable.
|
returnNode * | _return_stmt |
| Return statement.
|
bool | _never_returns |
| Never returns.
|
callsite_changes_map | _pending_changes |
| Pending changes.
|
bool | _context_insensitive |
| Current call siteContext insensitive.
|
bool | _prefer_context_sensitive |
| Prefer context sensitive.
|
TREE procLocation * | _only_context |
| Only context.
|
memoryblock_set | _external_inputs |
| External inputs.
|
memoryblock_set | _external_outputs |
| External outputs.
|
map< memoryBlock *, memoryblock_set > | _input_values |
| Points-to set of input blocks to this procedure.
|
map< block_loc_pair, memoryblock_set > | _input_site_values |
| Points-to set of input blocks to this procedure, for a particular callsite. Used by adaptor.
|
procedureinfo_set | _ancestors |
| Ancestors.
|
procedureinfo_set | _decestors |
| Ancestors.
|
procedureInfo * | _first_caller |
| First caller.
|
procedureinfo_set | _calls |
| Called procedures.
|
bool | _is_recursive |
| Called recursively.
|
basicblock_set | _blocks_to_skip |
| Blocks to skip.
|
cfg_edge_set | _active_edges |
| Active edges.
|
true_branch_map | _true_branches |
int | _analysis_count |
| Analysis count.
|
bool | _verbose |
| Verbose.
|
cbzTimer | _self_timer |
| Self timer.
|
cbzTimer | _total_timer |
| Total timer.
|
int | _cg_depth_min |
| Depth in call graph.
|
int | _cg_depth_max |
| Depth in call graph.
|
int | _cg_height_min |
| Height in call graph to a leaf.
|
int | _cg_height_max |
| Height in call graph to a leaf.
|
Detailed Description
Procedure information.
This class holds information about a single procedure definition, including:
_unit : the unit in which it is defined _worklist_order : the best ordering of its basic blocks for the worklist _dominance_frontiers : the precomputed dominance frontiers _callsites : the set of places this procedure is called
At the start of analysis, only the first two fields are filled. When a procedure is actually encountered during analysis, then the worklist order and dominance frontiers are computed.
Definition at line 76 of file proceduredb.h.
Member Typedef Documentation
|
True branches.
This sucks: keep a mapping from conditionals to the true branches. Apparently there is no convention in the dismantler/cfg.
Definition at line 327 of file proceduredb.h. |
Constructor & Destructor Documentation
procedureInfo::procedureInfo |
( |
procNode * |
the_proc |
) |
|
|
|
Create a procedureInfo object for a procedure.
This constructor creates a new instance, and precomputes the worklist orderings, and the dominance frontiers. |
procedureInfo::~procedureInfo |
( |
|
) |
|
|
|
Destroy a procedureInfo object.
|
Member Function Documentation
void procedureInfo::add_all_blocks |
( |
|
) |
|
|
|
Add all blocks.
Add all blocks in the procedure to the worklist |
|
Add ancestor set.
(Only called once by the procedureDB::build method). Add the list of ancestors. This list is used to force reanalysis to reach the procedure. |
|
Add a block to the worklist.
Add a block, fixing the position as necessary to point to the earliest block on the list. |
bool procedureInfo::add_external_input |
( |
memoryBlock * |
block |
) |
|
|
|
Add an external input.
This method is called by Pointers::record_external_inputs_and_outputs when it finds a use whose reaching definition is outside the current procedure. This method adds that variable as an external input.
Return true if the input wasn't already there. |
bool procedureInfo::add_external_output |
( |
memoryBlock * |
block |
) |
|
|
|
Add an external output.
This method is called by Pointers::record_external_inputs_and_outputs when it finds a def that could be accessed outside the current procedure. This method adds that variable as an extern output.
If the output is the result of a weak update, then we also add to the external inputs, and return whether or not this created a new input. |
void procedureInfo::add_one_ancestor |
( |
procedureInfo * |
ancestor |
) |
|
|
|
Add one ancestor.
Add one ancestor. This is called when new call edges are discovered during analysis (discovery of targets of function pointers). This procedure's decestors also get that ancestors set updated. |
|
Add all reachable blocks to the worklist.
Add all the blocks reachable from the given block, NOT including the block itself. |
void procedureInfo::add_start_block |
( |
Direction |
dir |
) |
|
|
|
Add the start node.
This is either the entry node (for forward analysis) or the exit node (for backward analysis). |
int procedureInfo::analysis_count |
( |
|
) |
const [inline] |
|
|
Return the current callsiteReturn the current callerReturn the caller.
Given a callsite, return the caller at that callsite. |
|
Return the calls.
Return the set of procedures that this one calls.
Definition at line 441 of file proceduredb.h.
References _calls. |
const callsite_map& procedureInfo::callsites |
( |
|
) |
const [inline] |
|
|
Check merge point.
This method is used only for debugging to make sure we aren't finding new things to merge. |
int procedureInfo::count_calling_contexts |
( |
|
) |
|
|
|
Count contexts.
Count the number of calling contexts for the given procedure. |
int procedureInfo::count_calling_contexts_rec |
( |
proc_int_map & |
count, |
|
|
stmtNode * |
callsite |
|
) |
[private] |
|
|
Count contexts.
Count the number of calling contexts for the given procedure. |
|
Alternative ordering.
Depth-first search of the dominator tree. |
DFPreds* procedureInfo::dominance_frontiers |
( |
|
) |
const [inline] |
|
void procedureInfo::get_cg_statistics |
( |
int & |
cg_depth_min, |
|
|
int & |
cg_depth_max, |
|
|
int & |
cg_height_min, |
|
|
int & |
cg_height_max |
|
) |
|
|
|
Get context-insensitive.
Return the context-insensitive callsite, or null if there is none.
Definition at line 573 of file proceduredb.h.
References _only_context. |
|
Get the next block on the worklist.
Return the next block on the worklist, and update the position. |
|
Get pending changes.
Check the current callsite to see if changes were left behind by a previous analysis in a different context. If so, get the changes now and merge them in. |
void procedureInfo::incr_analysis_count |
( |
|
) |
[inline] |
|
|
Is ancestor?
Return true if the given procedure is an ancestor in the call graph. |
bool procedureInfo::is_context_insensitive |
( |
|
) |
const [inline] |
|
bool procedureInfo::is_empty |
( |
|
) |
const |
|
|
Test for empty worklist.
Return true if the worklist is empty, which typically indicates that we are done analyzing this particular procedure. |
bool procedureInfo::is_library_routine |
( |
|
) |
[inline] |
|
bool procedureInfo::is_recursive |
( |
|
) |
const [inline] |
|
|
Is procedure recursive?
This boolean is set if the analyzer discovers that the procedure is part of a recursive cycle.
Definition at line 456 of file proceduredb.h.
References _is_recursive. |
bool procedureInfo::is_verbose |
( |
|
) |
const [inline] |
|
|
Lookup a merge point.
Given a particular basic block, see if there are any objects to be merged at its entry. |
string& procedureInfo::name |
( |
|
) |
[inline] |
|
bool procedureInfo::never_returns |
( |
|
) |
const [inline] |
|
|
Test never returns flag.
When true, it indicates that this procedure never returns, probably because it always calls exit() or abort().
Definition at line 496 of file proceduredb.h.
References _never_returns. |
bool procedureInfo::prefer_context_sensitive |
( |
|
) |
const [inline] |
|
void procedureInfo::print |
( |
ostream & |
out |
) |
|
|
procNode* procedureInfo::proc |
( |
|
) |
const [inline] |
|
|
Get the procedure location.
For a given callsite, return the corresponding procLocation of the called procedure. For context-insensitive procedures, we just return the one context. |
int procedureInfo::procedure_size |
( |
|
) |
|
|
|
Procedure size.
Count the number of statements in the dismantled form of the procedure. |
string procedureInfo::qualified_name |
( |
|
) |
|
|
|
Qualified name.
Includes either (I), (S), or (R) for context-insensitive, context-sensitive, or recursive. |
|
Remove branch.
This routine removes basic blocks that will not be visited when the direction of a branch can be determined. |
void procedureInfo::return_block |
( |
memoryBlock * |
r |
) |
[inline] |
|
memoryBlock* procedureInfo::return_block |
( |
|
) |
const [inline] |
|
returnNode* procedureInfo::return_stmt |
( |
|
) |
const [inline] |
|
declNode* procedureInfo::return_variable |
( |
|
) |
const [inline] |
|
|
Return variable.
For procedures with a return value this field holds the declaration of the special dismantler-created variable to hold that value. Such variables are flagged as return values in their declaration.
Definition at line 471 of file proceduredb.h.
References _return_variable. |
|
Compute a reverse post-ordering of the basic blocks.
This routine builds a reverse-post-order traversal of the control-flow graph. The direction argument is used to produce an ordering for the regular CFG as well as the reverse CFG (for backward analysis). |
double procedureInfo::self_timer |
( |
|
) |
[inline] |
|
void procedureInfo::set_never_returns |
( |
|
) |
[inline] |
|
|
Set never returns flag.
Setting this flag indicates that the procedure never returns. This is caused by a call to exit() or abort() that dominates the end of the procedure.
Definition at line 504 of file proceduredb.h.
References _never_returns. |
|
Set pending changes.
In context-sensitive analysis when we pass external outputs back to other callsites, we need to collect those changes so that the calling procedure will see them when it's analyzed. This routine stores that set of changes for the caller according to the callsite. |
void procedureInfo::set_prefer_context_sensitive |
( |
|
) |
[inline] |
|
void procedureInfo::set_recursive |
( |
|
) |
[inline] |
|
|
Set recursive flag.
Set by the analyzer when it discovers that the procedure is part of a recrusive cycle.
Definition at line 463 of file proceduredb.h.
References _is_recursive. |
void procedureInfo::setup_call_at |
( |
procedureInfo * |
caller, |
|
|
stmtLocation * |
callsite, |
|
|
bool |
is_recursive_call, |
|
|
bool |
multiple_target_call |
|
) |
|
|
|
Call the procedure.
Set up the procedure at the given callsite. This method performs many tasks, including making the procedure context-insensitive, if that's called for. |
|
Set up merge points.
When a memory block changes during pointer analysis, this method sets up merg points for the block in the dominance frontier of the procedure. |
void procedureInfo::start_self_timer |
( |
|
) |
[inline] |
|
void procedureInfo::start_total_timer |
( |
|
) |
[inline] |
|
void procedureInfo::stats |
( |
ostream & |
out |
) |
|
|
|
Stats.
Output a whole bunch of statistics about this procedure (particularly useful after analysis is complete). |
void procedureInfo::stop_self_timer |
( |
|
) |
[inline] |
|
void procedureInfo::stop_total_timer |
( |
|
) |
[inline] |
|
double procedureInfo::total_timer |
( |
|
) |
[inline] |
|
void procedureInfo::update_cg_statistics_call |
( |
procedureInfo * |
callee |
) |
|
|
void procedureInfo::update_cg_statistics_return |
( |
procedureInfo * |
callee |
) |
|
|
void procedureInfo::update_conditional_worklist |
( |
basicblockNode * |
block, |
|
|
bool |
has_truth_value, |
|
|
bool |
which_branch |
|
) |
|
|
|
Conditional worklist algorithm.
Process a conditional branch. |
Member Data Documentation
|
Ancestors.
Maintain a set of ancestors in the call graph. This makes searching the scope and updating the worklist faster.
Definition at line 287 of file proceduredb.h.
Referenced by ancestors(). |
|
The backward enumeration of basic blocks.
This maps basic blocks to bit positions in the worklist.
Definition at line 136 of file proceduredb.h. |
|
The backward ordering of basic blocks in the worklist.
We precompute this ordering to favor quick convergence of dataflow problems. It's just a depth-first ordering.
Definition at line 130 of file proceduredb.h. |
|
Blocks to skip.
In conditional mode, this tells us which blocks are currently being skipped because they are on branches that are not taken. We need this list in order to set up the merge points properly.
Definition at line 314 of file proceduredb.h. |
|
Called procedures.
The procedures directly called by this one.
Definition at line 300 of file proceduredb.h.
Referenced by calls(). |
|
Call sites.
This set holds all of the statements that are determined to be calls to this procedure. The map is from callsites to the procedure making the call (the context).
Definition at line 168 of file proceduredb.h.
Referenced by callsites(). |
|
Ancestors.
Maintain a set of ancestors in the call graph. This makes searching the scope and updating the worklist faster.
Definition at line 287 of file proceduredb.h. |
|
Dominance frontiers.
This is a special version of dominance frontiers. For each node X in the dominance frontier of some node Y, it also provide the particular immediate predecessor of Y that is dominated by X.
Definition at line 152 of file proceduredb.h.
Referenced by dominance_frontiers(). |
|
External inputs.
When a procedure is analyzed without context sensitivity, we need to record those objects that enter the procedure from outside. We can think of these objects as inputs to the procedure that are not represented in the parameter list (e.g, a global variable). Since each context could have a different reaching def, we need to merge together those reaching defs before entering the procedure. This works a bit like a merge-point.
Definition at line 260 of file proceduredb.h.
Referenced by external_inputs(). |
|
External outputs.
Like the external inputs, when we're using context insensitive mode, defs inside the procedure can reach outside the procedure. We can think of these objects as outputs from the procedure. In order to make sure that those defs reach the right uses, we create a def at the callsite with a use whose reaching definition is inside the procedure.
Definition at line 271 of file proceduredb.h.
Referenced by external_outputs(). |
|
First caller.
Creates a minimum spanning tree of the call graph. We use this to mark for reanalysis.
Definition at line 294 of file proceduredb.h.
Referenced by first_caller(). |
|
The forward enumeration of basic blocks.
This maps basic blocks to bit positions in the worklist.
Definition at line 123 of file proceduredb.h. |
|
The forward ordering of basic blocks in the worklist.
We precompute this ordering to favor quick convergence of dataflow problems. It's just a depth-first ordering.
Definition at line 117 of file proceduredb.h. |
|
Loop tree.
This object contains all the information we need about the loops in this procedure. In addition, it provides a classification of all edges in the control-flow graph.
Definition at line 160 of file proceduredb.h. |
|
Merge points.
These are the phi functions for this procedure. Note that since a procedure may be called in many different contexts, we need to separate the merge points out.
Definition at line 144 of file proceduredb.h. |
|
Never returns.
When this flag is set true it indicates that the given procedure never returns. This can happen if a procedure always calls exit(), for example. We'll use this information to prune the control-flow graph.
Definition at line 197 of file proceduredb.h.
Referenced by never_returns(), and set_never_returns(). |
|
Only context.
For context insensitive procedures, we build a separate location tree that holds all of the context insensitive uses and defs.
Note that since this location is removed from the location tree, this object actually owns it.
Definition at line 248 of file proceduredb.h.
Referenced by get_context(). |
|
Pending changes.
When this procedure calls a procedure that is context-insensitive, it is possible that other callsites will produce changes that are propagated here. For example:
foo() { bar(); } baz() { bar(); }
Assume bar() is context-insensitive. While analyzing bar() in the baz() context, we may need to propagate changes to the foo() callsite. The reason that this isn't a problem in the baz() context is that we actually pass the changes back to baz() as the external_changes set.
The solution is to store the changes produced by passing the external output in this map, and then pick them up when we actually revisit the context.
Definition at line 218 of file proceduredb.h. |
|
Block for return value variable.
Store the block for special return value variable so that we can easily get it when we need to retrieve the return value.
Definition at line 182 of file proceduredb.h.
Referenced by return_block(). |
|
Return statement.
Store a pointer to the return statement (there should only be one!)
Definition at line 188 of file proceduredb.h.
Referenced by return_stmt(). |
|
Return value variable.
Store the special return value variable so that we can easily get it when we need to retrieve the return value.
Definition at line 175 of file proceduredb.h.
Referenced by return_variable(). |
|
Verbose.
When true, turn on verbose output when we're analyzing this procedure.
Definition at line 343 of file proceduredb.h.
Referenced by is_verbose(). |
The documentation for this class was generated from the following file:
|