From: Richard Guenther Date: Fri, 30 Apr 2010 08:22:15 +0000 (+0000) Subject: re PR tree-optimization/43879 (-fipa-pta causes various miscompilations) X-Git-Tag: releases/gcc-4.6.0~7569 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4be68d9a2d50985d79835f109a46d7665eec721a;p=thirdparty%2Fgcc.git re PR tree-optimization/43879 (-fipa-pta causes various miscompilations) 2010-04-30 Richard Guenther 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. From-SVN: r158924 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d20e202253c2..936a83861376 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-04-30 Richard Guenther + + PR tree-optimization/43879 + * tree-ssa-structalias.c (get_constraint_for_1): Properly + handle non-zero initializers. + 2010-04-30 Richard Guenther * builtins.c (fold_builtin_1): Delete free (0). diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cf678b87ef39..f3284dc07adc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-04-30 Richard Guenther + + PR tree-optimization/43879 + * gcc.dg/torture/pr43879_1.c: New testcase. + 2010-04-30 Richard Guenther * gcc.dg/tree-ssa/builtin-free.c: New testcase. diff --git a/gcc/testsuite/gcc.dg/torture/pr43879_1.c b/gcc/testsuite/gcc.dg/torture/pr43879_1.c new file mode 100644 index 000000000000..151a184cb19d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr43879_1.c @@ -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 index 000000000000..8155653a6279 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr43879_2.c @@ -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 }; + diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 08d3fa7e15b2..928dc04d131d 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -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;