aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/tree-cfg.c16
2 files changed, 21 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bd63a97..b851e51 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2004-06-02 Jan Hubicka <jh@suse.cz>
+
+ * tree-cfg.c (tree_find_edge_insert_loc): Allow inserting before
+ return_stmt.
+
2004-06-02 Jason Merrill <jason@redhat.com>
* Makefile.in (TAGS): Don't mess with c-parse.[ch].
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index e53d71c..21277d8 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -2931,6 +2931,22 @@ tree_find_edge_insert_loc (edge e, block_stmt_iterator *bsi)
tmp = bsi_stmt (*bsi);
if (!stmt_ends_bb_p (tmp))
return true;
+
+ /* Insert code just before returning the value. We may need to decompose
+ the return in the case it contains non-trivial operand. */
+ if (TREE_CODE (tmp) == RETURN_EXPR)
+ {
+ tree op = TREE_OPERAND (tmp, 0);
+ if (!is_gimple_val (op))
+ {
+ if (TREE_CODE (op) != MODIFY_EXPR)
+ abort ();
+ bsi_insert_before (bsi, op, BSI_NEW_STMT);
+ TREE_OPERAND (tmp, 0) = TREE_OPERAND (op, 0);
+ }
+ bsi_prev (bsi);
+ return true;
+ }
}
/* Otherwise, create a new basic block, and split this edge. */