This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

[Bug target/65753] [i386] Incorrect tail call inhibition logic on i386 (32-bit)


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


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