Skip to content

Commit 5c46c1c

Browse files
committed
Initialize output parameter
Or code like this have UB passing uninitialized CmpValue: ``` int64_t CmpMask, CmpValue; if (!TII->analyzeCompare(MI, SrcReg, SrcReg2, CmpMask, CmpValue)) return false; if (TII->optimizeCompareInstr(MI, SrcReg, SrcReg2, CmpMask, CmpValue, MRI)) { ``` Detected by msan with: -Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1 Differential Revision: https://reviews.llvm.org/D116831
1 parent bd9ae59 commit 5c46c1c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,6 +1893,7 @@ bool HexagonInstrInfo::analyzeCompare(const MachineInstr &MI, Register &SrcReg,
18931893
case Hexagon::C4_cmplte:
18941894
case Hexagon::C4_cmplteu:
18951895
SrcReg2 = MI.getOperand(2).getReg();
1896+
Value = 0;
18961897
return true;
18971898

18981899
case Hexagon::C2_cmpeqi:

0 commit comments

Comments
 (0)