[clang] [CIR] Add structured control flow for coroutine suspend points (PR #213191)

via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 20 20:23:56 PDT 2026


Andres-Salamanca wrote:

My last commit makes a fairly large structural change:

* Removes `cir.coroBody` and introduces `cir.coroutine`. The logic previously handled by `cir.coroBody` is now part of the `body` region of `cir.coroutine`, so `cir.co_return` now lives directly in that region. The new `cir.co_return` verifier also checks that it is only used inside the coroutine `body` region.
* Renames the previous `prolog`/`epilog` regions to `initial_suspend`/`final_suspend`. I think this terminology is closer to the coroutine model: `initial_suspend` represents the coroutine ramp/setup phase, while `final_suspend` marks the point where the coroutine has completed and enters its final suspension/destruction flow.
*  `gro` and `unwind` regions for future PRs.
* The `destroy` and `unwind` regions will be treated similarly to cleanup regions in the loop operations. I did not introduce an explicit cleanup kind: `destroy` is always `all`, while `unwind` is `eh`.
* I also stopped using `builder.restoreInsertionPoint`, as discussed.


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


More information about the cfe-commits mailing list