| 1 |
/* PR target/29198 */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "-O2 -fpic" } */ |
| 4 |
/* { dg-require-effective-target tls_runtime } */ |
| 5 |
/* { dg-add-options tls } */ |
| 6 |
/* { dg-require-effective-target fpic } */ |
| 7 |
|
| 8 |
extern void abort (void); |
| 9 |
|
| 10 |
int f2 (int, int, int, int); |
| 11 |
struct s { char b[4]; }; |
| 12 |
__thread struct s thra[2]; |
| 13 |
|
| 14 |
void |
| 15 |
__attribute__((noinline)) |
| 16 |
f1 (int a1, int a2) |
| 17 |
{ |
| 18 |
int i, j; |
| 19 |
for (i = 0; i < 4; i++) |
| 20 |
{ |
| 21 |
int tot = 0; |
| 22 |
for (j = 0; j < 4; j++) |
| 23 |
tot += f2 (a1, a2, i, j); |
| 24 |
*(&thra[0].b[0] + i) = tot; |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
int |
| 29 |
__attribute__((noinline)) |
| 30 |
f2 (int a, int b, int c, int d) |
| 31 |
{ |
| 32 |
return a + b + c + d; |
| 33 |
} |
| 34 |
|
| 35 |
int |
| 36 |
main (void) |
| 37 |
{ |
| 38 |
f1 (0, 0); |
| 39 |
if (thra[0].b[0] != 6 |
| 40 |
|| thra[0].b[1] != 10 |
| 41 |
|| thra[0].b[2] != 14 |
| 42 |
|| thra[0].b[3] != 18) |
| 43 |
abort (); |
| 44 |
f1 (2, 3); |
| 45 |
if (thra[0].b[0] != 26 |
| 46 |
|| thra[0].b[1] != 30 |
| 47 |
|| thra[0].b[2] != 34 |
| 48 |
|| thra[0].b[3] != 38) |
| 49 |
abort (); |
| 50 |
return 0; |
| 51 |
} |