[Mesa-dev] [PATCH 1/2] nir: Handle call instructions in foreach_src

Jason Ekstrand jason at jlekstrand.net
Mon Jun 25 16:13:06 UTC 2018


Even though they don't have regular sources, they do have derefs and
those may have implied sources that should be handled.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106980
---
 src/compiler/nir/nir.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 36a79f57ee5..baeb3490e67 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -1373,6 +1373,20 @@ visit_tex_src(nir_tex_instr *instr, nir_foreach_src_cb cb, void *state)
    return true;
 }
 
+static bool
+visit_call_src(nir_call_instr *instr, nir_foreach_src_cb cb, void *state)
+{
+   if (instr->return_deref && !visit_deref_src(instr->return_deref, cb, state))
+      return false;
+
+   for (unsigned i = 0; i < instr->num_params; i++) {
+      if (!visit_deref_src(instr->params[i], cb, state))
+         return false;
+   }
+
+   return true;
+}
+
 static bool
 visit_intrinsic_src(nir_intrinsic_instr *instr, nir_foreach_src_cb cb,
                     void *state)
@@ -1449,7 +1463,8 @@ nir_foreach_src(nir_instr *instr, nir_foreach_src_cb cb, void *state)
          return false;
       break;
    case nir_instr_type_call:
-      /* Call instructions have no regular sources */
+      if (!visit_call_src(nir_instr_as_call(instr), cb, state))
+         return false;
       break;
    case nir_instr_type_load_const:
       /* Constant load instructions have no regular sources */
-- 
2.17.1



More information about the mesa-dev mailing list