To insert an instruction at the end of a basic block, we typically do
something like
inst = block->last_non_control_flow_inst();
inst->insert_after(block, new_inst);
But blocks can consist of a single control flow instruction, so inst
will actually be the exec_list's head sentinel. We shouldn't use it as
if it were a regular instruction, but it is safe to insert something after
it.
This patch avoids assert-failing because an exec_list sentinel wasn't in
the basic block's instruction list.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
void
backend_instruction::insert_after(bblock_t *block, backend_instruction *inst)
{
- assert(inst_is_in_block(block, this) || !"Instruction not in block");
+ if (!this->is_head_sentinel())
+ assert(inst_is_in_block(block, this) || !"Instruction not in block");
block->end_ip++;
void
backend_instruction::insert_before(bblock_t *block, backend_instruction *inst)
{
- assert(inst_is_in_block(block, this) || !"Instruction not in block");
+ if (!this->is_tail_sentinel())
+ assert(inst_is_in_block(block, this) || !"Instruction not in block");
block->end_ip++;