PR ipa/61602
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / tls / tls-reload-1.c
blobbd9a0b891a465dde61cd03d424f210252bf8ec2e
1 /* { dg-do run } */
2 /* { dg-require-effective-target tls_runtime } */
3 /* { dg-add-options tls } */
5 #define ARRAY(X) X##_array
6 #define DECLARE(X) \
7 __thread int X; \
8 __thread int ARRAY(X)[4]; \
9 int *volatile *__attribute__((noinline)) \
10 check##X (int *volatile *y) \
11 { \
12 if (!y || *y++ != &X || *y++ != &ARRAY(X)[3]) \
13 return 0; \
14 return y; \
16 #define COPY(X) *y++ = &X; *y++ = &ARRAY(X)[3];
17 #define CHECK(X) y = check##X (y);
18 #define A(M, X) M(X##0) M(X##1) M(X##2) M(X##3) M(X##4) M(X##5) M(X##6) M(X##7)
19 #define B(M, X) A(M, X##0) A(M, X##1) A(M, X##2)
20 #define C(M, X) B(M, X) B(M, X) B(M, X)
22 #define NM 2
23 #define NA (NM * 8)
24 #define NB (NA * 3)
25 #define NC (NB * 3)
27 extern void abort (void);
29 B(DECLARE, tls)
31 void __attribute__ ((noinline))
32 setup (int *volatile *y)
34 C(COPY, tls)
37 int
38 main (void)
40 int *volatile array[NC];
41 int *volatile *y = array;
42 int i;
44 setup (array);
45 C(CHECK, tls);
46 if (!y)
47 abort ();
48 return 0;