http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54824
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> 2012-10-24 13:14:21 UTC --- For example Index: cfgexpand.c =================================================================== --- cfgexpand.c (revision 192760) +++ cfgexpand.c (working copy) @@ -4474,7 +4474,17 @@ gimple_expand_cfg (void) lab_rtx_for_bb = pointer_map_create (); FOR_BB_BETWEEN (bb, init_block->next_bb, EXIT_BLOCK_PTR, next_bb) - bb = expand_gimple_basic_block (bb); + { + /* If we have a basic-block with no successors connect it to itself. + This avoids find_many_sub_basic_blocks to connect it randomly + to the next block. + ??? We can for example end up here when inlining a noreturn + function that does in fact return. Infinite loop is as good + as noreturn and better than falling though to a random block. */ + if (EDGE_COUNT (bb->succs) == 0) + make_edge (bb, bb, EDGE_FALLTHRU); + bb = expand_gimple_basic_block (bb); + } if (MAY_HAVE_DEBUG_INSNS) expand_debug_locations (); "fixes" it. We can also fix it in fixup_cfg as soon as the situation occurs. That's what I am testing.