[clang] [llvm] [Coroutines] Mark parameter allocas with coro.outside.frame metadata (PR #127653)

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 27 16:15:42 PST 2025


================
@@ -855,6 +855,16 @@ void CodeGenFunction::EmitCoroutineBody(const CoroutineBodyStmt &S) {
     // Create parameter copies. We do it before creating a promise, since an
     // evolution of coroutine TS may allow promise constructor to observe
     // parameter copies.
+    for (const ParmVarDecl *Parm : FnArgs) {
+      // If the original param is in an alloca, exclude it from the coroutine
+      // frame. The parameter copy will be part of the frame.
----------------
rnk wrote:

Please elaborate in this comment:
```
// frame. The parameter copy will be part of the frame. The parameter copy 
// will live on the heap, but the original parameter memory should remain on
// the stack. This is necessary to ensure that parameters destroyed in callees, as
// with `trivial_abi` or in the MSVC C++ ABI, are appropriately destroyed after
// setting up the coroutine.
```

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


More information about the cfe-commits mailing list