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 17749


Hello,

in find_tail_calls we check that the parameters that have to be copied
have gimple_reg_type.  However parameters that have gimple_reg_type
still do not have to be gimple_regs, in case their address is taken.
If this happens, we are creating phi nodes with mixed normal and
virtual operands, which ICEs (and would be completely bogus without
checking).

This patch makes us avoid optimizing such tailcalls.  This is not
strictly the best possible (we could copy the value by a normal MODIFY_EXPR
statement and fix up the virtual arguments), but it should be safe,
and obviously this situation does not occur too often (otherwise we
would see the ICE before).

Bootstrapped & regtested on ia64.

Zdenek

	PR tree-optimization/17749
	* tree-tailcall.c (find_tail_calls): Check that parameter is
	a gimple_reg.

Index: tree-tailcall.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-tailcall.c,v
retrieving revision 2.30
diff -c -3 -p -r2.30 tree-tailcall.c
*** tree-tailcall.c	28 Sep 2004 07:59:52 -0000	2.30
--- tree-tailcall.c	1 Oct 2004 11:05:59 -0000
*************** find_tail_calls (basic_block bb, struct 
*** 431,445 ****
  	   param = TREE_CHAIN (param), args = TREE_CHAIN (args))
  	{
  	  tree arg = TREE_VALUE (args);
! 	  if (param != arg
  	      /* Make sure there are no problems with copying.  Note we must
  	         have a copyable type and the two arguments must have reasonably
  	         equivalent types.  The latter requirement could be relaxed if
  	         we emitted a suitable type conversion statement.  */
! 	      && (!is_gimple_reg_type (TREE_TYPE (param))
  		  || !lang_hooks.types_compatible_p (TREE_TYPE (param),
! 						     TREE_TYPE (arg))))
! 	    break;
  	}
        if (!args && !param)
  	tail_recursion = true;
--- 431,456 ----
  	   param = TREE_CHAIN (param), args = TREE_CHAIN (args))
  	{
  	  tree arg = TREE_VALUE (args);
! 	  if (param != arg)
! 	    {
  	      /* Make sure there are no problems with copying.  Note we must
  	         have a copyable type and the two arguments must have reasonably
  	         equivalent types.  The latter requirement could be relaxed if
  	         we emitted a suitable type conversion statement.  */
! 	      if (!is_gimple_reg_type (TREE_TYPE (param))
  		  || !lang_hooks.types_compatible_p (TREE_TYPE (param),
! 						     TREE_TYPE (arg)))
! 		break;
! 
! 	      /* The parameter should be a real operand, so that phi node
! 		 created for it at the start of the function has the meaning
! 		 of copying the value.  */
! 	      if (var_ann (param)
! 		  && var_ann (param)->default_def
! 		  && TREE_CODE (var_ann (param)->default_def) == SSA_NAME
! 		  && !is_gimple_reg (var_ann (param)->default_def))
! 		break;
! 	    }
  	}
        if (!args && !param)
  	tail_recursion = true;


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