On Wed, May 05, 2021 at 02:19:27PM +0200, Eric Botcazou wrote:
> > At least for NOTE_INSN_BASIC_BLOCK skipping more than one might
> > be problematic, because that would mean we've skipped into a different basic
> > block and it wouldn't surprise me if split_block in that case crashed or
> > did something weird (if the first argument is not BLOCK_FOR_INSN of the
> > second argument when it is non-NULL).
> > For the other notes, I think they should normally appear just once and
> > shouldn't be a problem therefore.
> 
> OK, version essentially equivalent to the original one, but with a loop.

LGTM.

> diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
> index f05cb6136c7..17edc4f37ad 100644
> --- a/gcc/cfgcleanup.c
> +++ b/gcc/cfgcleanup.c
> @@ -2145,7 +2145,11 @@ try_crossjump_to_edge (int mode, edge e1, edge e2,
>    if (NOTE_INSN_BASIC_BLOCK_P (newpos1))
>      newpos1 = NEXT_INSN (newpos1);
>  
> -  while (DEBUG_INSN_P (newpos1))
> +  /* Skip also prologue and function markers.  */
> +  while (DEBUG_INSN_P (newpos1)
> +      || (NOTE_P (newpos1)
> +          && (NOTE_KIND (newpos1) == NOTE_INSN_PROLOGUE_END
> +              || NOTE_KIND (newpos1) == NOTE_INSN_FUNCTION_BEG)))
>      newpos1 = NEXT_INSN (newpos1);
>  
>    redirect_from = split_block (src1, PREV_INSN (newpos1))->src;


        Jakub

Reply via email to