[LLVMdev] First-class aggregate semantics
Duncan Sands
baldrick at free.fr
Thu Jan 7 22:55:03 PST 2010
Hi Jon,
>> In the case that prompted the question the struct isn't going to be
>> bigger than two of whatever the architecture regards as a word, which
>> surely should be fine, but in principle shouldn't LLVM and not the
>> front-end programmer be making the decision about whether the struct is
>> big enough to spill into memory?
>
> Good question. There was a very interesting discussion about this here a while
> ago and everyone coming to LLVM says the same thing: why doesn't LLVM just
> handle this for me automatically? The answer is that LLVM cannot make that
> decision because it depends upon the ABI.
actually LLVM does now handle this for you automatically: if there aren't
enough registers to return the first class aggregate in registers, then it
is automagically returned on the stack. If this is not ABI conformant then
it is up to the front-end to not generate IR that returns such large structs.
In practice front-ends only generate functions returning first class aggregates
when the ABI says the aggregate should be entirely returned in registers. Thus
by definition it is sure not to require more registers than the machine has!
This is why the enhancement to automagically use the stack if there aren't
enough registers has no impact on ABI conformance.
Ciao,
Duncan.
More information about the llvm-dev
mailing list