* [tuples] Assert that GIMPLE_RETURN is returning a gimple value
@ 2007-07-28 16:34 Diego Novillo
0 siblings, 0 replies; only message in thread
From: Diego Novillo @ 2007-07-28 16:34 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 186 bytes --]
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.
[-- Attachment #2: 20070728-no-modify_expr-in-return.diff --]
[-- Type: text/x-patch, Size: 2273 bytes --]
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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-07-28 15:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-28 16:34 [tuples] Assert that GIMPLE_RETURN is returning a gimple value Diego Novillo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).