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]

Copying a DECL_SIZE for inlining multiple times (was: [testcase] C tree inlining ICE)


On Oct 15, 2001, Jakub Jelinek <jakub@redhat.com> wrote:

> 	* gcc.dg/20011015-3.c: New test.

Thanks.  The problem was that we copy the DECL_SIZE of a declaration
multiple times, and we'd get different SAVE_EXPRs that wouldn't match
other uses of SAVE_EXPRs should they be remapped a different number of
times.

This patch arranges for us to remember a SAVE_EXPR was already copied
during the inlining of a function, and don't copy it again.  I thought
of removing the copying of the DECL_SIZEs in remap_decl, and it worked
for this testcase, but I feared it might break other uses of
remap_decl that are not called directly from copy_body_r, and decided
to take the safer approach implemented below.

This hasn't completed bootstrapping yet, but I have to call this a
day, so I'm posting it earlier so that this no longer blocks you, and
whoever wrote this decl remapping code may have more time to step in a
suggest a different approach to fix the problem.

Ok to install if bootstrap on athlon-pc-linux-gnu succeeds and no
regressions are introduced?

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* tree-inline.c (remap_save_expr): Map a copied SAVE_EXPR to
	itself.

Index: gcc/tree-inline.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree-inline.c,v
retrieving revision 1.6
diff -u -p -r1.6 tree-inline.c
--- gcc/tree-inline.c 2001/10/16 21:17:59 1.6
+++ gcc/tree-inline.c 2001/10/17 03:07:41
@@ -147,6 +147,8 @@ remap_decl (decl, id)
       /* The decl T could be a dynamic array or other variable size type,
 	 in which case some fields need to be remapped because they may
 	 contain SAVE_EXPRs.  */
+      /* ??? perhaps we shouldn't copy the DECL sizes, as they'd be
+         copied by walk_tree.  */
       walk_tree (&DECL_SIZE (t), copy_body_r, id, NULL);
       walk_tree (&DECL_SIZE_UNIT (t), copy_body_r, id, NULL);
       if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE
@@ -1373,6 +1375,11 @@ remap_save_expr (tp, st_, fn, walk_subtr
       n = splay_tree_insert (st,
 			     (splay_tree_key) *tp,
 			     (splay_tree_value) t);
+      /* In case we encounter the remapped SAVE_EXPR, which is
+         possible if it's part of the expression that determines a
+         declaration's size (these may be mapped multiple times), map
+         the copied SAVE_EXPR to itself.  */
+      splay_tree_insert (st, (splay_tree_key) t, (splay_tree_value) t);
     }
   else
     /* We've already walked into this SAVE_EXPR, so we needn't do it

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

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