| 1 |
/* This is a copy of gcc/testsuite/gcc.c-torture/execute/pr56982.c to test the |
| 2 |
setjmp case of the bti pass. */ |
| 3 |
/* { dg-do run } */ |
| 4 |
/* { dg-require-effective-target lp64 } */ |
| 5 |
/* { dg-require-effective-target aarch64_bti_hw } */ |
| 6 |
/* { dg-options "--save-temps -mbranch-protection=standard" } */ |
| 7 |
|
| 8 |
#include <setjmp.h> |
| 9 |
|
| 10 |
extern void abort (void); |
| 11 |
extern void exit (int); |
| 12 |
|
| 13 |
static jmp_buf env; |
| 14 |
|
| 15 |
void baz (void) |
| 16 |
{ |
| 17 |
__asm__ volatile ("" : : : "memory"); |
| 18 |
} |
| 19 |
|
| 20 |
static inline int g(int x) |
| 21 |
{ |
| 22 |
if (x) |
| 23 |
{ |
| 24 |
baz(); |
| 25 |
return 0; |
| 26 |
} |
| 27 |
else |
| 28 |
{ |
| 29 |
baz(); |
| 30 |
return 1; |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
int f(int *e) |
| 35 |
{ |
| 36 |
if (*e) |
| 37 |
return 1; |
| 38 |
|
| 39 |
int x = setjmp(env); |
| 40 |
int n = g(x); |
| 41 |
if (n == 0) |
| 42 |
exit(0); |
| 43 |
if (x) |
| 44 |
abort(); |
| 45 |
longjmp(env, 42); |
| 46 |
} |
| 47 |
/* { dg-final { scan-assembler "hint\t36" } } */ |
| 48 |
|
| 49 |
int main(int argc, char** argv) |
| 50 |
{ |
| 51 |
int v = 0; |
| 52 |
return f(&v); |
| 53 |
} |