Debian Codegraph @

gcc/testsuite/gcc.dg/pr47893.c

raw
1 /* PR middle-end/47893 */
2 /* { dg-do run } */
3 /* { dg-options "-O2" } */
4 /* { dg-additional-options "-mtune=atom -fno-omit-frame-pointer -fno-strict-aliasing" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
5 /* { dg-skip-if "Too much RAM needed" { "avr-*-*" } } */
6 /* About 50 KB code, 33 KB stack, too big for byte-addressed
7 von Neumann targets with 16 bit addresses. */
8 /* { dg-require-effective-target size20plus } */
9
10 extern void abort (void);
11
12 struct S
13 {
14 unsigned s1:4, s2:2, s3:2, s4:2, s5:2, s6:1, s7:1, s8:1, s9:1, s10:1;
15 int s11:16; unsigned s12:4; int s13:16; unsigned s14:2;
16 int s15:16; unsigned s16:4; int s17:16; unsigned s18:2;
17 };
18
19 struct T
20 {
21 unsigned t[3];
22 };
23
24 struct U
25 {
26 unsigned u1, u2;
27 };
28
29 struct V;
30
31 struct W
32 {
33 char w1[24]; struct V *w2; unsigned w3; char w4[28912];
34 unsigned int w5; char w6[60];
35 };
36
37 struct X
38 {
39 unsigned int x[2];
40 };
41
42 struct V
43 {
44 int v1;
45 struct X v2[3];
46 char v3[28];
47 };
48
49 struct Y
50 {
51 void *y1;
52 char y2[3076];
53 struct T y3[32];
54 char y4[1052];
55 };
56
57 volatile struct S v1 = { .s15 = -1, .s16 = 15, .s17 = -1, .s18 = 3 };
58
59 __attribute__ ((noinline, noclone))
60 int
61 fn1 (int x)
62 {
63 int r;
64 __asm__ volatile ("" : "=r" (r) : "0" (1), "r" (x) : "memory");
65 return r;
66 }
67
68 volatile int cnt;
69
70 __attribute__ ((noinline, noclone))
71 #ifdef __i386__
72 __attribute__ ((regparm (2)))
73 #endif
74 struct S
75 fn2 (struct Y *x, const struct X *y)
76 {
77 if (++cnt > 1)
78 abort ();
79 __asm__ volatile ("" : : "r" (x), "r" (y) : "memory");
80 return v1;
81 }
82
83 __attribute__ ((noinline, noclone))
84 void fn3 (void *x, unsigned y, const struct S *z, unsigned w)
85 {
86 __asm__ volatile ("" : : "r" (x), "r" (y), "r" (z), "r" (w) : "memory");
87 }
88
89 volatile struct U v2;
90
91 __attribute__ ((noinline, noclone))
92 struct U
93 fn4 (void *x, unsigned y)
94 {
95 __asm__ volatile ("" : : "r" (x), "r" (y) : "memory");
96 return v2;
97 }
98
99 __attribute__ ((noinline, noclone))
100 struct S
101 fn5 (void *x)
102 {
103 __asm__ volatile ("" : : "r" (x) : "memory");
104 return v1;
105 }
106
107 volatile struct T v3;
108
109 __attribute__ ((noinline, noclone))
110 struct T fn6 (void *x)
111 {
112 __asm__ volatile ("" : : "r" (x) : "memory");
113 return v3;
114 }
115
116 __attribute__ ((noinline, noclone))
117 struct T fn7 (void *x, unsigned y, unsigned z)
118 {
119 __asm__ volatile ("" : : "r" (x), "r" (y), "r" (z) : "memory");
120 return v3;
121 }
122
123 static void
124 fn8 (struct Y *x, const struct V *y)
125 {
126 void *a = x->y1;
127 struct S b[4];
128 unsigned i, c;
129 c = fn1 (y->v1);
130 for (i = 0; i < c; i++)
131 b[i] = fn2 (x, &y->v2[i]);
132 fn3 (a, y->v1, b, c);
133 }
134
135 static inline void
136 fn9 (void *x, struct S y __attribute__((unused)))
137 {
138 fn4 (x, 8);
139 }
140
141 static void
142 fn10 (struct Y *x)
143 {
144 void *a = x->y1;
145 struct T b __attribute__((unused)) = fn6 (a);
146 fn9 (a, fn5 (a));
147 }
148
149 __attribute__((noinline, noclone))
150 int
151 fn11 (unsigned int x, void *y, const struct W *z,
152 unsigned int w, const char *v, const char *u)
153 {
154 struct Y a, *t;
155 unsigned i;
156 t = &a;
157 __builtin_memset (t, 0, sizeof *t);
158 t->y1 = y;
159 if (x == 0)
160 {
161 if (z->w3 & 1)
162 fn10 (t);
163 for (i = 0; i < w; i++)
164 {
165 if (v[i] == 0)
166 t->y3[i] = fn7 (y, 0, u[i]);
167 else
168 return 0;
169 }
170 }
171 else
172 for (i = 0; i < w; i++)
173 t->y3[i] = fn7 (y, v[i], u[i]);
174 for (i = 0; i < z->w5; i++)
175 fn8 (t, &z->w2[i]);
176 return 0;
177 }
178
179 volatile int i;
180 const char *volatile p = "";
181
182 int
183 main ()
184 {
185 struct V v = { .v1 = 0 };
186 struct W w = { .w5 = 1, .w2 = &v };
187 fn11 (i + 1, (void *) p, &w, i, (const char *) p, (const char *) p);
188 if (cnt != 1)
189 abort ();
190 return 0;
191 }