mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
`iterate_to_fixpoint` uses a FIFO worklist. It is seeded in a good order (reverse postorder for forward analyses, postorder for backward analyses). But when back edges are present, re-dirtied blocks are pushed to the back of the queue. Successor blocks of these re-dirtied blocks are then analyzed even though we know the input states may change later on. This commit switches to a new min-rank algorithm that always processes the earliest dirty block in dataflow order. On most code this makes little difference, but cranelift-codegen has one enormous function with over 18,000 basic blocks. The old algorithm required 1.5 million calls to `apply_effects_in_block` to reach a fixpoint for `EverInitializedPlaces`. The new algorithm requires 90,000. This results in a 17% reduction in instruction counts for a `Check Full` build. Note: the new algorithm also avoids doing anything for unreachable blocks in backward analyses. (The old algorithm computed states but never used them meaningfully.)