From: Segher Boessenkool Date: Tue, 24 Nov 2015 21:23:25 +0000 (+0100) Subject: shrink-wrap: Fix thinko (PR68520) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=82ad51444ff2a9faf3e019b07c98fbae0e753a0f;p=gcc.git shrink-wrap: Fix thinko (PR68520) Part of the shrink-wrapping algorithm has this comment: /* Now see if we can put the prologue at the start of PRO. Putting it there might require duplicating a block that cannot be duplicated, or in some cases we cannot insert the prologue there at all. If PRO wont't do, try again with the immediate dominator of PRO, and so on. The blocks that need duplicating are those reachable from PRO but not dominated by it. We keep in BB_WITH a bitmap of the blocks reachable from PRO that we already found, and in VEC a stack of those we still need to consider (to find successors). */ Two of the cases that push to that stack do not actually check the bitmap first. Either I thought those blocks could not be on the stack already, or more likely I didn't think and it just didn't crash during any testing. But of course those blocks *can* already be on the stack (if you have a hideous loop structure), and then we end up with the same block on the stack more than once. This is harmless, except that (like in the PR) this can overflow the stack. This fixes it, by doing the necessary bitmap checks before pushing. PR rtl-optimization/68520 * shrink-wrap.c (try_shrink_wrapping): Don't push a block to VEC if its bit was already set in BB_WITH. From-SVN: r230843 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b097f4ea71e..6333faa94f3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-11-24 Segher Boessenkool + + PR rtl-optimization/68520 + * shrink-wrap.c (try_shrink_wrapping): Don't push a block to VEC if + its bit was already set in BB_WITH. + 2015-11-24 Jan Hubicka * alias.c (get_alias_set): Before checking TYPE_ALIAS_SET_KNOWN_P diff --git a/gcc/shrink-wrap.c b/gcc/shrink-wrap.c index 61765ff2cfb..3a1df845e20 100644 --- a/gcc/shrink-wrap.c +++ b/gcc/shrink-wrap.c @@ -722,8 +722,8 @@ try_shrink_wrapping (edge *entry_edge, bitmap_head *bb_with, { pro = get_immediate_dominator (CDI_DOMINATORS, pro); - bitmap_set_bit (bb_with, pro->index); - vec.quick_push (pro); + if (bitmap_set_bit (bb_with, pro->index)) + vec.quick_push (pro); } basic_block bb = vec.pop (); @@ -734,8 +734,8 @@ try_shrink_wrapping (edge *entry_edge, bitmap_head *bb_with, pro = get_immediate_dominator (CDI_DOMINATORS, pro); - bitmap_set_bit (bb_with, pro->index); - vec.quick_push (pro); + if (bitmap_set_bit (bb_with, pro->index)) + vec.quick_push (pro); } FOR_EACH_EDGE (e, ei, bb->succs)