[Mesa-dev] [PATCH 7/8] nir: Silence unused parameter warnings

Ian Romanick idr at freedesktop.org
Mon Dec 14 15:34:31 PST 2015


From: Ian Romanick <ian.d.romanick at intel.com>

These cases had the parameter removed:

nir/nir_lower_vec_to_movs.c: In function ‘try_coalesce’:
nir/nir_lower_vec_to_movs.c:124:66: warning: unused parameter ‘shader’ [-Wunused-parameter]
 try_coalesce(nir_alu_instr *vec, unsigned start_idx, nir_shader *shader)
                                                                  ^
nir/nir_lower_io.c: In function ‘load_op’:
nir/nir_lower_io.c:147:32: warning: unused parameter ‘state’ [-Wunused-parameter]
 load_op(struct lower_io_state *state,
                                ^
nir/nir_lower_vars_to_ssa.c: In function 'get_ssa_def_for_block':
nir/nir_lower_vars_to_ssa.c:527:59: warning: unused parameter 'block' [-Wunused-parameter]
 get_ssa_def_for_block(struct deref_node *node, nir_block *block,
                                                           ^
nir/nir_print.c: In function 'print_deref_array':
nir/nir_print.c:278:60: warning: unused parameter 'state' [-Wunused-parameter]
 print_deref_array(nir_deref_array *deref, print_var_state *state, FILE *fp)
                                                            ^
nir/nir_print.c: In function 'print_deref_struct':
nir/nir_print.c:299:37: warning: unused parameter 'state' [-Wunused-parameter]
                    print_var_state *state, FILE *fp)
                                     ^
nir/nir_print.c: In function 'print_load_const_instr':
nir/nir_print.c:519:62: warning: unused parameter 'tabs' [-Wunused-parameter]
 print_load_const_instr(nir_load_const_instr *instr, unsigned tabs, FILE *fp)
                                                              ^

These cases had the parameter (void) silenced because the parameter was
necessary for an interface:

ir/nir_move_vec_src_uses_to_dest.c: In function ‘move_vec_src_uses_to_dest_block’:
nir/nir_move_vec_src_uses_to_dest.c:65:57: warning: unused parameter ‘shader’ [-Wunused-parameter]
 move_vec_src_uses_to_dest_block(nir_block *block, void *shader)
                                                         ^
nir/glsl_to_nir.cpp:1900:32: warning: unused parameter 'ir' [-Wunused-parameter]
 nir_visitor::visit(ir_barrier *ir)
                                ^
nir/nir_lower_load_const_to_scalar.c: In function 'lower_load_const_to_scalar_block':
nir/nir_lower_load_const_to_scalar.c:80:58: warning: unused parameter 'data' [-Wunused-parameter]
 lower_load_const_to_scalar_block(nir_block *block, void *data)
                                                          ^
nir/nir_lower_to_source_mods.c: In function 'nir_lower_to_source_mods_block':
nir/nir_lower_to_source_mods.c:37:56: warning: unused parameter 'state' [-Wunused-parameter]
 nir_lower_to_source_mods_block(nir_block *block, void *state)
                                                        ^
nir/nir.c: In function ‘remove_use_cb’:
nir/nir.c:802:35: warning: unused parameter ‘state’ [-Wunused-parameter]
 remove_use_cb(nir_src *src, void *state)
                                   ^
nir/nir.c: In function ‘remove_def_cb’:
nir/nir.c:811:37: warning: unused parameter ‘state’ [-Wunused-parameter]
 remove_def_cb(nir_dest *dest, void *state)
                                     ^

Number of total warnings in my build reduced from 1485 to 1476
(reduction of 9).

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/glsl/nir/glsl_to_nir.cpp                  | 2 +-
 src/glsl/nir/nir.c                            | 4 ++++
 src/glsl/nir/nir_lower_io.c                   | 5 ++---
 src/glsl/nir/nir_lower_load_const_to_scalar.c | 2 ++
 src/glsl/nir/nir_lower_to_source_mods.c       | 2 ++
 src/glsl/nir/nir_lower_vars_to_ssa.c          | 6 +++---
 src/glsl/nir/nir_lower_vec_to_movs.c          | 4 ++--
 src/glsl/nir/nir_move_vec_src_uses_to_dest.c  | 2 ++
 8 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index db8b0ca..97bfadb 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -2076,7 +2076,7 @@ nir_visitor::visit(ir_dereference_array *ir)
 }
 
 void
-nir_visitor::visit(ir_barrier *ir)
+nir_visitor::visit(ir_barrier *)
 {
    nir_intrinsic_instr *instr =
       nir_intrinsic_instr_create(this->shader, nir_intrinsic_barrier);
diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
index 35fc1de..6bae05b 100644
--- a/src/glsl/nir/nir.c
+++ b/src/glsl/nir/nir.c
@@ -801,6 +801,8 @@ src_is_valid(const nir_src *src)
 static bool
 remove_use_cb(nir_src *src, void *state)
 {
+   (void) state;
+
    if (src_is_valid(src))
       list_del(&src->use_link);
 
@@ -810,6 +812,8 @@ remove_use_cb(nir_src *src, void *state)
 static bool
 remove_def_cb(nir_dest *dest, void *state)
 {
+   (void) state;
+
    if (!dest->is_ssa)
       list_del(&dest->reg.def_link);
 
diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c
index 3d646eb..8b421a0 100644
--- a/src/glsl/nir/nir_lower_io.c
+++ b/src/glsl/nir/nir_lower_io.c
@@ -144,8 +144,7 @@ get_io_offset(nir_builder *b, nir_deref_var *deref,
 }
 
 static nir_intrinsic_op
-load_op(struct lower_io_state *state,
-        nir_variable_mode mode, bool per_vertex)
+load_op(nir_variable_mode mode, bool per_vertex)
 {
    nir_intrinsic_op op;
    switch (mode) {
@@ -210,7 +209,7 @@ nir_lower_io_block(nir_block *block, void *void_state)
 
          nir_intrinsic_instr *load =
             nir_intrinsic_instr_create(state->mem_ctx,
-                                       load_op(state, mode, per_vertex));
+                                       load_op(mode, per_vertex));
          load->num_components = intrin->num_components;
 
          load->const_index[0] =
diff --git a/src/glsl/nir/nir_lower_load_const_to_scalar.c b/src/glsl/nir/nir_lower_load_const_to_scalar.c
index 84d0c14..f7ffe7b 100644
--- a/src/glsl/nir/nir_lower_load_const_to_scalar.c
+++ b/src/glsl/nir/nir_lower_load_const_to_scalar.c
@@ -65,6 +65,8 @@ lower_load_const_instr_scalar(nir_load_const_instr *lower)
 static bool
 lower_load_const_to_scalar_block(nir_block *block, void *data)
 {
+   (void) data;
+
    nir_foreach_instr_safe(block, instr) {
       if (instr->type == nir_instr_type_load_const)
          lower_load_const_instr_scalar(nir_instr_as_load_const(instr));
diff --git a/src/glsl/nir/nir_lower_to_source_mods.c b/src/glsl/nir/nir_lower_to_source_mods.c
index 94c7e36..fc53d6b 100644
--- a/src/glsl/nir/nir_lower_to_source_mods.c
+++ b/src/glsl/nir/nir_lower_to_source_mods.c
@@ -36,6 +36,8 @@
 static bool
 nir_lower_to_source_mods_block(nir_block *block, void *state)
 {
+   (void) state;
+
    nir_foreach_instr(block, instr) {
       if (instr->type != nir_instr_type_alu)
          continue;
diff --git a/src/glsl/nir/nir_lower_vars_to_ssa.c b/src/glsl/nir/nir_lower_vars_to_ssa.c
index e670dbd..69267ab 100644
--- a/src/glsl/nir/nir_lower_vars_to_ssa.c
+++ b/src/glsl/nir/nir_lower_vars_to_ssa.c
@@ -527,7 +527,7 @@ def_stack_pop_if_in_block(struct deref_node *node, nir_block *block)
  * initializer (if it exists) or an SSA undef.
  */
 static nir_ssa_def *
-get_ssa_def_for_block(struct deref_node *node, nir_block *block,
+get_ssa_def_for_block(struct deref_node *node,
                       struct lower_variables_state *state)
 {
    /* If we have something on the stack, go ahead and return it.  We're
@@ -572,7 +572,7 @@ add_phi_sources(nir_block *block, nir_block *pred,
       src->pred = pred;
       src->src.parent_instr = &phi->instr;
       src->src.is_ssa = true;
-      src->src.ssa = get_ssa_def_for_block(node, pred, state);
+      src->src.ssa = get_ssa_def_for_block(node, state);
 
       list_addtail(&src->src.use_link, &src->src.ssa->uses);
 
@@ -638,7 +638,7 @@ rename_variables_block(nir_block *block, struct lower_variables_state *state)
             nir_alu_instr *mov = nir_alu_instr_create(state->shader,
                                                       nir_op_imov);
             mov->src[0].src.is_ssa = true;
-            mov->src[0].src.ssa = get_ssa_def_for_block(node, block, state);
+            mov->src[0].src.ssa = get_ssa_def_for_block(node, state);
             for (unsigned i = intrin->num_components; i < 4; i++)
                mov->src[0].swizzle[i] = 0;
 
diff --git a/src/glsl/nir/nir_lower_vec_to_movs.c b/src/glsl/nir/nir_lower_vec_to_movs.c
index 736a66c..c075a5d 100644
--- a/src/glsl/nir/nir_lower_vec_to_movs.c
+++ b/src/glsl/nir/nir_lower_vec_to_movs.c
@@ -121,7 +121,7 @@ has_replicated_dest(nir_alu_instr *alu)
  * can then call insert_mov as normal.
  */
 static unsigned
-try_coalesce(nir_alu_instr *vec, unsigned start_idx, nir_shader *shader)
+try_coalesce(nir_alu_instr *vec, unsigned start_idx)
 {
    assert(start_idx < nir_op_infos[vec->op].num_inputs);
 
@@ -267,7 +267,7 @@ lower_vec_to_movs_block(nir_block *block, void *void_state)
             continue;
 
          if (!(finished_write_mask & (1 << i)))
-            finished_write_mask |= try_coalesce(vec, i, shader);
+            finished_write_mask |= try_coalesce(vec, i);
 
          if (!(finished_write_mask & (1 << i)))
             finished_write_mask |= insert_mov(vec, i, shader);
diff --git a/src/glsl/nir/nir_move_vec_src_uses_to_dest.c b/src/glsl/nir/nir_move_vec_src_uses_to_dest.c
index 4c9032d..10e6926 100644
--- a/src/glsl/nir/nir_move_vec_src_uses_to_dest.c
+++ b/src/glsl/nir/nir_move_vec_src_uses_to_dest.c
@@ -64,6 +64,8 @@ ssa_def_dominates_instr(nir_ssa_def *def, nir_instr *instr)
 static bool
 move_vec_src_uses_to_dest_block(nir_block *block, void *shader)
 {
+   (void) shader;
+
    nir_foreach_instr(block, instr) {
       if (instr->type != nir_instr_type_alu)
          continue;
-- 
2.5.0



More information about the mesa-dev mailing list