This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Enable EBX for x86 in 32bits PIC code
- From: Ilya Enkovich <enkovich dot gnu at gmail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Evgeny Stupachenko <evstupac at gmail dot com>, Richard Biener <richard dot guenther at gmail dot com>, GCC Development <gcc at gcc dot gnu dot org>, Uros Bizjak <ubizjak at gmail dot com>
- Date: Mon, 7 Jul 2014 22:00:40 +0400
- Subject: Re: Enable EBX for x86 in 32bits PIC code
- Authentication-results: sourceware.org; auth=none
- References: <CAOvf_xxsQ_oYGqNAVQ1+BW+CuD3mzebZ2xma0jpF=WfyZMCRCA at mail dot gmail dot com> <CAFiYyc1mFtTezkTJORmJJq+yht=qPSwiN7KDn19+bSuSdaqvMQ at mail dot gmail dot com> <CAOvf_xyeVeg2oB9Xxz8RMEQ6gyfJY5whd9s4ygoAAEaMU9efnA at mail dot gmail dot com> <20140707114750 dot GB31640 at tucnak dot redhat dot com>
2014-07-07 15:47 GMT+04:00 Jakub Jelinek <jakub@redhat.com>:
> On Mon, Jul 07, 2014 at 03:35:06PM +0400, Evgeny Stupachenko wrote:
>> The key problem here is that EBX is not used in register allocation.
>> If we relax the restriction on EBX the performance is back, but there
>> are several fails.
>> Some of them could be fixed.
>> However I don't like that way as EBX register is uninitialized at
>> register allocation.
>
> That is nothing wrong. The magic registers are to be assumed live from the
> beginning until the prologue is emitted.
EBX does not need to be so magic. It is used to pass GOT pointer
according to ABI, so why not to make it a part of ABI?
We may use a target hook to identify if function has implicit input
parameter with GOT. Then we handle this parameter in a regular way
and spill it to a virtual register with the only difference -
resulting RTL is written into PIC_OFFSET_TABLE_REGNUM.
In a similar way we may have implicit argument for calls and fill a
hard reg according to ABI from PIC_OFFSET_TABLE_REGNUM.
EBX would become a regular register then. If overall it looks
reasonable then I may try to make an experimental patch and check how
it affects performance.
Ilya
>
>> Initialization (SET_GOT) appeared only at: "217r.pro_and_epilogue" phase.
>>
>> The key point in 2 suggestions is to set EBX register only prior to a
>> call (as it is required by ABI). In all other cases it could be any
>> other register.
>
> You could use special call insn patterns for calls that need to have ebx
> set, where there would be a
> (use (match_operand:SI NN "register_operand" "b"))
> and pass in the lgot pseudo and leave the register allocator to do its job.
> You'd need to remember in which hard register (or memory) the register
> allocator wants lgot to be at the start of the first basic block (so that
> when prologue is expanded you know where to store it).
>
> Jakub