From 44e93845c140fa916c1f3de91f085971bed77f82 Mon Sep 17 00:00:00 2001 From: rguenth Date: Sun, 8 Nov 2009 15:27:17 +0000 Subject: [PATCH] 2009-11-08 Richard Guenther * tree-ssa-structalias.c (build_succ_graph): Properly make variables escape if they are stored to anything. * gcc.dg/torture/pta-escape-1.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154010 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/torture/pta-escape-1.c | 34 +++++++++++++++++++++++++++++ gcc/tree-ssa-structalias.c | 3 +++ 4 files changed, 46 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/pta-escape-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 638d9a4d0ce..41f5b64b411 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2009-11-08 Richard Guenther + * tree-ssa-structalias.c (build_succ_graph): Properly make + variables escape if they are stored to anything. + +2009-11-08 Richard Guenther + PR rtl-optimization/41928 * loop-invariant.c (free_loop_data): If we didn't allocate loop data do not try to free it. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 73021d0e21b..9282ec3325c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-11-08 Richard Guenther + + * gcc.dg/torture/pta-escape-1.c: New testcase. + 2009-11-08 Eric Botcazou * gnat.dg/rep_clause4.adb: New test. diff --git a/gcc/testsuite/gcc.dg/torture/pta-escape-1.c b/gcc/testsuite/gcc.dg/torture/pta-escape-1.c new file mode 100644 index 00000000000..39aefb54310 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pta-escape-1.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-options "-fdump-tree-alias" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ + +int *p; +void __attribute__((noinline,noclone)) +bar (void) +{ + *p = 1; +} +int __attribute__((noinline,noclone)) +foo (__SIZE_TYPE__ addr) +{ + int i; + /* q points to ANYTHING */ + int **q = (int **)addr; + /* this store needs to cause i to escape */ + *q = &i; + i = 0; + /* and thus be clobbered by this function call */ + bar (); + return i; +} +extern void abort (void); +int +main() +{ + if (foo ((__SIZE_TYPE__)&p) != 1) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "ESCAPED = { i }" "alias" } } */ +/* { dg-final { cleanup-tree-dump "alias" } } */ diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 619875c048d..e0a681db2f2 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -1278,6 +1278,9 @@ build_succ_graph (void) && get_varinfo (i)->may_have_pointers) add_graph_edge (graph, find (i), t); } + + /* Everything stored to ANYTHING also potentially escapes. */ + add_graph_edge (graph, find (escaped_id), t); } -- 2.11.0