Commit ead553a1 by Steven Bosscher

re PR middle-end/19616 (missed tail call)

	PR middle-end/19616
	* tree.h (CALL_EXPR_TAILCALL): Add comment.
	* calls.c (check_sibcall_argument_overlap_1): Revert the change
	to this function from 2004-07-10.
	* tree-tailcall.c (suitable_for_tail_opt_p): Do not consider the
	the current function for tail call optimizations if the address
	of one of it its arguments is taken.

From-SVN: r94265
parent 75335440
2005-01-26 Steven Bosscher <stevenb@suse.de>
PR middle-end/19616
* tree.h (CALL_EXPR_TAILCALL): Add comment.
* calls.c (check_sibcall_argument_overlap_1): Revert the change
to this function from 2004-07-10.
* tree-tailcall.c (suitable_for_tail_opt_p): Do not consider the
the current function for tail call optimizations if the address
of one of it its arguments is taken.
2005-01-26 Kazu Hirata <kazu@cs.umass.edu> 2005-01-26 Kazu Hirata <kazu@cs.umass.edu>
* cse.c (fold_rtx): Call equiv_constant only when necessary. * cse.c (fold_rtx): Call equiv_constant only when necessary.
......
...@@ -1670,7 +1670,7 @@ check_sibcall_argument_overlap_1 (rtx x) ...@@ -1670,7 +1670,7 @@ check_sibcall_argument_overlap_1 (rtx x)
&& GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT) && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT)
i = INTVAL (XEXP (XEXP (x, 0), 1)); i = INTVAL (XEXP (XEXP (x, 0), 1));
else else
return 1; return 0;
#ifdef ARGS_GROW_DOWNWARD #ifdef ARGS_GROW_DOWNWARD
i = -i - GET_MODE_SIZE (GET_MODE (x)); i = -i - GET_MODE_SIZE (GET_MODE (x));
......
...@@ -159,6 +159,8 @@ suitable_for_tail_opt_p (void) ...@@ -159,6 +159,8 @@ suitable_for_tail_opt_p (void)
static bool static bool
suitable_for_tail_call_opt_p (void) suitable_for_tail_call_opt_p (void)
{ {
tree param;
/* alloca (until we have stack slot life analysis) inhibits /* alloca (until we have stack slot life analysis) inhibits
sibling call optimizations, but not tail recursion. */ sibling call optimizations, but not tail recursion. */
if (current_function_calls_alloca) if (current_function_calls_alloca)
...@@ -176,6 +178,14 @@ suitable_for_tail_call_opt_p (void) ...@@ -176,6 +178,14 @@ suitable_for_tail_call_opt_p (void)
if (current_function_calls_setjmp) if (current_function_calls_setjmp)
return false; return false;
/* ??? It is OK if the argument of a function is taken in some cases,
but not in all cases. See PR15387 and PR19616. Revisit for 4.1. */
for (param = DECL_ARGUMENTS (current_function_decl);
param;
param = TREE_CHAIN (param))
if (TREE_ADDRESSABLE (param))
return false;
return true; return true;
} }
......
...@@ -824,6 +824,9 @@ extern void tree_operand_check_failed (int, enum tree_code, ...@@ -824,6 +824,9 @@ extern void tree_operand_check_failed (int, enum tree_code,
had its address taken. That matters for inline functions. */ had its address taken. That matters for inline functions. */
#define TREE_ADDRESSABLE(NODE) ((NODE)->common.addressable_flag) #define TREE_ADDRESSABLE(NODE) ((NODE)->common.addressable_flag)
/* Set on a CALL_EXPR if the call is in a tail position, ie. just before the
exit of a function. Calls for which this is true are candidates for tail
call optimizations. */
#define CALL_EXPR_TAILCALL(NODE) (CALL_EXPR_CHECK(NODE)->common.addressable_flag) #define CALL_EXPR_TAILCALL(NODE) (CALL_EXPR_CHECK(NODE)->common.addressable_flag)
/* In a VAR_DECL, nonzero means allocate static storage. /* In a VAR_DECL, nonzero means allocate static storage.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment