diff --git a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp --- a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp +++ b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp @@ -46,9 +46,11 @@ } // Rewrite the original GPU function to an LLVM function. - auto funcType = typeConverter->convertType(gpuFuncOp.getType()) - .template cast() - .getElementType(); + auto convertedType = typeConverter->convertType(gpuFuncOp.getType()); + if (!convertedType) + return failure(); + auto funcType = + convertedType.template cast().getElementType(); // Remap proper input types. TypeConverter::SignatureConversion signatureConversion( diff --git a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp --- a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp +++ b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp @@ -197,6 +197,8 @@ SignatureConversion conversion(type.getNumInputs()); Type converted = convertFunctionSignature(type, /*isVariadic=*/false, conversion); + if (!converted) + return {}; return LLVM::LLVMPointerType::get(converted); } @@ -300,8 +302,13 @@ SmallVector LLVMTypeConverter::getMemRefDescriptorFields(MemRefType type, bool unpackAggregates) { - assert(isStrided(type) && - "Non-strided layout maps must have been normalized away"); + if (!isStrided(type)) { + emitError( + UnknownLoc::get(type.getContext()), + "Conversion to strided form failed either due to non-strided layout " + "maps (which should have been normalized away) or other reasons"); + return {}; + } Type elementType = convertType(type.getElementType()); if (!elementType)