Support dynamic early return in QIR generation via inserted mutable variable updates
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 212
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 65
Description
This is follow on from #2290. To fully support early returns from dynamic contexts, we need partial evaluation to do additional book keeping on each callable invocation (including the entry point). Specifically, when an explicit return is hit, a store into a special return variable should be inserted into the RIR. Then if there is an implicit return from the callable when any such early return was previously triggered the implicit return should be treated the same as an explicit return by inserting the same kind of store instructions. This special return variable would need to be created and managed for every call scope, with potential for optimizing it out in cases where it isn't used (such as explicitly returning from a `Unit`-typed callable).
Contributor guide
Research direction
Start by tracing partial evaluation for callable invocations, including the entry point, and how explicit and implicit returns are represented in the RIR during QIR generation. Done means each call scope manages the special return variable, explicit and previously-triggered implicit returns insert the required stores, and unused variables can be optimized away where applicable.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, quantum-computing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100