<div dir="ltr">Ah, that's why Clang is obsessively pushing them into return by reference?</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 24, 2018 at 6:29 PM, whitequark <span dir="ltr"><<a href="mailto:whitequark@whitequark.org" target="_blank">whitequark@whitequark.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 2018-05-25 00:39, Alexandre Isoard via llvm-dev wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
I see here: <a href="https://llvm.org/docs/LangRef.html#ret-instruction" rel="noreferrer" target="_blank">https://llvm.org/docs/LangRef.<wbr>html#ret-instruction</a><br>
<br>
That the return instruction must only return values of first class<br>
types, which would exclude struct and arrays. But some llvm<br>
instrinsics do return struct, and it does not seems to be enforced on<br>
any function.<br>
<br>
Is that restriction lifted and the documentation not up to date? Can<br>
we return arrays?<br>
I see the same restriction for select. Can/should we lift it too?<br>
</blockquote>
<br></span>
In practice, you can return structs and arrays, and this while you stay<br>
within the optimizer, but how targets handle this is very variable.<br>
X86 internally lowers it to sret or something very similar to sret<br>
whereas lesser used targets (think MSP430) may outright assert.<br>
<br>
My understanding is that calling an intrinsic that returns a struct<br>
is defined (and never needs a ret instruction), but returning a struct<br>
from user code (which does need a ret instruction) is not, which is<br>
why LangRef is written like that.<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
whitequark<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><b>Alexandre Isoard</b><br></div></div>
</div>