This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: max-stack-var-size


ÒýÑÔ Paul Brook <paul@nowt.org>:

> On Thursday 06 November 2003 3:15 pm, S. Bosscher 
wrote:
> > > + 2003-11-06  Canqun Yang  <canqun@nudt.edu.cn>
> > > +
> > > + 	* options.c (gfc_init_options): Set 
flag_max_stack_var_size as
> >
> > 32768.
> >
> > > + 	* trans-decl.c (gfc_finish_var_decl):
> >
> > OK, with one remark,
> 
> No, not OK. Consider the following:
> 
> program p
>   call s(1)
> contains
> recursive subroutine s(n)
>   integer n
>   integer, dimension(32769) :: a
> 
>   a(1) = 42
>   if (n .gt. 0) call s(n - 1)
>   if (a(1) .ne. 42) call abort
>   a(1) = 0
> end subroutine
> end program
> 
> Paul
> 
> 
It seems that recursive function is the only case that 
its local variables should be placed on stack. Is it 
true? If so, add an extra condition to avoid such case 
will let it work.

+   /* Keep variables larger than max-stack-var-size 
off stack.  */
+   if (!(sym->ns->proc_name->attr.recursive)
        && !gfc_can_put_var_on_stack (DECL_SIZE_UNIT 
(decl)))
+     TREE_STATIC (decl) = 1;

Canqun Yang




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]