[Mesa-dev] [PATCH] spirv: Move cursor before calling vtn_ssa_value() in phi 2nd pass.

Jason Ekstrand jason at jlekstrand.net
Mon Jan 9 15:19:41 UTC 2017


On Jan 9, 2017 1:48 AM, "Kenneth Graunke" <kenneth at whitecape.org> wrote:

vtn_ssa_value() can produce variable loads, and the cursor might
be after a return statement, causing nir_builder assert failures
about not inserting instructions after a jump.

This fixes:
dEQP-VK.spirv_assembly.instruction.graphics.barrier.in_if
dEQP-VK.spirv_assembly.instruction.graphics.barrier.in_switch

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/compiler/spirv/vtn_cfg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Please don't assume I know what I'm doing here.  I spent approximately
zero time thinking about the correctness of this solution.  It does
appear to cause no regressions.


No worries. This is correct.  Please cc all the stable.  R-b.

diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
index 62b9056990e..3a31657e099 100644
--- a/src/compiler/spirv/vtn_cfg.c
+++ b/src/compiler/spirv/vtn_cfg.c
@@ -527,12 +527,13 @@ vtn_handle_phi_second_pass(struct vtn_builder *b,
SpvOp opcode,
    nir_variable *phi_var = phi_entry->data;

    for (unsigned i = 3; i < count; i += 2) {
-      struct vtn_ssa_value *src = vtn_ssa_value(b, w[i]);
       struct vtn_block *pred =
          vtn_value(b, w[i + 1], vtn_value_type_block)->block;

       b->nb.cursor = nir_after_instr(&pred->end_nop->instr);

+      struct vtn_ssa_value *src = vtn_ssa_value(b, w[i]);
+
       vtn_local_store(b, src, nir_deref_var_create(b, phi_var));
    }

--
2.11.0

_______________________________________________
mesa-dev mailing list
mesa-dev at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170109/e4047d81/attachment.html>


More information about the mesa-dev mailing list