summaryrefslogtreecommitdiff
path: root/gcc/dce.c
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2012-06-15 09:22:00 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2012-06-15 09:22:00 +0000
commitbc0dfc8d56508f3390307d85291503b954f2a17f (patch)
tree25c62c51c178ea6a10880eb537b869fdb857970d /gcc/dce.c
parent22e93a4482890176e74b1c9626f00ae7108f8fee (diff)
downloadgcc-bc0dfc8d56508f3390307d85291503b954f2a17f.tar.gz
PR middle-end/53590
* common.opt (-fdelete-dead-exceptions): New switch. * doc/invoke.texi (Code Gen Options): Document it. * cse.c (count_reg_usage) <CALL_INSN>: Use !insn_nothrow_p in lieu of insn_could_throw_p predicate. Do not skip an insn that could throw if dead exceptions can be deleted. (insn_live_p): Likewise, do not return true in that case. * dce.c (can_alter_cfg): New flag. (deletable_insn_p): Do not return false for an insn that can throw if the CFG can be altered and dead exceptions can be deleted. (init_dce): Set can_alter_cfg to false for fast DCE, true otherwise. * dse.c (scan_insn): Use !insn_nothrow_p in lieu of insn_could_throw_ predicate. Do not preserve an insn that could throw if dead exceptions can be deleted. * function.h (struct function): Add can_delete_dead_exceptions flag. * function.c (allocate_struct_function): Set it. * lto-streamer-in.c (input_struct_function_base): Stream it. * lto-streamer-out.c (input_struct_function_base): Likewise. * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Do not mark a statement that could throw as necessary if dead exceptions can be deleted. ada/ * gcc-interface/misc.c (gnat_init_options_struct): Set opts->x_flag_delete_dead_exceptions to 1. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@188651 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/dce.c')
-rw-r--r--gcc/dce.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/gcc/dce.c b/gcc/dce.c
index 86edea11c55..8954d5c0c01 100644
--- a/gcc/dce.c
+++ b/gcc/dce.c
@@ -47,6 +47,9 @@ along with GCC; see the file COPYING3. If not see
we don't want to reenter it. */
static bool df_in_progress = false;
+/* True if we are allowed to alter the CFG in this pass. */
+static bool can_alter_cfg = false;
+
/* Instructions that have been marked but whose dependencies have not
yet been processed. */
static VEC(rtx,heap) *worklist;
@@ -113,8 +116,9 @@ deletable_insn_p (rtx insn, bool fast, bitmap arg_stores)
if (!NONJUMP_INSN_P (insn))
return false;
- /* Don't delete insns that can throw. */
- if (!insn_nothrow_p (insn))
+ /* Don't delete insns that may throw if we cannot do so. */
+ if (!(cfun->can_delete_dead_exceptions && can_alter_cfg)
+ && !insn_nothrow_p (insn))
return false;
body = PATTERN (insn);
@@ -711,7 +715,10 @@ init_dce (bool fast)
{
bitmap_obstack_initialize (&dce_blocks_bitmap_obstack);
bitmap_obstack_initialize (&dce_tmp_bitmap_obstack);
+ can_alter_cfg = false;
}
+ else
+ can_alter_cfg = true;
marked = sbitmap_alloc (get_max_uid () + 1);
sbitmap_zero (marked);