| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-mdejagnu-cpu=power10 -O2" } */ |
| 3 |
/* { dg-require-effective-target powerpc_elfv2 } */ |
| 4 |
/* { dg-require-effective-target power10_ok } */ |
| 5 |
|
| 6 |
/* Test that potential sibcalls are generated when the caller does not |
| 7 |
preserve the TOC, even for external calls; and that sibcalls are not |
| 8 |
generated when the caller preserves the TOC but the callee does not. */ |
| 9 |
|
| 10 |
#pragma GCC target ("cpu=power10,pcrel") |
| 11 |
int x (void) __attribute__((noipa)); |
| 12 |
int y (void) __attribute__((noipa)); |
| 13 |
int xx (void) __attribute__((noipa)); |
| 14 |
|
| 15 |
int x (void) |
| 16 |
{ |
| 17 |
return 1; |
| 18 |
} |
| 19 |
|
| 20 |
int y (void) |
| 21 |
{ |
| 22 |
return 2; |
| 23 |
} |
| 24 |
|
| 25 |
int sib_call (void) |
| 26 |
{ |
| 27 |
return x (); |
| 28 |
} |
| 29 |
|
| 30 |
#pragma GCC target ("cpu=power9,no-pcrel") |
| 31 |
int normal_call (void) |
| 32 |
{ |
| 33 |
return y (); |
| 34 |
} |
| 35 |
|
| 36 |
int xx (void) |
| 37 |
{ |
| 38 |
return 1; |
| 39 |
} |
| 40 |
|
| 41 |
extern int yy (void); |
| 42 |
|
| 43 |
#pragma GCC target ("cpu=power10,pcrel") |
| 44 |
int notoc_sibcall (void) |
| 45 |
{ |
| 46 |
return xx (); |
| 47 |
} |
| 48 |
|
| 49 |
int extern_sibcall (void) |
| 50 |
{ |
| 51 |
return yy (); |
| 52 |
} |
| 53 |
|
| 54 |
/* { dg-final { scan-assembler {\mb x@notoc\M} } } */ |
| 55 |
/* { dg-final { scan-assembler {\mbl y\M} } } */ |
| 56 |
/* { dg-final { scan-assembler {\mb xx@notoc\M} } } */ |
| 57 |
/* { dg-final { scan-assembler {\mb yy@notoc\M} } } */ |