| 1 |
/* builtin_return_address(n) with n>0 has always been troublesome ... |
| 2 |
especially when the S/390 packed stack layout comes into play. */ |
| 3 |
|
| 4 |
/* { dg-do run } */ |
| 5 |
/* { dg-options "-O3 -fno-optimize-sibling-calls -mbackchain -mpacked-stack -msoft-float" } */ |
| 6 |
|
| 7 |
void *addr1; |
| 8 |
|
| 9 |
extern void abort (void); |
| 10 |
|
| 11 |
void * __attribute__((noinline)) |
| 12 |
foo1 () |
| 13 |
{ |
| 14 |
addr1 = __builtin_return_address (2); |
| 15 |
} |
| 16 |
|
| 17 |
void * __attribute__((noinline)) |
| 18 |
foo2 () |
| 19 |
{ |
| 20 |
foo1 (); |
| 21 |
} |
| 22 |
|
| 23 |
void * __attribute__((noinline)) |
| 24 |
foo3 () |
| 25 |
{ |
| 26 |
foo2 (); |
| 27 |
} |
| 28 |
|
| 29 |
void __attribute__((noinline)) |
| 30 |
bar () |
| 31 |
{ |
| 32 |
void *addr2; |
| 33 |
|
| 34 |
foo3 (); |
| 35 |
asm volatile ("basr %0,0\n\t" : "=d" (addr2)); |
| 36 |
/* basr is two bytes in length. */ |
| 37 |
if (addr2 - addr1 != 2) |
| 38 |
abort (); |
| 39 |
} |
| 40 |
|
| 41 |
int |
| 42 |
main () |
| 43 |
{ |
| 44 |
bar(); |
| 45 |
return 0; |
| 46 |
} |