Skip to content

Commit 67754a9

Browse files
[mlir][gpu] NFC - Fail gracefully when type conversion fails instead of crashing
1 parent 1bf6f55 commit 67754a9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,16 @@ GPUFuncOpLowering::matchAndRewrite(gpu::GPUFuncOp gpuFuncOp, OpAdaptor adaptor,
5151
// Remap proper input types.
5252
TypeConverter::SignatureConversion signatureConversion(
5353
gpuFuncOp.front().getNumArguments());
54+
5455
Type funcType = getTypeConverter()->convertFunctionSignature(
5556
gpuFuncOp.getFunctionType(), /*isVariadic=*/false,
5657
getTypeConverter()->getOptions().useBarePtrCallConv, signatureConversion);
58+
if (!funcType) {
59+
return rewriter.notifyMatchFailure(gpuFuncOp, [&](Diagnostic &diag) {
60+
diag << "failed to convert function signature type for: "
61+
<< gpuFuncOp.getFunctionType();
62+
});
63+
}
5764

5865
// Create the new function operation. Only copy those attributes that are
5966
// not specific to function modeling.

0 commit comments

Comments
 (0)