[llvm] 6e440ee - [RISCV][ISel] Finally fix the UBSan error

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


Author: Quentin Colombet
Date: 2022-10-05T21:43:09Z
New Revision: 6e440ee2aa76a8a9b71b5f0d4efc5f9d0301d119

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

LOG: [RISCV][ISel] Finally fix the UBSan error

Forgot another SDValue check and a boolean initialization.

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 775287ea0960..3c0ab3d36912 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -8478,6 +8478,7 @@ struct NodeExtensionHelper {
             Opc == RISCVISD::VWADDU_W_VL || Opc == RISCVISD::VWSUBU_W_VL;
         SupportsSExt = !SupportsZExt;
         std::tie(Mask, VL) = getMaskAndVL(Root);
+        CheckMask = true;
         // There's no existing extension here, so we don't have to worry about
         // making sure it gets removed.
         EnforceOneUse = false;
@@ -8497,7 +8498,7 @@ struct NodeExtensionHelper {
 
   /// Check if this operand is compatible with the given \p Mask.
   bool isMaskCompatible(SDValue Mask) const {
-    return !CheckMask || (this->Mask && this->Mask == Mask);
+    return !CheckMask || (this->Mask != SDValue() && this->Mask == Mask);
   }
 
   /// Helper function to get the Mask and VL from \p Root.


        


More information about the llvm-commits mailing list