aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/arm/thumb-find-work-register.c
blob: f2c0225a4d2a91ad3cfc7e6ae66dac24963fb562 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* Wrong method to get number of arg reg will cause argument corruption.  */
/* { dg-do run } */
/* { dg-require-effective-target arm_eabi } */
/* { dg-options "-mthumb -O1" } */

extern void abort (void);

int foo (int, int, int, int) __attribute__((noinline));

int
foo (int a, int b, int c, int d)
{
  register int m asm ("r8");

  m = a;
  m += b;
  m += c;
  m += d;

  asm ("" : "=r" (m) : "0" (m));

  return m;
}

int
main ()
{
  volatile int a = 10;
  volatile int b = 20;
  volatile int c = 30;
  volatile int d = 40;
  volatile int sum = 0;

  sum = foo (a, b, c, d);

  if (sum != 100)
    abort ();

  return 0;
}