[Mlir-commits] [mlir] [MLIR][Linalg] Harden parsing Linalg named ops (PR #145337)

Andrzej WarzyƄski llvmlistbot at llvm.org
Tue Jun 24 09:30:41 PDT 2025


================
@@ -472,18 +488,34 @@ class RegionBuilderHelper {
     case UnaryFn::erf:
       return builder.create<math::ErfOp>(arg.getLoc(), arg);
     }
+    if (emitError) {
+      emitError() << "unsupported unary function";
+      return nullptr;
+    }
     llvm_unreachable("unsupported unary function");
   }
 
   // Build the binary functions defined by OpDSL.
-  Value buildBinaryFn(BinaryFn binaryFn, Value arg0, Value arg1) {
+  // If emitError is provided, an error will be emitted if the operation is not
+  // supported and a nullptr will be returned, otherwise an assertion will be
+  // raised.
----------------
banach-space wrote:

Any particular reason for allowing empty `emitError`? I would make it mandatory and just remove `llvm_unreachable`. Both approaches work, but if the extra flexibility is not needed then we could remove some code :)

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


More information about the Mlir-commits mailing list