Mesa (master): intel/compiler: Silence maybe-uninitialized warning in GCC 9.1.1

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 23 20:26:42 UTC 2019


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

Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date:   Fri Aug 23 07:41:18 2019 -0700

intel/compiler: Silence maybe-uninitialized warning in GCC 9.1.1

Compiler can't see that d is initialized.

    ../src/intel/compiler/brw_vec4_nir.cpp: In function ‘int brw::try_immediate_source(const nir_alu_instr*, brw::src_reg*, bool, const gen_device_info*)’:
    ../src/intel/compiler/brw_vec4_nir.cpp:984:12: warning: ‘d’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      984 |          d = MAX2(-d, d);

Assert that we expect at least one component -- hence d going to be
set.  That by itself is not enough, so also zero initialize the
variable.

Acked-by: Eric Engestrom <eric.engestrom at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

---

 src/intel/compiler/brw_vec4_nir.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/intel/compiler/brw_vec4_nir.cpp b/src/intel/compiler/brw_vec4_nir.cpp
index 6301c951144..c357ee2271b 100644
--- a/src/intel/compiler/brw_vec4_nir.cpp
+++ b/src/intel/compiler/brw_vec4_nir.cpp
@@ -963,7 +963,7 @@ try_immediate_source(const nir_alu_instr *instr, src_reg *op,
    case BRW_REGISTER_TYPE_D:
    case BRW_REGISTER_TYPE_UD: {
       int first_comp = -1;
-      int d;
+      int d = 0;
 
       for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++) {
          if (nir_alu_instr_channel_used(instr, idx, i)) {
@@ -978,6 +978,8 @@ try_immediate_source(const nir_alu_instr *instr, src_reg *op,
          }
       }
 
+      assert(first_comp >= 0);
+
       if (op[idx].abs)
          d = MAX2(-d, d);
 




More information about the mesa-commit mailing list