BIR and CFG Drop analysis ยท PR #4748
Use BIR Drop analysis in backend cleanup
Objective
Connect the straight-line BIR Drop result to backend cleanup. Skip backend Drop calls classified as Dead.
Why it was needed
PR #4730 could classify the source local in a move as Dead, but backend cleanup did not use that result yet.
The backend could still call Drop on the moved-from local.
This PR connected the analysis to cleanup, skipped the dead Drop call, and kept the Drop call for the destination.
Main changes
- Records the
HirIdof each whole local classified as definitely dead. - Clears old Drop-analysis results before analyzing each BIR function.
- Skips definitely-dead candidates when backend cleanup is built.
Test case
- drop-whole-local-move.rs: Checks that a moved value is dropped through its destination while the moved-from local is skipped. A normal initialized local is still dropped.
Scope of this PR
The backend connection is limited to whole variables.
Projections and partial moves are not supported by this patch.