aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-04-13 21:55:15 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2018-04-13 21:55:15 +0200
commit465d00877e3d96ff827f02a699e7398ef62bef67 (patch)
tree7f4ab9bb1912581694938de5c77978fedb10f791 /gcc
parent9b91582429ca0b78f235e3c11b809a861b3d0f19 (diff)
downloadgcc-465d00877e3d96ff827f02a699e7398ef62bef67.zip
gcc-465d00877e3d96ff827f02a699e7398ef62bef67.tar.gz
gcc-465d00877e3d96ff827f02a699e7398ef62bef67.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/bb-reorder.c22
-rw-r--r--gcc/except.c2
-rw-r--r--gcc/except.h1
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/opt/pr85393-aux.cc5
-rw-r--r--gcc/testsuite/g++.dg/opt/pr85393.C29
7 files changed, 56 insertions, 15 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2754c48..9624786 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
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
diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c
index 8a65d6b..d2b4160 100644
--- a/gcc/bb-reorder.c
+++ b/gcc/bb-reorder.c
@@ -1409,14 +1409,14 @@ get_uncond_jump_length (void)
}
/* 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;
@@ -1431,24 +1431,20 @@ fix_up_crossing_landing_pad (eh_landing_pad old_lp, basic_block old_bb)
/* 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);
@@ -1457,7 +1453,7 @@ fix_up_crossing_landing_pad (eh_landing_pad old_lp, basic_block 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);
diff --git a/gcc/except.c b/gcc/except.c
index 53e5773..ba42bf6 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -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
pad for the given region. */
-void
+static void
expand_dw2_landing_pad_for_region (eh_region region)
{
if (targetm.have_exception_receiver ())
diff --git a/gcc/except.h b/gcc/except.h
index 229e446..caa375e 100644
--- a/gcc/except.h
+++ b/gcc/except.h
@@ -243,7 +243,6 @@ extern rtx expand_builtin_dwarf_sp_column (void);
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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 90ffbf8..88c7185 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
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
* gcc.dg/pr85376.c: New test.
diff --git a/gcc/testsuite/g++.dg/opt/pr85393-aux.cc b/gcc/testsuite/g++.dg/opt/pr85393-aux.cc
new file mode 100644
index 0000000..45e4767
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr85393-aux.cc
@@ -0,0 +1,5 @@
+// PR rtl-optimization/85393
+// { dg-do compile }
+// { dg-options "" }
+
+void foo (char const *) {}
diff --git a/gcc/testsuite/g++.dg/opt/pr85393.C b/gcc/testsuite/g++.dg/opt/pr85393.C
new file mode 100644
index 0000000..a2a3162
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr85393.C
@@ -0,0 +1,29 @@
+// 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)
+ {}
+}