[clang] [CIR] Support aggregate co_await / co_yield in AggExprEmitter (PR #225412)

via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 22 07:40:16 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Aman Maurya (amanmaurya92)

<details>
<summary>Changes</summary>

Implement support for evaluating `co_await` and `co_yield` expressions whose result is an aggregate type in `AggExprEmitter`.

### Summary of Changes:
1. **`AggExprEmitter`**:
   - Implement `VisitCoawaitExpr` and `VisitCoyieldExpr` by delegating to `emitCoawaitExpr` and `emitCoyieldExpr` with the destination `AggValueSlot`.
   - Implement `VisitUnaryCoawait` by visiting the subexpression, matching classic Clang (`CGExprAgg.cpp`).
2. **`CIRGenCoroutine.cpp`**:
   - In `emitSuspendExpression`: Omit the scalar/complex `__coawait_resume_rval` temporary alloca for aggregate return values, as the aggregate is emitted directly into `aggSlot`.
   - In `emitSuspendExpr`: Remove the `emitSuspendExpr Aggregate` NYI assertion left as a TODO in #<!-- -->194027, return `rval` directly, and defensively instantiate an aggregate temporary slot when `aggSlot.isIgnored()`.
3. **Tests**:
   - Add `clang/test/CIR/CodeGenCoroutines/coro-agg.cpp` covering used and unused results for aggregate `co_await` and `co_yield`.

Fixes #<!-- -->225317
Resolves Row 11 in the August 2026 ClangIR Progress Report.

---
Full diff: https://github.com/llvm/llvm-project/pull/225412.diff


3 Files Affected:

- (modified) clang/lib/CIR/CodeGen/CIRGenCoroutine.cpp (+18-19) 
- (modified) clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp (+3-5) 
- (added) clang/test/CIR/CodeGenCoroutines/coro-agg.cpp (+72) 


``````````diff
The server is unavailable at this time. Please wait a few minutes before you try again.
``````````

</details>


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


More information about the cfe-commits mailing list