On Wed, 7 May 2008, Matthijs Kooijman wrote:>> Aggregates as First Class Values: > it seems to me that having this would make the byval parameter attribute > partly obsolete? Will there be semantic differences between passing a struct > directly and a pointer to a struct byval? > > I can see that byval can be used on pointers to other things, but is that > really useful? I can't see any use for compiling C code, are there other > languages that have a direct use for a byval attribute?Byval and passing a first class aggregate have the same semantics. However, byval is very efficient for large aggregates and first-class aggregates is efficient for small ones. -Chris -- http://nondot.org/sabre/ http://llvm.org/
> Byval and passing a first class aggregate have the same semantics. > However, byval is very efficient for large aggregates and first-class > aggregates is efficient for small ones.I was making the assumption that having the same semantics actually means being equivalent and thus resulting in the same generated code. Since, AFAICS, the LLVM IR mainly conveys semantics, what do both ways of writing this imply for the generated code, then? Gr. Matthij -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080507/3ed8c52b/attachment.sig>
On Wed, 7 May 2008, Matthijs Kooijman wrote:>> Byval and passing a first class aggregate have the same semantics. >> However, byval is very efficient for large aggregates and first-class >> aggregates is efficient for small ones. > I was making the assumption that having the same semantics actually means > being equivalent and thus resulting in the same generated code. Since, AFAICS, > the LLVM IR mainly conveys semantics, what do both ways of writing this imply > for the generated code, then?'byval' is address exposed in the IR, and is thus living in memory. First class aggregates are not address exposed. Think of them as being implicitly scalarized to their elements with each element held in registers. -Chris -- http://nondot.org/sabre/ http://llvm.org/