BIR and CFG Drop analysis ยท PR #4798
Generate backend Drop flags for conditional moves
Objective
Connect Conditional BIR Drop results to backend cleanup with boolean Drop flags.
Why it was needed
A Conditional result means a value still exists on some runtime paths but was moved on others.
The compiler cannot decide at compile time whether Drop should run.
This patch adds a boolean flag, updates it after initialization or a move, and checks it during cleanup.
Main changes
- Creates the flag before initializing the local.
- Sets the flag to
trueafter initialization. - Clears the flag to
falsewhen the value is moved. - Checks and clears the flag before the Drop call.
Test case
- drop-conditional-move.rs: Runs true and false paths for a one-branch move, a value that remains initialized, and a move on both branches.