"H.J. Lu" <hjl.to...@gmail.com> writes: > On Mon, Aug 12, 2024 at 4:25 AM Jakub Jelinek <ja...@redhat.com> wrote: >> >> On Mon, Aug 12, 2024 at 04:19:58AM -0700, H.J. Lu wrote: >> > > This is wrong. As documented, BB_HEAD needs to be either a CODE_LABEL, >> > > or >> > > NOTE_INSN_BASIC_BLOCK. >> > >> > ira.cc has >> > >> > new_insn = emit_insn_before (PATTERN (def_insn), use_insn); >> > REG_NOTES (new_insn) = REG_NOTES (def_insn); >> > REG_NOTES (def_insn) = 0; >> > /* Rescan it to process the notes. */ >> > df_insn_rescan (new_insn); >> > >> > /* Make sure this insn is recognized before reload begins, >> > otherwise eliminate_regs_in_insn will die. */ >> > INSN_CODE (new_insn) = INSN_CODE (def_insn); >> > >> > delete_insn (def_insn); >> > >> > XEXP (reg_equiv[regno].init_insns, 0) = new_insn; >> > >> > REG_BASIC_BLOCK (regno) = use_bb->index; >> > REG_N_CALLS_CROSSED (regno) = 0; >> > >> > if (use_insn == BB_HEAD (use_bb)) >> > BB_HEAD (use_bb) = new_insn; >> > >> > new_insn isn't CODE_LABEL nor NOTE_INSN_BASIC_BLOCK. >> > Should it be changed? >> >> Guess it depends if it survives that way until after the pass or not, if >> the pass can tolerate temporary violation, fine, if it survives to next >> passes, it is not. > > I assume that the IRA code is triggered and works.
Looks like it might be a left-over. The code was originally added to local-alloc.c by r0-13022-g2e1253f38590: commit 2e1253f38590eb4bd47b3635e0f04c28423764d0 (HEAD) Author: Ian Lance Taylor <i...@gcc.gnu.org> Date: Fri Jan 31 22:09:12 1997 +0000 If we can't substitute an equiv reg only used once, move the assignment which unfortunately predates the current list archives. But at the time, there were no basic block notes in the current sense. Instead, NOTE_INSN_BLOCK_BEG/END were only emitted by stmt.c (i.e. during expand), and AFAICT marked the boundaries of source language blocks. The basic blocks constructed by flow could start with any instruction: /* A basic block starts at label, or after something that can jump. */ else if (code == CODE_LABEL || (GET_RTX_CLASS (code) == 'i' && (prev_code == JUMP_INSN || (prev_code == CALL_INSN && nonlocal_label_list != 0 && ! find_reg_note (insn, REG_RETVAL, NULL_RTX)) || prev_code == BARRIER))) { basic_block_head[++i] = insn; Combine also had similar code: /* If this insn was emitted between blocks, then update basic_block_head of the current block to include it. */ if (basic_block_end[this_basic_block - 1] == tem) basic_block_head[this_basic_block] = place; but that was removed in r0-24369-gd3a923ee2e1. Thanks, Richard