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]

C++ PATCH to remap_block for clones


We weren't copying the block structure to the clones properly, because
DECL_INITIAL isn't set up yet.  This would have been caught before if we
were using BLOCK_CHECK properly.

Checked in on both mainline and branch.

2001-02-16  Jason Merrill  <jason@redhat.com>

	* tree.h (BLOCK_CHAIN): Use BLOCK_CHECK.

2001-02-16  Jason Merrill  <jason@redhat.com>

	* optimize.c (remap_block): If we're compiling a clone, pass the
	new block to insert_block.

Index: tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree.h,v
retrieving revision 1.224
diff -c -p -r1.224 tree.h
*** tree.h	2001/02/14 07:57:48	1.224
--- tree.h	2001/02/16 12:36:35
*************** struct tree_exp
*** 823,829 ****
  #define BLOCK_SUPERCONTEXT(NODE) (BLOCK_CHECK (NODE)->block.supercontext)
  /* Note: when changing this, make sure to find the places
     that use chainon or nreverse.  */
! #define BLOCK_CHAIN(NODE) TREE_CHAIN (NODE)
  #define BLOCK_ABSTRACT_ORIGIN(NODE) (BLOCK_CHECK (NODE)->block.abstract_origin)
  #define BLOCK_ABSTRACT(NODE) (BLOCK_CHECK (NODE)->block.abstract_flag)
  
--- 823,829 ----
  #define BLOCK_SUPERCONTEXT(NODE) (BLOCK_CHECK (NODE)->block.supercontext)
  /* Note: when changing this, make sure to find the places
     that use chainon or nreverse.  */
! #define BLOCK_CHAIN(NODE) TREE_CHAIN (BLOCK_CHECK (NODE))
  #define BLOCK_ABSTRACT_ORIGIN(NODE) (BLOCK_CHECK (NODE)->block.abstract_origin)
  #define BLOCK_ABSTRACT(NODE) (BLOCK_CHECK (NODE)->block.abstract_flag)
  
Index: cp/optimize.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/optimize.c,v
retrieving revision 1.51
diff -c -p -r1.51 optimize.c
*** cp/optimize.c	2001/02/12 09:58:18	1.51
--- cp/optimize.c	2001/02/16 12:36:36
*************** remap_block (scope_stmt, decls, id)
*** 161,167 ****
        tree old_block;
        tree new_block;
        tree old_var;
-       tree *first_block;
        tree fn;
  
        /* Make the new block.  */
--- 161,166 ----
*************** remap_block (scope_stmt, decls, id)
*** 195,210 ****
  	}
        /* We put the BLOCK_VARS in reverse order; fix that now.  */
        BLOCK_VARS (new_block) = nreverse (BLOCK_VARS (new_block));
-       /* Attach this new block after the DECL_INITIAL block for the
- 	 function into which this block is being inlined.  In
- 	 rest_of_compilation we will straighten out the BLOCK tree.  */
        fn = VARRAY_TREE (id->fns, 0);
!       if (DECL_INITIAL (fn))
! 	first_block = &BLOCK_CHAIN (DECL_INITIAL (fn));
        else
! 	first_block = &DECL_INITIAL (fn);
!       BLOCK_CHAIN (new_block) = *first_block;
!       *first_block = new_block;
        /* Remember the remapped block.  */
        splay_tree_insert (id->decl_map,
  			 (splay_tree_key) old_block,
--- 194,217 ----
  	}
        /* We put the BLOCK_VARS in reverse order; fix that now.  */
        BLOCK_VARS (new_block) = nreverse (BLOCK_VARS (new_block));
        fn = VARRAY_TREE (id->fns, 0);
!       if (fn == current_function_decl)
! 	/* We're building a clone; DECL_INITIAL is still error_mark_node, and
! 	   current_binding_level is the parm binding level.  */
! 	insert_block (new_block);
        else
! 	{
! 	  /* Attach this new block after the DECL_INITIAL block for the
! 	     function into which this block is being inlined.  In
! 	     rest_of_compilation we will straighten out the BLOCK tree.  */
! 	  tree *first_block;
! 	  if (DECL_INITIAL (fn))
! 	    first_block = &BLOCK_CHAIN (DECL_INITIAL (fn));
! 	  else
! 	    first_block = &DECL_INITIAL (fn);
! 	  BLOCK_CHAIN (new_block) = *first_block;
! 	  *first_block = new_block;
! 	}
        /* Remember the remapped block.  */
        splay_tree_insert (id->decl_map,
  			 (splay_tree_key) old_block,

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