[Mlir-commits] [mlir] [RFC][mlir][func] Enforce func.return as sole terminator in func.func regions (PR #184778)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Mar 5 04:09:28 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,c -- mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp mlir/lib/Conversion/FuncToSPIRV/FuncToSPIRV.cpp mlir/lib/Dialect/Func/IR/FuncOps.cpp mlir/test/CAPI/execution_engine.c mlir/test/lib/Dialect/Test/TestPatterns.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/mlir/lib/Dialect/Func/IR/FuncOps.cpp b/mlir/lib/Dialect/Func/IR/FuncOps.cpp
index c30e36a7c..ea2a0ffbf 100644
--- a/mlir/lib/Dialect/Func/IR/FuncOps.cpp
+++ b/mlir/lib/Dialect/Func/IR/FuncOps.cpp
@@ -307,17 +307,18 @@ LogicalResult FuncOp::verifyRegions() {
 
     if (returnOp->getNumOperands() != resultTypes.size())
       return returnOp->emitOpError("has ")
-             << returnOp->getNumOperands() << " operands, but enclosing function (@"
-             << getName() << ") returns " << resultTypes.size();
+             << returnOp->getNumOperands()
+             << " operands, but enclosing function (@" << getName()
+             << ") returns " << resultTypes.size();
 
     for (auto [i, opType] :
          llvm::enumerate(llvm::zip(returnOp->getOperands(), resultTypes))) {
       auto [operand, resTy] = opType;
       if (operand.getType() != resTy)
-        return returnOp->emitError() << "type of return operand " << i << " ("
-                                     << operand.getType()
-                                     << ") doesn't match function result type ("
-                                     << resTy << ") in function @" << getName();
+        return returnOp->emitError()
+               << "type of return operand " << i << " (" << operand.getType()
+               << ") doesn't match function result type (" << resTy
+               << ") in function @" << getName();
     }
   }
 

``````````

</details>


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


More information about the Mlir-commits mailing list