[Mlir-commits] [mlir] f1a7e50 - [mlir][spirv] Check nullptr before usage to fix crash

Lei Zhang llvmlistbot at llvm.org
Mon Apr 4 14:20:07 PDT 2022


Author: Lei Zhang
Date: 2022-04-04T17:20:00-04:00
New Revision: f1a7e508a5e45c00b11b6c7f3e734249059f7956

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

LOG: [mlir][spirv] Check nullptr before usage to fix crash

Reviewed By: mravishankar, hanchung

Differential Revision: https://reviews.llvm.org/D123035

Added: 
    

Modified: 
    mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp b/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp
index 435019702ecfd..0170edac742da 100644
--- a/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp
+++ b/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp
@@ -294,10 +294,11 @@ LogicalResult ConstantCompositeOpPattern::matchAndRewrite(
     return failure();
 
   auto dstElementsAttr = constOp.getValue().dyn_cast<DenseElementsAttr>();
-  ShapedType dstAttrType = dstElementsAttr.getType();
   if (!dstElementsAttr)
     return failure();
 
+  ShapedType dstAttrType = dstElementsAttr.getType();
+
   // If the composite type has more than one dimensions, perform linearization.
   if (srcType.getRank() > 1) {
     if (srcType.isa<RankedTensorType>()) {


        


More information about the Mlir-commits mailing list