From ead553a1d9f9206c1f5a3b1a6799ea877fc9a845 Mon Sep 17 00:00:00 2001 From: Steven Bosscher Date: Wed, 26 Jan 2005 15:08:50 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 24 +++++++++++++++++------- gcc/calls.c | 2 +- gcc/tree-tailcall.c | 10 ++++++++++ gcc/tree.h | 3 +++ 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 202edce6dc1..ef8f274bc90 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2005-01-26 Steven Bosscher + + 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 * cse.c (fold_rtx): Call equiv_constant only when necessary. @@ -24,7 +34,7 @@ -lsyssim. Wrap -lc -lsyssim in --start-group --end-group instead of doubling. (STARTFILE_SPEC): Add crti.o, before crtbegin.o. - : Always use crt1.o, regardless of N in simN. + : Always use crt1.o, regardless of N in simN. : Drop support for -pg and -p variants; always use crt0.o. (ENDFILE_SPEC): Add crtn.o, after crtend.o. (CRT_CALL_STATIC_FUNCTION): Remove. @@ -103,10 +113,10 @@ 2005-01-25 Alexandre Oliva - * config/frv/frv.h (ASM_OUTPUT_DWARF_DTPREL): Define. - * config/frv/frv-protos.h (frv_output_dwarf_dtprel): Declare. - * config/frv/frv.c (TLS_BIAS): Define. - (frv_output_dwarf_dtprel): New. + * config/frv/frv.h (ASM_OUTPUT_DWARF_DTPREL): Define. + * config/frv/frv-protos.h (frv_output_dwarf_dtprel): Declare. + * config/frv/frv.c (TLS_BIAS): Define. + (frv_output_dwarf_dtprel): New. 2005-01-26 Jakub Jelinek @@ -436,7 +446,7 @@ first label to see if it is a nonlocal label. 2005-01-22 David Edelsohn - Andrew Pinski + Andrew Pinski PR target/19491 * config/rs6000/rs6000.c (rs6000_va_start): Saturate n_gpr at @@ -2185,7 +2195,7 @@ 2004-01-05 Uros Bizjak * doc/invoke.texi (Intel 386 and AMD x86-64 Options): - Replace i387 with 'i386 compiler' in -mfpmath=sse option. + Replace i387 with 'i386 compiler' in -mfpmath=sse option. 2005-01-04 Roger Sayle diff --git a/gcc/calls.c b/gcc/calls.c index 9e228ac0e3f..291f88cb835 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1670,7 +1670,7 @@ check_sibcall_argument_overlap_1 (rtx x) && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT) i = INTVAL (XEXP (XEXP (x, 0), 1)); else - return 1; + return 0; #ifdef ARGS_GROW_DOWNWARD i = -i - GET_MODE_SIZE (GET_MODE (x)); diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c index 5c5e09cce05..a76314bc835 100644 --- a/gcc/tree-tailcall.c +++ b/gcc/tree-tailcall.c @@ -159,6 +159,8 @@ suitable_for_tail_opt_p (void) static bool suitable_for_tail_call_opt_p (void) { + tree param; + /* alloca (until we have stack slot life analysis) inhibits sibling call optimizations, but not tail recursion. */ if (current_function_calls_alloca) @@ -176,6 +178,14 @@ suitable_for_tail_call_opt_p (void) if (current_function_calls_setjmp) 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; } diff --git a/gcc/tree.h b/gcc/tree.h index 4fdff0c76e1..884f2c43d45 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -824,6 +824,9 @@ extern void tree_operand_check_failed (int, enum tree_code, had its address taken. That matters for inline functions. */ #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) /* In a VAR_DECL, nonzero means allocate static storage. -- 2.30.2