[llvm] 5c46c1c - Initialize output parameter
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 7 15:21:42 PST 2022
Author: Vitaly Buka
Date: 2022-01-07T15:21:22-08:00
New Revision: 5c46c1c23abb4a01f7f40bfcb8851cb893739e14
URL: https://github.com/llvm/llvm-project/commit/5c46c1c23abb4a01f7f40bfcb8851cb893739e14
DIFF: https://github.com/llvm/llvm-project/commit/5c46c1c23abb4a01f7f40bfcb8851cb893739e14.diff
LOG: 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
Added:
Modified:
llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp
index dadedff4038e..9b4e92a16663 100644
--- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp
@@ -1893,6 +1893,7 @@ bool HexagonInstrInfo::analyzeCompare(const MachineInstr &MI, Register &SrcReg,
case Hexagon::C4_cmplte:
case Hexagon::C4_cmplteu:
SrcReg2 = MI.getOperand(2).getReg();
+ Value = 0;
return true;
case Hexagon::C2_cmpeqi:
More information about the llvm-commits
mailing list