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


On 15-01-14 19:40, Richard Sandiford wrote:
Tom de Vries <Tom_deVries@mentor.com> writes:
This patch adds scanning of clobbers in CALL_INSN_FUNCTION_USAGE to
find_all_hard_reg_sets.

For MIPS, calls are split at some point. After the split, one of the
resulting insns may clobber $6. But before the split, that's not
explicit in the rtl representation of the unsplit call.

For -fuse-caller-save, that's a problem, and Richard S. suggested to
add the clobber of $6 to the CALL_INSN_FUNCTION_USAGE of the unsplit
call.

Maybe here's a good place to raise this, but I was hoping all targets
could use CALL_INSN_FUNCTION_USAGE  and we'd be able to drop the new
hook for -fuse-caller-save.  That seems better than adding another
place that needs to be checked when figuring out what a call clobbers.


Hi Richard,

There are the following sets of registers involved:
 * CALL_REALLY_USED_REGS, which is the set normally clobbered by called
   functions (or PLTs, resolvers, or any other piece of code that runs during a
   function call)
* The set of registers discovered by the use-caller-save optimization, which
  takes into account only the registers clobbered by the called function itself
* 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
* 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).

In other words, I didn't want MIPS to be different from the other targets.

MIPS just needs some special handling for the unsplit call. There might be other targets which need similar tweaks.

If we decide to keep the hook then MIPS should use it too.


I think the current proposal is good:
- use the hook to model registers clobbered during a call
- use CALL_INSN_FUNCTION_USAGE to model the r6 clobber for the unsplit MIPS
  call_insn

Thanks,
- Tom

Thanks,
Richard



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