Fixed SSAInfo.uses def-use population at finalize.#687
Merged
Conversation
Roger-luo
approved these changes
Jul 22, 2026
Roger-luo
pushed a commit
that referenced
this pull request
Jul 22, 2026
Builders set `SSAInfo.kind` (use→def) but nobody ever populated
`SSAInfo.uses` (def→use). Both finalize paths just copied an
always-empty vec through. So finalized IR shipped an empty def-use.
- `StageInfo::rebuild_use_index()`: clears every live value's `uses,`
then scans each live statement's operands (`HasArguments` order) and
records one `Use { stmt, operand_index } `on the value each slot reads.
Idempotent, so the future rewriter can re-run it. Skips deleted
statements/tombstoned SSAs.
- both `finalize()` and `finalize_unchecked()` call it before returning.
- `Use` gains `new()` + `stmt()/operand_index()` accessors, `Copy`, and
serde parity with its container `SSAInfo`.
- `rebuild_use_index` now scan over nodes.digraphs, pushing a
`DiGraphYield { graph, index }` into `SSAInfo.uses`.
```rust
pub enum Use {
StatementOperand { stmt: Statement, index: usize },
DiGraphYield { graph: DiGraph, index: usize },
}
```
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.
Builders set
SSAInfo.kind(use→def) but nobody ever populatedSSAInfo.uses(def→use). Both finalize paths just copied an always-empty vec through. So finalized IR shipped an empty def-use.StageInfo::rebuild_use_index(): clears every live value'suses,then scans each live statement's operands (HasArgumentsorder) and records oneUse { stmt, operand_index }on the value each slot reads. Idempotent, so the future rewriter can re-run it. Skips deleted statements/tombstoned SSAs.finalize()andfinalize_unchecked()call it before returning.Usegainsnew()+stmt()/operand_index()accessors,Copy, and serde parity with its containerSSAInfo.rebuild_use_indexnow scan over nodes.digraphs, pushing aDiGraphYield { graph, index }intoSSAInfo.uses.