diff options
| author | bors <bors@rust-lang.org> | 2019-06-24 20:44:18 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-06-24 20:44:18 +0000 |
| commit | 8aa42ed7c2adb9f37faa6eb905f890f6199e1db9 (patch) | |
| tree | 4adb27a7ad0464b384825c885844ef22b33332fa /src/librustc_data_structures | |
| parent | 7e08576e4276a97b523c25bfd196d419c39c7b87 (diff) | |
| parent | c8cbd4fc784e5d432c02b0dc14a592f112dab59f (diff) | |
| download | rust-8aa42ed7c2adb9f37faa6eb905f890f6199e1db9.tar.gz rust-8aa42ed7c2adb9f37faa6eb905f890f6199e1db9.zip | |
Auto merge of #61787 - ecstatic-morse:dataflow-split-block-sets, r=pnkfelix
rustc_mir: Hide initial block state when defining transfer functions
This PR addresses [this FIXME](https://github.com/rust-lang/rust/blob/2887008e0ce0824be4e0e9562c22ea397b165c97/src/librustc_mir/dataflow/mod.rs#L594-L596).
This makes `sets.on_entry` inaccessible in `{before_,}{statement,terminator}_effect`. This field was meant to allow implementors of `BitDenotation` to access the initial state for each block (optionally with the effect of all previous statements applied via `accumulates_intrablock_state`) while defining transfer functions. However, the ability to set the initial value for the entry set of each basic block (except for START_BLOCK) no longer exists. As a result, this functionality is mostly useless, and when it *was* used it was used erroneously (see #62007).
Since `on_entry` is now useless, we can also remove `BlockSets`, which held the `gen`, `kill`, and `on_entry` bitvectors and replace it with a `GenKill` struct. Variables of this type are called `trans` since they represent a transfer function. `GenKill`s are stored contiguously in `AllSets`, which reduces the number of bounds checks and may improve cache performance: one is almost never accessed without the other.
Replacing `BlockSets` with `GenKill` allows us to define some new helper functions which streamline dataflow iteration and the dataflow-at-location APIs. Notably, `state_for_location` used a subtle side-effect of the `kill`/`kill_all` setters to apply the transfer function, and could be incorrect if a transfer function depended on effects of previous statements in the block on `gen_set`.
Additionally, this PR merges `BitSetOperator` and `InitialFlow` into one trait. Since the value of `InitialFlow` defines the semantics of the `join` operation, there's no reason to have seperate traits for each. We can add a default impl of `join` which branches based on `BOTTOM_VALUE`. This should get optimized away.
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/bit_set.rs | 5 |
1 files changed, 0 insertions, 5 deletions
diff --git a/src/librustc_data_structures/bit_set.rs b/src/librustc_data_structures/bit_set.rs index 3430d83f23f..5d8388d89f5 100644 --- a/src/librustc_data_structures/bit_set.rs +++ b/src/librustc_data_structures/bit_set.rs @@ -316,11 +316,6 @@ impl<'a, T: Idx> Iterator for BitIter<'a, T> { } } -pub trait BitSetOperator { - /// Combine one bitset into another. - fn join<T: Idx>(&self, inout_set: &mut BitSet<T>, in_set: &BitSet<T>) -> bool; -} - #[inline] fn bitwise<Op>(out_vec: &mut [Word], in_vec: &[Word], op: Op) -> bool where Op: Fn(Word, Word) -> Word |
