| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2" } */ |
| 3 |
|
| 4 |
/* Technically we shouldn't save any register for this function: it should be |
| 5 |
compiled as if it accepts 3 named arguments. But AFAIK no compilers can |
| 6 |
achieve this "perfect" optimization now, so just ensure we are using the |
| 7 |
knowledge provided by stdarg pass and we won't save GARs impossible to be |
| 8 |
accessed with __builtin_va_arg () when the va_list does not escape. */ |
| 9 |
|
| 10 |
/* { dg-final { scan-assembler-not "st.*r7" } } */ |
| 11 |
|
| 12 |
int |
| 13 |
test (int a0, ...) |
| 14 |
{ |
| 15 |
void *arg; |
| 16 |
int a1, a2; |
| 17 |
|
| 18 |
__builtin_va_start (arg, a0); |
| 19 |
a1 = __builtin_va_arg (arg, int); |
| 20 |
a2 = __builtin_va_arg (arg, int); |
| 21 |
__builtin_va_end (arg); |
| 22 |
|
| 23 |
return a0 + a1 + a2; |
| 24 |
} |