#include <proceduredb.h>
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 set< procedureInfo * > | procedure_set |
typedef procedure_set::iterator | procedure_set_p |
typedef procedure_set::const_iterator | procedure_set_cp |
Public Methods | |
DFPreds * | dominance_frontiers () const |
Return the dominance frontiers. More... | |
procedureInfo (procNode *the_proc) | |
Create a procedureInfo object for a procedure. More... | |
~procedureInfo () | |
Destroy a procedureInfo object. More... | |
void | add_ancestor_set (procedure_set &ancestors) |
Add ancestor set. More... | |
void | setup_call_at (procedureInfo *caller, stmtLocation *callsite) |
Call the procedure. More... | |
void | return_from () |
Return from the procedure. More... | |
procNode * | proc () const |
Get the procedure. More... | |
string & | name () |
Get the procedure name. More... | |
const procedure_set & | ancestors () const |
Set of ancestors. More... | |
const procedure_set & | calls () const |
Return the calls. More... | |
const callsite_map & | callsites () const |
Return the set of callsites. More... | |
stmtLocation * | current_callsite () const |
Return the current callsite. More... | |
procedureInfo * | current_caller () |
Return the current caller. More... | |
procedureInfo * | caller_at (stmtLocation *callsite) |
Return the caller. More... | |
bool | is_current_call_recursive (procedureInfo *caller) |
Is recursive call? More... | |
procLocation * | current_procedure_location () |
Return the procedure location. More... | |
void | print_call_stack (ostream &out) |
Print call stack. More... | |
void | progress_meter (ostream &out) |
Progress meter. More... | |
void | print (ostream &out) |
Output. More... | |
void | stats (ostream &out) |
Stats. More... | |
Context insensitivity | |
void | make_context_insensitive () |
Set context-insensitive. More... | |
bool | is_context_insensitive () const |
Is context-insensitive. More... | |
procLocation * | get_context () const |
Get context-insensitive. More... | |
basicblockLocation * | external_inputs_mergepoint () |
Location to merge external inputs. More... | |
Merge-point management | |
void | setup_merge_point (memoryBlock *block_to_merge, basicblockLocation *cur) |
Set up merge points. More... | |
memoryblock_set * | lookup_merge_point (basicblockLocation *where) |
Lookup a merge point. More... | |
External input and output management | |
Manage external inputs and outputs when working in context-insensitive mode. | |
const memoryblock_set & | external_inputs () const |
Get external inputs. More... | |
const memoryblock_set & | external_outputs () const |
Get external outputs. More... | |
bool | add_external_input (memoryBlock *block) |
Add an external input. More... | |
bool | add_external_output (memoryBlock *block) |
Add an external output. More... | |
Worklist management | |
basicblockNode * | get_next_block (Direction dir) |
Get the next block on the worklist. More... | |
void | add_block (basicblockNode *block, Direction dir) |
Add a block to the worklist. More... | |
void | add_reachable_blocks (basicblockNode *block, Direction dir) |
Add all reachable blocks to the worklist. More... | |
void | add_all_blocks () |
Add all blocks. More... | |
void | add_start_block (Direction dir) |
Add the start node. More... | |
bool | is_empty () const |
Test for empty worklist. More... | |
Private Methods | |
void | reverse_post_order (Direction dir, basicblockNode *cur, basicblock_set &visited, basicblock_list &order) |
Compute a reverse post-ordering of the basic blocks. More... | |
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. More... | |
workList | _worklist |
The worklist of basic blocks. More... | |
worklist_order_map | _forward_worklist_order |
The forward ordering of basic blocks in the worklist. More... | |
vector< basicblockNode * > | _forward_basicblock_order |
The forward enumeration of basic blocks. More... | |
worklist_order_map | _backward_worklist_order |
The backward ordering of basic blocks in the worklist. More... | |
vector< basicblockNode * > | _backward_basicblock_order |
The backward enumeration of basic blocks. More... | |
mergepoint_map | _merge_points |
Merge points. More... | |
DFPreds * | _dominance_frontiers |
Dominance frontiers. More... | |
loopTree * | _loops |
Loop tree. More... | |
callsite_map | _callsites |
Call sites. More... | |
stmtLocation * | _current_callsite |
Current call site. More... | |
bool | _context_insensitive |
Context insensitive. More... | |
TREE procLocation * | _only_context |
Only context. More... | |
memoryblock_set | _external_inputs |
External inputs. More... | |
memoryblock_set | _external_outputs |
External outputs. More... | |
procedure_set | _ancestors |
Ancestors. More... | |
procedure_set | _calls |
Called procedures. More... | |
bool | _is_recursive |
Called recursively. More... |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Create a procedureInfo object for a procedure. This constructor creates a new instance, and precomputes the worklist orderings, and the dominance frontiers. |
|
Destroy a procedureInfo object.
|
|
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. |
|
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. |
|
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. |
|
Add all reachable blocks to the worklist. Add all the blocks reachable from the given block, NOT including the block itself. |
|
|
|
Add the start node. This is either the entry node (for forward analysis) or the exit node (for backward analysis). |
|
Set of ancestors.
|
|
|
|
|
|
Return the caller. Given a callsite, return the caller at that callsite. |
|
Return the calls. Return the set of procedures that this one calls. |
|
Return the set of callsites.
|
|
Return the current caller. Returns null is there is none. |
|
Return the current callsite.
|
|
Return the procedure location. For context insensitive calls, this just returns the only context (see below). For context sensitive calls, it gets the procLocation attached to the current callsite. |
|
Return the dominance frontiers.
|
|
Get external inputs.
|
|
Location to merge external inputs. Attach the merge of external inputs to this location. |
|
Get external outputs.
|
|
Get context-insensitive. Return the context-insensitive callsite, or null if there is none. |
|
Get the next block on the worklist. Return the next block on the worklist, and update the position. |
|
Is context-insensitive.
|
|
Is recursive call? Check the callsite for recursion |
|
Test for empty worklist. Return true if the worklist is empty, which typically indicates that we are done analyzing this particular procedure. |
|
Lookup a merge point. Given a particular basic block, see if there are any objects to be merged at its entry. |
|
Set context-insensitive. This flag can only be set before the first analysis of the procedure. |
|
Get the procedure name.
|
|
Output.
|
|
Print call stack.
|
|
Get the procedure.
|
|
Progress meter.
|
|
Return from the procedure. This just clears the current callsite, so that there's no confusion. |
|
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). |
|
Call the procedure. Set up the procedure at the given callsite. This sets the current call site pointer. |
|
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. |
|
Stats. Output a whole bunch of statistics about this procedure (particularly useful after analysis is complete). |
|
Ancestors. Maintain a set of ancestors in the call graph. This makes searching the scope and updating the worklist faster. |
|
The backward enumeration of basic blocks. This maps basic blocks to bit positions in the worklist. |
|
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. |
|
Called procedures. The procedures directly called by this one. |
|
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). |
|
Context insensitive. Set to true if this procedure is analyzed context insensitively. |
|
Current call site. Set by the call() method. |
|
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. |
|
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. |
|
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. |
|
The forward enumeration of basic blocks. This maps basic blocks to bit positions in the worklist. |
|
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. |
|
Called recursively. Record if this procedure is recursive. |
|
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. |
|
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. |
|
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. |
|
A pointer to the procedure definition.
|
|
The worklist of basic blocks.
|