`forest_loop_merges` caches a `LoopForest` and a selection-merge map across the loop headers it
plans, because deriving them once per graph edit instead of once per header is the difference
between a bounded translation and a quadratic one. It invalidated that cache by hand: eight
separate `collision_cache = None` assignments, one per mutation site, plus a `mutated` flag
threaded through the collision branch to drive two more. Every future edit that adds a mutation
has to remember to add a ninth, and a missing one is invisible — the stale forest still answers
every query, just about the graph as it was.
`RewriteBlocks` owns the block list and a revision only it can advance; `AnalysisCache` remembers
the revision an analysis came from and re-derives exactly when it no longer matches. The eight
assignments and the `mutated` flag are gone, and there is nothing left to forget.
`rewrite` advances the revision only when a rewrite commits, which is sound because a decline
leaves the list untouched (02c3f9e). Debug builds check that instead of trusting it: a rewrite that
declines with the list edited fails at that call rather than at whatever wrong answer the poisoned
cache produces later. `edit` — for a rewrite that does not report whether it fired — advances
unconditionally.
The reuse this buys was previously argued rather than checked. The collision test re-derived the
forest that the top of the same iteration had just derived; they are the same forest because the
only edit between them is on a path that `continue`s, which is a claim about code shape that
nothing enforced. Now they are the same forest because the revision is the same.
Verified: 2880 corpus sources byte-identical against eac559d. Slowest source (`fc78a004`) 2.81s ->
2.56s, and 2.77s at eac559d, so the analysis this recovers more than pays for the staged copy
02c3f9e added. `bounded_work`'s kernel: 871 -> 867 source CFGs (it reaches the selection
structurizer, not this cache; comment updated). `cargo fmt --all --check`, clippy `-D warnings`,
`RUSTDOCFLAGS='-D warnings' cargo doc`, `cargo test -p metal2vulkan` debug and release,
`cargo test -p metal2vulkan-validation`.