← Contribution overview

BIR and CFG Drop analysis ยท PR #4730

Add straight-line BIR Drop-style analysis

Merged

Objective

Add an initial BIR Drop-state analysis for whole local variables in straight-line control flow. Classify each Drop point as Static or Dead.

Why it was needed

After a non-Copy move such as let y = x, x no longer owns the value and must not be dropped.

gccrs needed an analysis to check if a local was still initialized at each Drop point.

This first step handled whole locals in straight-line code. PR #4748 later connected the result to backend cleanup.

Main changes

  • Fixes the sized IndexVec constructor so it creates the requested elements instead of only reserving space.
  • Adds BIR Drop statements at scope exits and for function arguments.
  • Tracks assignments, whole-local moves, and Copy values.
  • Prints the Static and Dead classifications in BIR dumps.

Test case

Scope of this PR

This first patch covers straight-line functions, whole-local moves, Copy versus move assignments, function arguments, and Static or Dead Drops.

Branches, loops, partial moves, needs_drop filtering, and backend integration were left for follow-up patches.

View PR on GitHub ← Contribution overview