[clang] [CIR] Add coroutine cleanup handling and update co_return semantics (PR #189281)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 23 09:16:59 PDT 2026
================
@@ -2538,15 +2538,24 @@ mlir::LogicalResult cir::FuncOp::verify() {
if (!isDeclaration() && getCoroutine()) {
bool foundAwait = false;
+ int coroBodyCount = 0;
this->walk([&](Operation *op) {
if (auto await = dyn_cast<AwaitOp>(op)) {
foundAwait = true;
- return;
+ } else if (isa<CoroBodyOp>(op)) {
+ coroBodyCount++;
+ if (coroBodyCount > 1) {
+ return mlir::WalkResult::interrupt();
+ }
}
+ return mlir::WalkResult::advance();
});
if (!foundAwait)
return emitOpError()
<< "coroutine body must use at least one cir.await op";
+ if (coroBodyCount > 1)
+ return emitOpError()
+ << "coroutine body must use at least one cir.await op";
----------------
andykaylor wrote:
```suggestion
if (coroBodyCount != 1)
return emitOpError()
<< "coroutine body must use exactly one cir.body op";
```
https://github.com/llvm/llvm-project/pull/189281
More information about the cfe-commits
mailing list