https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125266

--- Comment #9 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Richard Sandiford from comment #8)
> (In reply to H.J. Lu from comment #7)
> > While working on PR 124798, I use function ABI to pass the call clobbered
> > info to RA to avoid saving and restoring registers unnecessarily.
> Yeah, that seems like the right thing to do.  But it means that:
> 
> (a) The reinit_regs calls shouldn't be needed any more.

How do we allow target attribute on a function to enable additional
registers or disable some registers in a function without calling
reinit_regs?

> (b) This part of ix86_conditional_register_usage:
> 
>   /* If there are no caller-saved registers, preserve all registers.
>      except fixed_regs and registers used for function return value
>      since aggregate_value_p checks call_used_regs[regno] on return
>      value.  */
>   if (cfun
>       && (cfun->machine->call_saved_registers
>         == TYPE_NO_CALLER_SAVED_REGISTERS))
>     for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
>       if (!fixed_regs[i] && !ix86_function_value_regno_p (i))
>       call_used_regs[i] = 0;
> 
>     should be removed, and should instead be reflected in the
>     function_abi entry.
> 
> These days, as far as target-independent code is concerned, call_used_regs
> just exists as a way for the target to communicate the *default* call-used
> set to init_regs_1, for initialising the default ABI.  Other
> target-independent code does not use call_used_regs & co.  Instead it
> queries the function_abi structures.
> 
> Thus call_used_regs is not expected to (and should not) change based on the
> current function's ABI.  It should always describe the default ABI.  Any
> variations from the default ABI should be described in the function_abi
> instead.

If I understand it correctly, call_used_regs only describes registers clobbered
by callee and it shouldn't be used for anything else.  If a target attribute
enables additional registers in a function, shouldn't callee's call_used_regs
in such a function be different, i.e., clobber more registers?  Also a target
attribute may reduce number of registers in a function, like GPRs only.  How
does call_used_regs work in these cases?

Reply via email to