[clang] [ClangIR] Support bool-returning await_suspend (PR #227527)

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 29 19:18:08 PDT 2026


================
@@ -701,10 +701,21 @@ void cir::ConditionOp::getSuccessorRegions(
     return;
   }
 
-  // Parent is an await: condition may branch to resume or suspend regions.
+  // Parent is an await: condition in ready region branches to resume or
+  // suspend regions. Condition in suspend region branches to resume (veto) or
+  // exits to parent op (suspend).
   auto await = cast<AwaitOp>(getOperation()->getParentOp());
-  regions.emplace_back(&await.getResume());
-  regions.emplace_back(&await.getSuspend());
+  mlir::Region *parentRegion = getOperation()->getBlock()->getParent();
+  if (parentRegion == &await.getReady()) {
+    regions.emplace_back(&await.getResume());
+    regions.emplace_back(&await.getSuspend());
+    return;
+  }
+  if (parentRegion == &await.getSuspend()) {
----------------
bcardosolopes wrote:

The other two cases list the region taken when the condition is true first: `body` for loops, `resume` for the ready region. Here true means suspend, i.e. exit to the parent, but `resume` is listed first. Please swap them so all three agree, otherwise whoever implements the TODO above (folding a constant condition to narrow the successors) gets this one backwards.

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


More information about the cfe-commits mailing list