re PR tree-optimization/15654 (ICE in calculate_live_on_entry with -O2 -fno-tree...
authorZdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
Sun, 11 Jul 2004 19:57:47 +0000 (21:57 +0200)
committerZdenek Dvorak <rakdver@gcc.gnu.org>
Sun, 11 Jul 2004 19:57:47 +0000 (19:57 +0000)
PR tree-optimization/15654
* tree-tailcall.c (eliminate_tail_call): Remove unreachable code.

From-SVN: r84527

gcc/ChangeLog
gcc/tree-tailcall.c

index 3ff14d40a3a2f6a98d5923c9eef7a51aea27c379..ca5666d00d83d273c49e77b7e17d7b8aa72c8e13 100644 (file)
@@ -1,3 +1,8 @@
+2004-07-11  Zdenek Dvorak  <rakdver@atrey.karlin.mff.cuni.cz>
+
+       PR tree-optimization/15654
+       * tree-tailcall.c (eliminate_tail_call): Remove unreachable code.
+
 2004-07-11  Roger Sayle  <roger@eyesopen.com>
 
        * builtins.c (fold_builtin_fputs): Don't bother converting the
index 323c239cece634e570101877fc2c4d416f002ebe..fdd010f160cafa680de0e8b05c63384f933016ab 100644 (file)
@@ -647,6 +647,7 @@ eliminate_tail_call (struct tailcall *t)
   stmt_ann_t ann;
   v_may_def_optype v_may_defs;
   unsigned i;
+  block_stmt_iterator bsi;
 
   stmt = bsi_stmt (t->call_bsi);
   get_stmt_operands (stmt);
@@ -666,6 +667,21 @@ eliminate_tail_call (struct tailcall *t)
 
   first = ENTRY_BLOCK_PTR->succ->dest;
 
+  /* Remove the code after call_bsi that will become unreachable.  The
+     possibly unreachable code in other blocks is removed later in
+     cfg cleanup.  */
+  bsi = t->call_bsi;
+  bsi_next (&bsi);
+  while (!bsi_end_p (bsi))
+    {
+      /* Do not remove the return statement, so that redirect_edge_and_branch
+        sees how the block ends.  */
+      if (TREE_CODE (bsi_stmt (bsi)) == RETURN_EXPR)
+       break;
+
+      bsi_remove (&bsi);
+    }
+
   /* Replace the call by a jump to the start of function.  */
   e = redirect_edge_and_branch (t->call_block->succ, first);
   if (!e)