diff mbox

Fix stack slot sharing for Fortran IO

Message ID 20110121075453.GD2724@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Jan. 21, 2011, 7:54 a.m. UTC
Hi!

On testcases like:
  integer :: i
  i = 6
  print *, i
  print *, i
! 98 times more print *, i
end
(and any other Fortran procedures that have lots of IO statements)
we allocate ~48000 bytes on the stack instead of ~500, because
none of the __dt_parm.N etc. variables share the stack slots.

The expansion stack sharing algorithm uses BLOCK_VARS to determine
what can and what can't be shared, but remove_unused_scope_block_p
considers solely debuginfo reasons and removes such vars as unused
because debug info is not emitted for them.

Fixed by only ignoring small vars like that, but not larger ones.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2011-01-20  Jakub Jelinek  <jakub@redhat.com>

	* tree-ssa-live.c (remove_unused_scope_block_p): Don't remove
	DECL_IGNORED_P non-reg vars if they are used.


	Jakub

Comments

Richard Biener Jan. 21, 2011, 10:51 a.m. UTC | #1
On Fri, Jan 21, 2011 at 8:54 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> On testcases like:
>  integer :: i
>  i = 6
>  print *, i
>  print *, i
> ! 98 times more print *, i
> end
> (and any other Fortran procedures that have lots of IO statements)
> we allocate ~48000 bytes on the stack instead of ~500, because
> none of the __dt_parm.N etc. variables share the stack slots.
>
> The expansion stack sharing algorithm uses BLOCK_VARS to determine
> what can and what can't be shared, but remove_unused_scope_block_p
> considers solely debuginfo reasons and removes such vars as unused
> because debug info is not emitted for them.
>
> Fixed by only ignoring small vars like that, but not larger ones.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2011-01-20  Jakub Jelinek  <jakub@redhat.com>
>
>        * tree-ssa-live.c (remove_unused_scope_block_p): Don't remove
>        DECL_IGNORED_P non-reg vars if they are used.
>
> --- gcc/tree-ssa-live.c.jj      2010-12-02 11:51:31.000000000 +0100
> +++ gcc/tree-ssa-live.c 2011-01-20 17:51:55.000000000 +0100
> @@ -453,8 +453,11 @@ remove_unused_scope_block_p (tree scope)
>       else if (TREE_CODE (*t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (*t))
>        unused = false;
>
> -      /* Remove everything we don't generate debug info for.  */
> -      else if (DECL_IGNORED_P (*t))
> +      /* Remove everything we don't generate debug info for.
> +        Don't remove larger vars though, because BLOCK_VARS are
> +        used also during expansion to determine which variables
> +        might share stack space.  */
> +      else if (DECL_IGNORED_P (*t) && is_gimple_reg (*t))
>        {
>          *t = DECL_CHAIN (*t);
>          next = t;
>
>        Jakub
>
diff mbox

Patch

--- gcc/tree-ssa-live.c.jj	2010-12-02 11:51:31.000000000 +0100
+++ gcc/tree-ssa-live.c	2011-01-20 17:51:55.000000000 +0100
@@ -453,8 +453,11 @@  remove_unused_scope_block_p (tree scope)
       else if (TREE_CODE (*t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (*t))
 	unused = false;
 
-      /* Remove everything we don't generate debug info for.  */
-      else if (DECL_IGNORED_P (*t))
+      /* Remove everything we don't generate debug info for.
+	 Don't remove larger vars though, because BLOCK_VARS are
+	 used also during expansion to determine which variables
+	 might share stack space.  */
+      else if (DECL_IGNORED_P (*t) && is_gimple_reg (*t))
 	{
 	  *t = DECL_CHAIN (*t);
 	  next = t;