aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@redhat.com>2004-09-15 02:58:28 +0000
committerDiego Novillo <dnovillo@gcc.gnu.org>2004-09-14 22:58:28 -0400
commit391f9afbd2d6ac8dd691c6d79a8817c63a637ca8 (patch)
tree1e2d0774d13dac9492acaed1a577afad8dd177c7
parent67f236204409bd498339b92c65fdb031344e8e36 (diff)
downloadgcc-391f9afbd2d6ac8dd691c6d79a8817c63a637ca8.zip
gcc-391f9afbd2d6ac8dd691c6d79a8817c63a637ca8.tar.gz
gcc-391f9afbd2d6ac8dd691c6d79a8817c63a637ca8.tar.bz2
re PR tree-optimization/17252 (not marking char types as aliasing anything)
PR tree-optimization/17252 * tree-ssa-alias.c (may_alias_p): Don't assume that a pointer may not point to itself when using relaxed aliasing rules. testsuite/ChangeLog PR tree-optimization/17252 * gcc.c-torture/execute/pr17252.c: New test. From-SVN: r87529
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr17252.c24
-rw-r--r--gcc/tree-ssa-alias.c3
4 files changed, 38 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ff7e392..a2f169c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2004-09-14 Diego Novillo <dnovillo@redhat.com>
+
+ PR tree-optimization/17252
+ * tree-ssa-alias.c (may_alias_p): Don't assume that a
+ pointer may not point to itself when using relaxed
+ aliasing rules.
+
2004-09-14 Richard Henderson <rth@redhat.com>
PR middle-end/17397
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 78de08e..61744bf 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2004-09-14 Diego Novillo <dnovillo@redhat.com>
+
+ PR tree-optimization/17252
+ * gcc.c-torture/execute/pr17252.c: New test.
+
2004-09-14 Andrew Pinski <apinski@apple.com>
* g++.dg/tree-ssa/pointer-reference-alias.C: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr17252.c b/gcc/testsuite/gcc.c-torture/execute/pr17252.c
new file mode 100644
index 0000000..e31622f
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr17252.c
@@ -0,0 +1,24 @@
+/* PR 17252. When a char * pointer P takes its own address, storing
+ into *P changes P itself. */
+
+char *a;
+
+main ()
+{
+ int i;
+
+ /* Make 'a' point to itself. */
+ a = (char *)&a;
+
+ /* Assign NULL to 'a' byte by byte. */
+ for (i = 0; i < sizeof(char *); i++)
+ a[i] = 0;
+
+ /* If a's memory tag does not contain 'a' in its alias set, we will
+ think that this predicate is superfluous and change it to
+ 'if (1)'. */
+ if (a == (char *)&a)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 65b0d7b..801de5b 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -1558,7 +1558,8 @@ may_alias_p (tree ptr, HOST_WIDE_INT mem_alias_set,
for PTR's alias set here, not its pointed-to type. We also can't
do this check with relaxed aliasing enabled. */
if (POINTER_TYPE_P (TREE_TYPE (var))
- && var_alias_set != 0)
+ && var_alias_set != 0
+ && mem_alias_set != 0)
{
HOST_WIDE_INT ptr_alias_set = get_alias_set (ptr);
if (ptr_alias_set == var_alias_set)