yuxuanchen1997 wrote: > why it is incorrect to replace coro.free with calls to destroy/cleanup?
The [LangRef](https://github.com/llvm/llvm-project/blob/e49aac8ff793d782e8b8a000077fb39b37629090/llvm/docs/Coroutines.md?plain=1#L1085-L1088) says `llvm.coro.free` "returns a pointer to a block of memory where the coroutine frame is stored, or null if the instance did not use dynamic allocation." The pointer then flows into the user defined delete operator for the type. I think we can do exactly that. Meanwhile, I think at the fallthrough branch, the Clang FE generated clean up logic for the current coroutine has already been run. I don't remember us calling `.destroy` or `.cleanup` from a non-suspended state. The resume function here would have stepped ahead from the last known suspend state (S) here and the coroutine internal state machine must be at (S+1) for the destroy/cleanup call to be safe. I don't think we model that S+1 in the switch ABI. https://github.com/llvm/llvm-project/pull/207799 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
