* [PATCH] shrink-wrap: Fix thinko (PR68520)
@ 2015-11-24 18:19 Segher Boessenkool
2015-11-24 18:35 ` Bernd Schmidt
0 siblings, 1 reply; 2+ messages in thread
From: Segher Boessenkool @ 2015-11-24 18:19 UTC (permalink / raw)
To: gcc-patches; +Cc: bschmidt, Segher Boessenkool
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.
Tested on the testcase in the PR, with an x86_64 cross-compiler;
bootstrap+regcheck in progress (on powerpc64-linux). Is this okay for
trunk if that succeeds?
Segher
2015-11-24 Segher Boessenkool <segher@kernel.crashing.org>
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.
---
gcc/shrink-wrap.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gcc/shrink-wrap.c b/gcc/shrink-wrap.c
index 61765ff..3a1df84 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)
--
1.9.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] shrink-wrap: Fix thinko (PR68520)
2015-11-24 18:19 [PATCH] shrink-wrap: Fix thinko (PR68520) Segher Boessenkool
@ 2015-11-24 18:35 ` Bernd Schmidt
0 siblings, 0 replies; 2+ messages in thread
From: Bernd Schmidt @ 2015-11-24 18:35 UTC (permalink / raw)
To: Segher Boessenkool, gcc-patches
On 11/24/2015 07:13 PM, Segher Boessenkool wrote:
>
> 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.
Ok.
Bernd
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-24 18:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-24 18:19 [PATCH] shrink-wrap: Fix thinko (PR68520) Segher Boessenkool
2015-11-24 18:35 ` Bernd Schmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).