[llvm-branch-commits] [mlir] 2c5ed2d - [mlir][gpu] NFC - Fail gracefully when type conversion fails instead of crashing

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Aug 10 00:09:55 PDT 2023


Author: Nicolas Vasilache
Date: 2023-08-10T09:06:20+02:00
New Revision: 2c5ed2da4fb464e144e580ea294049db630b64ea

URL: https://github.com/llvm/llvm-project/commit/2c5ed2da4fb464e144e580ea294049db630b64ea
DIFF: https://github.com/llvm/llvm-project/commit/2c5ed2da4fb464e144e580ea294049db630b64ea.diff

LOG: [mlir][gpu] NFC - Fail gracefully when type conversion fails instead of crashing

Added: 
    

Modified: 
    mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
index 2fe1c7c7f7af14..6e8ba7a33fd8f4 100644
--- a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
+++ b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
@@ -51,9 +51,16 @@ GPUFuncOpLowering::matchAndRewrite(gpu::GPUFuncOp gpuFuncOp, OpAdaptor adaptor,
   // Remap proper input types.
   TypeConverter::SignatureConversion signatureConversion(
       gpuFuncOp.front().getNumArguments());
+
   Type funcType = getTypeConverter()->convertFunctionSignature(
       gpuFuncOp.getFunctionType(), /*isVariadic=*/false,
       getTypeConverter()->getOptions().useBarePtrCallConv, signatureConversion);
+  if (!funcType) {
+    return rewriter.notifyMatchFailure(gpuFuncOp, [&](Diagnostic &diag) {
+      diag << "failed to convert function signature type for: "
+           << gpuFuncOp.getFunctionType();
+    });
+  }
 
   // Create the new function operation. Only copy those attributes that are
   // not specific to function modeling.


        


More information about the llvm-branch-commits mailing list