This is the mail archive of the
gcc-patches@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: Hans-Peter Nilsson <hp at bitrange dot com>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, Evgeny Stupachenko <evstupac at gmail dot com>
- Date: Mon, 25 Aug 2014 13:25:34 +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> <CAMbmDYZV_fx0jxmKHhLsC2pJ7pDzuu6toEAH72izOdpq6KGyfg at mail dot gmail dot com> <20140822121151 dot GA60032 at msticlxl57 dot ims dot intel dot com> <alpine dot BSF dot 2 dot 02 dot 1408222137320 dot 29125 at arjuna dot pair dot com>
2014-08-23 5:47 GMT+04:00 Hans-Peter Nilsson <hp@bitrange.com>:
> (Dropping gcc@ and people known to subscribe to gcc-patches
> from the CC.)
>
> Sorry for the drive-by review, but...
>
> On Fri, 22 Aug 2014, Ilya Enkovich wrote:
>> Hi,
>>
>> On Cauldron 2014 we had a couple of talks about relaxation of
>> ebx usage in 32bit PIC mode. It was decided that the best
>> approach would be to not fix ebx register, use speudo register
>> for GOT base address and let allocator do the rest. This should
>> be similar to how clang and icc work with GOT base address.
>> I've been working for some time on such patch and now want to
>> share my results.
>
> ...did you send the right version of the patch?
> This one uses the RTX-returning hook only in boolean tests,
> unless I misread.
>
> Using the return value in boolean tests (non/NULL) here:
NULL returned by hook means we do not have implicit pic arg to
pass/receive and there are pieces of code which should be executed
only when implicit pic arg exists. This causes these boolean tests.
There are also non boolean usages. E.g.:
+ rtx old_reg = targetm.calls.implicit_pic_arg (fndecl);
+ rtx new_reg = gen_reg_rtx (GET_MODE (old_reg));
+ emit_move_insn (new_reg, old_reg);
+ pic_offset_table_rtx = new_reg;
>
>> diff --git a/gcc/calls.c b/gcc/calls.c
>> index 4285ec1..85dae6b 100644
>> --- a/gcc/calls.c
>> +++ b/gcc/calls.c
>> @@ -1122,6 +1122,14 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED,
>> call_expr_arg_iterator iter;
>> tree arg;
>>
>> + if (targetm.calls.implicit_pic_arg (fndecl ? fndecl : fntype))
> ...
>> + /* Add implicit PIC arg. */
>> + if (targetm.calls.implicit_pic_arg (fndecl ? fndecl : fntype))
>> + num_actuals++;
> ...
>> + if (targetm.calls.implicit_pic_arg (fndecl ? fndecl : fntype))
>
> but:
>
>> +/* Return reg in which implicit PIC base address
>> + arg is passed. */
>> +static rtx
>> +ix86_implicit_pic_arg (const_tree fntype_or_decl ATTRIBUTE_UNUSED)
> ...
>> +#undef TARGET_IMPLICIT_PIC_ARG
>> +#define TARGET_IMPLICIT_PIC_ARG ix86_implicit_pic_arg
>> #undef TARGET_FUNCTION_ARG_BOUNDARY
>
> and:
>
>> --- a/gcc/doc/tm.texi
>> +++ b/gcc/doc/tm.texi
>> @@ -3967,6 +3967,12 @@ If @code{TARGET_FUNCTION_INCOMING_ARG} is not defined,
>> @code{TARGET_FUNCTION_ARG} serves both purposes.
>> @end deftypefn
>>
>> +@deftypefn {Target Hook} rtx TARGET_IMPLICIT_PIC_ARG (const_tree @var{fntype_or_decl})
>> +This hook returns register holding PIC base address for functions
>> +which do not fix hard register but handle it similar to function arg
>> +assigning a virtual reg for it.
>> +@end deftypefn
>
> Also, the contains_symbol_ref removal seems like an independent
> cleanup-patch.
It was not removed, it was just moved into rtlanal.c for shared usage
(I used it in ira.c).
Thanks,
Ilya
>
>> index a458380..63d2be5 100644
>> --- a/gcc/var-tracking.c
>> +++ b/gcc/var-tracking.c
>> @@ -661,7 +661,6 @@ static bool variable_different_p (variable, variable);
>> static bool dataflow_set_different (dataflow_set *, dataflow_set *);
>> static void dataflow_set_destroy (dataflow_set *);
>>
>> -static bool contains_symbol_ref (rtx);
>
> brgds, H-P