aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-07-12 13:19:03 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2018-07-12 13:19:03 +0200
commit38eb12ee900742181232bfb195f173e7aab8a965 (patch)
treeb77d8cd6d8a4ba679676c98917ab4453e5fa65b1 /gcc
parentd9931da9b7941e375c78196a6b93897e79b65e51 (diff)
downloadgcc-38eb12ee900742181232bfb195f173e7aab8a965.zip
gcc-38eb12ee900742181232bfb195f173e7aab8a965.tar.gz
gcc-38eb12ee900742181232bfb195f173e7aab8a965.tar.bz2
* gcc.dg/torture/20180712-1.c: New test.
From-SVN: r262579
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/gcc.dg/torture/20180712-1.c76
2 files changed, 78 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5992e0d..4ce5afd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,7 @@
2018-07-12 Jakub Jelinek <jakub@redhat.com>
+ * gcc.dg/torture/20180712-1.c: New test.
+
PR tree-optimization/86492
* gcc.c-torture/execute/pr86492.c: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/20180712-1.c b/gcc/testsuite/gcc.dg/torture/20180712-1.c
new file mode 100644
index 0000000..3ac2c7f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/20180712-1.c
@@ -0,0 +1,76 @@
+/* { dg-do run } */
+/* { dg-additional-options "-fstack-protector" { target fstack_protector } } */
+/* { dg-additional-options "-fPIC" { target fpic } } */
+
+struct S { int *l, *u; };
+int a[3];
+
+__attribute__((noipa)) struct S
+foo (void)
+{
+ int *p = a, *q = a + 1;
+ struct S s;
+ asm volatile ("" : "+g" (p), "+g" (q) : : "memory");
+ s.l = p;
+ s.u = q;
+ a[0]++;
+ return s;
+}
+
+__attribute__((noipa)) void
+bar (struct S *x)
+{
+ asm volatile ("" : : "g" (x) : "memory");
+ if (x->l != a || x->u != a + 1)
+ __builtin_abort ();
+ a[1]++;
+}
+
+__attribute__((noipa)) int
+baz (int *x, int *y)
+{
+ int r = -1;
+ asm volatile ("" : "+g" (r) : "g" (x), "g" (y) : "memory");
+ a[2]++;
+ return r;
+}
+
+__attribute__((noipa)) void
+quux (void)
+{
+ asm volatile ("" : : : "memory");
+}
+
+__attribute__((noipa)) void
+qux (void)
+{
+ struct S v = foo ();
+ struct S w;
+ struct S x = foo ();
+ int y = 0;
+
+ w.l = x.l;
+ w.u = x.u;
+ if (baz (x.l, v.l) > 0)
+ {
+ w.l = v.l;
+ y = 1;
+ quux ();
+ }
+ if (baz (x.u, v.u) < 0)
+ {
+ w.u = v.u;
+ y = 1;
+ }
+ if (y)
+ bar (&w);
+}
+
+int
+main ()
+{
+ qux ();
+ if (a[0] != 2 || a[1] != 1 || a[2] != 2)
+ __builtin_abort ();
+ return 0;
+}