summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/call-1.c
blob: bd7c569c69db95fe0e441a9e448e19de58d47b8e (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
/* PR optimization/11304 */
/* Originator: <manuel.serrano@sophia.inria.fr> */
/* { dg-do run } */
/* { dg-options "-O -fomit-frame-pointer" } */

/* Verify that %eax is always restored after a call.  */

extern void abort(void);

volatile int r;

void set_eax(int val)
{
  __asm__ __volatile__ ("mov %0, %%eax" : : "m" (val));
}

void foo(int val)
{
  r = val;
}

int bar(int x)
{
  if (x)
  {
    set_eax(0);
    return x;
  }

  foo(x);
}

int main(void)
{
  if (bar(1) != 1)
    abort();

  return 0;
}