[Mlir-commits] [mlir] [mlir][spirv] Fix a crash of typeConverter with non supported type (PR #79955)

Kohei Yamaguchi llvmlistbot at llvm.org
Tue Jan 30 16:57:08 PST 2024


================
@@ -367,12 +367,13 @@ class AccessChainPattern : public SPIRVToLLVMConversion<spirv::AccessChainOp> {
     Value zero = rewriter.create<LLVM::ConstantOp>(
         op.getLoc(), llvmIndexType, rewriter.getIntegerAttr(indexType, 0));
     indices.insert(indices.begin(), zero);
-    rewriter.replaceOpWithNewOp<LLVM::GEPOp>(
-        op, dstType,
-        typeConverter.convertType(
-            cast<spirv::PointerType>(op.getBasePtr().getType())
-                .getPointeeType()),
-        adaptor.getBasePtr(), indices);
+
+    auto elementType = typeConverter.convertType(
+        cast<spirv::PointerType>(op.getBasePtr().getType()).getPointeeType());
+    if (!elementType)
+      return failure();
----------------
sott0n wrote:

Thanks! I've noted the purpose of `notifyMatchFailure` for failure logging in debug mode. Should we use `notifyMatchFailure` to handle `convertType` failures elsewhere in the code, such L389, L407?

https://github.com/llvm/llvm-project/pull/79955


More information about the Mlir-commits mailing list