[Mesa-dev] [PATCH] nir/builder: Use nir_after_instr to advance the cursor
Kenneth Graunke
kenneth at whitecape.org
Mon Aug 31 17:04:18 PDT 2015
On Monday, August 31, 2015 04:55:51 PM Jason Ekstrand wrote:
> This *should* ensure that the cursor gets properly advanced in all cases.
> We had a problem before where, if the cursor was created using
> nir_after_cf_node on a non-block cf_node, that would call nir_before_block
> on the block following the cf node. Instructions would then get inserted
> in backwards order at the top of the block which is not at all what you
> would expect from nir_after_cf_node. By just resetting to after_instr, we
> avoid all these problems.
> ---
> src/glsl/nir/nir_builder.h | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/src/glsl/nir/nir_builder.h b/src/glsl/nir/nir_builder.h
> index 3aa0efd..295a209 100644
> --- a/src/glsl/nir/nir_builder.h
> +++ b/src/glsl/nir/nir_builder.h
> @@ -49,8 +49,7 @@ nir_builder_instr_insert(nir_builder *build, nir_instr *instr)
> nir_instr_insert(build->cursor, instr);
>
> /* Move the cursor forward. */
> - if (build->cursor.option == nir_cursor_after_instr)
> - build->cursor.instr = instr;
> + build->cursor = nir_after_instr(instr);
> }
>
> static inline void
>
This seems like the right behavior for the builder to take.
Sorry for the breakage - I hadn't thought through how the
nir_{before,after}_cf_{node,list} functions translate to blocks.
Thanks for fixing it.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
You've regression tested this, I assume?
-------------- 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/20150831/f8bfc50d/attachment.sig>
More information about the mesa-dev
mailing list