BIR and CFG Drop analysis ยท PR #4777
Handle conditional moves in BIR Drop analysis
Objective
Track whole-local initialization across BIR CFG branches. Classify Drop points as Static, Dead, or Conditional.
Why it was needed
Straight-line analysis cannot combine different states from two branches. A local can be moved on one path and remain initialized on another.
At the join, neither Static nor Dead is correct for every run.
This patch combines the incoming CFG states and classifies the Drop as Conditional.
Main changes
- Stores maybe-initialized, maybe-uninitialized, and reachability state for each block.
- Propagates states through the CFG with a worklist.
- Combines incoming states at branch joins.
- Classifies each Drop as
Static,Dead, orConditional.
Test case
- drop_analysis_conditional_move.rs: Checks one-branch move =
Conditional, no move =Static, and both-branch move =Dead.
Related patch
This PR handles the BIR analysis.
The backend Drop flags are in PR #4798.