Mesa (master): nir/builder: Use nir_after_instr to advance the cursor

Jason Ekstrand jekstrand at kemper.freedesktop.org
Tue Sep 1 01:17:38 UTC 2015


Module: Mesa
Branch: master
Commit: e16531fbe3a79bc27cf00701616a260b452597ef
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e16531fbe3a79bc27cf00701616a260b452597ef

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Mon Aug 31 16:54:02 2015 -0700

nir/builder: Use nir_after_instr to advance the cursor

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.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 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 08b40f8..ba988d7 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




More information about the mesa-commit mailing list