summaryrefslogtreecommitdiff
path: root/gcc/tree-eh.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-eh.c')
-rw-r--r--gcc/tree-eh.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 57abca80e4e..7ab8a90a37f 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -3173,6 +3173,26 @@ struct gimple_opt_pass pass_lower_resx =
}
};
+/* Try to optimize var = {v} {CLOBBER} stmts followed just by
+ external throw. */
+
+static void
+optimize_clobbers (basic_block bb)
+{
+ gimple_stmt_iterator gsi = gsi_last_bb (bb);
+ for (gsi_prev (&gsi); !gsi_end_p (gsi); gsi_prev (&gsi))
+ {
+ gimple stmt = gsi_stmt (gsi);
+ if (is_gimple_debug (stmt))
+ continue;
+ if (!gimple_clobber_p (stmt)
+ || TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME)
+ return;
+ unlink_stmt_vdef (stmt);
+ gsi_remove (&gsi, true);
+ release_defs (stmt);
+ }
+}
/* At the end of inlining, we can lower EH_DISPATCH. Return true when
we have found some duplicate labels and removed some edges. */
@@ -3337,11 +3357,16 @@ execute_lower_eh_dispatch (void)
FOR_EACH_BB (bb)
{
gimple last = last_stmt (bb);
- if (last && gimple_code (last) == GIMPLE_EH_DISPATCH)
+ if (last == NULL)
+ continue;
+ if (gimple_code (last) == GIMPLE_EH_DISPATCH)
{
redirected |= lower_eh_dispatch (bb, last);
any_rewritten = true;
}
+ else if (gimple_code (last) == GIMPLE_RESX
+ && stmt_can_throw_external (last))
+ optimize_clobbers (bb);
}
if (redirected)