https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91164
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think callers are expected to drop dominators if they do not keep them
up-to-date. In fact elsewhere we assume there are no unreachable blocks iff
dominators
are present(?).
We've fixed quite a few places in the RTL pipeline already (I remember
mode-switching.c).
Checking what GIMPLE cfg-cleanup does it now is implemented as part of
cleanup_control_flow_pre ():
/* Remove all now (and previously) unreachable blocks. */
for (int i = NUM_FIXED_BLOCKS; i < last_basic_block_for_fn (cfun); ++i)
{
basic_block bb = BASIC_BLOCK_FOR_FN (cfun, i);
if (bb && !bitmap_bit_p (visited, bb->index))
{
if (!retval)
free_dominance_info (CDI_DOMINATORS);
so IMHO we could mimick that. Note GIMPLE cleanup-cfg (re-)computes
dominators
(since it needs them itself) after that.
And no, there's no less expensive way in general.