[Mesa-dev] [PATCH] i965: Allow exec_list sentinels as arguments to insert functions.

Kenneth Graunke kenneth at whitecape.org
Tue Feb 17 19:36:23 PST 2015


On Tuesday, February 17, 2015 07:31:26 PM Matt Turner wrote:
> 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.
> ---
>  src/mesa/drivers/dri/i965/brw_shader.cpp | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
> index 83734a2..5781c6b 100644
> --- a/src/mesa/drivers/dri/i965/brw_shader.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
> @@ -993,7 +993,8 @@ adjust_later_block_ips(bblock_t *start_block, int ip_adjustment)
>  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++;
>  
> @@ -1005,7 +1006,8 @@ backend_instruction::insert_after(bblock_t *block, backend_instruction *inst)
>  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++;

Looks reasonable to me.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150217/d9793582/attachment.sig>


More information about the mesa-dev mailing list