2018-04-13 Jakub Jelinek <jakub@redhat.com>
+ PR rtl-optimization/85393
+ * except.h (expand_dw2_landing_pad_for_region): Remove declaration.
+ * except.c (expand_dw2_landing_pad_for_region): Make static.
+ * bb-reorder.c (fix_up_crossing_landing_pad): In new_bb emit just
+ a label and unconditional jump to old_bb, rather than
+ expand_dw2_landing_pad_for_region insn(s) and jump to single_succ
+ basic block.
+
PR rtl-optimization/85376
* simplify-rtx.c (simplify_const_unary_operation): For CLZ and CTZ and
zero op0, if C?Z_DEFINED_VALUE_AT_ZERO is false, return NULL_RTX
}
/* The landing pad OLD_LP, in block OLD_BB, has edges from both partitions.
- Duplicate the landing pad and split the edges so that no EH edge
- crosses partitions. */
+ Add a new landing pad that will just jump to the old one and split the
+ edges so that no EH edge crosses partitions. */
static void
fix_up_crossing_landing_pad (eh_landing_pad old_lp, basic_block old_bb)
{
eh_landing_pad new_lp;
- basic_block new_bb, last_bb, post_bb;
+ basic_block new_bb, last_bb;
rtx_insn *jump;
unsigned new_partition;
edge_iterator ei;
/* Put appropriate instructions in new bb. */
rtx_code_label *new_label = emit_label (new_lp->landing_pad);
- expand_dw2_landing_pad_for_region (old_lp->region);
-
- post_bb = BLOCK_FOR_INSN (old_lp->landing_pad);
- post_bb = single_succ (post_bb);
- rtx_code_label *post_label = block_label (post_bb);
- jump = emit_jump_insn (targetm.gen_jump (post_label));
- JUMP_LABEL (jump) = post_label;
+ rtx_code_label *old_label = block_label (old_bb);
+ jump = emit_jump_insn (targetm.gen_jump (old_label));
+ JUMP_LABEL (jump) = old_label;
/* Create new basic block to be dest for lp. */
last_bb = EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb;
new_bb = create_basic_block (new_label, jump, last_bb);
new_bb->aux = last_bb->aux;
- new_bb->count = post_bb->count;
+ new_bb->count = old_bb->count;
last_bb->aux = new_bb;
emit_barrier_after_bb (new_bb);
- make_single_succ_edge (new_bb, post_bb, 0);
+ make_single_succ_edge (new_bb, old_bb, 0);
/* Make sure new bb is in the other partition. */
new_partition = BB_PARTITION (old_bb);
/* Fix up the edges. */
for (ei = ei_start (old_bb->preds); (e = ei_safe_edge (ei)) != NULL; )
- if (BB_PARTITION (e->src) == new_partition)
+ if (e->src != new_bb && BB_PARTITION (e->src) == new_partition)
{
rtx_insn *insn = BB_END (e->src);
rtx note = find_reg_note (insn, REG_EH_REGION, NULL_RTX);
extern void expand_builtin_eh_return (tree, tree);
extern void expand_eh_return (void);
extern rtx expand_builtin_extend_pointer (tree);
-extern void expand_dw2_landing_pad_for_region (eh_region);
typedef tree (*duplicate_eh_regions_map) (tree, void *);
extern hash_map<void *, void *> *duplicate_eh_regions
--- /dev/null
+// PR rtl-optimization/85393
+// { dg-do run { target c++11 } }
+// { dg-options "-O2" }
+// { dg-additional-sources "pr85393-aux.cc" }
+
+#include <stdexcept>
+#include <vector>
+
+void foo (char const *s);
+struct S { ~S () noexcept (false) { throw std::runtime_error ("foo"); } };
+
+int
+main (int argc, char *argv[])
+{
+ std::vector <std::vector <char> > args;
+ try
+ {
+ {
+ S k;
+ foo ("A");
+ }
+
+ if (argv)
+ throw std::runtime_error ("foo");
+ args.push_back ({});
+ }
+ catch (std::runtime_error const& e)
+ {}
+}