| 1 |
/* ARM's load-and-call patterns used to allow automodified addresses. |
| 2 |
This was wrong, because if the modified register were spilled, |
| 3 |
the call would need an output reload. */ |
| 4 |
/* { dg-do run } */ |
| 5 |
/* { dg-options "-O2 -fno-omit-frame-pointer" } */ |
| 6 |
/* { dg-skip-if "r9 is reserved in FDPIC" { arm*-*-uclinuxfdpiceabi } "*" "" } */ |
| 7 |
extern void abort (void); |
| 8 |
typedef void (*callback) (void); |
| 9 |
|
| 10 |
static void |
| 11 |
foo (callback *first, callback *p) |
| 12 |
{ |
| 13 |
while (p > first) |
| 14 |
{ |
| 15 |
(*--p) (); |
| 16 |
#ifndef __thumb__ |
| 17 |
asm ("" : "=r" (p) : "0" (p) |
| 18 |
: "r4", "r5", "r6", "r7", "r8", "r9", "r10"); |
| 19 |
#endif |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
static void |
| 24 |
dummy (void) |
| 25 |
{ |
| 26 |
static int count; |
| 27 |
if (count++ == 1) |
| 28 |
abort (); |
| 29 |
} |
| 30 |
|
| 31 |
int |
| 32 |
main (void) |
| 33 |
{ |
| 34 |
callback list[1] = { dummy }; |
| 35 |
foo (&list[0], &list[1]); |
| 36 |
return 0; |
| 37 |
} |