[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#366377: gcc-4.1: does not optimize sibling calls with args



Quoth Florian Weimer <fw@deneb.enyo.de>, on 2006-05-08 19:45:21 +0200:
> * Drake Wilson:
> 
> >   extern int foo(int x);
> >   int bar(void) { return foo(32); }
> >
> > On i386 this compiles to
> >
> >         pushl   %ebp
> >         movl    %esp, %ebp
> >         subl    $8, %esp
> >         movl    $32, (%esp)
> >         call    foo
> >         leave
> >         ret
> >
> > which doesn't correctly convert the call to foo into a tail call.
> 
> With the default cdecl calling convention, the call isn't in a tail
> position. %esp needs to be adjusted after the return of foo.  Unless
> I'm missing something, this is very hard to fix.

Glargh.  You're right.  I thought the calling convention would permit
it but it doesn't.  Stupid me.

At least the resolved bug report can stand as a warning to future
submitters, I suppose... close at will.

   ---> Drake Wilson

Attachment: signature.asc
Description: Digital signature


Reply to: