summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2015-03-13 08:52:51 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2015-03-13 08:52:51 +0000
commit98b2c85f39b54df3bc2d48b16edf27d3e8703caf (patch)
tree8fc2a2876c706f677325a184d1ccf5c45ac26b51
parent25959a395efef4c26d979720c98df9a2737a5f1b (diff)
downloadgcc-98b2c85f39b54df3bc2d48b16edf27d3e8703caf.tar.gz
2015-03-12 Richard Biener <rguenther@suse.de>
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@221410 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/tree-cfg.c3
-rw-r--r--gcc/tree-cfgcleanup.c14
-rw-r--r--gcc/tree-inline.c11
4 files changed, 30 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 18ada578fd6..3f24ed8d569 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2015-03-12 Richard Biener <rguenther@suse.de>
+
+ 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.
+
2015-03-13 Richard Biener <rguenther@suse.de>
PR middle-end/44563
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index ac12a585c51..0f5e428124c 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -1703,7 +1703,8 @@ gimple_can_merge_blocks_p (basic_block a, basic_block b)
if (!single_pred_p (b))
return false;
- if (b == EXIT_BLOCK_PTR_FOR_FN (cfun))
+ if (a == ENTRY_BLOCK_PTR_FOR_FN (cfun)
+ || b == EXIT_BLOCK_PTR_FOR_FN (cfun))
return false;
/* If A ends by a statement causing exceptions or something similar, we
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index f5a21a30f85..e7122e33c28 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;
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 259a3488c34..83e43356f60 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -4779,18 +4779,19 @@ static bool
gimple_expand_calls_inline (basic_block bb, copy_body_data *id)
{
gimple_stmt_iterator gsi;
+ bool inlined = false;
- for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+ for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi);)
{
gimple stmt = gsi_stmt (gsi);
+ gsi_prev (&gsi);
if (is_gimple_call (stmt)
- && !gimple_call_internal_p (stmt)
- && expand_call_inline (bb, stmt, id))
- return true;
+ && !gimple_call_internal_p (stmt))
+ inlined |= expand_call_inline (bb, stmt, id);
}
- return false;
+ return inlined;
}