Richard Henderson wrote: > On 08/03/2011 07:07 AM, Georg-Johann Lay wrote: >> #include <stdio.h> >> >> void foo () >> { >> printf ("%d %d %d", 1, 2, 3); >> printf ("%d %d %d", 3, 4, 5); >> printf ("%d %d %d", 1, 4, 5); >> } >> >> Attached the output: The compiler happily pushes onto the stack >> but pops only at the end of the function. So in a function with >> many such calls that would eat up great deal of RAM. It that >> what we want? > > Add more printfs and find out. We'll consume 32 bytes and then > pop it all off in the middle of the function, then start again. > > See the use of pending_stack_adjust in expand_call. > > > r~ >
Yes, the following blocks are sprinkled all over the function: in r24,__SP_L__ ; 222 *movhi_sp/2 [length = 2] in r25,__SP_H__ adiw r24,32 ; 134 *addhi3/2 [length = 1] in __tmp_reg__,__SREG__ ; 223 *movhi_sp/1 [length = 5] cli out __SP_H__,r25 out __SREG__,__tmp_reg__ out __SP_L__,r24 With ACCUMULATE_OUTGOING_ARGS it looks much better: there is just one such block in the prologue/epilogue. I think ACCUMULATE_OUTGOING_ARGS would be a win definitely. Pushing more than 63 bytes for one function is no real world code for AVR and I think we can focus on functions receiving <= 63 bytes on stack. Johann