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

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



* 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.



Reply to: