[Mlir-commits] [mlir] [MLGO][EmitC] Scalarize single-element tensor returns (PR #199686)
ioana ghiban
llvmlistbot at llvm.org
Wed Jun 10 04:06:40 PDT 2026
================
----------------
ioghiban wrote:
Possibly the verifier is incomplete - currently there is [no explicit check](https://github.com/llvm/llvm-project/blob/main/mlir/lib/IR/Verifier.cpp#L221) for `func.return` as terminator. So, an empty block that needs a terminator becomes valid if it's ended by an op declaring the `Terminator` trait (alias for `IsTerminator`. Therefore, functions with no `ReturnOp` can still pass verification. The patch has no tests tripping on this check. These examples are valid IR and trip on that check, although they don't make much sense:
```mlir
func.func private @spin(%arg0: tensor<1xi64>, %cond: i1) -> tensor<1xi64> {
cf.cond_br %cond, ^left, ^right
^left:
cf.br ^right
^right:
cf.br ^left
}
```
```mlir
func.func private @no_return(%arg0: tensor<1xi64>) -> tensor<1xi64> {
cf.br ^loop
^loop:
cf.br ^loop
}
```
Both `cf.br `and `cf.cond_br` declare the `Terminator` trait in https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/Dialect/ControlFlow/IR/ControlFlowOps.td.
https://github.com/llvm/llvm-project/pull/199686
More information about the Mlir-commits
mailing list