[Mlir-commits] [mlir] [mlir][Linalg] Fix crash in buildBinaryFn on non-numeric types (PR #180594)
Guilherme oliveira de campos
llvmlistbot at llvm.org
Mon Feb 16 11:06:25 PST 2026
================
@@ -506,14 +506,13 @@ class RegionBuilderHelper {
bool allBool = allInteger && arg0.getType().getIntOrFloatBitWidth() == 1 &&
arg1.getType().getIntOrFloatBitWidth() == 1;
if (!allComplex && !allFloatingPoint && !allInteger) {
- if (emitError) {
- emitError()
- << "Cannot build binary Linalg operation: expects allComplex, "
- "allFloatingPoint, or allInteger, got "
- << arg0.getType() << " and " << arg1.getType();
- return nullptr;
- }
- llvm_unreachable("unsupported non numeric type");
+
+ auto diag = emitError ? emitError() : mlir::emitError(arg0.getLoc());
+ diag << "Cannot build binary Linalg operation: expects allComplex, "
+ << "allFloatingPoint, or allInteger, got " << arg0.getType()
+ << " and " << arg1.getType();
+
+ return arg0;
----------------
guiolidc wrote:
That makes sense. I originally returned `arg0` to prevent crashes because some callers weren't checking the result. I've now updated those callers to verify the return value, so I switched this to `return {};` as suggested
https://github.com/llvm/llvm-project/pull/180594
More information about the Mlir-commits
mailing list