OSDN Git Service

Index: gcc/ChangeLog
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / 20011119-1.c
1 /* Test for reload failing to eliminate from argp to sp.  */
2 /* { dg-do run { target i?86-*-* } } */
3 /* { dg-skip-if "" { i?86-*-* } { "-m64" "-fpic" "-fPIC" } { "" } } */
4 /* { dg-options "-O2 -fomit-frame-pointer" } */
5
6 static int ustrsize (const char *s);
7 static int (*ucwidth) (int c);
8 static int (*ugetxc) (const char **s);
9 static int (*usetc) (char *s, int c);
10
11 char *ustrzcat(char *dest, int size, const char *src)
12 {
13    int pos = ustrsize(dest);
14    int c;
15
16    size -= pos + ucwidth(0);
17
18    while ((c = ugetxc(&src)) != 0) {
19       size -= ucwidth(c);
20       if (size < 0)
21          break;
22
23       pos += usetc(dest+pos, c);
24    }
25
26    usetc(dest+pos, 0);
27
28    return dest;
29 }
30
31 static int __attribute__((noinline))
32 ustrsize (const char *s)
33 {
34   return 0;
35 }
36
37 static int
38 ucwidth_ (int c)
39 {
40   return 1;
41 }
42
43 static int
44 ugetxc_ (const char **s)
45 {
46   return '\0';
47 }
48
49 static int
50 usetc_ (char *s, int c)
51 {
52   return 1;
53 }
54
55 int
56 main()
57 {
58   ucwidth = ucwidth_;
59   ugetxc = ugetxc_;
60   usetc = usetc_;
61   
62   /* ??? It is impossible to explicitly modify the hard frame pointer.
63      This will run afoul of code in flow.c that declines to mark regs
64      in eliminate_regs in regs_ever_used.  Apparently, we have to wait
65      for reload to decide that it won't need a frame pointer before a
66      variable can be allocated to %ebp.
67
68      So save, restore, and clobber %ebp by hand.  */
69
70   asm ("pushl %%ebp\n\t"
71        "movl $-1, %%ebp\n\t"
72        "pushl $0\n\t"
73        "pushl $0\n\t"
74        "pushl $0\n\t"
75        "call %P0\n\t"
76        "addl $12, %%esp\n\t"
77        "popl %%ebp"
78        : : "i"(ustrzcat) : "memory" );
79
80   return 0;
81 }