From 4c27dd459452e4fd7d2821cc60813ba8ed6d3d8c Mon Sep 17 00:00:00 2001 From: rth Date: Mon, 16 May 2005 23:14:02 +0000 Subject: [PATCH] PR tree-opt/21399 * tree-eh.c (maybe_clean_or_replace_eh_stmt): Rename from maybe_clean_eh_stmt; take old stmt parameter. Update EH region data structure to match replacement. * tree-flow.h: Update to match. * tree-ssa-ccp.c (execute_fold_all_builtins): Likewise. * tree-ssa-dom.c (optimize_stmt): Likewise. * tree-ssa-pre.c (eliminate): Likewise. * tree-ssa-propagate.c (substitute_and_fold): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@99801 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 13 +++++++++++++ gcc/tree-eh.c | 32 ++++++++++++++++++++++++++------ gcc/tree-flow.h | 2 +- gcc/tree-ssa-ccp.c | 3 ++- gcc/tree-ssa-dom.c | 6 +++--- gcc/tree-ssa-pre.c | 2 +- gcc/tree-ssa-propagate.c | 3 ++- 7 files changed, 48 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2ac24ad..e3843ed 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2005-05-16 Richard Henderson + Steven Bosscher + + PR tree-opt/21399 + * tree-eh.c (maybe_clean_or_replace_eh_stmt): Rename from + maybe_clean_eh_stmt; take old stmt parameter. Update EH + region data structure to match replacement. + * tree-flow.h: Update to match. + * tree-ssa-ccp.c (execute_fold_all_builtins): Likewise. + * tree-ssa-dom.c (optimize_stmt): Likewise. + * tree-ssa-pre.c (eliminate): Likewise. + * tree-ssa-propagate.c (substitute_and_fold): Likewise. + 2005-05-16 Caroline Tice * bb-reorder.c (verify_hot_cold_block_grouping): Replace diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 7d83746..9f641e1 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -2034,12 +2034,32 @@ tree_can_throw_external (tree stmt) return can_throw_external_1 (region_nr); } -bool -maybe_clean_eh_stmt (tree stmt) +/* Given a statement OLD_STMT and a new statement NEW_STMT that has replaced + OLD_STMT in the function, remove OLD_STMT from the EH table and put NEW_STMT + in the table if it should be in there. Return TRUE if a replacement was + done that my require an EH edge purge. */ + +bool +maybe_clean_or_replace_eh_stmt (tree old_stmt, tree new_stmt) { - if (!tree_could_throw_p (stmt)) - if (remove_stmt_from_eh_region (stmt)) - return true; + int region_nr = lookup_stmt_eh_region (old_stmt); + + if (region_nr >= 0) + { + bool new_stmt_could_throw = tree_could_throw_p (new_stmt); + + if (new_stmt == old_stmt && new_stmt_could_throw) + return false; + + remove_stmt_from_eh_region (old_stmt); + if (new_stmt_could_throw) + { + add_stmt_to_eh_region (new_stmt, region_nr); + return false; + } + else + return true; + } + return false; } - diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h index 2835c22..6a6e348 100644 --- a/gcc/tree-flow.h +++ b/gcc/tree-flow.h @@ -751,7 +751,7 @@ extern bool tree_can_throw_external (tree); extern int lookup_stmt_eh_region (tree); extern void add_stmt_to_eh_region (tree, int); extern bool remove_stmt_from_eh_region (tree); -extern bool maybe_clean_eh_stmt (tree); +extern bool maybe_clean_or_replace_eh_stmt (tree, tree); /* In tree-ssa-pre.c */ void add_to_value (tree, tree); diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 58b8c2c..85753bd 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -2355,6 +2355,7 @@ execute_fold_all_builtins (void) for (i = bsi_start (bb); !bsi_end_p (i); bsi_next (&i)) { tree *stmtp = bsi_stmt_ptr (i); + tree old_stmt = *stmtp; tree call = get_rhs (*stmtp); tree callee, result; @@ -2396,7 +2397,7 @@ execute_fold_all_builtins (void) } } update_stmt (*stmtp); - if (maybe_clean_eh_stmt (*stmtp) + if (maybe_clean_or_replace_eh_stmt (old_stmt, *stmtp) && tree_purge_dead_eh_edges (bb)) cfg_changed = true; diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 42c0c30..b827494 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -2946,11 +2946,11 @@ optimize_stmt (struct dom_walk_data *walk_data, basic_block bb, block_stmt_iterator si) { stmt_ann_t ann; - tree stmt; + tree stmt, old_stmt; bool may_optimize_p; bool may_have_exposed_new_symbols = false; - stmt = bsi_stmt (si); + old_stmt = stmt = bsi_stmt (si); update_stmt_if_modified (stmt); ann = stmt_ann (stmt); @@ -3055,7 +3055,7 @@ optimize_stmt (struct dom_walk_data *walk_data, basic_block bb, /* If we simplified a statement in such a way as to be shown that it cannot trap, update the eh information and the cfg to match. */ - if (maybe_clean_eh_stmt (stmt)) + if (maybe_clean_or_replace_eh_stmt (old_stmt, stmt)) { bitmap_set_bit (need_eh_cleanup, bb->index); if (dump_file && (dump_flags & TDF_DETAILS)) diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 183b2cd..54cbf63 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -2321,7 +2321,7 @@ eliminate (void) /* If we removed EH side effects from the statement, clean its EH information. */ - if (maybe_clean_eh_stmt (stmt)) + if (maybe_clean_or_replace_eh_stmt (stmt, stmt)) { bitmap_set_bit (need_eh_cleanup, bb_for_stmt (stmt)->index); diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index c83d2cd..ee8b165 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -1051,6 +1051,7 @@ substitute_and_fold (prop_value_t *prop_value) did_replace |= replace_vuses_in (stmt, &replaced_address, prop_value); if (did_replace) { + tree old_stmt = stmt; fold_stmt (bsi_stmt_ptr (i)); stmt = bsi_stmt(i); @@ -1060,7 +1061,7 @@ substitute_and_fold (prop_value_t *prop_value) /* If we cleaned up EH information from the statement, remove EH edges. */ - if (maybe_clean_eh_stmt (stmt)) + if (maybe_clean_or_replace_eh_stmt (old_stmt, stmt)) tree_purge_dead_eh_edges (bb); } -- 2.7.4