On 16 March 2012 19:13, Iain Buclaw <ibuc...@ubuntu.com> wrote:

> On 16 March 2012 16:53, Andrei Alexandrescu
> <seewebsiteforem...@erdani.org> wrote:
> > On 3/16/12 11:50 AM, Iain Buclaw wrote:
> >>
> >> If you were to forget all about MRV for a brief moment, the change
> >> request being proposed here is to return *all* structures (including
> >> delegates, complex types and vectors) in registers if at all possible
> >> even if the underlying ABI default is to return it in memory.
> >
> >
> > That sounds great. Must have missed this point, this is a weird
> discussion
> > in which one sentence is about machine code and the next about syntax.
> >
> > Andrei
> >
> >
>
> Indeed it is.  Though in all honesty, I'm not sure how we can address
> this. X86 and X86_64 architectures already return small structures
> (less or equal to than 8 bytes iirc) in registers as an optimisation
> trick if the function is private/static, and optimisations are of
> course turned on.
>

It's good for a pair of ints, but still inefficient for a struct with
smaller data types, each of which could occupy their own register, avoiding
the pack and unpack before and after the return...

Implementing this for other architectures would require explicitly
> patching each backend architecture, which is simply not feasible to
> do, especially when such patches may likely get rejected (A
> 'reg_return' attribute for ARM has been submitted before back in 2007,
> but has never been accepted despite after several revisions).
>

Brutal. LLVM supports this efficiently out of the box.
It'd be interesting to have the GCC people weigh in on this argument
actually. I wonder if they'd see the merit here... ie, presenting it as a
fundamental language feature, it has a potential of offering a lot more
value than it would applied to C.

Reply via email to