[new-ra] GCC-3.3.2/x86: some suspicious behaviour
Denis Zaitsev <[email protected]> Thu, 8 Jul 2004 04:06:43 +0600
| Newsgroups | org.kernel.vger.linux-gcc |
|---|---|
| Message-ID | <[email protected]> |
This source
extern inline
void *i(void *d, void *s, int n)
{
__asm__ __volatile__ ( ""
:"+&c"(n), "+&D"(d), "+&S"(s)
);
}
void *o(void *d, void *s, int n)
{
return i(d, s, n);
}
is compiled into that assembler:
o:
pushl %edi
pushl %esi
movl 12(%esp), %edi
movl 16(%esp), %esi
movl 20(%esp), %ecx
popl %esi
popl %edi
ret
Everything looks ok. But the source modified slightly
extern inline
void *i(void *d, void *s, int n)
{
__asm__ __volatile__ ( ""
:"+&c"(n), "+&D"(d), "+&S"(s)
);
__asm__ __volatile__ ( ""
:"+&c"(n), "+&D"(d), "+&S"(s)
);
}
void *o(void *d, void *s, int n)
{
return i(d, s, n);
}
is compiled into that assembler:
o:
pushl %edi
pushl %esi
movl 12(%esp), %edi
movl 20(%esp), %ecx
movl 16(%esp), %esi
movl %ecx, 16(%esp)
movl %esi, 20(%esp)
popl %esi
popl %edi
ret
So, what does these two commands mean:
movl %ecx, 16(%esp)
movl %esi, 20(%esp)
? The options for the compiler are:
-O2 -fomit-frame-pointer -fnew-ra
The result is the same for any -O >0 and for -Os. And the presence of
these suspicious commands are not affected by the frame-pointer
option.