===================================================================
@@ -5190,6 +5190,23 @@ emit_return_into_block (bool simple_p, b
}
#endif
+/* Return true if BB has any active insns. */
+static bool
+bb_active_p (basic_block bb)
+{
+ rtx label;
+
+ /* Test whether there are active instructions in the last block. */
+ label = BB_END (bb);
+ while (label && !LABEL_P (label))
+ {
+ if (active_insn_p (label))
+ break;
+ label = PREV_INSN (label);
+ }
+ return BB_HEAD (bb) != label || !LABEL_P (label);
+}
+
/* Generate the prologue and epilogue RTL if the machine supports it. Thread
this into place with notes indicating where the prologue ends and where
the epilogue begins. Update the basic block information when possible.
@@ -5275,19 +5292,8 @@ thread_prologue_and_epilogue_insns (void
exit_fallthru_edge = find_fallthru_edge (EXIT_BLOCK_PTR->preds);
if (exit_fallthru_edge != NULL)
{
- rtx label;
-
last_bb = exit_fallthru_edge->src;
- /* Test whether there are active instructions in the last block. */
- label = BB_END (last_bb);
- while (label && !LABEL_P (label))
- {
- if (active_insn_p (label))
- break;
- label = PREV_INSN (label);
- }
-
- last_bb_active = BB_HEAD (last_bb) != label || !LABEL_P (label);
+ last_bb_active = bb_active_p (last_bb);
}
else
{
@@ -5344,6 +5350,10 @@ thread_prologue_and_epilogue_insns (void
prepare_shrink_wrap (entry_edge->dest);
+ /* That may have inserted instructions into the last block. */
+ if (last_bb && !last_bb_active)
+ last_bb_active = bb_active_p (last_bb);
+
bitmap_initialize (&bb_antic_flags, &bitmap_default_obstack);
bitmap_initialize (&bb_on_list, &bitmap_default_obstack);