From: Lei Zhang Date: Mon, 4 Apr 2022 21:19:44 +0000 (-0400) Subject: [mlir][spirv] Check nullptr before usage to fix crash X-Git-Tag: upstream/15.0.7~11521 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f1a7e508a5e45c00b11b6c7f3e734249059f7956;p=platform%2Fupstream%2Fllvm.git [mlir][spirv] Check nullptr before usage to fix crash Reviewed By: mravishankar, hanchung Differential Revision: https://reviews.llvm.org/D123035 --- diff --git a/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp b/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp index 4350197..0170eda 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(); - 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()) {