Commit 465d0087 by Jakub Jelinek Committed by Jakub Jelinek

re PR rtl-optimization/85393 (Miscompilation with hot/cold partitioning starting with r254832)

	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.

	* g++.dg/opt/pr85393.C: New test.
	* g++.dg/opt/pr85393-aux.cc: New file.

From-SVN: r259378
parent 9b915824
2018-04-13 Jakub Jelinek <jakub@redhat.com> 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 PR rtl-optimization/85376
* simplify-rtx.c (simplify_const_unary_operation): For CLZ and CTZ and * 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 zero op0, if C?Z_DEFINED_VALUE_AT_ZERO is false, return NULL_RTX
......
...@@ -1409,14 +1409,14 @@ get_uncond_jump_length (void) ...@@ -1409,14 +1409,14 @@ get_uncond_jump_length (void)
} }
/* The landing pad OLD_LP, in block OLD_BB, has edges from both partitions. /* 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 Add a new landing pad that will just jump to the old one and split the
crosses partitions. */ edges so that no EH edge crosses partitions. */
static void static void
fix_up_crossing_landing_pad (eh_landing_pad old_lp, basic_block old_bb) fix_up_crossing_landing_pad (eh_landing_pad old_lp, basic_block old_bb)
{ {
eh_landing_pad new_lp; eh_landing_pad new_lp;
basic_block new_bb, last_bb, post_bb; basic_block new_bb, last_bb;
rtx_insn *jump; rtx_insn *jump;
unsigned new_partition; unsigned new_partition;
edge_iterator ei; edge_iterator ei;
...@@ -1431,24 +1431,20 @@ fix_up_crossing_landing_pad (eh_landing_pad old_lp, basic_block old_bb) ...@@ -1431,24 +1431,20 @@ fix_up_crossing_landing_pad (eh_landing_pad old_lp, basic_block old_bb)
/* Put appropriate instructions in new bb. */ /* Put appropriate instructions in new bb. */
rtx_code_label *new_label = emit_label (new_lp->landing_pad); rtx_code_label *new_label = emit_label (new_lp->landing_pad);
expand_dw2_landing_pad_for_region (old_lp->region); rtx_code_label *old_label = block_label (old_bb);
jump = emit_jump_insn (targetm.gen_jump (old_label));
post_bb = BLOCK_FOR_INSN (old_lp->landing_pad); JUMP_LABEL (jump) = old_label;
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;
/* Create new basic block to be dest for lp. */ /* Create new basic block to be dest for lp. */
last_bb = EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb; last_bb = EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb;
new_bb = create_basic_block (new_label, jump, last_bb); new_bb = create_basic_block (new_label, jump, last_bb);
new_bb->aux = last_bb->aux; new_bb->aux = last_bb->aux;
new_bb->count = post_bb->count; new_bb->count = old_bb->count;
last_bb->aux = new_bb; last_bb->aux = new_bb;
emit_barrier_after_bb (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. */ /* Make sure new bb is in the other partition. */
new_partition = BB_PARTITION (old_bb); new_partition = BB_PARTITION (old_bb);
...@@ -1457,7 +1453,7 @@ fix_up_crossing_landing_pad (eh_landing_pad old_lp, basic_block old_bb) ...@@ -1457,7 +1453,7 @@ fix_up_crossing_landing_pad (eh_landing_pad old_lp, basic_block old_bb)
/* Fix up the edges. */ /* Fix up the edges. */
for (ei = ei_start (old_bb->preds); (e = ei_safe_edge (ei)) != NULL; ) 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_insn *insn = BB_END (e->src);
rtx note = find_reg_note (insn, REG_EH_REGION, NULL_RTX); rtx note = find_reg_note (insn, REG_EH_REGION, NULL_RTX);
......
...@@ -947,7 +947,7 @@ emit_to_new_bb_before (rtx_insn *seq, rtx_insn *insn) ...@@ -947,7 +947,7 @@ emit_to_new_bb_before (rtx_insn *seq, rtx_insn *insn)
at the rtl level. Emit the code required by the target at a landing at the rtl level. Emit the code required by the target at a landing
pad for the given region. */ pad for the given region. */
void static void
expand_dw2_landing_pad_for_region (eh_region region) expand_dw2_landing_pad_for_region (eh_region region)
{ {
if (targetm.have_exception_receiver ()) if (targetm.have_exception_receiver ())
......
...@@ -243,7 +243,6 @@ extern rtx expand_builtin_dwarf_sp_column (void); ...@@ -243,7 +243,6 @@ extern rtx expand_builtin_dwarf_sp_column (void);
extern void expand_builtin_eh_return (tree, tree); extern void expand_builtin_eh_return (tree, tree);
extern void expand_eh_return (void); extern void expand_eh_return (void);
extern rtx expand_builtin_extend_pointer (tree); 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 *); typedef tree (*duplicate_eh_regions_map) (tree, void *);
extern hash_map<void *, void *> *duplicate_eh_regions extern hash_map<void *, void *> *duplicate_eh_regions
......
2018-04-13 Jakub Jelinek <jakub@redhat.com> 2018-04-13 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/85393
* g++.dg/opt/pr85393.C: New test.
* g++.dg/opt/pr85393-aux.cc: New file.
PR rtl-optimization/85376 PR rtl-optimization/85376
* gcc.dg/pr85376.c: New test. * gcc.dg/pr85376.c: New test.
......
// PR rtl-optimization/85393
// { dg-do compile }
// { dg-options "" }
void foo (char const *) {}
// 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)
{}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment