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

Mehdi Amini llvmlistbot at llvm.org
Tue Jun 24 09:47:36 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.
----------------
joker-eph wrote:

We only want emitError in parsing code: these utilities are used outside of parsing context where this becomes an invariant expectation of the API.

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


More information about the Mlir-commits mailing list