<div class="gmail_quote">On 16 March 2012 19:13, Iain Buclaw <span dir="ltr"><<a href="mailto:ibuclaw@ubuntu.com">ibuclaw@ubuntu.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 16 March 2012 16:53, Andrei Alexandrescu<br>
<div><div class="h5"><<a href="mailto:SeeWebsiteForEmail@erdani.org">SeeWebsiteForEmail@erdani.org</a>> wrote:<br>
> On 3/16/12 11:50 AM, Iain Buclaw wrote:<br>
>><br>
>> If you were to forget all about MRV for a brief moment, the change<br>
>> request being proposed here is to return *all* structures (including<br>
>> delegates, complex types and vectors) in registers if at all possible<br>
>> even if the underlying ABI default is to return it in memory.<br>
><br>
><br>
> That sounds great. Must have missed this point, this is a weird discussion<br>
> in which one sentence is about machine code and the next about syntax.<br>
><br>
> Andrei<br>
><br>
><br>
<br>
</div></div>Indeed it is.  Though in all honesty, I'm not sure how we can address<br>
this. X86 and X86_64 architectures already return small structures<br>
(less or equal to than 8 bytes iirc) in registers as an optimisation<br>
trick if the function is private/static, and optimisations are of<br>
course turned on.<br></blockquote><div><br></div><div>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...</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Implementing this for other architectures would require explicitly<br>
patching each backend architecture, which is simply not feasible to<br>
do, especially when such patches may likely get rejected (A<br>
'reg_return' attribute for ARM has been submitted before back in 2007,<br>
but has never been accepted despite after several revisions).<br></blockquote><div><br></div><div>Brutal. LLVM supports this efficiently out of the box.</div><div>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.</div>
</div>