| 1 |
/* { dg-additional-options "-mharden-sls=blr -save-temps" } */ |
| 2 |
/* Ensure that the SLS hardening of BLR leaves no BLR instructions. |
| 3 |
We only test that all BLR instructions have been removed, not that the |
| 4 |
resulting code makes sense. */ |
| 5 |
typedef int (foo) (int, int); |
| 6 |
typedef void (bar) (int, int); |
| 7 |
struct sls_testclass { |
| 8 |
foo *x; |
| 9 |
bar *y; |
| 10 |
int left; |
| 11 |
int right; |
| 12 |
}; |
| 13 |
|
| 14 |
/* We test both RTL patterns for a call which returns a value and a call which |
| 15 |
does not. */ |
| 16 |
int blr_call_value (struct sls_testclass x) |
| 17 |
{ |
| 18 |
int retval = x.x(x.left, x.right); |
| 19 |
if (retval % 10) |
| 20 |
return 100; |
| 21 |
return 9; |
| 22 |
} |
| 23 |
|
| 24 |
int blr_call (struct sls_testclass x) |
| 25 |
{ |
| 26 |
x.y(x.left, x.right); |
| 27 |
if (x.left % 10) |
| 28 |
return 100; |
| 29 |
return 9; |
| 30 |
} |
| 31 |
|
| 32 |
/* { dg-final { scan-assembler-not {\tblr\t} } } */ |
| 33 |
/* { dg-final { scan-assembler {\tbr\tx[0-9][0-9]?} } } */ |