re PR tree-optimization/17252 (not marking char types as aliasing anything)
authorDiego Novillo <dnovillo@redhat.com>
Wed, 15 Sep 2004 02:58:28 +0000 (02:58 +0000)
committerDiego Novillo <dnovillo@gcc.gnu.org>
Wed, 15 Sep 2004 02:58:28 +0000 (22:58 -0400)
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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr17252.c [new file with mode: 0644]
gcc/tree-ssa-alias.c

index ff7e392a1779bd6e05cba307584fe3e9ea4021ee..a2f169c575d0a1c2d3a705ef3da0b83947aa5a20 100644 (file)
@@ -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
index 78de08e73e3434afae789b7c5f87004212807ad0..61744bf33f7e11109b5aef8dd25217b3b665b5e9 100644 (file)
@@ -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 (file)
index 0000000..e31622f
--- /dev/null
@@ -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;
+}
index 65b0d7bc776e75f89c9883934ebf8cd236318c59..801de5bfaa5bea5c7d7eb95342443e591d1ede28 100644 (file)
@@ -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)