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 for revised BLOCK handling during inlining



Here's the C++-specific part.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

1999-12-16  Mark Mitchell  <mark@codesourcery.com>

	* optimize.c (struct inline_data): Remove scope_stmt.
	(remap_block): Don't use insert_block_after_note.  Don't update
	scope_stmt.
	(expand_call_inline): Don't update scope_stmt.
	(optimize_function): Don't initialize scope_stmt.
	* semantics.c (expand_stmt): Set NOTE_BLOCK for newly emitted
	NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END notes.

Index: cp/optimize.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/optimize.c,v
retrieving revision 1.10
diff -c -p -r1.10 optimize.c
*** optimize.c	1999/12/16 00:09:35	1.10
--- optimize.c	1999/12/16 17:44:52
*************** typedef struct inline_data
*** 53,60 ****
       inlining the body of `h', the stack will contain, `h', followed
       by `g', followed by `f'.  */
    varray_type fns;
-   /* The last SCOPE_STMT we have encountered.  */
-   tree scope_stmt;
    /* The label to jump to when a return statement is encountered.  */
    tree ret_label;
    /* The map from local declarations in the inlined function to
--- 53,58 ----
*************** remap_block (scope_stmt, decls, id)
*** 146,151 ****
--- 144,150 ----
        tree old_block;
        tree new_block;
        tree old_var;
+       tree fn;
  
        /* Make the new block.  */
        old_block = SCOPE_STMT_BLOCK (scope_stmt);
*************** remap_block (scope_stmt, decls, id)
*** 175,187 ****
  	}
        /* We put the BLOCK_VARS in reverse order; fix that now.  */
        BLOCK_VARS (new_block) = nreverse (BLOCK_VARS (new_block));
!       /* Graft the new block into the tree.  */
!       insert_block_after_note (new_block,
! 			       SCOPE_STMT_BLOCK (id->scope_stmt),
! 			       SCOPE_BEGIN_P (id->scope_stmt));
!       /* Remember that this is now the last scope statement with
! 	 an associated block.  */
!       id->scope_stmt = scope_stmt;
        /* Remember the remapped block.  */
        splay_tree_insert (id->decl_map,
  			 (splay_tree_key) old_block,
--- 174,185 ----
  	}
        /* 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);
!       BLOCK_CHAIN (new_block) = BLOCK_CHAIN (DECL_INITIAL (fn));
!       BLOCK_CHAIN (DECL_INITIAL (fn)) = new_block;
        /* Remember the remapped block.  */
        splay_tree_insert (id->decl_map,
  			 (splay_tree_key) old_block,
*************** remap_block (scope_stmt, decls, id)
*** 198,207 ****
  			     (splay_tree_key) SCOPE_STMT_BLOCK (scope_stmt));
        my_friendly_assert (n != NULL, 19991203);
        SCOPE_STMT_BLOCK (scope_stmt) = (tree) n->value;
- 
-       /* Remember that this is now the last scope statement with an
- 	 associated block.  */
-       id->scope_stmt = scope_stmt;
      }
  }
  
--- 196,201 ----
*************** expand_call_inline (tp, walk_subtrees, d
*** 520,533 ****
    id = (inline_data *) data;
    t = *tp;  
  
-   /* Keep track of the last SCOPE_STMT we've seen.  */
-   if (TREE_CODE (t) == SCOPE_STMT)
-     {
-       if (SCOPE_STMT_BLOCK (t) && !id->in_target_cleanup_p)
- 	id->scope_stmt = t;
-       return NULL_TREE;
-     }
- 
    /* Recurse, but letting recursive invocations know that we are
       inside the body of a TARGET_EXPR.  */
    if (TREE_CODE (*tp) == TARGET_EXPR)
--- 514,519 ----
*************** expand_call_inline (tp, walk_subtrees, d
*** 608,618 ****
    remap_block (scope_stmt, DECL_ARGUMENTS (fn), id);
    TREE_CHAIN (scope_stmt) = STMT_EXPR_STMT (expr);
    STMT_EXPR_STMT (expr) = scope_stmt;
-   id->scope_stmt = scope_stmt;
  
    /* Tell the debugging backends that this block represents the
!      outermost scope of the inlined function.  FIXME what to do for
!      inlines in cleanups?  */
    if (SCOPE_STMT_BLOCK (scope_stmt))
      BLOCK_ABSTRACT_ORIGIN (SCOPE_STMT_BLOCK (scope_stmt)) = DECL_ORIGIN (fn);
  
--- 594,602 ----
    remap_block (scope_stmt, DECL_ARGUMENTS (fn), id);
    TREE_CHAIN (scope_stmt) = STMT_EXPR_STMT (expr);
    STMT_EXPR_STMT (expr) = scope_stmt;
  
    /* Tell the debugging backends that this block represents the
!      outermost scope of the inlined function.  */
    if (SCOPE_STMT_BLOCK (scope_stmt))
      BLOCK_ABSTRACT_ORIGIN (SCOPE_STMT_BLOCK (scope_stmt)) = DECL_ORIGIN (fn);
  
*************** optimize_function (fn)
*** 722,733 ****
  	    VARRAY_PUSH_TREE (id.fns, s->function_decl);
  	    prev_fn = s->function_decl;
  	  }
- 
-       /* Initialize id->scope_stmt with a fake SCOPE_STMT for the outermost
- 	 block of the function (i.e. the BLOCK with __FUNCTION__ et al).  */
-       id.scope_stmt = build_min_nt (SCOPE_STMT,
- 				    BLOCK_SUBBLOCKS (DECL_INITIAL (fn)));
-       SCOPE_BEGIN_P (id.scope_stmt) = 1;
  
        /* Replace all calls to inline functions with the bodies of those
  	 functions.  */
--- 706,711 ----
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/semantics.c,v
retrieving revision 1.116
diff -c -p -r1.116 semantics.c
*** semantics.c	1999/12/15 09:51:24	1.116
--- semantics.c	1999/12/16 17:44:52
*************** expand_stmt (t)
*** 2514,2529 ****
  	  if (!SCOPE_NO_CLEANUPS_P (t))
  	    {
  	      if (SCOPE_BEGIN_P (t))
! 		expand_start_bindings (2 * SCOPE_NULLIFIED_P (t));
  	      else if (SCOPE_END_P (t))
  		expand_end_bindings (NULL_TREE, !SCOPE_NULLIFIED_P (t), 
  				     SCOPE_PARTIAL_P (t));
  	    }
  	  else if (!SCOPE_NULLIFIED_P (t))
! 	    emit_note (NULL,
! 		       (SCOPE_BEGIN_P (t) 
! 			? NOTE_INSN_BLOCK_BEG
! 			: NOTE_INSN_BLOCK_END));
  	  break;
  
  	case RETURN_INIT:
--- 2514,2534 ----
  	  if (!SCOPE_NO_CLEANUPS_P (t))
  	    {
  	      if (SCOPE_BEGIN_P (t))
! 		expand_start_bindings_and_block (2 * SCOPE_NULLIFIED_P (t),
! 						 SCOPE_STMT_BLOCK (t));
  	      else if (SCOPE_END_P (t))
  		expand_end_bindings (NULL_TREE, !SCOPE_NULLIFIED_P (t), 
  				     SCOPE_PARTIAL_P (t));
  	    }
  	  else if (!SCOPE_NULLIFIED_P (t))
! 	    {
! 	      rtx note = emit_note (NULL,
! 				    (SCOPE_BEGIN_P (t) 
! 				     ? NOTE_INSN_BLOCK_BEG
! 				     : NOTE_INSN_BLOCK_END));
! 	      NOTE_BLOCK (note) = SCOPE_STMT_BLOCK (t);
! 	    }
! 	      
  	  break;
  
  	case RETURN_INIT:


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