| 1 |
/* Check local register variables using a register conventionally |
| 2 |
used as the frame pointer aren't clobbered under high register pressure. */ |
| 3 |
/* { dg-do run } */ |
| 4 |
/* { dg-skip-if "incompatible options" { ! { arm_thumb1_ok || arm_thumb2_ok } } } */ |
| 5 |
/* { dg-options "-Os -mthumb -fomit-frame-pointer" } */ |
| 6 |
|
| 7 |
#include <stdlib.h> |
| 8 |
|
| 9 |
int global=5; |
| 10 |
|
| 11 |
void __attribute__((noinline)) foo(int p1, int p2, int p3, int p4) |
| 12 |
{ |
| 13 |
if (global != 5 || p1 != 1 || p2 != 2 || p3 != 3 || p4 != 4) |
| 14 |
abort(); |
| 15 |
} |
| 16 |
|
| 17 |
int __attribute__((noinline)) test(int a, int b, int c, int d) |
| 18 |
{ |
| 19 |
register unsigned long r __asm__("r7") = 0xdeadbeef; |
| 20 |
int e; |
| 21 |
|
| 22 |
/* ABCD are live after the call which should be enough |
| 23 |
to cause r7 to be used if it weren't for the register variable. */ |
| 24 |
foo(a,b,c,d); |
| 25 |
|
| 26 |
e = 0; |
| 27 |
__asm__ __volatile__ ("mov %0, %2" |
| 28 |
: "=r" (e) |
| 29 |
: "0" (e), "r" (r)); |
| 30 |
|
| 31 |
global = a+b+c+d; |
| 32 |
|
| 33 |
return e; |
| 34 |
} |
| 35 |
|
| 36 |
int main() |
| 37 |
{ |
| 38 |
if (test(1, 2, 3, 4) != 0xdeadbeef) |
| 39 |
abort(); |
| 40 |
if (global != 10) |
| 41 |
abort(); |
| 42 |
return 0; |
| 43 |
} |