microsoft / microsoft/qdk

Support dynamic early return in QIR generation via inserted mutable variable updates

Open
#2,387 0 comments 0 reactions 0 assignees View on GitHub
enhancement
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.