deadcode.cc File Reference
Go to the source code of this file.
|
Functions |
| static void | _collect_candidates (const ProgramUnit &pgm, Map< Symbol, IntElem > &candidates, Array< Symbol * > &tag_to_candidate, DCE_ARRAY_BOOL deadcode_arrays) |
| | collect_candidates - Determine all the variables that are candidates for forward substitution and initialize the _candidates and _tag_to_candidates data structures to contain these variables.
|
| static void | _init_workspaces (ProgramUnit &pgm, const Map< Symbol, IntElem > &candidates) |
| | init_workspaces Initialize the workspaces for each statement in the program.
|
| static DeadCodeElimWS & | _get_workspace (const Statement &stmt) |
| | get_workspace Get the workspace for the given statement.
|
| static void | _dump_workspaces (ostream &o, const ProgramUnit &pgm, const Array< Symbol * > &tag_to_candidate) |
| | dump_workspaces Dump out the data inside all of the workspaces of the program
|
| static void | _init_non_local_vars (IntSet &non_local_vars, IntSet &live_end_vars, const ProgramUnit &pgm, const Map< Symbol, IntElem > &candidates, const Array< Symbol * > &tag_to_candidate) |
| | _init_non_local_vars Initialize the sets of non-local and live-end variables.
|
| static void | _make_nonlocals_used_at_calls (StmtList &stmts, const IntSet &non_local_vars) |
| | _make_nonlocals_used_at_calls Make all non-local variables be marked as potentially used for all call statements and all statements containing function calls.
|
| static void | _compute_private_kill_sets (StmtList &stmts, const Map< Symbol, IntElem > &candidates) |
| | _compute_private_kill_sets Compute the set of array variables to kill for do loop bodies because they are private to the loop's body.
|
| static void | _calc_toporder1 (Statement &stmt, int &toporder) |
| | _calc_toporder Calculate toporder for the flow graph.
|
| static void | _calc_toporder (ProgramUnit &pgm, Array< Statement * > &toporder_to_stmt) |
| static void | _put_pred_on_work_list (IntSet &work_list, Statement &stmt) |
| | put_pred_on_work_list Put all of my predecessors on the work list.
|
| static void | _iterate_to_fixed_point (ProgramUnit &pgm, const Array< Statement * > &toporder_to_stmt, const Map< Symbol, IntElem > &, const Array< Symbol * > &tag_to_candidate, const IntSet &flow_exit_vars) |
| | iterate_to_fixed_point Propagate the constants contained in the statement's const_maps until a fixed point is reached.
|
| static void | _remove_assertion (const Symbol &var, Statement &stmt, AssertionType atyp) |
| | remove_assertion Remove all assertions of the given type with the given variable.
|
| static Boolean | _are_vars_in_expr (const Expression &e, const RefSet< Symbol > &vars) |
| | _are_vars_in_expr Return true if the given expression uses any of the variables in the given set.
|
| static void | _delete_dead_code (ProgramUnit &pgm, const Array< Symbol * > tag_to_candidate, const IntSet &non_local_vars) |
| | delete_dead_code Delete all dead code from a program unit.
|
| void | dfs_stmts (Statement &stmt, set< Statement * > &visited) |
| void | eliminate_unreachable_statements (ProgramUnit &pgm) |
| | silvius: eliminate all statements that cannot be reached from any entry.
|
| void | eliminate_dead_code (ProgramUnit &pgm, DCE_ARRAY_BOOL deadcode_arrays GIV(DONT_DEADCODE_ARRAYS), int debug GIV(0)) |
| | eliminate_dead_code Delete all dead code from a program unit.
|
Variables |
| static unsigned int | _pass_tag |
| static int | _debug_level = 0 |
| | ... Pass tag associated with this pass
|
Detailed Description
Definition in file deadcode.cc.
Function Documentation
|
|
get_workspace Get the workspace for the given statement.
Definition at line 103 of file deadcode.cc.
References _pass_tag. |
| static void _dump_workspaces |
( |
ostream & |
o, |
|
|
const ProgramUnit & |
pgm, |
|
|
const Array< Symbol * > & |
tag_to_candidate |
|
) |
[static] |
|
|
|
_init_non_local_vars Initialize the sets of non-local and live-end variables.
... Determine all variables that are contained in DATA statements.
... Mark any variables aliased to the non-local variable ... as also non-local and live-end
... Mark any variables aliased to the live-end variable ... as also live-end
Definition at line 136 of file deadcode.cc.
References NonBinaryExpr::arg_list(), Expression::base_variable_ref(), Symbol::common_ref(), Iterator< T >::current(), equiv_aliases(), Symbol::formal(), RefSet< T >::ins(), IS_FORMAL, IS_SAVED, RefSet< T >::member(), Symbol::saved(), Symbol::sym_class(), Iterator< T >::valid(), IntElem::value(), VARIABLE_CLASS, and Data::variable_list().
Referenced by eliminate_dead_code(). |
| static void _make_nonlocals_used_at_calls |
( |
StmtList & |
stmts, |
|
|
const IntSet & |
non_local_vars |
|
) |
[static] |
|
|
|
_compute_private_kill_sets Compute the set of array variables to kill for do loop bodies because they are private to the loop's body.
Definition at line 247 of file deadcode.cc.
References _get_workspace(), Assertion::arg_list_guarded(), AS_FIRSTVALUE, AS_PRIVATE, Statement::assertions(), Expression::base_variable_ref(), Iterator< T >::current(), RefSet< T >::del(), DO_STMT, RefSet< T >::entries(), IntSet::ins(), RefSet< T >::ins(), Symbol::is_array(), RefSet< T >::member(), Iterator< T >::reset(), Assertion::type(), Iterator< T >::valid(), and IntElem::value().
Referenced by eliminate_dead_code(). |
| static void _calc_toporder1 |
( |
Statement & |
stmt, |
|
|
int & |
toporder |
|
) |
[static] |
|
| static void _put_pred_on_work_list |
( |
IntSet & |
work_list, |
|
|
Statement & |
stmt |
|
) |
[static] |
|
|
|
iterate_to_fixed_point Propagate the constants contained in the statement's const_maps until a fixed point is reached.
... List of statements that need to be updated.
... Mark all variables for entry statements as non-const and put all ... entries on the work list.
... Iterate until there are no more elements on the work list
... Visit each statement in the work list, in topological order
... Generate the new live variable set for the end of the statement.
... New entering live variable set differs from the old ... one. So update the entering and exiting live variable ... sets for the statement.
... Exiting live var set has changed, so place ... the statement's predecessors on the work list so ... that they can update their live variable sets ... with my live var set.
Definition at line 375 of file deadcode.cc.
References _debug_level, _get_workspace(), _put_pred_on_work_list(), Iterator< T >::current(), DO_STMT, False, FLOW_EXIT_STMT, Statement::follow_ref(), DeadCodeElimWS::in_live_vars, DeadCodeElimWS::incr_num_visits(), Statement::next_ref(), DeadCodeElimWS::num_visits(), DeadCodeElimWS::out_live_vars, DeadCodeElimWS::pretty_print(), Statement::print_debug(), DeadCodeElimWS::private_kill_set(), PROGRAM_PU_TYPE, Statement::stmt_class(), Statement::succ(), PropConstWS::toporder(), DeadCodeElimWS::update_out_live_vars(), and Iterator< T >::valid(). |
|
|
delete_dead_code Delete all dead code from a program unit.
... Delete all dead LAST VALUE assertions.
... Look at the workspace of the statement after the DO loop's ... ENDDO statement.
... Delete the statement if it is dead code.
... Compute the set of variables that are dead for the entire program
... Delete all assertions containing any of the dead variables.
... Delete all dead variables from the symbol table.
Definition at line 526 of file deadcode.cc.
References _are_vars_in_expr(), _debug_level, _get_workspace(), _remove_assertion(), Assertion::arg_list_guarded(), Assertion::arg_list_valid(), AS_DYNLASTVALUE, AS_LASTVALUE, Statement::assertions(), BLOCK_ENTRY_STMT, Iterator< T >::current(), List< T >::del(), Mutator< T >::del(), DO_STMT, List< T >::entries(), Array< T >::entries(), Statement::follow_ref(), DeadCodeElimWS::in_live_vars, RefSet< T >::ins(), DeadCodeElimWS::is_dead_code(), DeadCodeElimWS::kill_set, Symbol::name_ref(), Statement::next_ref(), DeadCodeElimWS::out_live_vars, Statement::print_debug(), Iterator< T >::reset(), Statement::stmt_class(), and Iterator< T >::valid().
Referenced by eliminate_dead_code(). |
| void eliminate_unreachable_statements |
( |
ProgramUnit & |
pgm |
) |
|
|
|
|
eliminate_dead_code Delete all dead code from a program unit.
... Set of all variables that are candidates for dead code elimination.
... An array that maps integers to variable candidates.
... An array that maps integers to statements.
... Initialize
... Iteratively propagate the constants throughout the program until a ... fixed point is reached.
... Delete all dead code from the program unit.
... Clean up
... silvius:
... This test is a kluge. This causes the code below to run ... before privatization and not after. When this is done ... permanently, we'll figure out a better way.
... The stuff below eliminates IF statements whose conditions are ... found (through range propagation) to be constant, either .TRUE. ... or .FALSE. . The IF itself and the appropriate side of the IF are ... removed.
if (deadcode_arrays == DONT_DEADCODE_ARRAYS) { AIRangeDict *ranges = new AIRangeDict ( pgm );
Iterator<Statement> if_iter = pgm.stmts().stmts_of_type (IF_STMT);
for (; if_iter.valid(); ++if_iter) { Statement & ifstmt = if_iter.current(); RangeAccessor if_ranges ( *ranges, ifstmt );
Expression *ifcondition = ifstmt.expr().clone(); if_ranges.eliminate_vars (ifcondition, NULL);
if (ifcondition->op() == LOGICAL_CONSTANT_OP) { if (ifcondition->str_data() == ".TRUE.") { } else { } } } }
Definition at line 656 of file deadcode.cc.
References _calc_toporder(), _collect_candidates(), _compute_private_kill_sets(), _debug_level, _delete_dead_code(), _dump_workspaces(), _init_non_local_vars(), _init_workspaces(), _iterate_to_fixed_point(), _make_nonlocals_used_at_calls(), _pass_tag, create_pass_tag(), DEADCODE_ARRAYS, eliminate_unreachable_statements(), BaseMapRoot::entries(), and Timer::reset().
Referenced by cleanup_program(), and main(). |
Variable Documentation
|