From 2aa26a5543cfd6fc2c03051d532f778da8318e9b Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 13 Mar 2015 08:52:51 +0000 Subject: re PR ipa/44563 (GCC uses a lot of RAM when compiling a large numbers of functions) 2015-03-12 Richard Biener PR middle-end/44563 * tree-inline.c (gimple_expand_calls_inline): Walk BB backwards to avoid quadratic behavior with inline expansion splitting blocks. * tree-cfgcleanup.c (cleanup_tree_cfg_bb): Do not merge block with the successor if the predecessor will be merged with it. * tree-cfg.c (gimple_can_merge_blocks_p): We can't merge the entry block with its successor. From-SVN: r221410 --- gcc/tree-cfgcleanup.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'gcc/tree-cfgcleanup.c') diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index f5a21a30..e7122e3 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -650,8 +650,18 @@ cleanup_tree_cfg_bb (basic_block bb) if (single_succ_p (bb) && can_merge_blocks_p (bb, single_succ (bb))) { - merge_blocks (bb, single_succ (bb)); - return true; + /* If there is a merge opportunity with the predecessor + do nothing now but wait until we process the predecessor. + This happens when we visit BBs in a non-optimal order and + avoids quadratic behavior with adjusting stmts BB pointer. */ + if (single_pred_p (bb) + && can_merge_blocks_p (single_pred (bb), bb)) + ; + else + { + merge_blocks (bb, single_succ (bb)); + return true; + } } return retval; -- cgit v1.1