[LLVMdev] tail call optimization

Rafael EspĂ­ndola rafael.espindola at gmail.com
Sat Jul 15 16:44:11 PDT 2006


compiling:

void f(void);
void g(void) {
  f();
}

With GCC 4.0.3 (-Os) produces the code

        pushl   %ebp
        movl    %esp, %ebp
        popl    %ebp
        jmp     f

With llvm-gcc the result is

        subl $4, %esp
        call f
        addl $4, %esp
        ret

Note that llvm-gcc automatically removes the frame pointer, but
doesn't use a tail call as GCC does. LLVM has support for a tail
calling convention. Is it missing a pass that tries to "promote" a
regular call to a tail call?

Thanks,
Rafael



More information about the llvm-dev mailing list