[Mlir-commits] [mlir] [mlir][tosa] Fix validation check on controlflow operators (PR #159754)

Mehdi Amini llvmlistbot at llvm.org
Fri Sep 19 09:27:50 PDT 2025


================
@@ -1257,17 +1257,17 @@ bool checkErrorIfCondIf(Operation *op) {
   //   tosa.yield %arg4
   // }
 
-  return failed(checkIsolatedRegion(op, ifOp.getThenGraph(), "then")) ||
-         failed(checkIsolatedRegion(op, ifOp.getElseGraph(), "else"));
+  return succeeded(checkIsolatedRegion(op, ifOp.getThenGraph(), "then")) &&
+         succeeded(checkIsolatedRegion(op, ifOp.getElseGraph(), "else"));
 }
 
 bool checkErrorIfWhileLoop(Operation *op) {
   auto whileOp = dyn_cast<tosa::WhileOp>(op);
   if (!whileOp)
     return true;
 
-  return failed(checkIsolatedRegion(op, whileOp.getCondGraph(), "cond")) ||
-         failed(checkIsolatedRegion(op, whileOp.getBodyGraph(), "body"));
+  return succeeded(checkIsolatedRegion(op, whileOp.getCondGraph(), "cond")) &&
+         succeeded(checkIsolatedRegion(op, whileOp.getBodyGraph(), "body"));
----------------
joker-eph wrote:

A contributing factor to this issue is that these APIs are returning a bool to signal an error, which is ambiguous. This is the whole reason why LogicalResult was introduced in the codebase.

Can you please update all of these checks in this file to propagate LogicalResult instead of bool please?

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


More information about the Mlir-commits mailing list