summaryrefslogtreecommitdiff
path: root/gcc/cfgcleanup.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2009-10-26 20:21:09 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2009-10-26 20:21:09 +0000
commit17d1c688288ddf654b4d9f6c18e491b5ba4155c5 (patch)
tree7f67ad702c8066bb4a2237aa09d28bd7f8cfe6ed /gcc/cfgcleanup.c
parent709be7ff7011587d1edfb75d34e5f0dedae260a1 (diff)
downloadgcc-17d1c688288ddf654b4d9f6c18e491b5ba4155c5.tar.gz
PR bootstrap/41345
* cfgcleanup.c (trivially_empty_bb_p): New function. (try_optimize_bb): Use it instead of checking BB_HEAD == BB_END. * gcc.dg/pr41345.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153569 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfgcleanup.c')
-rw-r--r--gcc/cfgcleanup.c26
1 files changed, 20 insertions, 6 deletions
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;