]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[RISC-V] Fix false positive from Wuninitialized
authorJeff Law <jlaw@ventanamicro.com>
Mon, 19 May 2025 18:00:56 +0000 (12:00 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Mon, 19 May 2025 18:00:56 +0000 (12:00 -0600)
As Mark and I independently tripped, there's a Wuninitialized issue in the
RISC-V backend.  While *I* know the value would always be properly initialized,
it'd be somewhat painful to either eliminate the infeasible paths or do deep
enough analysis to suppress the false positive.

So this initializes OUTPUT and verifies it's got a reasonable value before
using it for the final copy into operands[0].

Bootstrapped on the BPI (regression testing still has ~12hrs to go).

gcc/
* config/riscv/riscv.cc (synthesize_ior_xor): Initialize OUTPUT and
verify it's non-null before emitting the final copy insn.

gcc/config/riscv/riscv.cc

index 54395b8d3a7482ddb8573bf0c7855829f71704a8..0b10842d1765dec41a05a6ae16cc3cf5680b7c5f 100644 (file)
@@ -14429,7 +14429,7 @@ synthesize_ior_xor (rtx_code code, rtx operands[3])
   /* Synthesis is better than loading the constant.  */
   ival = INTVAL (operands[2]);
   rtx input = operands[1];
-  rtx output;
+  rtx output = NULL_RTX;
 
   /* Emit the [x]ori insn that sets the low 11 bits into
      the proper state.  */
@@ -14458,6 +14458,8 @@ synthesize_ior_xor (rtx_code code, rtx operands[3])
       input = output;
       ival &= ~tmpval;
     }
+
+  gcc_assert (output);
   emit_move_insn (operands[0], output);
   return true;
 }