From f1a7e508a5e45c00b11b6c7f3e734249059f7956 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 4 Apr 2022 17:19:44 -0400 Subject: [PATCH] [mlir][spirv] Check nullptr before usage to fix crash Reviewed By: mravishankar, hanchung Differential Revision: https://reviews.llvm.org/D123035 --- mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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()) { -- 2.7.4