[LLVMdev] Status of first-class aggregate types

Chris Lattner clattner at apple.com
Sun Dec 20 09:50:15 PST 2009

On Dec 20, 2009, at 12:27 AM, Talin wrote:

> What's the current status on support for first-class structs? The last I heard was:
> Structs which are smaller or equal to two pointers can be passed / returned / loaded / stored by value.
> There are plans to expand this in the future to support arbitrary-sized structs as first class values. (Probably via some transformation pass the converts the return value into a hidden parameter.)
> First question - are those statements still true?

Yes, I think so.  Also support is actually better than that, the sticking issue occurs when passing and returning large aggregates.  I think that improved recently but am not sure of the status.

> The reason I am asking all of this is that I am starting to work on supporting tuple types in my language - and I'm trying to decide what is the best way to implement them. Since these are value types, not reference types, they need to be copied when passing to or returning from a function. The two approaches I am considering is (a) always pass them by reference internally, using a hidden parameter for the return value, and then have the receiver of the value copy it into an SSA value before use, and (b) for types <= 2 pointers, use SSA values only, and then pass larger types as in case (a). Of course, if support for large, first-class SSA values was finished, then I wouldn't have to care about any of these issues :)

I'd pass them by value if they are small but by reference if they are large.  Passing large tuples by value isn't going to provide a win.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091220/93ac6bcd/attachment.html>

More information about the llvm-dev mailing list