aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/cfgcleanup.c33
-rw-r--r--gcc/cfgrtl.c23
3 files changed, 48 insertions, 17 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 72be43d..b834082 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2010-10-21 Eric Botcazou <ebotcazou@adacore.com>
+
+ * cfgcleanup.c (try_forward_edges): Do not throw away previous steps
+ when stopping because of a different locus on edge or insn.
+ (try_optimize_cfg): Add comment.
+ * cfgrtl.c (rtl_merge_blocks): Tweak log message. If the destination
+ block is a forwarder block, propagate locus on the edge.
+ (cfg_layout_merge_blocks): Likewise.
+
2010-10-21 Uros Bizjak <ubizjak@gmail.com>
PR target/45946
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 9563e3f..881a4f3 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -485,22 +485,28 @@ try_forward_edges (int mode, basic_block b)
{
/* When not optimizing, ensure that edges or forwarder
blocks with different locus are not optimized out. */
- int locus = single_succ_edge (target)->goto_locus;
+ int new_locus = single_succ_edge (target)->goto_locus;
+ int locus = goto_locus;
- if (locus && goto_locus && !locator_eq (locus, goto_locus))
- counter = n_basic_blocks;
- else if (locus)
- goto_locus = locus;
-
- if (INSN_P (BB_END (target)))
+ if (new_locus && locus && !locator_eq (new_locus, locus))
+ new_target = NULL;
+ else
{
- locus = INSN_LOCATOR (BB_END (target));
+ if (new_locus)
+ locus = new_locus;
- if (locus && goto_locus
- && !locator_eq (locus, goto_locus))
- counter = n_basic_blocks;
- else if (locus)
- goto_locus = locus;
+ new_locus = INSN_P (BB_END (target))
+ ? INSN_LOCATOR (BB_END (target)) : 0;
+
+ if (new_locus && locus && !locator_eq (new_locus, locus))
+ new_target = NULL;
+ else
+ {
+ if (new_locus)
+ locus = new_locus;
+
+ goto_locus = locus;
+ }
}
}
}
@@ -2379,6 +2385,7 @@ try_optimize_cfg (int mode)
continue;
}
+ /* Merge B with its single successor, if any. */
if (single_succ_p (b)
&& (s = single_succ_edge (b))
&& !(s->flags & EDGE_COMPLEX)
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index a158112..a19ba8d 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -588,10 +588,12 @@ rtl_merge_blocks (basic_block a, basic_block b)
rtx b_head = BB_HEAD (b), b_end = BB_END (b), a_end = BB_END (a);
rtx del_first = NULL_RTX, del_last = NULL_RTX;
rtx b_debug_start = b_end, b_debug_end = b_end;
+ bool forwarder_p = (b->flags & BB_FORWARDER_BLOCK) != 0;
int b_empty = 0;
if (dump_file)
- fprintf (dump_file, "merging block %d into block %d\n", b->index, a->index);
+ fprintf (dump_file, "Merging block %d into block %d...\n", b->index,
+ a->index);
while (DEBUG_INSN_P (b_end))
b_end = PREV_INSN (b_debug_start = b_end);
@@ -680,6 +682,13 @@ rtl_merge_blocks (basic_block a, basic_block b)
df_bb_delete (b->index);
BB_END (a) = a_end;
+
+ /* If B was a forwarder block, propagate the locus on the edge. */
+ if (forwarder_p && !EDGE_SUCC (b, 0)->goto_locus)
+ EDGE_SUCC (b, 0)->goto_locus = EDGE_SUCC (a, 0)->goto_locus;
+
+ if (dump_file)
+ fprintf (dump_file, "Merged blocks %d and %d.\n", a->index, b->index);
}
@@ -2692,10 +2701,13 @@ cfg_layout_can_merge_blocks_p (basic_block a, basic_block b)
static void
cfg_layout_merge_blocks (basic_block a, basic_block b)
{
+ bool forwarder_p = (b->flags & BB_FORWARDER_BLOCK) != 0;
+
gcc_checking_assert (cfg_layout_can_merge_blocks_p (a, b));
if (dump_file)
- fprintf (dump_file, "merging block %d into block %d\n", b->index, a->index);
+ fprintf (dump_file, "Merging block %d into block %d...\n", b->index,
+ a->index);
/* If there was a CODE_LABEL beginning B, delete it. */
if (LABEL_P (BB_HEAD (b)))
@@ -2803,9 +2815,12 @@ cfg_layout_merge_blocks (basic_block a, basic_block b)
b->il.rtl->footer = NULL;
}
+ /* If B was a forwarder block, propagate the locus on the edge. */
+ if (forwarder_p && !EDGE_SUCC (b, 0)->goto_locus)
+ EDGE_SUCC (b, 0)->goto_locus = EDGE_SUCC (a, 0)->goto_locus;
+
if (dump_file)
- fprintf (dump_file, "Merged blocks %d and %d.\n",
- a->index, b->index);
+ fprintf (dump_file, "Merged blocks %d and %d.\n", a->index, b->index);
}
/* Split edge E. */