]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cse.c (have_eh_succ_edges): New function.
authorSteven Bosscher <steven@gcc.gnu.org>
Sun, 17 Dec 2006 20:27:25 +0000 (20:27 +0000)
committerSteven Bosscher <steven@gcc.gnu.org>
Sun, 17 Dec 2006 20:27:25 +0000 (20:27 +0000)
* cse.c (have_eh_succ_edges): New function.
(cse_insn): Don't remove dead EH edges here
(cse_extended_basic_block): Do it here.
(rest_of_handle_cse, rest_of_handle_cse2): Don't assert
that we have removed all dead edges.

From-SVN: r119993

gcc/ChangeLog
gcc/cse.c

index 86cff5c55be14dc75cc026c0eb88c13a3df511fc..30cd10676da2f15958e64f77b3a2e7c7ed9d1ce0 100644 (file)
@@ -1,3 +1,11 @@
+2006-12-17  Steven Bosscher  <steven@gcc.gnu.org>
+
+       * cse.c (have_eh_succ_edges): New function.
+       (cse_insn): Don't remove dead EH edges here
+       (cse_extended_basic_block): Do it here.
+       (rest_of_handle_cse, rest_of_handle_cse2): Don't assert
+       that we have removed all dead edges.
+
 2006-12-17  Matthias Klose  <doko@debian.org>
 
        PR libstdc++/11953
index bd33190b51878f03063039002a5814bb49d333a1..fae16dabcc2e667bbbfd0b2cc39f858e92226868 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -4858,13 +4858,6 @@ cse_insn (rtx insn, rtx libcall_insn)
              validate_change (insn, &SET_SRC (sets[i].rtl), new, 1);
              apply_change_group ();
 
-             /* With non-call exceptions, if this was an insn that could
-                trap, we may have made it non-throwing now.  For example
-                we may have replaced a load with a register.  */
-             if (flag_non_call_exceptions
-                 && insn == BB_END (BLOCK_FOR_INSN (insn)))
-               purge_dead_edges (BLOCK_FOR_INSN (insn));
-
              break;
            }
 
@@ -5938,6 +5931,22 @@ cse_dump_path (struct cse_basic_block_data *data, int nsets, FILE *f)
   fflush (f);
 }
 
+\f
+/* Return true if BB has exception handling successor edges.  */
+
+static bool
+have_eh_succ_edges (basic_block bb)
+{
+  edge e;
+  edge_iterator ei;
+
+  FOR_EACH_EDGE (e, ei, bb->succs)
+    if (e->flags & EDGE_EH)
+      return true;
+
+  return false;
+}
+
 \f
 /* Scan to the end of the path described by DATA.  Return an estimate of
    the total number of SETs, and the lowest and highest insn CUID, of all
@@ -6109,6 +6118,12 @@ cse_extended_basic_block (struct cse_basic_block_data *ebb_data)
       /* Make sure that libcalls don't span multiple basic blocks.  */
       gcc_assert (libcall_insn == NULL_RTX);
 
+      /* With non-call exceptions, we are not always able to update
+        the CFG properly inside cse_insn.  So clean up possibly
+        redundant EH edges here.  */
+      if (flag_non_call_exceptions && have_eh_succ_edges (bb))
+       purge_dead_edges (bb);
+
       /* If we changed a conditional jump, we may have terminated
         the path we are following.  Check that by verifying that
         the edge we would take still exists.  If the edge does
@@ -6210,13 +6225,13 @@ cse_main (rtx f ATTRIBUTE_UNUSED, int nregs)
        INSN_CUID (insn) = ++i;
     }
 
-  /* Loop over basic blocks in DFS order,
+  /* Loop over basic blocks in reverse completion order (RPO),
      excluding the ENTRY and EXIT blocks.  */
   n_blocks = pre_and_rev_post_order_compute (NULL, rc_order, false);
   i = 0;
   while (i < n_blocks)
     {
-      /* Find the first block in the DFS queue that we have not yet
+      /* Find the first block in the RPO queue that we have not yet
         processed before.  */
       do
        {
@@ -6988,10 +7003,6 @@ rest_of_handle_cse (void)
      expecting CSE to be run.  But always rerun it in a cheap mode.  */
   cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
 
-  /* If there are dead edges to purge, we haven't properly updated
-     the CFG incrementally.  */
-  gcc_assert (!purge_all_dead_edges ());
-
   if (tem)
     rebuild_jump_labels (get_insns ());
 
@@ -7044,10 +7055,6 @@ rest_of_handle_cse2 (void)
      bypassed safely.  */
   cse_condition_code_reg ();
 
-  /* If there are dead edges to purge, we haven't properly updated
-     the CFG incrementally.  */
-  gcc_assert (!purge_all_dead_edges ());
-
   delete_trivially_dead_insns (get_insns (), max_reg_num ());
 
   if (tem)