This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] RETURN_EXPR argument
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: gcc at gcc dot gnu dot org
- Cc: dnovillo at redhat dot com
- Date: Wed, 19 Nov 2003 01:20:56 +0100
- Subject: [tree-ssa] RETURN_EXPR argument
Hello,
what is the reason for allowing the argument of a RETURN_EXPR to be a
regular modify statement? It would IMHO be simpler to manipulate
if there was only the returned value; a comment in tree-simple.c claims
that "some of expand_return depends on getting a MODIFY_EXPR", but
the following patch passes at least c testsuite without any problems.
Zdenek
Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gimplify.c,v
retrieving revision 1.1.2.118
diff -c -3 -p -r1.1.2.118 gimplify.c
*** gimplify.c 17 Nov 2003 23:18:12 -0000 1.1.2.118
--- gimplify.c 19 Nov 2003 00:16:30 -0000
*************** gimplify_return_expr (tree stmt, tree *p
*** 867,920 ****
#endif
}
! /* We need to pass the full MODIFY_EXPR down so that special handling
! can replace it with something else. */
gimplify_stmt (&ret_expr);
-
- if (result == NULL_TREE)
- TREE_OPERAND (stmt, 0) = NULL_TREE;
- else if (ret_expr == TREE_OPERAND (stmt, 0))
- /* It was already GIMPLE. */
- return GS_ALL_DONE;
- else
- {
- /* If there's still a MODIFY_EXPR of the RESULT_DECL after
- gimplification, find it so we can put it in the RETURN_EXPR. */
- tree ret = NULL_TREE;
-
- if (TREE_CODE (ret_expr) == STATEMENT_LIST)
- {
- tree_stmt_iterator si;
- for (si = tsi_start (ret_expr); !tsi_end_p (si); tsi_next (&si))
- {
- tree sub = tsi_stmt (si);
- if (TREE_CODE (sub) == MODIFY_EXPR
- && TREE_OPERAND (sub, 0) == result)
- {
- ret = sub;
- if (tsi_one_before_end_p (si))
- tsi_delink (&si);
- else
- {
- /* If there were posteffects after the MODIFY_EXPR,
- we need a temporary. */
- tree tmp = create_tmp_var (TREE_TYPE (result), "retval");
- TREE_OPERAND (ret, 0) = tmp;
- ret = build (MODIFY_EXPR, TREE_TYPE (result),
- result, tmp);
- }
- break;
- }
- }
- }
-
- if (ret)
- TREE_OPERAND (stmt, 0) = ret;
- else
- /* The return value must be set up some other way. Just tell
- expand_return that we're returning the RESULT_DECL. */
- TREE_OPERAND (stmt, 0) = result;
- }
append_to_statement_list (ret_expr, pre_p);
return GS_ALL_DONE;
--- 867,874 ----
#endif
}
! TREE_OPERAND (stmt, 0) = result;
gimplify_stmt (&ret_expr);
append_to_statement_list (ret_expr, pre_p);
return GS_ALL_DONE;