summary refs log tree commit diff
path: root/src/librustc_mir/dataflow/impls/mod.rs
AgeCommit message (Collapse)AuthorLines
2018-09-20Improve handling of type bounds in `bit_set.rs`.Nicholas Nethercote-1/+2
Currently, `BitSet` doesn't actually know its own domain size; it just knows how many words it contains. To improve things, this commit makes the following changes. - It changes `BitSet` and `SparseBitSet` to store their own domain size, and do more precise bounds and same-size checks with it. It also changes the signature of `BitSet::to_string()` (and puts it within `impl ToString`) now that the domain size need not be passed in from outside. - It uses `derive(RustcDecodable, RustcEncodable)` for `BitSet`. This required adding code to handle `PhantomData` in `libserialize`. - As a result, it removes the domain size from `HybridBitSet`, making a lot of that code nicer. - Both set_up_to() and clear_above() were overly general, working with arbitrary sizes when they are only needed for the domain size. The commit removes the former, degeneralizes the latter, and removes the (overly general) tests. - Changes `GrowableBitSet::grow()` to `ensure()`, fixing a bug where a (1-based) domain size was confused with a (0-based) element index. - Changes `BitMatrix` to store its row count, and do more precise bounds checks with it. - Changes `ty_params` in `select.rs` from a `BitSet` to a `GrowableBitSet` because it repeatedly failed the new, more precise bounds checks. (Changing the type was simpler than computing an accurate domain size.) - Various other minor improvements.
2018-09-18Eliminate `BitwiseOperator`.Nicholas Nethercote-13/+13
`BitwiseOperator` is an unnecessarily low-level thing. This commit replaces it with `BitSetOperator`, which works on `BitSet`s instead of words. Within `bit_set.rs`, the commit eliminates `Intersect`, `Union`, and `Subtract` by instead passing a function to `bitwise()`.
2018-09-18Merge indexed_set.rs into bitvec.rs, and rename it bit_set.rs.Nicholas Nethercote-24/+23
Currently we have two files implementing bitsets (and 2D bit matrices). This commit combines them into one, taking the best features from each. This involves renaming a lot of things. The high level changes are as follows. - bitvec.rs --> bit_set.rs - indexed_set.rs --> (removed) - BitArray + IdxSet --> BitSet (merged, see below) - BitVector --> GrowableBitSet - {,Sparse,Hybrid}IdxSet --> {,Sparse,Hybrid}BitSet - BitMatrix --> BitMatrix - SparseBitMatrix --> SparseBitMatrix The changes within the bitset types themselves are as follows. ``` OLD OLD NEW BitArray<C> IdxSet<T> BitSet<T> -------- ------ ------ grow - grow new - (remove) new_empty new_empty new_empty new_filled new_filled new_filled - to_hybrid to_hybrid clear clear clear set_up_to set_up_to set_up_to clear_above - clear_above count - count contains(T) contains(&T) contains(T) contains_all - superset is_empty - is_empty insert(T) add(&T) insert(T) insert_all - insert_all() remove(T) remove(&T) remove(T) words words words words_mut words_mut words_mut - overwrite overwrite merge union union - subtract subtract - intersect intersect iter iter iter ``` In general, when choosing names I went with: - names that are more obvious (e.g. `BitSet` over `IdxSet`). - names that are more like the Rust libraries (e.g. `T` over `C`, `insert` over `add`); - names that are more set-like (e.g. `union` over `merge`, `superset` over `contains_all`, `domain_size` over `num_bits`). Also, using `T` for index arguments seems more sensible than `&T` -- even though the latter is standard in Rust collection types -- because indices are always copyable. It also results in fewer `&` and `*` sigils in practice.
2018-09-13Remove bitslice.rs.Nicholas Nethercote-1/+1
This requires the following changes. - It moves parts of bitslice.rs into bitvec.rs: `bitwise()`, `BitwiseOperator`, `bits_to_string()`. - It changes `IdxSet` to just be a wrapper around `BitArray`. - It changes `BitArray` and `BitVec` to use `usize` words instead of `u128` words. (`BitSlice` and `IdxSet` already use `usize`.) Local profiling showed `usize` was better. - It moves some operations from `IdxSet` into `BitArray`: `new_filled()`, `clear()`, `set_up_to()`, `trim_to()` (renamed `clear_above()`), `words()` and `words_mut()`, `encode()` and `decode(). The `IdxSet` operations now just call the `BitArray` operations. - It replaces `BitArray`'s iterator implementation with `IdxSet`'s, because the latter is more concise. It also removes the buggy `size_hint` function from `BitArray`'s iterator, which counted the number of *words* rather than the number of *bits*. `IdxSet`'s iterator is now just a thin wrapper around `BitArray`'s iterator. - It moves some unit tests from `indexed_set.rs` to `bitvec.rs`.
2018-08-30Make move out computation lazySantiago Pastorino-127/+2
2018-07-13Make BitSlice's `Word` properly generic.Nicholas Nethercote-6/+6
Currently `Word` is `usize`, and there are various places in the code that assume this. This patch mostly just changes `usize` occurrences to `Word`. Most of the changes were found as compile errors when I changed `Word` to a type other than `usize`, but there was one non-obvious case in librustc_mir/dataflow/mod.rs that caused bounds check failures before I fixed it.
2018-04-15construct the `BorrowSet` outside of `borrows`Niko Matsakis-1/+0
2018-04-15relocate `BorrowData` etc into `borrow_check::borrow_set`Niko Matsakis-0/+1
2018-04-02avoid IdxSets containing garbage above the universe lengthAriel Ben-Yehuda-2/+2
This makes sure that all bits in each IdxSet between the universe length and the end of the word are all zero instead of being in an indeterminate state. This fixes a crash with RUST_LOG=rustc_mir, and is probably a good idea anyway.
2018-02-03Auto merge of #47845 - Zoxc:gen-fixes, r=nikomatsakisbors-0/+4
Generator bugfixes r? @nikomatsakis
2018-01-30Force locals to be live after they are borrowed for immovable generators. ↵John Kåre Alsaker-0/+4
Fixes #47736
2018-01-29rustc: replace "lvalue" terminology with "place" in the code.Eduard-Mihai Burtescu-52/+52
2017-12-13Refactoring: pull bitvector initialization out from other parts of dataflow.Felix S. Klock II-6/+6
This is meant to ease development of multi-stage dataflow analyses where the output from one analysis is used to initialize the state for the next; in such a context, you cannot start with `bottom_value` for all the bits.
2017-12-10avoid passing the gen/kill bits to `start_block_effects`Ariel Ben-Yehuda-12/+15
If the gen/kill bits are set there, the effects of `start_block_effects` will not be seen when using `FlowAtLocation` etc. to go over the MIR. EverInitializedLvals is the only pass that got this wrong, but this fixes the footgun for everyone.
2017-12-06work around weird match arm lifetimesAriel Ben-Yehuda-3/+23
2017-12-06handle gen/kill sets togetherAriel Ben-Yehuda-50/+16
2017-12-01MIR: s/lv(al(ue)?)?/place in function/variable/module names.Eduard-Mihai Burtescu-14/+14
2017-12-01MIR: s/Lvalue/Place in type names.Eduard-Mihai Burtescu-6/+6
2017-11-27Add initialization info to `MoveData`Matthew Jasper-54/+168
* Used for new dataflow to track if a variable has every been initialized * Used for other dataflows that need to be updated for initializations
2017-11-15fix comment, remove redundant codeMikhail Modin-1/+4
2017-11-15add `StorageDead` handlingMikhail Modin-7/+14
2017-11-09Add `TerminatorKind::DropAndReplace` handlingMikhail Modin-0/+13
2017-11-08restore move out dataflow, add report of move out errorsMikhail Modin-1/+161
2017-10-31make the dataflow / mir-borrowck types carry a `'tcx` lifetimeNiko Matsakis-33/+33
Also, factor out `do_mir_borrowck`, which is the code that actually performs the MIR borrowck from within the scope of an inference context. This change should be a pure refactoring.
2017-09-13Analyse storage liveness and preserve it during generator transformationJohn Kåre Alsaker-0/+4
2017-08-19rustc: Remove some dead codeVadim Petrochenkov-160/+1
2017-08-16Added dataflow analysis for `Borrows`.Felix S. Klock II-0/+3
post-rebase: addressed review comment: rename `loc_map`/`location_map` and `rgn_map`/`region_map`. post-rebase: remove now unnecessary `mut` decl. post-rebase: address comments: bind iterator expr, and alpha-rename `loc`/`location` and `idx`/`index`.
2017-08-16Refactor `trait BitDenotation` to take `Location` instead of ↵Felix S. Klock II-30/+20
`BasicBlock`/`usize` argument pairs.
2017-08-12Auto merge of #43794 - Eijebong:fix_typos, r=lukaramu,steveklanik,imperiobors-1/+1
Fix some typos I wrote a really naive script and found those typos in the documentation.
2017-08-11Fix some typosBastien Orivel-1/+1
2017-08-10For box expressions, use NZ drop instead of a free blockAriel Ben-Yehuda-9/+22
This falls naturally out of making drop elaboration work with `box` expressions, which is probably required for sane MIR borrow-checking. This is a pure refactoring with no intentional functional effects.
2017-07-30add new instructions for asserting when values are valid, and to describe ↵Ralf Jung-0/+1
when we can rely on them being locked in memory
2017-06-28Shift mir-dataflow from `rustc_borrowck` to `rustc_mir` crate.Felix S. Klock II-0/+600
Turn `elaborate_drops` and `rustc_peek` implementations into MIR passes that also live in `rustc_mir` crate. Rewire things so `rustc_driver` uses the `ElaborateDrops` from `rustc_mir` crate.