re PR middle-end/19616 (missed tail call)
authorSteven Bosscher <steven@gcc.gnu.org>
Wed, 26 Jan 2005 15:08:50 +0000 (15:08 +0000)
committerSteven Bosscher <steven@gcc.gnu.org>
Wed, 26 Jan 2005 15:08:50 +0000 (15:08 +0000)
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
gcc/calls.c
gcc/tree-tailcall.c
gcc/tree.h

index 202edce6dc1d8264fee85c2b4580230389a8a461..ef8f274bc90493197a655ed2a8ea2f820d9ce1bd 100644 (file)
@@ -1,3 +1,13 @@
+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>
 
        * 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.
-       <sim*>: Always use crt1.o, regardless of N in simN.
+       <sim*>: Always use crt1.o, regardless of N in simN.
        <!sim>: Drop support for -pg and -p variants; always use crt0.o.
        (ENDFILE_SPEC): Add crtn.o, after crtend.o.
        (CRT_CALL_STATIC_FUNCTION): Remove.
 
        2005-01-25  Alexandre Oliva  <aoliva@redhat.com>
 
-        * 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  <jakub@redhat.com>
 
        first label to see if it is a nonlocal label.
 
 2005-01-22  David Edelsohn  <edelsohn@gnu.org>
-            Andrew Pinski  <pinskia@physics.uc.edu>
+           Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR target/19491
        * config/rs6000/rs6000.c (rs6000_va_start): Saturate n_gpr at
 2004-01-05  Uros Bizjak  <uros@kss-loka.si>
 
        * 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  <roger@eyesopen.com>
 
index 9e228ac0e3f2671deb0e05b44e01812a39f80165..291f88cb83572d6417c9c87a2c0ecc3bf8376eaa 100644 (file)
@@ -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));
index 5c5e09cce0573412819fdf5f75d860d59e271ce7..a76314bc83549c7f4e4108c4538d52d0a7f6f9b0 100644 (file)
@@ -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;
 }
 
index 4fdff0c76e10ac10059b429b191b196e810ede8d..884f2c43d45d8d515d398cf7a7abccad35d3fe36 100644 (file)
@@ -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.