[llvm-commits] [LLVMdev] ABI: how to let the backend know that an aggregate should be allocated on stack

Duncan Sands baldrick at free.fr
Fri Oct 26 07:27:39 PDT 2012


Hi Bob,

On 26/10/12 16:16, Bob Wilson wrote:
>
> On Oct 24, 2012, at 12:40 PM, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:
>
>> On 24 October 2012 01:00, Manman Ren <mren at apple.com> wrote:
>>>
>>> Byval does not work for me, it will try to split the struct to fit into
>>> available core registers and the rest on stack.
>>
>> That is a strange byval implementation. Maybe the llvm ARM backend
>> should be changed to always pass byval on the stack? Clang can create
>> regular (integer, fp) arguments for the registers.
>
> The current definition of the byval attribute in LangRef says nothing about requiring passing the argument on the stack.  It just says it "should really be passed by value".  When discussing the alignment, it does refer to a stack slot, but it isn't at all clear that it is required to be on the stack.

it needs to be addressable.  The "byval" parameter is a pointer, and that
pointer can be passed to any old routine as an ordinary pointer, and they
may read or write the memory it points to.  So while you could pass in
registers, the callee would still need to construct a stack object using
those values, then use the address of the stack object for all references
to the byval parameter.  (That said, if the callee doesn't ever dereference
the byval pointer then you could not bother constructing the stack object).

Ciao, Duncan.

>
>  From looking at the PowerPC backend, I got the impression that it does not interpret the byval attribute to mean that an argument must go on the stack.  It could be entirely in registers or split between registers and stack.  For Intel, on the other hand, there seem to be many cases where byval is intentionally used as a substitute for the "on stack" attribute that Manman was looking for.
>
> It would be good to clarify the intention of this in the docs.
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list