diff mbox series

bb-reorder: Fix for ICEs caused by 69ca5f3a9882

Message ID fd4319db17828cea62d4b2ea65fc7afb802f1f1d.1600120957.git.segher@kernel.crashing.org
State New
Headers show
Series bb-reorder: Fix for ICEs caused by 69ca5f3a9882 | expand

Commit Message

Segher Boessenkool Sept. 14, 2020, 10:05 p.m. UTC
After the previous patch we are left with an unreachable BB.  This will
ICE if either we have -fschedule-fusion, or we do not have peephole2.

This fixes it.  Okay for trunk?


Segher


2020-09-14  Segher Boessenkool  <segher@kernel.crashing.org>

	PR rtl-optimization/96475
	* bb-reorder.c (duplicate_computed_gotos): If we did anything, run
	cleanup_cfg.

---
 gcc/bb-reorder.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Richard Biener Sept. 15, 2020, 6:32 a.m. UTC | #1
On Tue, Sep 15, 2020 at 12:06 AM Segher Boessenkool
<segher@kernel.crashing.org> wrote:
>
> After the previous patch we are left with an unreachable BB.  This will
> ICE if either we have -fschedule-fusion, or we do not have peephole2.
>
> This fixes it.  Okay for trunk?

Just delete_unreachable_blocks () would have worked as well?

Anyway, OK.

Thanks,
Richard.

>
> Segher
>
>
> 2020-09-14  Segher Boessenkool  <segher@kernel.crashing.org>
>
>         PR rtl-optimization/96475
>         * bb-reorder.c (duplicate_computed_gotos): If we did anything, run
>         cleanup_cfg.
>
> ---
>  gcc/bb-reorder.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c
> index 76e56b5..2ad5197 100644
> --- a/gcc/bb-reorder.c
> +++ b/gcc/bb-reorder.c
> @@ -2760,6 +2760,10 @@ duplicate_computed_gotos (function *fun)
>      if (computed_jump_p (BB_END (bb)) && can_duplicate_block_p (bb))
>        changed |= maybe_duplicate_computed_goto (bb, max_size);
>
> +  /* Some blocks may have become unreachable.  */
> +  if (changed)
> +    cleanup_cfg (0);
> +
>    /* Duplicating blocks will redirect edges and may cause hot blocks
>      previously reached by both hot and cold blocks to become dominated
>      only by cold blocks.  */
> --
> 1.8.3.1
>
Segher Boessenkool Sept. 15, 2020, 1:29 p.m. UTC | #2
On Tue, Sep 15, 2020 at 08:32:54AM +0200, Richard Biener wrote:
> On Tue, Sep 15, 2020 at 12:06 AM Segher Boessenkool
> <segher@kernel.crashing.org> wrote:
> >
> > After the previous patch we are left with an unreachable BB.  This will
> > ICE if either we have -fschedule-fusion, or we do not have peephole2.
> >
> > This fixes it.  Okay for trunk?
> 
> Just delete_unreachable_blocks () would have worked as well?

Bunch of reasons:

1) We might want some other things that cleanup_cfg does.  This
unreachable block things caused ICEs in some cases, but what else is
there;
2) cleanup_cfg (0) is quite cheap anyway;
3) And, it is only run if the compgotos pass did do work;
4) I did not even remember delete_unreachable_blocks existed :-)

> Anyway, OK.

Thanks, committed.


Segher
diff mbox series

Patch

diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c
index 76e56b5..2ad5197 100644
--- a/gcc/bb-reorder.c
+++ b/gcc/bb-reorder.c
@@ -2760,6 +2760,10 @@  duplicate_computed_gotos (function *fun)
     if (computed_jump_p (BB_END (bb)) && can_duplicate_block_p (bb))
       changed |= maybe_duplicate_computed_goto (bb, max_size);
 
+  /* Some blocks may have become unreachable.  */
+  if (changed)
+    cleanup_cfg (0);
+
   /* Duplicating blocks will redirect edges and may cause hot blocks
     previously reached by both hot and cold blocks to become dominated
     only by cold blocks.  */