> > Why does find_basic_block ignore NOTE_INSN_BASIC_BLOCK notes? > > The same question arises to me.
That's explained in the head comment of find_basic_block: the CFG is destroyed by the DBR pass in some controlled way so the strategy is to recompute the liveness info starting from data that are still correct given the properties of the aforementioned controlled way. Here we start from the beginning of the function for insn 32 with ;; Start of basic block ( 0) -> 2 ;; bb 2 artificial_defs: { } ;; bb 2 artificial_uses: { u-1(15){ }} ;; lr in 4 [r4] 5 [r5] 6 [r6] 15 [r15] 146 [pr] 151 [] ;; lr use 4 [r4] 5 [r5] 15 [r15] 146 [pr] ;; lr def 1 [r1] 2 [r2] 3 [r3] 15 [r15] 147 [t] ;; live in 4 [r4] 5 [r5] 6 [r6] 146 [pr] ;; live gen 1 [r1] 2 [r2] 3 [r3] 15 [r15] 147 [t] ;; live kill and run into (insn/f 111 8 112 fs/ext3/balloc.c:51 (set (mem:SI (pre_dec:SI (reg/f:SI 15 r15)) [0 S4 A32]) (reg:SI 146 pr)) 171 {movsi_i} (expr_list:REG_DEAD (reg:SI 146 pr) (expr_list:REG_INC (reg/f:SI 15 r15) (nil)))) The problem is that resource.c is doing life analysis the old fashioned way, i.e. the LR way, with a mere note_stores (PATTERN (real_insn), update_live_status, NULL); which doesn't take into account PRE_DEC because the register is supposed to be live before the PRE_DEC. It's true for LR but not for LIVE, as the use of the stack pointer is considered artificial by the latter. So I made a mistake when changing back the DF problem to LIVE in 2009-04-27 Richard Sandiford <rdsandif...@googlemail.com> Eric Botcazou <ebotca...@adacore.com> * resource.c (find_basic_block): Use BLOCK_FOR_INSN to look up a label's basic block. (mark_target_live_regs): Tidy and rework obsolete comments. Change back DF problem to LIVE. If a label starts a basic block, assume that all registers that used to be live then still are. (init_resource_info): If a label starts a basic block, set its BLOCK_FOR_INSN accordingly. (fini_resource_info): Undo the setting of BLOCK_FOR_INSN. it should be reset to LR. Patch attached. I'll give it a whirl on SPARC but not immediately so, Kaz, if you can test it on SH in the meantime, you can apply it on all branches. 2009-07-14 Eric Botcazou <ebotca...@adacore.com> PR rtl-optimization/40710 * resource.c (mark_target_live_regs): Reset DF problem to LR. -- Eric Botcazou
Index: resource.c =================================================================== --- resource.c (revision 149515) +++ resource.c (working copy) @@ -948,10 +948,11 @@ mark_target_live_regs (rtx insns, rtx ta /* If we found a basic block, get the live registers from it and update them with anything set or killed between its start and the insn before - TARGET. Otherwise, we must assume everything is live. */ + TARGET; this custom life analysis is really about registers so we need + to use the LR problem. Otherwise, we must assume everything is live. */ if (b != -1) { - regset regs_live = df_get_live_in (BASIC_BLOCK (b)); + regset regs_live = DF_LR_IN (BASIC_BLOCK (b)); rtx start_insn, stop_insn; /* Compute hard regs live at start of block. */ @@ -1055,7 +1056,7 @@ mark_target_live_regs (rtx insns, rtx ta { HARD_REG_SET extra_live; - REG_SET_TO_HARD_REG_SET (extra_live, df_get_live_in (bb)); + REG_SET_TO_HARD_REG_SET (extra_live, DF_LR_IN (bb)); IOR_HARD_REG_SET (current_live_regs, extra_live); } }