https://github.com/Andres-Salamanca created 
https://github.com/llvm/llvm-project/pull/179076

After running the cir-flatten-cfg pass, the scope op inside the cir.await ready 
region can be expanded into multiple basic blocks. The ready region was 
previously assuming a single block, which caused verification/lowering failures.
```bash
error: 'cir.await' op region #0 ('ready') failed to verify constraint: region 
with 1 blocks
```
This change relaxes that restriction and allows the ready region to contain 
more than one block.

>From d75559342d35b5009f7b0fbbce26a742d74a3b99 Mon Sep 17 00:00:00 2001
From: Andres Salamanca <[email protected]>
Date: Sat, 31 Jan 2026 18:50:22 -0500
Subject: [PATCH] [CIR] Allow multiple blocks in cir.await ready region

---
 clang/include/clang/CIR/Dialect/IR/CIROps.td |  2 +-
 clang/test/CIR/IR/await.cir                  | 28 +++++++++++++++++++-
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 6cebf6e62af6f..61656774edcd2 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -3411,7 +3411,7 @@ def CIR_AwaitOp : CIR_Op<"await",[
   }];
 
   let arguments = (ins CIR_AwaitKind:$kind);
-  let regions = (region SizedRegion<1>:$ready,
+  let regions = (region MinSizedRegion<1>:$ready,
                         SizedRegion<1>:$suspend,
                         SizedRegion<1>:$resume);
   let assemblyFormat = [{
diff --git a/clang/test/CIR/IR/await.cir b/clang/test/CIR/IR/await.cir
index c1fb0d6d7c57c..db213a7a164e2 100644
--- a/clang/test/CIR/IR/await.cir
+++ b/clang/test/CIR/IR/await.cir
@@ -1,4 +1,4 @@
-// RUN: cir-opt %s --verify-roundtrip | FileCheck %s
+// RUN: cir-opt %s --cir-flatten-cfg --verify-roundtrip | FileCheck %s
 
 cir.func coroutine @checkPrintParse(%arg0 : !cir.bool) {
   cir.await(user, ready : {
@@ -19,3 +19,29 @@ cir.func coroutine @checkPrintParse(%arg0 : !cir.bool) {
 // CHECK:  }, resume : {
 // CHECK:    cir.yield
 // CHECK:  },)
+
+#true = #cir.bool<true> : !cir.bool
+
+cir.func coroutine @checkReadyRegion() {
+  cir.await(init, ready : {
+    %1 = cir.scope {
+      %0 = cir.const #true
+      cir.yield %0 : !cir.bool
+    } : !cir.bool
+    cir.condition(%1)
+  }, suspend : {
+    cir.yield
+  }, resume : {
+    cir.yield
+  },)
+  cir.return
+}
+
+// CHECK:  cir.await(init, ready : {
+// CHECK:    cir.br ^bb1
+// CHECK:^bb1
+// CHECK:    %0 = cir.const #true
+// CHECK:    cir.br ^bb2(%0 : !cir.bool)
+// CHECK:^bb2(%1: !cir.bool)
+// CHECK:    cir.condition(%1)
+// CHECK:  },

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to