[Mlir-commits] [mlir] [mlir][linalg] Fix crashes in parser on linalg ops without operands (PR #97944)
Matthias Springer
llvmlistbot at llvm.org
Sun Jul 7 04:10:20 PDT 2024
================
@@ -1356,8 +1356,10 @@ ParseResult MapOp::parse(OpAsmParser &parser, OperationState &result) {
return failure();
if (payloadOpName.has_value()) {
- addBodyWithPayloadOp(parser, result, payloadOpName.value(), payloadOpAttrs,
- ArrayRef(result.operands).drop_back());
+ if (!result.operands.empty())
----------------
matthias-springer wrote:
nit: Can you try something like this instead of guarding it with an `if` check?
```c++
addBodyWithPayloadOp(parser, result, payloadOpName.value(),
payloadOpAttrs,
result.operands.empty() ? ArrayRef(result.operands) : ArrayRef(result.operands).drop_back())
```
I don't know if it will work, but maybe we can get a better error message than:
```mlir
// expected-error @+1 {{'linalg.map' op requires one region}}
linalg.map { arith.addf }
```
(We did specify a region, we just didn't parse it.)
https://github.com/llvm/llvm-project/pull/97944
More information about the Mlir-commits
mailing list