Lower async functions to backend-neutral resumable state machines
- Dominant language
- Rust
- Stars
- 53
- Forks
- 16
- Avg merge
- 4h 22m
- Merged PRs (30d)
- 46
Description
Parent: #439
Depends on: #440 and #442.
## Summary
Lower typed async functions into a backend-neutral resumable state-machine representation before LLVM emission.
## Required contract
- Split control flow at await sites and assign deterministic suspension states.
- Move locals that survive suspension into an explicit frame with target-correct size and alignment.
- Preserve return, loop, match, branch, and early-completion behavior across suspension.
- Represent ready, pending, failure, and cancellation according to the agreed semantic contract.
- Keep raw pointer values unchanged while documenting that pointee validity remains the program's responsibility.
- Support nested awaits, multiple awaits, generic specializations, and async calls returning variants or structs.
- Do not use LLVM coroutine intrinsics as the public or frontend contract; LLVM-specific optimization may be added behind the lowered representation.
## Completion criteria
- [ ] A backend-neutral async frame/state-machine IR is documented in code and consumed by LLVM.
- [ ] Generated LLVM verifies for x86_64, AArch64, and RV64 layouts.
- [ ] Locals live across exactly the required suspension states.
- [ ] Completed frames cannot resume again, and cancelled frames follow the defined cleanup contract.
- [ ] Regression tests cover branches, loops, match, nested calls, generics, and pointer-bearing frames.
- [ ] No valid async program reaches an unimplemented-node panic in LLVM.
This is a high-difficulty compiler task.
Contributor guide
Research direction
Start by reading the parent issue #439 and dependencies #440 and #442, then trace the existing async lowering path through LLVM emission. Define the backend-neutral frame and state-machine representation, and verify it against the listed completion criteria, including cross-target LLVM verification and regression coverage for control flow, generics, nested calls, and pointer-bearing frames.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100