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

bugdal at aerifal dot cx gcc-bugzilla@gcc.gnu.org
Mon Apr 13 16:26:00 GMT 2015


            Bug ID: 65753
           Summary: [i386] Incorrect tail call inhibition logic on i386
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugdal at aerifal dot cx

i386.c contains the following comment (line 5448 as of this writing):

   /* If we are generating position-independent code, we cannot sibcall
      optimize any indirect call, or a direct call to a global function,
      as the PLT requires %ebx be live. (Darwin does not have a PLT.)  */

And the subsequent code disables tail calls via function pointers. The claim in
the comment that %ebx must be live for PLT use by indirect calls, and the
corresponding code that inhibits sibcall, is wrong.

For PLT slots in the non-PIE main executable, %ebx is not required at all. PLT
slots in PIE or shared libraries need %ebx, but a function pointer can never
evaluate to such a PLT slot; it always evaluates to the nominal address of the
function which is the same in all DSOs and therefore fundamentally cannot
depend on the address of the GOT in the calling DSO.

Removing this incorrect check will significantly improve code generation in
certain circumstances.

More information about the Gcc-bugs mailing list