Description
The simulate_block
helper takes the set of live variables at the exit of the block and computes the live variables at each point in the block:
rust/src/librustc_mir/util/liveness.rs
Lines 161 to 167 in 764232c
It works by creating a temporary bitset that contains the final value from the end of the block to start:
rust/src/librustc_mir/util/liveness.rs
Lines 171 to 172 in 764232c
Rather than re-allocating this buffer, it would be nice to share it across invocations of simulate_block
. This makes sense because simulate_block
is really only invoked from one place (apart from debugging output), which is the method add_liveness_constraint
. That method is invoked from a simple loop over all basic blocks:
We could therefore have simulate_block
take some extra "buffer" parameter (which would be stored on the stack and passed to add_liveness_constraint
).
According to recent profiles, this fn accounts for about 2% of MIR borrowck, though, so this may not be worth it. Still, we're at the point where "every little bit helps!"