diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-09-05 13:04:40 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-09-05 13:04:40 +0000 |
commit | 6437689e431efe19c416e50810609b043bec3f76 (patch) | |
tree | 90b86e5c02c302902763114e914e357c26422e94 /gcc/loop-init.c | |
parent | df53c4418ed1e046556cbc17784ebdc0c6c31ce6 (diff) |
2014-09-05 Richard Biener <rguenther@suse.de>
* cfgloop.c (mark_loop_for_removal): Record former header
when ENABLE_CHECKING.
* cfgloop.h (strut loop): Add former_header member when
ENABLE_CHECKING.
* loop-init.c (fix_loop_structure): Sanity check loops
marked for removal if they re-appeared.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@214957 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/loop-init.c')
-rw-r--r-- | gcc/loop-init.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/loop-init.c b/gcc/loop-init.c index 26c953f71e51..e3734abadcea 100644 --- a/gcc/loop-init.c +++ b/gcc/loop-init.c @@ -245,6 +245,12 @@ fix_loop_structure (bitmap changed_bbs) } /* Remove the loop. */ +#ifdef ENABLE_CHECKING + if (loop->header) + loop->former_header = loop->header; + else + gcc_assert (loop->former_header != NULL); +#endif loop->header = NULL; flow_loop_tree_node_remove (loop); } @@ -272,6 +278,35 @@ fix_loop_structure (bitmap changed_bbs) FOR_EACH_VEC_ELT (*get_loops (cfun), i, loop) if (loop && loop->header == NULL) { +#ifdef ENABLE_CHECKING + if (dump_file + && ((unsigned) loop->former_header->index + < basic_block_info_for_fn (cfun)->length ())) + { + basic_block former_header + = BASIC_BLOCK_FOR_FN (cfun, loop->former_header->index); + /* If the old header still exists we want to check if the + original loop is re-discovered or the old header is now + part of a newly discovered loop. + In both cases we should have avoided removing the loop. */ + if (former_header == loop->former_header) + { + if (former_header->loop_father->header == former_header) + fprintf (dump_file, "fix_loop_structure: rediscovered " + "removed loop %d as loop %d with old header %d\n", + loop->num, former_header->loop_father->num, + former_header->index); + else if ((unsigned) former_header->loop_father->num + >= old_nloops) + fprintf (dump_file, "fix_loop_structure: header %d of " + "removed loop %d is part of the newly " + "discovered loop %d with header %d\n", + former_header->index, loop->num, + former_header->loop_father->num, + former_header->loop_father->header->index); + } + } +#endif (*get_loops (cfun))[i] = NULL; flow_loop_free (loop); } |