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][4.5] Fix PR43572


This fixes PR43572 - is_call_clobbered is no longer a suitable
predicate to asses that a specific call stmt does not clobber
a variable.  Instead it's legacy and implemented ontop of
escape analysis - so it misses clobbers for calls that are
not escape points (which are several builtins).

In the testcase this caused a bogus tailcall to memcpy.

The fix is to use the alias-oracle to assess that the tailcall
candidate is not using a local variable.  A more complete
patch (eliminating is_call_clobbered alltogether) is in testing
for 4.6.

Bootstrapped and tested on x86_64-unknown-linux-gnu, Ramana is
testing on arm.

Richard.

2010-04-16  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/43572
	* tree-tailcall.c (find_tail_calls): Verify the tail call
	properly.

	* gcc.dg/tree-ssa/tailcall-5.c: New testcase.

Index: gcc/tree-tailcall.c
===================================================================
*** gcc/tree-tailcall.c	(revision 158375)
--- gcc/tree-tailcall.c	(working copy)
*************** find_tail_calls (basic_block bb, struct
*** 375,380 ****
--- 375,382 ----
    tree m, a;
    basic_block abb;
    size_t idx;
+   tree var;
+   referenced_var_iterator rvi;
  
    if (!single_succ_p (bb))
      return;
*************** find_tail_calls (basic_block bb, struct
*** 462,467 ****
--- 464,478 ----
  	tail_recursion = true;
      }
  
+   /* Make sure the tail invocation of this function does not refer
+      to local variables.  */
+   FOR_EACH_REFERENCED_VAR (var, rvi)
+     {
+       if (!is_global_var (var)
+ 	  && ref_maybe_used_by_stmt_p (call, var))
+ 	return;
+     }
+ 
    /* Now check the statements after the call.  None of them has virtual
       operands, so they may only depend on the call through its return
       value.  The return value should also be dependent on each of them,
Index: gcc/testsuite/gcc.dg/tree-ssa/tailcall-5.c
===================================================================
*** gcc/testsuite/gcc.dg/tree-ssa/tailcall-5.c	(revision 0)
--- gcc/testsuite/gcc.dg/tree-ssa/tailcall-5.c	(revision 0)
***************
*** 0 ****
--- 1,12 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O2 -fdump-tree-tailc" } */
+ 
+ void
+ set_integer (void *dest, int value, int length)
+ {
+   int tmp = value;
+   __builtin_memcpy (dest, (void *) &tmp, length);
+ }
+ 
+ /* { dg-final { scan-tree-dump-not "tail call" "tailc" } } */
+ /* { dg-final { cleanup-tree-dump "tailc" } } */


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