[llvm] 6bbe7d3 - [RISCV][ISel] Attempt to fix UBSan error

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 5 14:01:25 PDT 2022


Author: Quentin Colombet
Date: 2022-10-05T20:59:28Z
New Revision: 6bbe7d376e48946ea5450ca4a7d48637ed6a67a4

URL: https://github.com/llvm/llvm-project/commit/6bbe7d376e48946ea5450ca4a7d48637ed6a67a4
DIFF: https://github.com/llvm/llvm-project/commit/6bbe7d376e48946ea5450ca4a7d48637ed6a67a4.diff

LOG: [RISCV][ISel] Attempt to fix UBSan error

Explicitly check an SDValue with the invalid SDValue.

UBSan reports:
runtime error: load of value 36, which is not a valid value for type
'bool'

https://lab.llvm.org/buildbot/#/builders/85/builds/11231

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 4a8bc3177c85..775287ea0960 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -8491,7 +8491,9 @@ struct NodeExtensionHelper {
   }
 
   /// Check if this operand is compatible with the given vector length \p VL.
-  bool isVLCompatible(SDValue VL) const { return this->VL && this->VL == VL; }
+  bool isVLCompatible(SDValue VL) const {
+    return this->VL != SDValue() && this->VL == VL;
+  }
 
   /// Check if this operand is compatible with the given \p Mask.
   bool isMaskCompatible(SDValue Mask) const {


        


More information about the llvm-commits mailing list