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 remove of redunant setting of TREE_SIDE_EFFECTS



It's so nice when infrastructure improvements let us blow away code.
Kaboom.

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

1999-10-04  Mark Mitchell  <mark@codesourcery.com>

	* call.c (build_over_call): Don't set TREE_SIDE_EFFECTS for
	situations where make_node will do it automatically.
	* decl.c (grok_reference_init): Likewise.
	(expand_static_init): Likewise.
	(do_static_initialization): Likewise.
	* init.c (perform_member_init): Likewise.
	(expand_aggr_init_1): Likewise.
	(build_new_1): Likewise.
	* method.c (do_build_copy_constructor): Likewise.
	(do_build_assign_ref): Likewise.
	* search.c (expand_upcast_fixups): Likewise.
	* semantics.c (finish_stmt_expr): Likewise.
	* typeck.c (build_unary_op): Likewise.
	(check_return_expr): Likewise.

Index: cp/call.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/call.c,v
retrieving revision 1.174
diff -c -p -r1.174 call.c
*** call.c	1999/09/17 18:25:54	1.174
--- call.c	1999/10/04 03:36:16
*************** build_over_call (cand, args, flags)
*** 4066,4072 ****
  	  val = build (is_empty_class (DECL_CLASS_CONTEXT (fn))
  		       ? MODIFY_EXPR : INIT_EXPR, 
  		       DECL_CONTEXT (fn), to, arg);
- 	  TREE_SIDE_EFFECTS (val) = 1;
  	  address = build_unary_op (ADDR_EXPR, val, 0);
  	  /* Avoid a warning about this expression, if the address is
  	     never used.  */
--- 4066,4071 ----
*************** build_over_call (cand, args, flags)
*** 4084,4090 ****
        arg = build_indirect_ref (TREE_VALUE (TREE_CHAIN (converted_args)), 0);
  
        val = build (MODIFY_EXPR, TREE_TYPE (to), to, arg);
-       TREE_SIDE_EFFECTS (val) = 1;
        return val;
      }
  
--- 4083,4088 ----
Index: cp/decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.476
diff -c -p -r1.476 decl.c
*** decl.c	1999/10/01 04:45:08	1.476
--- decl.c	1999/10/04 03:36:24
*************** grok_reference_init (decl, type, init)
*** 6985,6993 ****
  	{
  	  /* Initialize the declaration.  */
  	  tmp = build (INIT_EXPR, TREE_TYPE (decl), decl, tmp);
- 	  /* Setting TREE_SIDE_EFFECTS prevents expand_expr from
- 	     omitting this expression entirely.  */
- 	  TREE_SIDE_EFFECTS (tmp) = 1;
  	  finish_expr_stmt (tmp);
  	}
        else
--- 6985,6990 ----
*************** expand_static_init (decl, init)
*** 8014,8025 ****
  	  || (init && TREE_CODE (init) == TREE_LIST))
  	assignment = build_aggr_init (decl, init, 0);
        else if (init)
! 	{
! 	  /* The initialization we're doing here is just a bitwise
! 	     copy.  */
! 	  assignment = build (INIT_EXPR, TREE_TYPE (decl), decl, init);
! 	  TREE_SIDE_EFFECTS (assignment) = 1;
! 	}
        else
  	assignment = NULL_TREE;
  
--- 8011,8019 ----
  	  || (init && TREE_CODE (init) == TREE_LIST))
  	assignment = build_aggr_init (decl, init, 0);
        else if (init)
! 	/* The initialization we're doing here is just a bitwise
! 	   copy.  */
! 	assignment = build (INIT_EXPR, TREE_TYPE (decl), decl, init);
        else
  	assignment = NULL_TREE;
  
Index: cp/decl2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl2.c,v
retrieving revision 1.272
diff -c -p -r1.272 decl2.c
*** decl2.c	1999/10/01 00:43:27	1.272
--- decl2.c	1999/10/04 03:36:28
*************** do_static_initialization (decl, init)
*** 3206,3215 ****
  			   TREE_VEC_ELT (init, 1),
  			   TREE_VEC_ELT (init, 2), 0);
    else
!     {
!       expr = build (INIT_EXPR, TREE_TYPE (decl), decl, init);
!       TREE_SIDE_EFFECTS (expr) = 1;
!     }
    finish_expr_stmt (expr);
  
    /* Finsh up.  */
--- 3206,3212 ----
  			   TREE_VEC_ELT (init, 1),
  			   TREE_VEC_ELT (init, 2), 0);
    else
!     expr = build (INIT_EXPR, TREE_TYPE (decl), decl, init);
    finish_expr_stmt (expr);
  
    /* Finsh up.  */
Index: cp/init.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/init.c,v
retrieving revision 1.140
diff -c -p -r1.140 init.c
*** init.c	1999/09/26 18:16:47	1.140
--- init.c	1999/10/04 03:36:30
*************** perform_member_init (member, name, init,
*** 149,155 ****
    if (ANON_AGGR_TYPE_P (type))
      {
        init = build (INIT_EXPR, type, decl, TREE_VALUE (init));
-       TREE_SIDE_EFFECTS (init) = 1;
        finish_expr_stmt (init);
      }
    else if (TYPE_NEEDS_CONSTRUCTING (type)
--- 149,154 ----
*************** expand_aggr_init_1 (binfo, true_exp, exp
*** 1247,1257 ****
  	    expand_decl_init (exp);
  	}
        else
! 	{
! 	  tree t = build (INIT_EXPR, type, exp, init);
! 	  TREE_SIDE_EFFECTS (t) = 1;
! 	  finish_expr_stmt (t);
! 	}
        return;
      }
  
--- 1246,1252 ----
  	    expand_decl_init (exp);
  	}
        else
! 	finish_expr_stmt (build (INIT_EXPR, type, exp, init));
        return;
      }
  
*************** build_new_1 (exp)
*** 2271,2277 ****
  		    build_component_ref (cookie, nelts_identifier,
  					 NULL_TREE, 0),
  		    nelts);
-       TREE_SIDE_EFFECTS (exp1) = 1;
        rval = cp_convert (build_pointer_type (true_type), rval);
        rval = build_compound_expr
  	(tree_cons (NULL_TREE, exp1,
--- 2266,2271 ----
*************** build_new_1 (exp)
*** 2427,2433 ****
  
  	      end = build (MODIFY_EXPR, TREE_TYPE (sentry),
  			   sentry, boolean_false_node);
- 	      TREE_SIDE_EFFECTS (end) = 1;
  
  	      buf = TREE_OPERAND (rval, 0);
  
--- 2421,2426 ----
Index: cp/method.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/method.c,v
retrieving revision 1.120
diff -c -p -r1.120 method.c
*** method.c	1999/10/01 04:34:24	1.120
--- method.c	1999/10/04 03:36:31
*************** do_build_copy_constructor (fndecl)
*** 2188,2194 ****
    else if (TYPE_HAS_TRIVIAL_INIT_REF (current_class_type))
      {
        t = build (INIT_EXPR, void_type_node, current_class_ref, parm);
-       TREE_SIDE_EFFECTS (t) = 1;
        finish_expr_stmt (t);
      }
    else
--- 2188,2193 ----
*************** do_build_assign_ref (fndecl)
*** 2270,2276 ****
    else if (TYPE_HAS_TRIVIAL_ASSIGN_REF (current_class_type))
      {
        tree t = build (MODIFY_EXPR, void_type_node, current_class_ref, parm);
-       TREE_SIDE_EFFECTS (t) = 1;
        finish_expr_stmt (t);
      }
    else
--- 2269,2274 ----
Index: cp/search.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/search.c,v
retrieving revision 1.126
diff -c -p -r1.126 search.c
*** search.c	1999/09/29 22:52:56	1.126
--- search.c	1999/10/04 03:36:33
*************** expand_upcast_fixups (binfo, addr, orig_
*** 2680,2686 ****
  
  	      init = build (MODIFY_EXPR, TREE_TYPE (nvtbl),
  			    nvtbl, vtbl);
- 	      TREE_SIDE_EFFECTS (init) = 1;
  	      finish_expr_stmt (init);
  	      /* Update the vtable pointers as necessary.  */
  	      ref = build_vfield_ref
--- 2680,2685 ----
Index: cp/semantics.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/semantics.c,v
retrieving revision 1.92
diff -c -p -r1.92 semantics.c
*** semantics.c	1999/10/01 04:45:10	1.92
--- semantics.c	1999/10/04 03:36:34
*************** finish_stmt_expr (rtl_expr)
*** 1342,1352 ****
    tree result;
  
    if (!building_stmt_tree ())
!     {
!       rtl_expr = expand_end_stmt_expr (rtl_expr);
!       /* The statements have side effects, so the group does too.  */
!       TREE_SIDE_EFFECTS (rtl_expr) = 1;
!     }
  
    if (building_stmt_tree ())
      {
--- 1342,1348 ----
    tree result;
  
    if (!building_stmt_tree ())
!     rtl_expr = expand_end_stmt_expr (rtl_expr);
  
    if (building_stmt_tree ())
      {
Index: cp/typeck.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/typeck.c,v
retrieving revision 1.220
diff -c -p -r1.220 typeck.c
*** typeck.c	1999/10/02 01:09:54	1.220
--- typeck.c	1999/10/04 03:36:38
*************** build_unary_op (code, xarg, noconvert)
*** 4567,4573 ****
  				     || code == POSTINCREMENT_EXPR)
  				    ? PLUS_EXPR : MINUS_EXPR),
  				   argtype, value, inc);
- 	      TREE_SIDE_EFFECTS (incremented) = 1;
  
  	      modify = build_modify_expr (arg, NOP_EXPR, incremented);
  	      compound = build (COMPOUND_EXPR, TREE_TYPE (arg), modify, value);
--- 4567,4572 ----
*************** build_unary_op (code, xarg, noconvert)
*** 4605,4611 ****
  		arg = stabilize_reference (arg);
  		val = build (MODIFY_EXPR, TREE_TYPE (arg), arg,
  			     boolean_true_node);
- 		TREE_SIDE_EFFECTS (val) = 1;
  		arg = save_expr (arg);
  		val = build (COMPOUND_EXPR, TREE_TYPE (arg), val, arg);
  		val = build (COMPOUND_EXPR, TREE_TYPE (arg), arg, val);
--- 4604,4609 ----
*************** check_return_expr (retval)
*** 6854,6863 ****
    
    /* Actually copy the value returned into the appropriate location.  */
    if (retval && retval != result)
!     {
!       retval = build (INIT_EXPR, TREE_TYPE (result), result, retval);
!       TREE_SIDE_EFFECTS (retval) = 1;
!     }
  
    /* All done.  Remember that this function did return a value.  */
    current_function_returns_value = 1;
--- 6852,6858 ----
    
    /* Actually copy the value returned into the appropriate location.  */
    if (retval && retval != result)
!     retval = build (INIT_EXPR, TREE_TYPE (result), result, retval);
  
    /* All done.  Remember that this function did return a value.  */
    current_function_returns_value = 1;


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