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]
Other format: [Raw text]

[ tree-ssa ] Simplify RETURN_EXPR handling


Conversion of TRY_FINALLY_EXPR into TRY_CATCH_EXPR requires insertion of
some code fragments on exit points of the TRY_FINALLY_EXPRs.

Insertion of those code fragments isn't terribly difficult, except in
one case -- a CALL_EXPR which appears on the RHS of a MODIFY_EXPR 
inside a RETURN_EXPR.

It's critical that the code fragments run after the CALL_EXPR.  If the
CALL_EXPR is in the RETURN_EXPR, then there's really not anywhere to
insert our code fragments.

Luckily it's not terribly difficult to limit the RHS of a MODIFY_EXPR
appearing in a RETURN_EXPR.

	* gimplify.c (simplify_return_expr): Only allow simple values
	on the RHS of a MODIFY_EXPR appearing in a RETURN_EXPR.
	* tree-cfg.c (make_exit_edges): We no longer need to look for
	CALL_EXPRs on the RHS of a MODIFY_EXPR inside RETURN_EXPRs.

Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gimplify.c,v
retrieving revision 1.1.2.30
diff -c -3 -p -r1.1.2.30 gimplify.c
*** gimplify.c	13 Mar 2003 22:24:24 -0000	1.1.2.30
--- gimplify.c	19 Mar 2003 20:07:05 -0000
*************** simplify_return_expr (stmt, pre_p)
*** 864,872 ****
  	}
        else
  	{
! 	  /* Make sure the RHS is really simple.  */
  	  simplify_expr (&TREE_OPERAND (ret_expr, 1), pre_p, NULL,
! 			 is_simple_rhs, fb_rvalue);
  	  TREE_OPERAND (stmt, 0) = ret_expr;
  	}
      }
--- 864,875 ----
  	}
        else
  	{
! 	  /* We want the RHS to be a simple value as that makes conversion
! 	     of TRY_FINALLY_EXPRs into TRY_CATCH_EXPRs much simpler as
! 	     we do not have to worry about having a CALL_EXPR on the RHS
! 	     of a MODIFY_EXPR which appears in a RETURN_EXPR.  */
  	  simplify_expr (&TREE_OPERAND (ret_expr, 1), pre_p, NULL,
! 			 is_simple_val, fb_rvalue);
  	  TREE_OPERAND (stmt, 0) = ret_expr;
  	}
      }
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.62
diff -c -3 -p -r1.1.4.62 tree-cfg.c
*** tree-cfg.c	18 Mar 2003 14:52:25 -0000	1.1.4.62
--- tree-cfg.c	19 Mar 2003 20:07:09 -0000
*************** make_exit_edges (bb)
*** 748,762 ****
  
      case RETURN_EXPR:
        make_edge (bb, EXIT_BLOCK_PTR, 0);
- 
-       /* A RETURN_EXPR may contain a CALL_EXPR and the CALL_EXPR may
- 	 have an abnormal edge.  Search the operand of the RETURN_EXPR
- 	 for this case and create any required edges.  */
-       if (TREE_OPERAND (last, 0)
- 	  && TREE_CODE (TREE_OPERAND (last, 0)) == MODIFY_EXPR
- 	  && TREE_CODE (TREE_OPERAND (TREE_OPERAND (last, 0), 1)) == CALL_EXPR
- 	  && FUNCTION_RECEIVES_NONLOCAL_GOTO (current_function_decl))
- 	make_goto_expr_edges (bb);
        break;
  
      case MODIFY_EXPR:
--- 748,753 ----




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