[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 11:50:52 PDT 2012


Hi manman,

>> 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).
 > That's true, for ARM, we construct a stack object for the register-portion of 
the byval and it is right next to the stack-portion of the byval.
> It did cause some problem with tail call if address of the byval argument is passed to a call (see r165853).

I don't understand why you don't just have byval mean "pass on the stack" and
require front-ends to break up arguments into register parts and on the stack
parts.  I'm pretty sure that the original intent was that byval should have the
same simple meaning everywhere: pass on the stack.  Maybe I'm misunderstanding
what you are doing for ARM, but it sounds like you are teaching the backend to
do ABI conformance, having it break byval objects up into register bits and non
register bits (and having to do this kind of "put the registers back on the
stack" dance as a consequence).

Ciao, Duncan.



More information about the llvm-commits mailing list