llvm-project
92ab9001 - [CIR] Destroy coroutine body locals before the implicit co_return (#229743)

Commit
43 days ago
[CIR] Destroy coroutine body locals before the implicit co_return (#229743) When a coroutine body flows off its end, CIRGen calls the promise's `return_void()` while the local variables of the body are still alive, and destroys them afterwards. Flowing off the end of the function-body is equivalent to a `co_return` with no operand. Control only flows off the end of the function-body when it leaves the body's block, and leaving the block destroys the block's automatic variables. This patch wraps the body in a `RunCleanupsScope`, so the body's cleanups are popped when the body ends, before the fall-through handler is emitted. The body's `cir.cleanup.scope` now ends with a `cir.yield`, and `return_void()` and `cir.co_return` follow it. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Author
Parents
Loading