OSDN Git Service

2010-04-30 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 30 Apr 2010 08:22:15 +0000 (08:22 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 30 Apr 2010 08:22:15 +0000 (08:22 +0000)
PR tree-optimization/43879
* tree-ssa-structalias.c (get_constraint_for_1): Properly
handle non-zero initializers.

* gcc.dg/torture/pr43879_1.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158924 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr43879_1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr43879_2.c [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index d20e202..936a838 100644 (file)
@@ -1,5 +1,11 @@
 2010-04-30  Richard Guenther  <rguenther@suse.de>
 
+       PR tree-optimization/43879
+       * tree-ssa-structalias.c (get_constraint_for_1): Properly
+       handle non-zero initializers.
+
+2010-04-30  Richard Guenther  <rguenther@suse.de>
+
        * builtins.c (fold_builtin_1): Delete free (0).
 
 2010-04-29  Jan HUbicka  <jh@suse.cz>
index cf678b8..f3284dc 100644 (file)
@@ -1,5 +1,10 @@
 2010-04-30  Richard Guenther  <rguenther@suse.de>
 
+       PR tree-optimization/43879
+       * gcc.dg/torture/pr43879_1.c: New testcase.
+
+2010-04-30  Richard Guenther  <rguenther@suse.de>
+
        * gcc.dg/tree-ssa/builtin-free.c: New testcase.
 
 2010-04-29  Fabien ChĂȘne  <fabien.chene@gmail.com>
diff --git a/gcc/testsuite/gcc.dg/torture/pr43879_1.c b/gcc/testsuite/gcc.dg/torture/pr43879_1.c
new file mode 100644 (file)
index 0000000..151a184
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+/* { dg-options "-fipa-pta" } */
+/* { dg-additional-sources "pr43879_2.c" } */
+
+void bar(int c)
+{
+       static int x = 1;
+       if (c != x) __builtin_abort();
+       x--;
+}
+
+void baz(int *i)
+{
+       (*i)--;
+}
+
+struct TBL {
+       int (*p)(int *i);
+};
+extern struct TBL tbl;
+
+int main()
+{
+       int c = 1;
+       return tbl.p(&c);
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr43879_2.c b/gcc/testsuite/gcc.dg/torture/pr43879_2.c
new file mode 100644 (file)
index 0000000..8155653
--- /dev/null
@@ -0,0 +1,17 @@
+struct TBL {
+       int (*p)(int *i);
+};
+
+extern void bar(int i);
+extern void baz(int *i);
+
+static int foo(int *i)
+{
+       bar(*i);
+       baz(i);
+       bar(*i);
+       return *i;
+}
+
+struct TBL tbl = { foo };
+
index 08d3fa7..928dc04 100644 (file)
@@ -3285,8 +3285,10 @@ get_constraint_for_1 (tree t, VEC (ce_s, heap) **results, bool address_p)
       && ((TREE_CODE (t) == INTEGER_CST
           && integer_zerop (t))
          /* The only valid CONSTRUCTORs in gimple with pointer typed
-            elements are zero-initializer.  */
-         || TREE_CODE (t) == CONSTRUCTOR))
+            elements are zero-initializer.  But in IPA mode we also
+            process global initializers, so verify at least.  */
+         || (TREE_CODE (t) == CONSTRUCTOR
+             && CONSTRUCTOR_NELTS (t) == 0)))
     {
       temp.var = nothing_id;
       temp.type = ADDRESSOF;