This is the mail archive of the
mailing list for the GCC project.
[PATCH] Fix stack slot sharing for Fortran IO
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 21 Jan 2011 08:54:53 +0100
- Subject: [PATCH] Fix stack slot sharing for Fortran IO
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On testcases like:
integer :: i
i = 6
print *, i
print *, i
! 98 times more print *, i
(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 <firstname.lastname@example.org>
* 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;