[v1] RISC-V: Fix one warning of maybe-uninitialized in riscv-vsetvl.cc

Message ID 20230616113514.327122-1-pan2.li@intel.com
State Unresolved
Headers
Series [v1] RISC-V: Fix one warning of maybe-uninitialized in riscv-vsetvl.cc |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Li, Pan2 via Gcc-patches June 16, 2023, 11:35 a.m. UTC
  From: Pan Li <pan2.li@intel.com>

This patch would like to fix one maybe-uninitialized warning. Aka:

riscv-vsetvl.cc:4354:3: error: 'vsetvl_rinsn' may be used uninitialized [-Werror=maybe-uninitialized]

Signed-off-by: Pan Li <pan2.li@intel.com>

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc
	(pass_vsetvl::global_eliminate_vsetvl_insn): Initialize var by NULL.
---
 gcc/config/riscv/riscv-vsetvl.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Robin Dapp June 16, 2023, 11:40 a.m. UTC | #1
> This patch would like to fix one maybe-uninitialized warning. Aka:
> 
> riscv-vsetvl.cc:4354:3: error: 'vsetvl_rinsn' may be used uninitialized [-Werror=maybe-uninitialized]
> 
> Signed-off-by: Pan Li <pan2.li@intel.com>

IMHO obvious enough that it doesn't need a maintainer's OK, so go
ahead.

We should make sure to find such nits before Andreas does in the
future, though, as we don't want to waste his time.
This means either proper bootstrapping or always configuring
with -Werror=all (or similar).  The latter should catch most and
is less intrusive.

Regards
 Robin
  
Li, Pan2 via Gcc-patches June 16, 2023, 11:49 a.m. UTC | #2
Committed, thanks Robin.

Pan

-----Original Message-----
From: Robin Dapp <rdapp.gcc@gmail.com> 
Sent: Friday, June 16, 2023 7:41 PM
To: Li, Pan2 <pan2.li@intel.com>; gcc-patches@gcc.gnu.org
Cc: rdapp.gcc@gmail.com; juzhe.zhong@rivai.ai; jeffreyalaw@gmail.com; Wang, Yanzhang <yanzhang.wang@intel.com>; kito.cheng@gmail.com
Subject: Re: [PATCH v1] RISC-V: Fix one warning of maybe-uninitialized in riscv-vsetvl.cc

> This patch would like to fix one maybe-uninitialized warning. Aka:
> 
> riscv-vsetvl.cc:4354:3: error: 'vsetvl_rinsn' may be used uninitialized [-Werror=maybe-uninitialized]
> 
> Signed-off-by: Pan Li <pan2.li@intel.com>

IMHO obvious enough that it doesn't need a maintainer's OK, so go
ahead.

We should make sure to find such nits before Andreas does in the
future, though, as we don't want to waste his time.
This means either proper bootstrapping or always configuring
with -Werror=all (or similar).  The latter should catch most and
is less intrusive.

Regards
 Robin
  

Patch

diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
index cae9be0d928..7066dea3d14 100644
--- a/gcc/config/riscv/riscv-vsetvl.cc
+++ b/gcc/config/riscv/riscv-vsetvl.cc
@@ -4340,7 +4340,7 @@  get_first_vsetvl_before_rvv_insns (basic_block cfg_bb)
 bool
 pass_vsetvl::global_eliminate_vsetvl_insn (const bb_info *bb) const
 {
-  rtx_insn *vsetvl_rinsn;
+  rtx_insn *vsetvl_rinsn = NULL;
   vector_insn_info dem = vector_insn_info ();
   const auto &block_info = get_block_info (bb);
   basic_block cfg_bb = bb->cfg_bb ();