diff options
Diffstat (limited to 'gcc/testsuite/gcc.target/i386/call-1.c')
-rw-r--r-- | gcc/testsuite/gcc.target/i386/call-1.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/i386/call-1.c b/gcc/testsuite/gcc.target/i386/call-1.c new file mode 100644 index 000000000..bd7c569c6 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/call-1.c @@ -0,0 +1,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; +} |