Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/pr15296.c

raw
1 /* PR optimization/15296. The delayed-branch scheduler caused code that
2 SEGV:d for CRIS; a register was set to -1 in a delay-slot for the
3 fall-through code, while that register held a pointer used in code at
4 the branch target. */
5
6 void abort (void);
7 void exit (int);
8
9 typedef __INTPTR_TYPE__ intptr_t;
10 typedef intptr_t W;
11 union u0
12 {
13 union u0 *r;
14 W i;
15 };
16 struct s1
17 {
18 union u0 **m0;
19 union u0 m1[4];
20 };
21
22 void f (void *, struct s1 *, const union u0 *, W, W, W)
23 __attribute__ ((__noinline__));
24 void g (void *, char *) __attribute__ ((__noinline__));
25
26 void
27 f (void *a, struct s1 *b, const union u0 *h, W v0, W v1, W v4)
28 {
29 union u0 *e = 0;
30 union u0 *k = 0;
31 union u0 **v5 = b->m0;
32 union u0 *c = b->m1;
33 union u0 **d = &v5[0];
34 l0:;
35 if (v0 < v1)
36 goto l0;
37 if (v0 == 0)
38 goto l3;
39 v0 = v4;
40 if (v0 != 0)
41 goto l3;
42 c[0].r = *d;
43 v1 = -1;
44 e = c[0].r;
45 if (e != 0)
46 g (a, "");
47 k = e + 3;
48 k->i = v1;
49 goto l4;
50 l3:;
51 c[0].i = v0;
52 e = c[1].r;
53 if (e != 0)
54 g (a, "");
55 e = c[0].r;
56 if (e == 0)
57 g (a, "");
58 k = e + 2;
59 k->r = c[1].r;
60 l4:;
61 }
62
63 void g (void *a, char *b) { abort (); }
64
65 int
66 main ()
67 {
68 union u0 uv[] = {{ .i = 111 }, { .i = 222 }, { .i = 333 }, { .i = 444 }};
69 struct s1 s = { 0, {{ .i = 555 }, { .i = 0 }, { .i = 999 }, { .i = 777 }}};
70 f (0, &s, 0, 20000, 10000, (W) uv);
71 if (s.m1[0].i != (W) uv || s.m1[1].i != 0 || s.m1[2].i != 999
72 || s.m1[3].i != 777 || uv[0].i != 111 || uv[1].i != 222
73 || uv[2].i != 0 || uv[3].i != 444)
74 abort ();
75 exit (0);
76 }