===================================================================
@@ -485,22 +485,28 @@ try_forward_edges (int mode, basic_block
{
/* 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)
===================================================================
@@ -588,10 +588,12 @@ rtl_merge_blocks (basic_block a, basic_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_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_blo
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,
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. */