This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
-foptimize-sibling-calls and passing structs
- To: gcc at gcc dot gnu dot org
- Subject: -foptimize-sibling-calls and passing structs
- From: Artur Skawina <skawina at geocities dot com>
- Date: Sun, 04 Jun 2000 06:58:20 +0200
i was going to try a recent gcc snapshot , but noticed this...
struct s { int one; int two; int three; } si = {1,2,3};
int p( struct s *s ) { printf("%d %d %d\n", s->one, s->two, s->three ); }
int r( struct s s ) { return p( &s ); }
int main() { r( si ); }
r() gets compiled to:
<r>:
sub $0xc,%esp
lea 0x10(%esp,1),%eax
mov %eax,0x10(%esp,1)
add $0xc,%esp
jmp <p>
which does seem to be a bit aggressive...
$ gcc -O2 test.c -o /tmp/o && /tmp/o
-1073743220 2 3
$ gcc -O2 test.c -fno-optimize-sibling-calls -o /tmp/o && /tmp/o
1 2 3
$ gcc -v
Reading specs from /pkg/gcc-ss-20000531-232458/lib/gcc-lib/i386-pc-linux-gnu/2.96/specs
gcc version 2.96 20000530 (experimental)