PR tree-opt/21399
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 16 May 2005 23:14:02 +0000 (23:14 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 16 May 2005 23:14:02 +0000 (23:14 +0000)
        * 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
gcc/tree-eh.c
gcc/tree-flow.h
gcc/tree-ssa-ccp.c
gcc/tree-ssa-dom.c
gcc/tree-ssa-pre.c
gcc/tree-ssa-propagate.c

index 2ac24ad..e3843ed 100644 (file)
@@ -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
index 7d83746..9f641e1 100644 (file)
@@ -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;
 }
-
index 2835c22..6a6e348 100644 (file)
@@ -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);
index 58b8c2c..85753bd 100644 (file)
@@ -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;
 
index 42c0c30..b827494 100644 (file)
@@ -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))
index 183b2cd..54cbf63 100644 (file)
@@ -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);
index c83d2cd..ee8b165 100644 (file)
@@ -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);
            }