Skip to content

Fixed SSAInfo.uses def-use population at finalize.#687

Merged
Roger-luo merged 2 commits into
dl/simplify-toy-livenessfrom
dl/populate-uses
Jul 22, 2026
Merged

Fixed SSAInfo.uses def-use population at finalize.#687
Roger-luo merged 2 commits into
dl/simplify-toy-livenessfrom
dl/populate-uses

Conversation

@zhenrongliew

@zhenrongliew zhenrongliew commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

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.
pub enum Use {
    StatementOperand { stmt: Statement, index: usize },
    DiGraphYield     { graph: DiGraph,  index: usize },
}

@zhenrongliew
zhenrongliew requested a review from Roger-luo July 21, 2026 19:18
@zhenrongliew zhenrongliew added area: Rust Area: issues and pull requests related to Rust code. area: Kirin-rs Area: Rust-version Kirin related components. area: builder Area: issues related to the builder module. labels Jul 21, 2026
@Roger-luo
Roger-luo merged commit 928dfc3 into dl/simplify-toy-liveness Jul 22, 2026
@Roger-luo
Roger-luo deleted the dl/populate-uses branch July 22, 2026 15:19
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 },
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: builder Area: issues related to the builder module. area: Kirin-rs Area: Rust-version Kirin related components. area: Rust Area: issues and pull requests related to Rust code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants