------- Comment #15 from spark at gcc dot gnu dot org 2007-11-21 22:43 ------- (In reply to comment #14) > The patch is semi-wrong. The call to emit_insn_after_noloc() should already > set the proper BLOCK_FOR_INSN for every insn. Only doing the > df_insn_change_bb() should be sufficient.
Thanks Steven. Something like: diff -r fad6feb87420 gcc/cfgrtl.c --- a/gcc/cfgrtl.c Wed Nov 21 00:17:50 2007 +0000 +++ b/gcc/cfgrtl.c Wed Nov 21 14:40:43 2007 -0800 @@ -2629,6 +2629,7 @@ cfg_layout_merge_blocks (basic_block a, /* In the case basic blocks are not adjacent, move them around. */ if (NEXT_INSN (BB_END (a)) != BB_HEAD (b)) { + rtx insn; rtx first = unlink_insn_chain (BB_HEAD (b), BB_END (b)); emit_insn_after_noloc (first, BB_END (a), a); @@ -2637,6 +2638,14 @@ cfg_layout_merge_blocks (basic_block a, first = NEXT_INSN (first); gcc_assert (NOTE_INSN_BASIC_BLOCK_P (first)); BB_HEAD (b) = NULL; + + /* emit_insn_after_noloc doesn't call df_insn_change_bb. + We need to explicitly call df_insn_change_bb here. */ + for (insn = NEXT_INSN (first); + insn != NEXT_INSN (BB_END (b)); + insn = NEXT_INSN (insn)) + df_insn_change_bb (insn); + delete_insn (first); } /* Otherwise just re-associate the instructions. */ I see bunch of similar loops throughout cfgrtl.c. I'll see if I should refactor those loops into separate functions (one with set_block_for_insn and one without). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34171