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 @@ -43,9 +43,11 @@ } // Rewrite the original GPU function to an LLVM function. - auto funcType = typeConverter->convertType(gpuFuncOp.getFunctionType()) - .template cast() - .getElementType(); + auto convertedType = typeConverter->convertType(gpuFuncOp.getFunctionType()); + 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 @@ -199,6 +199,8 @@ SignatureConversion conversion(type.getNumInputs()); Type converted = convertFunctionSignature(type, /*isVariadic=*/false, conversion); + if (!converted) + return {}; return LLVM::LLVMPointerType::get(converted); } @@ -298,8 +300,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)