re PR middle-end/55430 (LRA miscompilation of ree.c)
authorJakub Jelinek <jakub@redhat.com>
Fri, 23 Nov 2012 15:12:58 +0000 (16:12 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 23 Nov 2012 15:12:58 +0000 (16:12 +0100)
PR middle-end/55430
* gcc.dg/pr55430.c: New test.

From-SVN: r193757

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr55430.c [new file with mode: 0644]

index 74a120d1c0d1a0bc0b1b7cdbfbdedbcee87da907..ee90eeb74bde6fdf43415ae2bfdb845f048e96c8 100644 (file)
@@ -1,3 +1,8 @@
+2012-11-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/55430
+       * gcc.dg/pr55430.c: New test.
+
 2012-11-23  Kostya Serebryany  <kcc@google.com>
 
        * c-c++-common/asan/memcmp-1.c: Update to match the new libsanitizer.
diff --git a/gcc/testsuite/gcc.dg/pr55430.c b/gcc/testsuite/gcc.dg/pr55430.c
new file mode 100644 (file)
index 0000000..dda02f3
--- /dev/null
@@ -0,0 +1,43 @@
+/* PR middle-end/55430 */
+/* { dg-do run { target mmap } } */
+/* { dg-options "-O2" } */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <sys/mman.h>
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+#ifndef MAP_ANON
+#define MAP_ANON 0
+#endif
+#include <stdlib.h>
+
+struct S
+{
+  unsigned int s1 : 8;
+  unsigned int s2 : 2;
+};
+
+__attribute__((noinline, noclone)) int
+foo (int x, int y, struct S *z, unsigned int w)
+{
+  if (z[y].s2 == x && z[y].s1 == w)
+    return 1;
+  return 0;
+}
+
+int
+main ()
+{
+  char *p = mmap (NULL, 131072, PROT_READ | PROT_WRITE,
+                 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+  if (p == MAP_FAILED)
+    return 0;
+  if (munmap (p + 65536, 65536) < 0)
+    return 0;
+  if ((65536 / sizeof (struct S)) * sizeof (struct S) != 65536)
+    return 0;
+  struct S *s = (struct S *) (p + 65536);
+  return foo (0, 0, s - 1, 0) != 1;
+}