<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Oct 26, 2012, at 11:50 AM, Duncan Sands <<a href="mailto:baldrick@free.fr">baldrick@free.fr</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi manman,<br><br><blockquote type="cite"><blockquote type="cite">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.<br></blockquote><br>it needs to be addressable.  The "byval" parameter is a pointer, and that<br>pointer can be passed to any old routine as an ordinary pointer, and they<br>may read or write the memory it points to.  So while you could pass in<br>registers, the callee would still need to construct a stack object using<br>those values, then use the address of the stack object for all references<br>to the byval parameter.  (That said, if the callee doesn't ever dereference<br>the byval pointer then you could not bother constructing the stack object).<br></blockquote>> 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.<br><blockquote type="cite">It did cause some problem with tail call if address of the byval argument is passed to a call (see r165853).<br></blockquote><br>I don't understand why you don't just have byval mean "pass on the stack" and<br>require front-ends to break up arguments into register parts and on the stack<br>parts.  I'm pretty sure that the original intent was that byval should have the<br>same simple meaning everywhere: pass on the stack.  Maybe I'm misunderstanding<br>what you are doing for ARM, but it sounds like you are teaching the backend to<br>do ABI conformance, having it break byval objects up into register bits and non<br>register bits (and having to do this kind of "put the registers back on the<br>stack" dance as a consequence).<br></blockquote><div><br></div>Hi Duncan,</div><div><br></div><div>That part of the implementation was not implemented by me. I was stating the current state of byval for ARM.</div><div>And I believe it is true for Mips and PowerPC as well.</div><div><br></div><div>I think the implementation tries to conform to the ABI standard:</div><div><p><span style="font-size: 10pt; font-family: ArialMT; ">If the NCRN is less than r4 and the NSAA is equal to the SP, the argument is split between core registers and the stack. The first part of the argument is copied into the core registers starting at the NCRN up to and including r3. The remainder of the argument is copied onto the stack, starting at the NSAA.</span></p></div><div><span style="font-family: ArialMT; font-size: 10pt; ">We can change how backend handles byval to make all these simpler.</span></div><div><span style="font-family: ArialMT; font-size: 10pt; "><br></span></div><div>Thanks,</div><div><span style="font-family: ArialMT; font-size: 10pt; ">Manman </span></div><div><blockquote type="cite"><br>Ciao, Duncan.<br></blockquote></div><br></body></html>