diff options
Diffstat (limited to 'gcc/tree-cfgcleanup.c')
-rw-r--r-- | gcc/tree-cfgcleanup.c | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index 00fed83..c35001c 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -596,8 +596,8 @@ cleanup_tree_cfg_1 (void) /* Remove unreachable blocks and other miscellaneous clean up work. Return true if the flowgraph was modified, false otherwise. */ -bool -cleanup_tree_cfg (void) +static bool +cleanup_tree_cfg_noloop (void) { bool changed; @@ -632,34 +632,47 @@ cleanup_tree_cfg (void) timevar_pop (TV_TREE_CLEANUP_CFG); + if (changed && current_loops) + current_loops->state |= LOOPS_NEED_FIXUP; + return changed; } -/* Cleanup cfg and repair loop structures. */ +/* Repairs loop structures. */ -bool -cleanup_tree_cfg_loop (void) +static void +repair_loop_structures (void) { - bool changed = cleanup_tree_cfg (); + bitmap changed_bbs = BITMAP_ALLOC (NULL); + fix_loop_structure (changed_bbs); - if (changed && current_loops != NULL) - { - bitmap changed_bbs = BITMAP_ALLOC (NULL); - fix_loop_structure (changed_bbs); + /* This usually does nothing. But sometimes parts of cfg that originally + were inside a loop get out of it due to edge removal (since they + become unreachable by back edges from latch). */ + if ((current_loops->state & LOOP_CLOSED_SSA) != 0) + rewrite_into_loop_closed_ssa (changed_bbs, TODO_update_ssa); - /* This usually does nothing. But sometimes parts of cfg that originally - were inside a loop get out of it due to edge removal (since they - become unreachable by back edges from latch). */ - if ((current_loops->state & LOOP_CLOSED_SSA) != 0) - rewrite_into_loop_closed_ssa (changed_bbs, TODO_update_ssa); - - BITMAP_FREE (changed_bbs); + BITMAP_FREE (changed_bbs); #ifdef ENABLE_CHECKING - verify_loop_structure (); + verify_loop_structure (); #endif - scev_reset (); - } + scev_reset (); + + current_loops->state &= ~LOOPS_NEED_FIXUP; +} + +/* Cleanup cfg and repair loop structures. */ + +bool +cleanup_tree_cfg (void) +{ + bool changed = cleanup_tree_cfg_noloop (); + + if (current_loops != NULL + && (current_loops->state & LOOPS_NEED_FIXUP)) + repair_loop_structures (); + return changed; } |