Hi All,

Currently GCC permanently reserves EBX as the GOT register.

    (config/i386/i386.c:4289)

      /* The PIC register, if it exists, is fixed.  */
      j = PIC_OFFSET_TABLE_REGNUM;
      if (j != INVALID_REGNUM)
        fixed_regs[j] = call_used_regs[j] = 1;

This leads to significant performance losses in PIC mode:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54232
According to my measurements ~3% generally and up to 20% in inner loops.

CLANG uses all registers for allocation and therefore now has
competitive advantage in 32bits PIC mode comparing to GCC.
This mode is used in all Android applications and therefore is
important  for many compiler customers.

There are at least 2 possible solutions.

1.

While call expand emit SET_GOT -> EBX and MOV EBX -> some local register: LGOT
Prior to each call emit MOV LGOT -> EBX
Use LGOT as new GOT register for globals.

2.

Set EBX as each CALL parameter.
Emit MOV EBX->LGOT in each call.
Use LGOT as new GOT register for globals.

Do you have any comments, ideas?

Thanks,
Evgeny

Reply via email to