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

--- Comment #17 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Richard Sandiford from comment #16)
> (In reply to H.J. Lu from comment #15)
> > (In reply to Richard Sandiford from comment #14)
> > 
> > > 
> > > I don't know if you've looked at it, but aarch64 already uses function_abi
> > > for preserve_none.  Like x86, aarch64 allows the target to be changed with
> > > function attributes, which has the effect of enabling and disabling
> > > registers.  But aarch64_conditional_register_usage doesn't depend on cfun 
> > > at
> > > all.
> > 
> > Yes, I did.  But I am not sure if it works correctly for all cases.  For
> > 
> > extern void ext (long a, long b, long c, long d, long e, long f,
> >              long g, long *);
> > 
> > extern void tail (long a, long b) __attribute__ ((preserve_none));
> > 
> > __attribute__ ((preserve_none)) void
> > caller (long a, long b, long c, long d, long e, long f, long g)
> > {
> >   __attribute__ ((aligned (32))) long x[4]; // for stack alignment
> >   ext (a, b, c, d, e, f, g, x);
> >   __attribute__ ((musttail)) return tail (a + b, b + c);
> > }
> > 
> > Insider caller, default_function_abi is the preserve_none ABI.
> No, default_function_abi is always ARM_PCS_AAPCS64, even when compiling
> caller.  That's my point.  The default ABI is fixed.  It doesn't vary from
> one function to another.
> 
> When compiling caller:
> - default_function_abi is ARM_PCS_AAPCS64
> - crtl->abi is ARM_PCS_PRESERVE_NONE
> - ext is ARM_PCS_AAPCS64
> 
> Calling aarch64_conditional_register_usage always sets up call_used_regs for
> ARM_PCS_AAPCS64, regardless of when it is called.

This scheme won't work for x86 since ix86_conditional_register_usage is
called on every function.  Each of them may enable/disable a different
sets of registers.   The register set matrix can be quite big.  On x86,
default_function_abi depends on the set of available registers.  It can
be different for each function.

Reply via email to