[Mlir-commits] [mlir] [RFC][mlir][func] Enforce func.return as sole terminator in func.func regions (PR #184778)
Matthias Springer
llvmlistbot at llvm.org
Thu Mar 5 04:46:37 PST 2026
================
@@ -42,6 +42,24 @@ class ReturnOpPattern final : public OpConversionPattern<func::ReturnOp> {
if (returnOp.getNumOperands() > 1)
return failure();
+ // Only convert func.return when the enclosing func.func is being converted
+ // to spirv.func. Check that all argument and result types of the parent
+ // function are convertible; if not, leave this op unconverted so the
+ // func.func stays in the Func dialect with a valid func.return terminator.
+ if (auto funcOp = returnOp->getParentOfType<func::FuncOp>()) {
+ FunctionType fnType = funcOp.getFunctionType();
+ if (fnType.getNumResults() > 1)
+ return failure();
----------------
matthias-springer wrote:
I don't follow the logic here: this aborts when the function has more than one result, but that case is handled by the code below.
Similarly, why are you doing the type conversion here?
https://github.com/llvm/llvm-project/pull/184778
More information about the Mlir-commits
mailing list