[llvm-dev] first class types

whitequark via llvm-dev llvm-dev at lists.llvm.org
Thu May 24 18:29:50 PDT 2018


On 2018-05-25 00:39, Alexandre Isoard via llvm-dev wrote:
> Hello,
> 
> I see here: https://llvm.org/docs/LangRef.html#ret-instruction
> 
> That the return instruction must only return values of first class
> types, which would exclude struct and arrays. But some llvm
> instrinsics do return struct, and it does not seems to be enforced on
> any function.
> 
> Is that restriction lifted and the documentation not up to date? Can
> we return arrays?
> I see the same restriction for select. Can/should we lift it too?

In practice, you can return structs and arrays, and this while you stay
within the optimizer, but how targets handle this is very variable.
X86 internally lowers it to sret or something very similar to sret
whereas lesser used targets (think MSP430) may outright assert.

My understanding is that calling an intrinsic that returns a struct
is defined (and never needs a ret instruction), but returning a struct
from user code (which does need a ret instruction) is not, which is
why LangRef is written like that.

-- 
whitequark


More information about the llvm-dev mailing list