From 3b31f6c23620cdeeafceb9063865d3fb8f3defc7 Mon Sep 17 00:00:00 2001 From: rguenth Date: Mon, 19 Apr 2010 09:12:13 +0000 Subject: [PATCH] 2010-04-19 Richard Guenther PR tree-optimization/43572 * tree-tailcall.c (find_tail_calls): Verify the tail call properly. * gcc.dg/tree-ssa/tailcall-5.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_5-branch@158507 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/tree-ssa/tailcall-5.c | 12 ++++++++++++ gcc/tree-tailcall.c | 11 +++++++++++ 4 files changed, 34 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/tailcall-5.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0a55ecb80cd..8cf3d589fd2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-04-19 Richard Guenther + + PR tree-optimization/43572 + * tree-tailcall.c (find_tail_calls): Verify the tail call + properly. + 2010-04-19 Ira Rosen PR tree-optimization/43771 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4a838cffda2..06c77c0ff35 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-04-19 Richard Guenther + + PR tree-optimization/43572 + * gcc.dg/tree-ssa/tailcall-5.c: New testcase. + 2010-04-19 Ira Rosen PR tree-optimization/43771 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/tailcall-5.c b/gcc/testsuite/gcc.dg/tree-ssa/tailcall-5.c new file mode 100644 index 00000000000..7aa433ecf7a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/tailcall-5.c @@ -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" } } */ diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c index 2ecca4aaae7..84c7da29844 100644 --- a/gcc/tree-tailcall.c +++ b/gcc/tree-tailcall.c @@ -375,6 +375,8 @@ find_tail_calls (basic_block bb, struct tailcall **ret) tree m, a; basic_block abb; size_t idx; + tree var; + referenced_var_iterator rvi; if (!single_succ_p (bb)) return; @@ -462,6 +464,15 @@ find_tail_calls (basic_block bb, struct tailcall **ret) 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, -- 2.11.4.GIT