https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100382
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hum. OK, so DSE would also miss is_ctrl_altering_stmt (DCE checks this which
covers stmt_can_throw_internal). So with non-call-EH we even want to preserve
externally throwing EH? Given there's can_delete_dead_exceptions I wonder
if this applies to call EH as well. Note for this to make a practical
difference the throwing function would need to be pure at least (thus subject
to DCE in the first place).
So - wouldn't a more consistent check be
(!stmt_could_throw_p ()
|| cfun->can_delete_dead_exceptions)
?
int x, y;
int __attribute__((pure,noinline)) foo () { if (x) throw; return y; }
int main()
{
int a[2];
x = 1;
try {
int res = foo ();
a[0] = res;
} catch (...) {
return 0;
}
return 1;
}
should show this but the post-dom domwalk is plagued by the same ordering
issue as the dom domwalk was (we visit dom children in non-"RPO" order,
in this case inverted postorder).