Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages
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_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 procedure Get 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.
|
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 callsite Return the current caller Return 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.
|
|
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.
|
|
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 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.
|
returnNode * | _return_stmt |
| Return statement.
|
bool | _never_returns |
| Never returns.
|
callsite_changes_map | _pending_changes |
| Pending changes.
|
bool | _context_insensitive |
| Current call site Context 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.
|
procedureinfo_set | _ancestors |
| 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.
|
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
typedef callsite_changes_map::iterator procedureInfo::callsite_changes_map_p
|
|
typedef map< stmtLocation *, procedureInfo *> procedureInfo::callsite_map
|
|
typedef callsite_map::const_iterator procedureInfo::callsite_map_cp
|
|
typedef callsite_map::iterator procedureInfo::callsite_map_p
|
|
typedef mergepoint_map::iterator procedureInfo::mergepoint_map_p
|
|
typedef map< procedureInfo *, int > procedureInfo::proc_int_map
|
|
typedef proc_int_map::iterator procedureInfo::proc_int_map_p
|
|
|
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 311 of file proceduredb.h. |
typedef true_branch_map::iterator procedureInfo::true_branch_map_p [private]
|
|
typedef map< basicblockNode *, int > procedureInfo::worklist_order_map
|
|
typedef worklist_order_map::iterator procedureInfo::worklist_order_map_p
|
|
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.
Definition at line 701 of file proceduredb.cc.
References _backward_basicblock_order, _backward_worklist_order, _forward_basicblock_order, _forward_worklist_order, _prefer_context_sensitive, _proc, _return_stmt, _return_variable, _true_branches, _verbose, _worklist, basicblock_list, basicblock_list_p, basicblock_set, Condition, pointerOptions::Context_sensitive_procedures, procNode::decl(), idNode::decl(), dfs_dominators(), procNode::entry(), procNode::exit(), returnNode::expr(), Id, gotoNode::label(), Label, workList::max_size(), declNode::name(), name(), labelNode::name(), Return, reverse_post_order(), stmt_list_p, blockNode::stmts(), str_set_p, Node::typ(), and pointerOptions::Verbose_procedures. |
procedureInfo::~procedureInfo |
( |
|
) |
|
|
Member Function Documentation
void procedureInfo::add_all_blocks |
( |
|
) |
|
|
bool procedureInfo::add_external_input |
( |
memoryBlock * |
block |
) |
|
|
bool procedureInfo::add_external_output |
( |
memoryBlock * |
block |
) |
|
|
void procedureInfo::add_start_block |
( |
Direction |
dir |
) |
|
|
int procedureInfo::analysis_count |
( |
|
) |
const [inline] |
|
procedureInfo * procedureInfo::caller_at |
( |
stmtLocation * |
callsite |
) |
|
|
|
Return the current callsite Return the current caller Return the caller.
Given a callsite, return the caller at that callsite.
Definition at line 1118 of file proceduredb.cc.
References _callsites, and callsite_map_p. |
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.
Definition at line 1343 of file proceduredb.cc.
References _dominance_frontiers, basicblock_set, basicblock_set_map, basicblock_set_map_map_p, basicblock_set_map_p, basicblockLocation::block(), memoryBlock::current_def(), def, memoryBlock::is_flow_sensitive(), memoryBlock::last_def_at(), procLocation::lookup_block(), basicblockLocation::proc_location(), and pointerOptions::Verbose. |
int procedureInfo::count_calling_contexts |
( |
|
) |
|
|
int procedureInfo::count_calling_contexts_rec |
( |
proc_int_map & |
count, |
|
|
stmtNode * |
callsite |
|
) |
[private] |
|
DFPreds* procedureInfo::dominance_frontiers |
( |
|
) |
const [inline] |
|
procedureInfo* procedureInfo::first_caller |
( |
|
) |
const [inline] |
|
void procedureInfo::incr_analysis_count |
( |
|
) |
[inline] |
|
bool procedureInfo::is_ancestor |
( |
procedureInfo * |
other |
) |
|
|
bool procedureInfo::is_context_insensitive |
( |
|
) |
const [inline] |
|
bool procedureInfo::is_empty |
( |
|
) |
const |
|
bool procedureInfo::is_library_routine |
( |
|
) |
[inline] |
|
bool procedureInfo::is_recursive |
( |
|
) |
const [inline] |
|
bool procedureInfo::is_verbose |
( |
|
) |
const [inline] |
|
string& procedureInfo::name |
( |
|
) |
[inline] |
|
|
Get the procedure name.
Definition at line 394 of file proceduredb.h.
References procNode::decl(), declNode::name(), and proc().
Referenced by Pointers::analyze_procedure_at(), procedureDB::is_reanalysis_required(), procedureDB::mark_for_reanalysis(), Pointers::nearest_def_at(), Pointers::pass_return_value(), procedureDB::print_call_stack(), procedureInfo(), qualified_name(), and Pointers::record_external_inputs_and_outputs(). |
bool procedureInfo::never_returns |
( |
|
) |
const [inline] |
|
bool procedureInfo::prefer_context_sensitive |
( |
|
) |
const [inline] |
|
void procedureInfo::print |
( |
ostream & |
out |
) |
|
|
procNode* procedureInfo::proc |
( |
|
) |
const [inline] |
|
|
Return from the procedure Get the procedure.
Definition at line 390 of file proceduredb.h.
Referenced by add_start_block(), livenessAnalyzer::at_procedure_entry(), is_library_routine(), procedureDB::is_visible_to(), procedureDB::is_visible_to_caller(), name(), Pointers::nearest_def_at(), Pointers::pass_parameters(), Pointers::procedure_call(), procedure_size(), Pointers::record_external_inputs_and_outputs(), setup_call_at(), and procedureDB::times_called(). |
int procedureInfo::procedure_size |
( |
|
) |
|
|
string procedureInfo::qualified_name |
( |
|
) |
|
|
|
Qualified name.
Includes either (I), (S), or (R) for context-insensitive, context-sensitive, or recursive.
Definition at line 987 of file proceduredb.cc.
References _callsites, _external_inputs, _external_outputs, is_context_insensitive(), is_recursive(), name(), never_returns(), self_timer(), and total_timer().
Referenced by Pointers::analyze_procedure(), procedureDB::build(), procedureDB::progress_meter(), and setup_call_at(). |
returnNode* procedureInfo::return_stmt |
( |
|
) |
const [inline] |
|
declNode* procedureInfo::return_variable |
( |
|
) |
const [inline] |
|
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 462 of file proceduredb.h.
Referenced by Pointers::analyze_procedure(). |
|
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.
Definition at line 1065 of file proceduredb.cc.
References _pending_changes.
Referenced by Pointers::pass_one_external_output(). |
void procedureInfo::set_prefer_context_sensitive |
( |
|
) |
[inline] |
|
|
Set context-sensitivity preference.
Definition at line 525 of file proceduredb.h. |
void procedureInfo::set_recursive |
( |
|
) |
[inline] |
|
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.
Definition at line 888 of file proceduredb.cc.
References _calls, _callsites, _context_insensitive, _first_caller, _only_context, stmtLocation::calls(), pointerOptions::Context_insensitive, is_context_insensitive(), is_recursive(), prefer_context_sensitive(), proc(), procLocation::proc(), qualified_name(), pointerOptions::Recursion_Context_sensitive, stmtLocation::remove_call(), and stmtLocation::setup_cs_call().
Referenced by Pointers::procedure_call(). |
|
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.
Definition at line 1210 of file proceduredb.cc.
References _dominance_frontiers, _merge_points, basicblock_set, basicblock_set_map, basicblock_set_map_map_p, basicblock_set_map_p, basicblockLocation::block(), memoryBlock::current_def(), def, memoryBlock::is_flow_sensitive(), basicblockLocation::last(), procLocation::lookup_block(), memoryBlock::name(), memoryBlock::nearest_def_at(), basicblockLocation::proc_location(), memoryBlock::setup_merge_uses_at(), and pointerOptions::Verbose.
Referenced by Pointers::process_local_changes(). |
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).
Definition at line 1820 of file proceduredb.cc.
References _ancestors, _calls, _callsites, _external_inputs, _external_outputs, _proc, count_calling_contexts(), procNode::decl(), is_context_insensitive(), declNode::name(), procedure_size(), self_timer(), and total_timer().
Referenced by procedureDB::stats(). |
void procedureInfo::stop_self_timer |
( |
|
) |
[inline] |
|
void procedureInfo::stop_total_timer |
( |
|
) |
[inline] |
|
double procedureInfo::total_timer |
( |
|
) |
[inline] |
|
void procedureInfo::update_conditional_worklist |
( |
basicblockNode * |
block, |
|
|
bool |
has_truth_value, |
|
|
bool |
which_branch |
|
) |
|
|
Member Data Documentation
int procedureInfo::_analysis_count [private]
|
|
|
Analysis count.
Count the number of times the procedure is analyzed.
Definition at line 320 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.
Referenced by block_position(), and procedureInfo(). |
bool procedureInfo::_context_insensitive [private]
|
|
|
Current call site Context insensitive.
Set to true if this procedure is analyzed context insensitively.
Definition at line 223 of file proceduredb.h.
Referenced by setup_call_at(). |
DFPreds* procedureInfo::_dominance_frontiers [private]
|
|
|
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 253 of file proceduredb.h.
Referenced by add_external_input(), qualified_name(), and stats(). |
|
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 264 of file proceduredb.h.
Referenced by add_external_output(), qualified_name(), and stats(). |
procedureInfo* procedureInfo::_first_caller [private]
|
|
|
First caller.
Creates a minimum spanning tree of the call graph. We use this to mark for reanalysis.
Definition at line 278 of file proceduredb.h.
Referenced by setup_call_at(). |
|
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.
Referenced by block_position(), and procedureInfo(). |
bool procedureInfo::_is_recursive [private]
|
|
|
Called recursively.
Record if this procedure is recursive.
Definition at line 290 of file proceduredb.h. |
loopTree* procedureInfo::_loops [private]
|
|
|
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.
Referenced by reverse_post_order(), and ~procedureInfo(). |
|
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.
Referenced by lookup_merge_point(), and setup_merge_point(). |
bool procedureInfo::_never_returns [private]
|
|
|
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 190 of file proceduredb.h. |
|
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 241 of file proceduredb.h.
Referenced by procedure_location(), setup_call_at(), and ~procedureInfo(). |
|
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 211 of file proceduredb.h.
Referenced by get_pending_changes(), and set_pending_changes(). |
bool procedureInfo::_prefer_context_sensitive [private]
|
|
|
Prefer context sensitive.
This flag is set at the beginning of the analysis to indicate that the preferred mode for this procedure is context sensitive. We only check this flag during context insensitive analysis.
Definition at line 231 of file proceduredb.h.
Referenced by procedureInfo(). |
procNode* procedureInfo::_proc [private]
|
|
|
Return statement.
Store a pointer to the return statement (there should only be one!)
Definition at line 181 of file proceduredb.h.
Referenced by procedureInfo(). |
declNode* procedureInfo::_return_variable [private]
|
|
|
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 procedureInfo(). |
cbzTimer procedureInfo::_self_timer [private]
|
|
|
Self timer.
Keep track of the total time spent analyzing this routine (not including called routines).
Definition at line 334 of file proceduredb.h. |
cbzTimer procedureInfo::_total_timer [private]
|
|
|
Total timer.
Keep track of the total time spend analyzing this routine, including procedures that it calls.
Definition at line 341 of file proceduredb.h. |
bool procedureInfo::_verbose [private]
|
|
|
Verbose.
When true, turn on verbose output when we're analyzing this procedure.
Definition at line 327 of file proceduredb.h.
Referenced by procedureInfo(). |
workList procedureInfo::_worklist [private]
|
|
The documentation for this class was generated from the following files:
|