| 1 |
/* Check that indirect sibcalls understand regparm. */ |
| 2 |
/* { dg-do run { target ia32 } } */ |
| 3 |
/* { dg-options "-O2" } */ |
| 4 |
|
| 5 |
extern void abort (void); |
| 6 |
|
| 7 |
int (*f)(int, int) __attribute__((regparm(2))); |
| 8 |
int (*g)(int, int, int) __attribute__((regparm(3))); |
| 9 |
|
| 10 |
int __attribute__((noinline)) |
| 11 |
foo(void) |
| 12 |
{ |
| 13 |
return f(1, 2); |
| 14 |
} |
| 15 |
|
| 16 |
int __attribute__((noinline)) |
| 17 |
bar(void) |
| 18 |
{ |
| 19 |
return g(1, 2, 3); |
| 20 |
} |
| 21 |
|
| 22 |
int __attribute__((regparm(2))) |
| 23 |
f1(int x, int y) |
| 24 |
{ |
| 25 |
return x*3 + y; |
| 26 |
} |
| 27 |
|
| 28 |
int __attribute__((regparm(3))) |
| 29 |
g1(int x, int y, int z) |
| 30 |
{ |
| 31 |
return x*9 + y*3 + z; |
| 32 |
} |
| 33 |
|
| 34 |
int main() |
| 35 |
{ |
| 36 |
f = f1; |
| 37 |
g = g1; |
| 38 |
if (foo() != 1*3 + 2) |
| 39 |
abort (); |
| 40 |
if (bar() != 1*9 + 2*3 + 3) |
| 41 |
abort (); |
| 42 |
return 0; |
| 43 |
} |