> This is all swinging on my interpretation of first-class structs though. I am > under the impression that they are essentially a set of registers holding > their first-class fields. So you can pass them by value as arguments to > functions with the behaviour of any other first-class type regardless of > where they came from.This is not true in general and highly target- and CC- dependent. For example, you can ran out of registers and then your struct can be passed partly in registers and partly on stack. And depending on the stack frame size of the callee you can easily get infinite stack growth. As for returning struct-by-value - I think the situation is more complicated and you can expect only "small structs" to behave so (small = fits in the single target register) -- With best regards, Anton Korobeynikov. Faculty of Mathematics & Mechanics, Saint Petersburg State University.
On Feb 23, 2009, at 5:59 AM, Anton Korobeynikov wrote:>> This is all swinging on my interpretation of first-class structs >> though. I am >> under the impression that they are essentially a set of registers >> holding >> their first-class fields. So you can pass them by value as >> arguments to >> functions with the behaviour of any other first-class type >> regardless of >> where they came from. > This is not true in general and highly target- and CC- dependent. For > example, you can ran out of registers and then your struct can be > passed > partly in registers and partly on stack. And depending on the stack > frame size of the callee you can easily get infinite stack growth.There is a sense in which it is true -- first-class structs are converted to a set of *virtual* registers holding their first-class fields, which may of course be passed on the stack when physical registers run short, in exactly the same manner as with lots of scalar arguments. Dan
On Tuesday 24 February 2009 00:16:37 Dan Gohman wrote:> On Feb 23, 2009, at 5:59 AM, Anton Korobeynikov wrote: > > This is not true in general and highly target- and CC- dependent. For > > example, you can ran out of registers and then your struct can be > > passed > > partly in registers and partly on stack. And depending on the stack > > frame size of the callee you can easily get infinite stack growth. > > There is a sense in which it is true -- first-class structs are > converted to a set of *virtual* registers holding their first-class fields, > which may of course be passed on the stack when physical registers run > short, in exactly the same manner as with lots of scalar arguments.Exactly. -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e
Reasonably Related Threads
- [LLVMdev] Broke my tail (call)
- [LLVMdev] Broke my tail (call)
- [LLVMdev] Question about fastcc assumptions and seemingly superfluous %esp updates
- [LLVMdev] Question about fastcc assumptions and seemingly superfluous %esp updates
- [LLVMdev] Broke my tail (call)