aboutsummaryrefslogtreecommitdiff
path: root/gcc/dce.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-02-05 17:21:36 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-02-05 17:21:36 +0100
commitc64775619ecbb1efef27631100082d1e22230a3e (patch)
tree3466f750e6949e6838f72b7b735d2b19fba1b1ed /gcc/dce.c
parented99e818e02cd7b0c10c9e8cba7fec8ee17b0ca7 (diff)
downloadgcc-c64775619ecbb1efef27631100082d1e22230a3e.zip
gcc-c64775619ecbb1efef27631100082d1e22230a3e.tar.gz
gcc-c64775619ecbb1efef27631100082d1e22230a3e.tar.bz2
re PR target/89188 (ICE in pre_and_rev_post_order_compute, at cfganal.c:1055)
PR target/89188 * dce.c (delete_unmarked_insns): Don't remove no-op moves if they can throw, non-call exceptions are enabled and we can't delete dead exceptions or alter cfg. Set must_clean if delete_insn_and_edges returns true, don't set it blindly for calls. Assert that delete_unreachable_blocks is called only if can_alter_cfg. * g++.dg/opt/pr89188.C: New test. From-SVN: r268544
Diffstat (limited to 'gcc/dce.c')
-rw-r--r--gcc/dce.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/gcc/dce.c b/gcc/dce.c
index 7fd9c37..cb18e815 100644
--- a/gcc/dce.c
+++ b/gcc/dce.c
@@ -584,7 +584,12 @@ delete_unmarked_insns (void)
rtx turn_into_use = NULL_RTX;
/* Always delete no-op moves. */
- if (noop_move_p (insn))
+ if (noop_move_p (insn)
+ /* Unless the no-op move can throw and we are not allowed
+ to alter cfg. */
+ && (!cfun->can_throw_non_call_exceptions
+ || (cfun->can_delete_dead_exceptions && can_alter_cfg)
+ || insn_nothrow_p (insn)))
{
if (RTX_FRAME_RELATED_P (insn))
turn_into_use
@@ -627,12 +632,6 @@ delete_unmarked_insns (void)
for the destination regs in order to avoid dangling notes. */
remove_reg_equal_equiv_notes_for_defs (insn);
- /* If a pure or const call is deleted, this may make the cfg
- have unreachable blocks. We rememeber this and call
- delete_unreachable_blocks at the end. */
- if (CALL_P (insn))
- must_clean = true;
-
if (turn_into_use)
{
/* Don't remove frame related noop moves if they cary
@@ -645,12 +644,15 @@ delete_unmarked_insns (void)
}
else
/* Now delete the insn. */
- delete_insn_and_edges (insn);
+ must_clean |= delete_insn_and_edges (insn);
}
/* Deleted a pure or const call. */
if (must_clean)
- delete_unreachable_blocks ();
+ {
+ gcc_assert (can_alter_cfg);
+ delete_unreachable_blocks ();
+ }
}