Files
Yuxuan Chen b570122870 [Clang][coro] Fix coro.free in .resume clones with [[clang::coro_await_elidable]] (#207799)
Fixes https://github.com/llvm/llvm-project/issues/188230

CoroAnnotationElide rewrites annotated safe calls to the `.noalloc`
variant. The noalloc frame is caller-owned, but its `.resume` clone is
shared with ordinary heap-allocated instances.

With a `suspend_never` final suspend, normal resumption falls through to
the `coro.free` deallocation path. Regular frontend cleanup has already
run before this point. `coro.free` must therefore produce the frame
pointer for a heap instance and null for a `.noalloc` instance.

Use the frame destroy slot as a per-instance allocation tag. Cache its
value at resume entry, before user code can resume and release the
enclosing caller frame, then compare it with the cleanup clone. Replace
each `coro.free` result with the frame pointer for a heap instance and
null for an elided instance.

Update the CoroSplit and Clang CodeGen checks to cover the conditional
deallocation and the original suspend_never final-suspend shape.

Assisted-By: Codex GPT 5.5
(cherry picked from commit b9e3e6546dcb4b33d023b7a336163d5650cda9d4)
2026-07-23 08:05:05 +02:00
..