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]

[tuples] Assert that GIMPLE_RETURN is returning a gimple value


We no longer support return statements with an assignment to RESULT_DECL
in the returned expression.  This will need more fixes when we are
expanding to RTL, but we're not there yet.


2007-07-28  Diego Novillo  <dnovillo@google.com>

	* gimplify.c (gimplify_return_expr): Do not create a MODIFY_EXPR
	as return argument
	* gimple.c (build_gimple_return): Assert that the returned value
	is a GIMPLE value.

Index: gimplify.c
===================================================================
--- gimplify.c	(revision 127002)
+++ gimplify.c	(working copy)
@@ -1132,10 +1132,9 @@ gimplify_return_expr (tree stmt, gimple_
       || TREE_CODE (ret_expr) == RESULT_DECL
       || ret_expr == error_mark_node)
     {
-      gimple_add (pre_p,
-	      build_gimple_return (ret_expr
-				   && TREE_CODE (ret_expr) == RESULT_DECL,
-	                           ret_expr));
+      bool use_return_decl_p = ret_expr && TREE_CODE (ret_expr) == RESULT_DECL;
+      gimple ret = build_gimple_return (use_return_decl_p, ret_expr);
+      gimple_add (pre_p, ret);
       return GS_ALL_DONE;
     }
 
@@ -1144,8 +1143,9 @@ gimplify_return_expr (tree stmt, gimple_
   else
     {
       result_decl = GENERIC_TREE_OPERAND (ret_expr, 0);
+
+      /* See through a return by reference.  */
       if (TREE_CODE (result_decl) == INDIRECT_REF)
-	/* See through a return by reference.  */
 	result_decl = TREE_OPERAND (result_decl, 0);
 
       gcc_assert ((TREE_CODE (ret_expr) == MODIFY_EXPR
@@ -1190,14 +1190,7 @@ gimplify_return_expr (tree stmt, gimple_
 
   gimplify_and_add (TREE_OPERAND (stmt, 0), pre_p);
 
-  /* If we didn't use a temporary, then the result is just the result_decl.
-     Otherwise we need a simple copy.  This should already be gimple.  */
-  if (result == result_decl)
-    ret_expr = result;
-  else
-    ret_expr = build_gimple_modify_stmt (result_decl, result);
-
-  gimple_add (pre_p, build_gimple_return (result == result_decl, ret_expr));
+  gimple_add (pre_p, build_gimple_return (result == result_decl, result));
 
   return GS_ALL_DONE;
 }
Index: gimple.c
===================================================================
--- gimple.c	(revision 127002)
+++ gimple.c	(working copy)
@@ -145,6 +145,7 @@ gimple
 build_gimple_return (bool result_decl_p, tree retval)
 {
   gimple s = build_gimple_with_ops (GIMPLE_RETURN, (int) result_decl_p, 1);
+  gcc_assert (is_gimple_val (retval));
   gimple_return_set_retval (s, retval);
   return s;
 }

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