summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/tree-eh.c32
-rw-r--r--gcc/tree-flow.h2
-rw-r--r--gcc/tree-ssa-ccp.c3
-rw-r--r--gcc/tree-ssa-dom.c6
-rw-r--r--gcc/tree-ssa-pre.c2
-rw-r--r--gcc/tree-ssa-propagate.c3
7 files changed, 48 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2ac24adee94..e3843ed9997 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2005-05-16 Richard Henderson <rth@redhat.com>
+ Steven Bosscher <stevenb@suse.de>
+
+ 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 <ctice@apple.com>
* bb-reorder.c (verify_hot_cold_block_grouping): Replace
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 7d83746b501..9f641e186d2 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 2835c221f01..6a6e3488312 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 58b8c2c01be..85753bdd764 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 42c0c306832..b827494b7dc 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 183b2cd9cfe..54cbf639b77 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 c83d2cdff9d..ee8b1652627 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);
}