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

--- Comment #7 from Michael Matz <matz at gcc dot gnu.org> ---
(In reply to Florian Weimer from comment #5)
> > It also makes argument registers be callee-saved, which is very
> > unconventional.
> 
> Isn't this done for the this pointer in some C++ ABIs?

There are some, yes.  But those are then incompatible with the normal
definition of C++ calling conventions in terms of the ones for C (where 'this'
is simply
the first pointer argument).

The sense of that deviation lies in observing that 'this' usually isn't changed
by the callee.  For arbitrary arguments this doesn't hold, they belong to the
called function and so using a call-clobbered reg makes most sense.  It's
possible to do different of course, but it's very unusual.

> > Does the clang implementation take into account the various problematic
> > cases that arise when calling a normal function from a (say) preserve_all
> > function
> > (hint: such call can't usually be done)?
> 
> How so? We need to version the __preserve_most__ attribute with the ISA
> level, of course.

I don't see how that helps.  Imagine a preserve_all function foo that calls
printf.  How do you propose that 'foo' saves all parts of the SSE registers,
even those that aren't invented yet, or those that can't be touched by the
current ISA?  (printf might clobber all of these)

Reply via email to