[Circuit Diagrams] 1 - RIR debug metadata#2942
Merged
minestarks merged 13 commits intomainfrom Feb 25, 2026
Merged
Conversation
…ks/rir-debug-metadata
minestarks
commented
Feb 23, 2026
minestarks
commented
Feb 23, 2026
minestarks
commented
Feb 23, 2026
minestarks
commented
Feb 24, 2026
swernli
reviewed
Feb 24, 2026
swernli
reviewed
Feb 24, 2026
swernli
reviewed
Feb 24, 2026
swernli
reviewed
Feb 24, 2026
swernli
approved these changes
Feb 24, 2026
minestarks
commented
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is part of the groundwork for supporting the visualization of classical control in circuit diagrams.
To support classical control flow (branches) in circuit diagrams, we will use the RIR representation which we will transform into a circuit. To be able to preserve source information in the circuit diagram, we first need to emit source metadata into RIR. This also sets us up nicely to potentially emit LLVM debug metadata to QIR, if ever the need arises.
debugmodule toqsc_rirwith structures modeled after LLVM's source-level debugging metadata (DbgLocation,DbgScope,DbgInfo). These track source offsets, callable scopes, loop body scopes (with per-iteration discriminators), and inline-at chains.Instructionenum toInstructionKindand introduce a newInstructionstruct that pairs anInstructionKindwith optionalInstructionDbgMetadata. All RIR passes, codegen, builder helpers, and tests updated accordingly.SubProgram), and loop iteration scopes (LexicalBlockFile). Unused entries are pruned before returning the program.PartialEvalConfigwith agenerate_debug_metadataflag. Enabled forfir_to_rir(used by the VS Code extension for circuit/RIR views), disabled forfir_to_qir(text QIR output).&&,||) — the continuation block now gets the correct source location.