https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65753

--- Comment #1 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Example testcase:

void *lookup_f(void);
void g()
{
  void (*f)(void) = lookup_f();
  f();
}

With -O2 -fPIC, on x86-64 GCC produces the desired tail call:

g:
    subq    $8, %rsp
    call    lookup_f@PLT
    addq    $8, %rsp
    jmp    *%rax

However for i386 the tail call is not produced:

g:
    pushl    %ebx
    call    __x86.get_pc_thunk.bx
    addl    $_GLOBAL_OFFSET_TABLE_, %ebx
    subl    $8, %esp
    call    lookup_f@PLT
    call    *%eax
    addl    $8, %esp
    popl    %ebx
    ret

Reply via email to