summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/cfgcleanup.c26
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.dg/pr41345.c14
4 files changed, 41 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5cb7752ea58..c001ccc9f7c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,9 @@
2009-10-26 Jakub Jelinek <jakub@redhat.com>
+ PR bootstrap/41345
+ * cfgcleanup.c (trivially_empty_bb_p): New function.
+ (try_optimize_bb): Use it instead of checking BB_HEAD == BB_END.
+
PR debug/41828
* dwarf2out.c (add_pubname, add_pubtype, generic_parameter_die,
add_name_and_src_coords_attributes, gen_namespace_die,
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index cfb19b60275..ffe36e45a9e 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -958,7 +958,7 @@ old_insns_match_p (int mode ATTRIBUTE_UNUSED, rtx i1, rtx i2)
if (NOTE_INSN_BASIC_BLOCK_P (i1) && NOTE_INSN_BASIC_BLOCK_P (i2))
return true;
- p1 = PATTERN (i1);
+ p1 = PATTERN (i1);
p2 = PATTERN (i2);
if (GET_CODE (p1) != GET_CODE (p2))
@@ -1814,6 +1814,24 @@ try_crossjump_bb (int mode, basic_block bb)
return changed;
}
+/* Return true if BB contains just bb note, or bb note followed
+ by only DEBUG_INSNs. */
+
+static bool
+trivially_empty_bb_p (basic_block bb)
+{
+ rtx insn = BB_END (bb);
+
+ while (1)
+ {
+ if (insn == BB_HEAD (bb))
+ return true;
+ if (!DEBUG_INSN_P (insn))
+ return false;
+ insn = PREV_INSN (insn);
+ }
+}
+
/* Do simple CFG optimizations - basic block merging, simplifying of jump
instructions etc. Return nonzero if changes were made. */
@@ -1865,14 +1883,10 @@ try_optimize_cfg (int mode)
__builtin_unreachable (). */
if (EDGE_COUNT (b->preds) == 0
|| (EDGE_COUNT (b->succs) == 0
- && BB_HEAD (b) == BB_END (b)
+ && trivially_empty_bb_p (b)
&& single_succ_edge (ENTRY_BLOCK_PTR)->dest != b))
{
c = b->prev_bb;
- if (dump_file)
- fprintf (dump_file, "Deleting block %i.\n",
- b->index);
-
delete_basic_block (b);
if (!(mode & CLEANUP_CFGLAYOUT))
changed = true;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 314d953752a..a8775085969 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2009-10-26 Jakub Jelinek <jakub@redhat.com>
+ PR bootstrap/41345
+ * gcc.dg/pr41345.c: New test.
+
PR debug/41828
* g++.dg/debug/dwarf2/anonname1.C: New test.
diff --git a/gcc/testsuite/gcc.dg/pr41345.c b/gcc/testsuite/gcc.dg/pr41345.c
new file mode 100644
index 00000000000..4b146c0c202
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr41345.c
@@ -0,0 +1,14 @@
+/* PR bootstrap/41345 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g -fcompare-debug" } */
+
+void
+foo (int *x)
+{
+ int a;
+ for (a = 0; a < 2; a++)
+ if (x[a])
+ goto lab;
+ __builtin_unreachable ();
+lab:;
+}