diff options
author | Richard Biener <rguenther@suse.de> | 2015-12-02 09:47:43 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2015-12-02 09:47:43 +0000 |
commit | 3810ff24db44fde0629e0fc1e6449a219aef94fb (patch) | |
tree | fa4021b1bfa7ec0b0f842b78c7121c7b80618428 /gcc/tree-cfgcleanup.c | |
parent | d95ab70a3cab2998b4671d842e1ad769e75f19a3 (diff) | |
download | gcc-3810ff24db44fde0629e0fc1e6449a219aef94fb.zip gcc-3810ff24db44fde0629e0fc1e6449a219aef94fb.tar.gz gcc-3810ff24db44fde0629e0fc1e6449a219aef94fb.tar.bz2 |
re PR tree-optimization/68625 (Segmentation fault in useless_type_conversion_p)
2015-12-02 Richard Biener <rguenther@suse.de>
PR tree-optimization/68625
* tree-cfgcleanup.c (cleanup_tree_cfg_bb): Do not call
cleanup_control_flow_bb.
(cleanup_tree_cfg_1): First perform cleanup_control_flow_bb
on all BBs, then cleanup_tree_cfg_bb and finally iterate
over the worklist doing both.
* gcc.dg/torture/pr68625.c: New testcase.
From-SVN: r231162
Diffstat (limited to 'gcc/tree-cfgcleanup.c')
-rw-r--r-- | gcc/tree-cfgcleanup.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index 9eee7bb..40ad5ca 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -614,8 +614,6 @@ fixup_noreturn_call (gimple *stmt) static bool cleanup_tree_cfg_bb (basic_block bb) { - bool retval = cleanup_control_flow_bb (bb); - if (tree_forwarder_block_p (bb, false) && remove_forwarder_block (bb)) return true; @@ -640,7 +638,7 @@ cleanup_tree_cfg_bb (basic_block bb) } } - return retval; + return false; } /* Iterate the cfg cleanups, while anything changes. */ @@ -660,8 +658,26 @@ cleanup_tree_cfg_1 (void) recording of edge to CASE_LABEL_EXPR. */ start_recording_case_labels (); - /* Start by iterating over all basic blocks. We cannot use FOR_EACH_BB_FN, + /* We cannot use FOR_EACH_BB_FN for the BB iterations below since the basic blocks may get removed. */ + + /* Start by iterating over all basic blocks looking for edge removal + opportunities. Do this first because incoming SSA form may be + invalid and we want to avoid performing SSA related tasks such + as propgating out a PHI node during BB merging in that state. */ + n = last_basic_block_for_fn (cfun); + for (i = NUM_FIXED_BLOCKS; i < n; i++) + { + bb = BASIC_BLOCK_FOR_FN (cfun, i); + if (bb) + retval |= cleanup_control_flow_bb (bb); + } + + /* After doing the above SSA form should be valid (or an update SSA + should be required). */ + + /* Continue by iterating over all basic blocks looking for BB merging + opportunities. */ n = last_basic_block_for_fn (cfun); for (i = NUM_FIXED_BLOCKS; i < n; i++) { @@ -682,6 +698,7 @@ cleanup_tree_cfg_1 (void) if (!bb) continue; + retval |= cleanup_control_flow_bb (bb); retval |= cleanup_tree_cfg_bb (bb); } |