| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -fno-inline" } */ |
| 3 |
|
| 4 |
/* Test that targets correctly round the size of the outgoing arguments |
| 5 |
to a multiple of STACK_BOUNDARY. There is a serious alignment bug if |
| 6 |
aligned alloca does not get aligned! */ |
| 7 |
|
| 8 |
__extension__ typedef __UINTPTR_TYPE__ uintptr_t; |
| 9 |
extern void abort (void); |
| 10 |
|
| 11 |
volatile int xx; |
| 12 |
volatile int x = 16; |
| 13 |
|
| 14 |
void |
| 15 |
t1 (int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7, |
| 16 |
void *p, int align) |
| 17 |
{ |
| 18 |
xx = x0 + x1 + x2 + x3 + x4 + x4 + x6 + x7; |
| 19 |
if ((int)(uintptr_t)p & (align-1)) |
| 20 |
abort (); |
| 21 |
} |
| 22 |
|
| 23 |
void |
| 24 |
t2 (int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7, |
| 25 |
void *p, int align, int dummy) |
| 26 |
{ |
| 27 |
xx = x0 + x1 + x2 + x3 + x4 + x4 + x6 + x7; |
| 28 |
if ((int)(uintptr_t)p & (align-1)) |
| 29 |
abort (); |
| 30 |
} |
| 31 |
|
| 32 |
void |
| 33 |
t1_a4 (int size) |
| 34 |
{ |
| 35 |
void *p = __builtin_alloca_with_align (size, 32); |
| 36 |
t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 4); |
| 37 |
} |
| 38 |
|
| 39 |
void |
| 40 |
t2_a4 (int size) |
| 41 |
{ |
| 42 |
void *p = __builtin_alloca_with_align (size, 32); |
| 43 |
t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 4, 0); |
| 44 |
} |
| 45 |
|
| 46 |
void |
| 47 |
t1_a8 (int size) |
| 48 |
{ |
| 49 |
void *p = __builtin_alloca_with_align (size, 64); |
| 50 |
t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 8); |
| 51 |
} |
| 52 |
|
| 53 |
void |
| 54 |
t2_a8 (int size) |
| 55 |
{ |
| 56 |
void *p = __builtin_alloca_with_align (size, 64); |
| 57 |
t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 8, 0); |
| 58 |
} |
| 59 |
|
| 60 |
void |
| 61 |
t1_a16 (int size) |
| 62 |
{ |
| 63 |
void *p = __builtin_alloca_with_align (size, 128); |
| 64 |
t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 16); |
| 65 |
} |
| 66 |
|
| 67 |
void |
| 68 |
t2_a16 (int size) |
| 69 |
{ |
| 70 |
void *p = __builtin_alloca_with_align (size, 128); |
| 71 |
t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 16, 0); |
| 72 |
} |
| 73 |
|
| 74 |
void |
| 75 |
t1_a32 (int size) |
| 76 |
{ |
| 77 |
void *p = __builtin_alloca_with_align (size, 256); |
| 78 |
t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 32); |
| 79 |
} |
| 80 |
|
| 81 |
void |
| 82 |
t2_a32 (int size) |
| 83 |
{ |
| 84 |
void *p = __builtin_alloca_with_align (size, 256); |
| 85 |
t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 32, 0); |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
int |
| 90 |
main () |
| 91 |
{ |
| 92 |
t1_a4 (x); |
| 93 |
t2_a4 (x); |
| 94 |
t1_a8 (x); |
| 95 |
t2_a8 (x); |
| 96 |
t1_a16 (x); |
| 97 |
t2_a16 (x); |
| 98 |
t1_a32 (x); |
| 99 |
t2_a32 (x); |
| 100 |
return 0; |
| 101 |
} |