diff options
Diffstat (limited to 'gcc/tree-ssa-dce.c')
-rw-r--r-- | gcc/tree-ssa-dce.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index effc148a844..69bd452038c 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -697,6 +697,9 @@ remove_dead_stmt (block_stmt_iterator *i, basic_block bb) redirect_edge_and_branch (bb->succ, post_dom_bb); PENDING_STMT (bb->succ) = NULL; + /* Dominators are wrong now. */ + free_dominance_info (CDI_DOMINATORS); + /* The edge is no longer associated with a conditional, so it does not have TRUE/FALSE flags. */ bb->succ->flags &= ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE); @@ -743,6 +746,7 @@ print_stats (void) stats.removed_phis, stats.total_phis, (int) percg); } } + /* Initialization for this pass. Set up the used data structures. */ @@ -797,6 +801,8 @@ tree_dce_done (bool aggressive) In aggressive mode, control dependences are taken into account, which results in more dead code elimination, but at the cost of some time. + If NO_CFG_CHANGES is true, avoid changing cfg. + FIXME: Aggressive mode before PRE doesn't work currently because the dominance info is not invalidated after DCE1. This is not an issue right now because we only run aggressive DCE @@ -804,10 +810,13 @@ tree_dce_done (bool aggressive) start experimenting with pass ordering. */ static void -perform_tree_ssa_dce (bool aggressive) +perform_tree_ssa_dce (bool aggressive, bool no_cfg_changes) { struct edge_list *el = NULL; + if (no_cfg_changes && aggressive) + abort (); + tree_dce_init (aggressive); if (aggressive) @@ -829,7 +838,8 @@ perform_tree_ssa_dce (bool aggressive) if (aggressive) free_dominance_info (CDI_POST_DOMINATORS); - cleanup_tree_cfg (); + if (!no_cfg_changes) + cleanup_tree_cfg (); /* Debugging dumps. */ if (dump_file) @@ -841,17 +851,25 @@ perform_tree_ssa_dce (bool aggressive) tree_dce_done (aggressive); } +/* Cleanup the dead code, but avoid cfg changes. */ + +void +tree_ssa_dce_no_cfg_changes (void) +{ + perform_tree_ssa_dce (false, true); +} + /* Pass entry points. */ static void tree_ssa_dce (void) { - perform_tree_ssa_dce (/*aggressive=*/false); + perform_tree_ssa_dce (/*aggressive=*/false, false); } static void tree_ssa_cd_dce (void) { - perform_tree_ssa_dce (/*aggressive=*/optimize >= 2); + perform_tree_ssa_dce (/*aggressive=*/optimize >= 2, false); } static bool @@ -892,4 +910,3 @@ struct tree_opt_pass pass_cd_dce = TODO_ggc_collect | TODO_verify_ssa | TODO_verify_flow /* todo_flags_finish */ }; - |