This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

-foptimize-sibling-calls and passing structs


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]