This is the mail archive of the 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]

Re: Enable EBX for x86 in 32bits PIC code

On Thu, Aug 28, 2014 at 2:54 PM, Ilya Enkovich <> wrote:

>>>>> 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
>>>>>       call_expr_arg_iterator iter;
>>>>>       tree arg;
>>>>> +    if (targetm.calls.implicit_pic_arg (fndecl ? fndecl : fntype))
>>>>> +      {
>>>>> +       gcc_assert (pic_offset_table_rtx);
>>>>> +       args[j].tree_value = make_tree (ptr_type_node,
>>>>> +                                       pic_offset_table_rtx);
>>>>> +       j--;
>>>>> +      }
>>>>> +
>>>>>       if (struct_value_addr_value)
>>>>>         {
>>>>>         args[j].tree_value = struct_value_addr_value;
>>>> So why do you need this?  Can't this be handled in the call/call_value
>>>> expanders or what about attaching the use to CALL_INSN_FUNCTION_USAGE from
>>>> inside ix86_expand_call?  Basically I'm not seeing the need for another
>>>> target hook here.  I think that would significantly simply the patch as
>>>> well.
>>> GOT base address become an additional implicit arg with EBX relaxed
>>> and I handled it as all other args. I can move EBX initialization into
>>> ix86_expand_call. Would still need some hint from target to init
>>> pic_offset_table_rtx with proper value in the beginning of function
>>> expand.
>> Maybe you can you use get_hard_reg_initial_val for this?
> Actually there is no input hard reg holding GOT address.  Currently I
> use initialization with ebx with following ebx initialization in
> prolog_epilog pass.  But this is a temporary workaround.  It is
> inefficient because always uses callee save reg to get GOT address.  I
> suppose we should generate pseudo reg for pic_offset_table_rtx and
> also set_got with this register as a destination in expand pass.
> After register allocation set_got may be transformed into get_pc_thunk
> call with proper hard reg.  But some target hook has to be used for
> this.

Let me expand my idea a bit. IIRC, get_hard_reg_initial_val and
friends will automatically emit intialization of a pseudo from
pic_offset_table_rtx hard reg. After reload, real initialization of
pic_offset_table_rtx hard reg is emitted in pro_and_epilogue pass. I
don't know if this works with current implementation of dynamic
pic_offset_table_rtx selection, though.


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