This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] for PR 15654


Hello,

we forget to remove the unreachable code after eliminated call,
which causes problems when dominator optimizations that ensure
that there is no such code is not run.

Bootstrapped & regtested on i686.

Zdenek

	* tree-tailcall.c (eliminate_tail_call): Remove unreachable code.

Index: tree-tailcall.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-tailcall.c,v
retrieving revision 2.3
diff -c -3 -p -r2.3 tree-tailcall.c
*** tree-tailcall.c	15 May 2004 09:39:29 -0000	2.3
--- tree-tailcall.c	26 May 2004 23:55:40 -0000
*************** eliminate_tail_call (struct tailcall *t)
*** 646,651 ****
--- 646,652 ----
    stmt_ann_t ann;
    vdef_optype vdefs;
    unsigned i;
+   block_stmt_iterator bsi;
  
    stmt = bsi_stmt (t->call_bsi);
    get_stmt_operands (stmt);
*************** eliminate_tail_call (struct tailcall *t)
*** 665,670 ****
--- 666,686 ----
  
    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)
*************** eliminate_tail_call (struct tailcall *t)
*** 682,688 ****
         param = TREE_CHAIN (param),
         args = TREE_CHAIN (args))
      {
-       
        for (phi = phi_nodes (first); phi; phi = TREE_CHAIN (phi))
  	if (param == SSA_NAME_VAR (PHI_RESULT (phi)))
  	  break;
--- 698,703 ----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]