Skip to content

Commit f1a7e50

Browse files
committed
[mlir][spirv] Check nullptr before usage to fix crash
Reviewed By: mravishankar, hanchung Differential Revision: https://reviews.llvm.org/D123035
1 parent 7ebcd88 commit f1a7e50

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,11 @@ LogicalResult ConstantCompositeOpPattern::matchAndRewrite(
294294
return failure();
295295

296296
auto dstElementsAttr = constOp.getValue().dyn_cast<DenseElementsAttr>();
297-
ShapedType dstAttrType = dstElementsAttr.getType();
298297
if (!dstElementsAttr)
299298
return failure();
300299

300+
ShapedType dstAttrType = dstElementsAttr.getType();
301+
301302
// If the composite type has more than one dimensions, perform linearization.
302303
if (srcType.getRank() > 1) {
303304
if (srcType.isa<RankedTensorType>()) {

0 commit comments

Comments
 (0)