2009-11-08 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 8 Nov 2009 15:27:17 +0000 (15:27 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 8 Nov 2009 15:27:17 +0000 (15:27 +0000)
* 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
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pta-escape-1.c [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index 638d9a4..41f5b64 100644 (file)
@@ -1,5 +1,10 @@
 2009-11-08  Richard Guenther  <rguenther@suse.de>
 
+       * tree-ssa-structalias.c (build_succ_graph): Properly make
+       variables escape if they are stored to anything.
+
+2009-11-08  Richard Guenther  <rguenther@suse.de>
+
        PR rtl-optimization/41928
        * loop-invariant.c (free_loop_data): If we didn't allocate
        loop data do not try to free it.
index 73021d0..9282ec3 100644 (file)
@@ -1,3 +1,7 @@
+2009-11-08  Richard Guenther  <rguenther@suse.de>
+
+       * gcc.dg/torture/pta-escape-1.c: New testcase.
+
 2009-11-08  Eric Botcazou  <ebotcazou@adacore.com>
 
        * 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 (file)
index 0000000..39aefb5
--- /dev/null
@@ -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" } } */
index 619875c..e0a681d 100644 (file)
@@ -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);
 }