This is the mail archive of the gcc-patches@gcc.gnu.org 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: [PATCH] register CALL_INSN_FUNCTION_USAGE in find_all_hard_reg_sets


Tom de Vries <Tom_deVries@mentor.com> writes:
> On 16-01-14 09:13, Richard Sandiford wrote:
>> Tom de Vries <Tom_deVries@mentor.com> writes:
>>> * The set of registers which are clobbered during a call by things
>>> like the plt
>>>     - these are not picked up by the use-caller-save optimization. We
>>> need the
>>>     hook to inform the compiler about these registers
>>
>> Right, but...
>>
>>> * And finally, registers clobbered in the caller itself during a sequence of
>>>     instructions implementing a function call. On mips, that's R6,
>>> which may be
>>>     clobbered by the call. Normally that doesn't need mentioning in
>>> the RTL since
>>>     it's a call_used_reg, but since use-caller-save might discover a set of
>>>     registers for the called function that does not include R6, it becomes
>>>     important to record this clobber explicitly. It could be
>>> represented in the
>>>     RTL by a clobber on the insn, or a clobber in C_I_F_U. Or it
>>> could just be
>>>     part of the registers returned by the hook - but that was
>>> previously deemed
>>>     not acceptable (and it doesn't match the description of the hook).
>>
>> ...why do we need two different mechanisms to deal with these two?
>> IMO the set recorded for the callee should contain what the callee
>> instructions clobber and nothing else.  CALL_INSN_FUNCTION_USAGE
>> should contain everything clobbered by a call outside the callee,
>> whether that's in the calling function itself, in a PLT, in a MIPS16
>> stub, or whatever.
>>
>
> Richard,
>
> Is this what you mean?
>
> This patch introduces a hook that specifies which registers are implicitly 
> clobbered by a call, not including the registers that are clobbered in the 
> called function, and then uses that hook to add those registers to 
> CALL_INSN_FUNCTION_USAGE.

I don't think a new hook is needed.  The call patterns should just add
the registers to CALL_INSN_FUNCTION_USAGE when generating the call insn.
MIPS already does this some cases where normally-call-saved registers
are actually clobbered:

      /* If we are handling a floating-point return value, we need to
         save $18 in the function prologue.  Putting a note on the
         call will mean that df_regs_ever_live_p ($18) will be true if the
         call is not eliminated, and we can check that in the prologue
         code.  */
      if (fp_ret_p)
	CALL_INSN_FUNCTION_USAGE (insn) =
	  gen_rtx_EXPR_LIST (VOIDmode,
			     gen_rtx_CLOBBER (VOIDmode,
					      gen_rtx_REG (word_mode, 18)),
			     CALL_INSN_FUNCTION_USAGE (insn));

Although we really should have a utility function like use_reg, but for
clobbers, so that the above would become:

  clobber_reg (&CALL_INSN_FUNCTION_USAGE (insn), gen_rtx_REG (word_mode, 18));

Thanks,
Richard


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