diff options
author | Kyrylo Tkachov <ktkachov@gcc.gnu.org> | 2015-11-24 11:03:51 +0000 |
---|---|---|
committer | Kyrylo Tkachov <ktkachov@gcc.gnu.org> | 2015-11-24 11:03:51 +0000 |
commit | 895548a571810f574a7f2a5ebdf6efa3250fa993 (patch) | |
tree | 764f838fee6d420fb2d792bc03d1db13516096df /gcc/cfgloop.c | |
parent | 3788cfb513d19a9b36311b1317aff2141a2c6a65 (diff) | |
download | gcc-895548a571810f574a7f2a5ebdf6efa3250fa993.tar.gz |
[cfgloop] PR middle-end/68375: Restructure get_loop_body_in_bfs_order to handle loops with only a header
PR middle-end/68375
* cfgloop.c (get_loop_body_in_bfs_order): Restructure loop to avoid
bogus assertion.
* gcc.dg/pr68375.c: New test.
From-SVN: r230798
Diffstat (limited to 'gcc/cfgloop.c')
-rw-r--r-- | gcc/cfgloop.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c index bf00e0e17f5..83a526276db 100644 --- a/gcc/cfgloop.c +++ b/gcc/cfgloop.c @@ -913,37 +913,32 @@ get_loop_body_in_bfs_order (const struct loop *loop) basic_block *blocks; basic_block bb; bitmap visited; - unsigned int i = 0; - unsigned int vc = 1; + unsigned int i = 1; + unsigned int vc = 0; gcc_assert (loop->num_nodes); gcc_assert (loop->latch != EXIT_BLOCK_PTR_FOR_FN (cfun)); blocks = XNEWVEC (basic_block, loop->num_nodes); visited = BITMAP_ALLOC (NULL); - - bb = loop->header; + blocks[0] = loop->header; + bitmap_set_bit (visited, loop->header->index); while (i < loop->num_nodes) { edge e; edge_iterator ei; - - if (bitmap_set_bit (visited, bb->index)) - /* This basic block is now visited */ - blocks[i++] = bb; + gcc_assert (i > vc); + bb = blocks[vc++]; FOR_EACH_EDGE (e, ei, bb->succs) { if (flow_bb_inside_loop_p (loop, e->dest)) { + /* This bb is now visited. */ if (bitmap_set_bit (visited, e->dest->index)) blocks[i++] = e->dest; } } - - gcc_assert (i > vc); - - bb = blocks[vc++]; } BITMAP_FREE (visited); |