OSDN Git Service

38586fe9725dd990340c26640a2d096fdcc957cc
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.target / i386 / pr9771-1.c
1 /* PR rtl-optimization/9771 */
2 /* { dg-do run } */
3 /* { dg-require-effective-target ia32 } */
4 /* { dg-options "-O2 -fomit-frame-pointer -ffixed-ebp" } */
5
6 extern void abort(void);
7 extern void exit(int);
8
9 register long *B asm ("ebp");
10
11 long x = 10;
12 long y = 20;
13
14 void bar(void)
15 {
16   B = &y;
17 }
18
19 void foo()
20 {
21   long *adr = B;
22   long save = *adr;
23
24   *adr = 123;
25
26   bar();
27
28   *adr = save;
29 }
30
31 /* This must not be inlined becuase main() requires the frame pointer
32    for stack alignment.  */
33 void test(void) __attribute__((noinline));
34 void test(void)
35 {
36   B = &x;
37
38   foo();
39
40   if (x != 10 || y != 20)
41     abort();
42
43   /* We can't return, as our caller may assume %ebp is preserved!  */
44   /* We could save/restore it (like foo), but its easier to exit.  */
45   exit(0);
46 }
47
48 int main()
49 {
50   test();
51   return 0;
52
53 }