On Wed, Nov 13, 2019 at 01:15:18PM +0100, Ilya Leoshkevich wrote:
> > But OTOH it may well be the case that other things in cleanup_cfg make
> > the known dominance info invalid as well, in which case just the comment
> > is a bit misleading. Sounds likely to me :-)
>
> Yeah, that's what I worry about as well. In particular, this block in
> try_optimize_cfg:
Heh, I did that code, whoops :-)
> /* Try to change a conditional branch to a return to the
> respective conditional return. */
> if (EDGE_COUNT (b->succs) == 2
> && any_condjump_p (BB_END (b))
> && bb_is_just_return (BRANCH_EDGE (b)->dest, &ret, &use))
> {
> if (redirect_jump (as_a <rtx_jump_insn *> (BB_END (b)),
> PATTERN (ret), 0))
> {
> if (use)
> emit_insn_before (copy_insn (PATTERN (use)),
> BB_END (b));
> if (dump_file)
> fprintf (dump_file, "Changed conditional jump %d->%d "
> "to conditional return.\n",
> b->index, BRANCH_EDGE (b)->dest->index);
> redirect_edge_succ (BRANCH_EDGE (b),
> EXIT_BLOCK_PTR_FOR_FN (cfun));
> BRANCH_EDGE (b)->flags &= ~EDGE_CROSSING;
> changed_here = true;
> }
> }
>
> runs regardless of cleanup mode, and it makes use of redirect_edge_succ,
> which does not update dominators.
Yeah. Of course this only does anything if the targeted block is only
a return insn (and maybe a USE of the return value), so nothing bad will
happen, but the dom info is not technically correct anymore.
Segher