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
On 2009-02-24 12:35, Jon Harrop wrote:> 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.In case of tailcall(+fastcc?), can't this be done in constant stackspace? First time you allocate stackspace to pass the parameters, then all other tailcalls will reuse the stackspace that it got its parameters in, to pass parameters to the next tailcall. Best regards --Edwin
Hi, Does anyone know an easy way to do same optimisations as 'opt -O2' or 'opt -O3' in the JIT. I can do the tedious way: pass_manager->add(createInstructionCombiningPass()); pass_manager->add(createGVNPass()); etc. etc. but I would rather reuse the code in 'opt' to manage the passes. Cheers, Mark. -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 2500 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090224/b6302dea/attachment.bin>
On Tue, Feb 24, 2009 at 11:57 AM, Török Edwin <edwintorok at gmail.com> wrote:> On 2009-02-24 12:35, Jon Harrop wrote: >> 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. > > In case of tailcall(+fastcc?), can't this be done in constant stackspace? > First time you allocate stackspace to pass the parameters, then all > other tailcalls will reuse the stackspace > that it got its parameters in, to pass parameters to the next tailcall.Yes and indeed it already does. define fastcc void @init2({ i32, i32, i32, i32}, i32) { entry: tail call fastcc void @init2({ i32, i32, i32, i32} %0, i32 %1) ret void } results in (admittedly a little to eager to move arguments around ) tail call version: Llabel1: subl $12, %esp movl 24(%esp), %eax movl %eax, 24(%esp) movl 20(%esp), %eax movl %eax, 20(%esp) movl 16(%esp), %eax movl %eax, 16(%esp) addl $12, %esp jmp _init2 # TAILCALL Leh_func_end1: The problem Jon is seeing has to do with the struct return. not the struct argument passing as i wrongly assumed at first. regards arnold