From: Jan Hubicka Date: Wed, 2 Jun 2004 21:13:55 +0000 (+0200) Subject: tree-cfg.c (tree_find_edge_insert_loc): Allow inserting before return_stmt. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ce068299f5f38bc06a50f08f751fc4c23288f36f;p=gcc.git tree-cfg.c (tree_find_edge_insert_loc): Allow inserting before return_stmt. * tree-cfg.c (tree_find_edge_insert_loc): Allow inserting before return_stmt. From-SVN: r82586 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bd63a97189c..b851e51b266 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-06-02 Jan Hubicka + + * tree-cfg.c (tree_find_edge_insert_loc): Allow inserting before + return_stmt. + 2004-06-02 Jason Merrill * Makefile.in (TAGS): Don't mess with c-parse.[ch]. diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index e53d71c2aaf..21277d86bf2 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. */