[clang] [CIR] Add coroutine cleanup handling and update co_return semantics (PR #189281)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 22 12:47:08 PDT 2026
================
@@ -2874,6 +2874,48 @@ LogicalResult cir::AwaitOp::verify() {
return success();
}
+LogicalResult cir::CoReturnOp::verify() {
+ if (!getOperation()->getParentOfType<CoroBodyOp>())
+ return emitOpError("must be inside a cir.coro.body");
+ return success();
+}
+
+//===----------------------------------------------------------------------===//
+// CoroBody
+//===----------------------------------------------------------------------===//
+
+void cir::CoroBodyOp::getSuccessorRegions(
+ mlir::RegionBranchPoint point, SmallVectorImpl<RegionSuccessor> ®ions) {
+ if (!point.isParent()) {
+ regions.push_back(RegionSuccessor::parent());
+ return;
+ }
+
+ regions.push_back(RegionSuccessor(&getBody()));
+}
+
+mlir::ValueRange
+cir::CoroBodyOp::getSuccessorInputs(RegionSuccessor successor) {
+ return ValueRange();
+}
+
+LogicalResult cir::CoroBodyOp::verify() {
+ if (!getOperation()->getParentOfType<FuncOp>().getCoroutine())
----------------
andykaylor wrote:
Would it be reasonable to add a corresponding check to FuncOp::verify that coroutine funcs contain one and only one CoroBodyOp?
https://github.com/llvm/llvm-project/pull/189281
More information about the cfe-commits
mailing list