The next change for Alpha will produce extra labels and branches in reload, which in turn requires basic blocks to be split at completion. We do this already for functions that can trap, so just extend the arrangement with a check for the changed number of labels necessarily implied by the extra ones produced by the backend.
gcc/ * lra.cc (lra): Also split basic blocks if the number of labels changed. * reload1.cc (reload): Likewise. --- Hi, This approach seems to me suitable to make it generic for all RTL passes and maybe earlier passes as well. But obviously it's something to maybe consider in the future and not now. Maciej Changes from v2: - Replace a flag to be explicitly set by the backend with a generic check for the change in the quantity of labels produced, as per Richard Sandiford's suggestion. No change from v1. --- gcc/lra.cc | 9 +++++++-- gcc/reload1.cc | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) gcc-split-basic-blocks-after-reload.diff Index: gcc/gcc/lra.cc =================================================================== --- gcc.orig/gcc/lra.cc +++ gcc/gcc/lra.cc @@ -2375,6 +2375,8 @@ lra (FILE *f, int verbose) timevar_push (TV_LRA); + int n_labels = max_label_num () - get_first_label_num (); + /* Make sure that the last insn is a note. Some subsequent passes need it. */ emit_note (NOTE_INSN_DELETED); @@ -2609,8 +2611,11 @@ lra (FILE *f, int verbose) inserted_p = fixup_abnormal_edges (); - /* We've possibly turned single trapping insn into multiple ones. */ - if (cfun->can_throw_non_call_exceptions) + /* Split basic blocks if we've possibly turned single trapping insn + into multiple ones or the changed number of labels indicates + branches may have been added. */ + if (cfun->can_throw_non_call_exceptions + || max_label_num () - get_first_label_num () != n_labels) { auto_sbitmap blocks (last_basic_block_for_fn (cfun)); bitmap_ones (blocks); Index: gcc/gcc/reload1.cc =================================================================== --- gcc.orig/gcc/reload1.cc +++ gcc/gcc/reload1.cc @@ -755,6 +755,8 @@ reload (rtx_insn *first, int global) basic_block bb; bool inserted; + int n_labels = max_label_num () - get_first_label_num (); + /* Make sure even insns with volatile mem refs are recognizable. */ init_recog (); @@ -1272,8 +1274,11 @@ reload (rtx_insn *first, int global) inserted = fixup_abnormal_edges (); - /* We've possibly turned single trapping insn into multiple ones. */ - if (cfun->can_throw_non_call_exceptions) + /* Split basic blocks if we've possibly turned single trapping insn + into multiple ones or the changed number of labels indicates + branches may have been added. */ + if (cfun->can_throw_non_call_exceptions + || max_label_num () - get_first_label_num () != n_labels) { auto_sbitmap blocks (last_basic_block_for_fn (cfun)); bitmap_ones (blocks);