From 38eb12ee900742181232bfb195f173e7aab8a965 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 12 Jul 2018 13:19:03 +0200 Subject: [PATCH] * gcc.dg/torture/20180712-1.c: New test. From-SVN: r262579 --- gcc/testsuite/ChangeLog | 2 + gcc/testsuite/gcc.dg/torture/20180712-1.c | 76 +++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/20180712-1.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5992e0d56d4..4ce5afdc416 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2018-07-12 Jakub Jelinek + * 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 00000000000..3ac2c7f9f54 --- /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; +} -- 2.30.2