summary refs log tree commit diff
path: root/src/librustc_mir/dataflow
AgeCommit message (Collapse)AuthorLines
2019-10-22Move Place::elem methods and friends to TyCtxtSantiago Pastorino-1/+1
2019-10-22Intern place projectionSantiago Pastorino-3/+3
2019-10-22Pattern match over PlaceRef rather than PlaceSantiago Pastorino-3/+5
This prepares the code base for when projection is interned. Place's projection field is going to be `&List<PlaceElem<'tcx>>` so we won't be able to pattern match against it.
2019-10-15Rollup merge of #65389 - ecstatic-morse:zero-sized-array-no-drop, r=eddybTyler Mandry-13/+4
Return `false` from `needs_drop` for all zero-sized arrays. Resolves #65348. This changes the result of the `needs_drop` query from `true` to `false` for types such as `[Box<i32>; 0]`. I believe this change to be sound because a zero-sized array can never actually hold a value. This is an elegant way of resolving #65348 and #64945, but obviously it has much broader implications.
2019-10-13Remove special case for zero-sized arrays from indirectly mut localsDylan MacKenzie-13/+4
2019-10-13ast: remove implicit pprust dependency via Display.Mazdak Farrokhzad-3/+3
Instead just use `pprust::path_to_string(..)` where needed. This has two benefits: a) The AST definition is now independent of printing it. (Therefore we get closer to extracting a data-crate.) b) Debugging should be easier as program flow is clearer.
2019-10-07Auto merge of #61430 - matthewjasper:drop-on-into-panic, r=oli-obkbors-8/+30
Make `into` schedule drop for the destination closes #47949
2019-10-02Do not mark unitinitialized locals as requiring storageMatthew Jasper-8/+30
2019-10-02Rollup merge of #64967 - ecstatic-morse:issue-64945, r=oli-obkMazdak Farrokhzad-15/+31
Don't mark borrows of zero-sized arrays as indirectly mutable Resolves #64945 r? @oli-obk
2019-10-01Update example table to match current outputDylan MacKenzie-19/+19
2019-10-01Reset row background for each blockDylan MacKenzie-0/+1
Now the first row of each basic block is always light instead of changing seemingly at random.
2019-10-01Don't mark zero-sized arrays as indirectly mutable when borrowedDylan MacKenzie-15/+31
2019-09-30Add graphviz debug output for generic dataflowDylan MacKenzie-5/+510
2019-09-30Allow `ResultsCursor` to borrow the underlying `Results`Dylan MacKenzie-8/+16
2019-09-30Fix typo in docsDylan MacKenzie-1/+1
2019-09-29remove indexed_vec re-export from rustc_data_structurescsmoe-11/+11
2019-09-29remove bit_set re-export from rustc_data_structurescsmoe-5/+5
2019-09-28Correct `IndirectlyMutableLocals` docsDylan MacKenzie-8/+4
2019-09-28Give usage instructions `IndirectlyMutableLocals` docsDylan MacKenzie-3/+7
2019-09-28Explain why `visit_terminator` does nothing for `IndirectlyMutableLocals`Dylan MacKenzie-0/+3
2019-09-28Don't treat locals as mutably borrowed after they're droppedDylan MacKenzie-12/+5
2019-09-28Add analysis to determine if a local is indirectly mutableDylan MacKenzie-4/+157
This adds a dataflow analysis that determines if a reference to a given `Local` or part of a `Local` that would allow mutation exists before a point in the CFG. If no such reference exists, we know for sure that that `Local` cannot have been mutated via an indirect assignment or function call.
2019-09-27Remove global_tcx from TyCtxtMark Rousskov-2/+1
The non-global context was removed; there's only one context now. This is a noop method that only serves to confuse readers -- remove it.
2019-09-25Rename `sty` to `kind`varkor-3/+3
2019-09-19Rollup merge of #64566 - ecstatic-morse:generic-dataflow, r=oli-obkMazdak Farrokhzad-0/+513
A more generic interface for dataflow analysis #64470 requires a transfer function that is slightly more complex than the typical `gen`/`kill` one. Namely, it must copy state bits between locals when assignments occur (see #62547 for an attempt to make this fit into the existing framework). This PR contains a dataflow interface that allows for arbitrary transfer functions. The trade-off is efficiency: we can no longer coalesce transfer functions for blocks and must visit each statement individually while iterating to fixpoint. Another issue is that poorly behaved transfer functions can result in an analysis that fails to converge. `gen`/`kill` sets do not have this problem. I believe that, in order to guarantee convergence, flipping a bit from `false` to `true` in the entry set cannot cause an output bit to go from `true` to `false` (negate all preceding booleans when `true` is the bottom value). Perhaps someone with a more formal background can confirm and we can add a section to the docs? This approach is not maximally generic: it still requires that the lattice used for analysis is the powerset of values of `Analysis::Idx` for the `mir::Body` of interest. This can be done at a later date. Also, this is the bare minimum to get #64470 working. I've not adapted the existing debug framework to work with the new analysis, so there are no `rustc_peek` tests either. I'm planning to do this after #64470 is merged. Finally, my ultimate plan is to make the existing, `gen`/`kill`-based `BitDenotation` a special case of `generic::Analysis`. Currently they share a ton of code. I should be able to do this without changing any implementers of `BitDenotation`. Something like: ```rust struct GenKillAnalysis<A: BitDenotation> { trans_for_block: IndexVec<BasicBlock, GenKillSet<A::Idx>>, analysis: A, } impl<A> generic::Analysis for GenKillAnalysis<A> { // specializations of `apply_{partial,whole}_block_effect`... } ``` r? @pnkfelix
2019-09-18Rollup merge of #64532 - ecstatic-morse:dataflow-cursor-get, r=tmandryTyler Mandry-26/+2
Replace `state_for_location` with `DataflowResultsCursor` These are two different ways of getting the same data from the result of a dataflow analysis. However, `state_for_location` goes quadratic if you try to call it for every statement in the body.
2019-09-18Rollup merge of #64207 - sinkuu:pub_dataflow, r=tmandryTyler Mandry-9/+9
Make rustc_mir::dataflow module pub (for clippy) I'm working on fixing false-positives of a MIR-based clippy lint (https://github.com/rust-lang/rust-clippy/pull/4509), and in need of the dataflow infrastructure.
2019-09-18Fix bug where `is_call_return_effect_applied` was never setDylan MacKenzie-0/+1
2019-09-18Add summary of the current state and future plansDylan MacKenzie-0/+18
2019-09-18Publish `rustc_mir::dataflow` and remove `#[allow(unused)]`Dylan MacKenzie-5/+0
2019-09-18Fix typoDylan MacKenzie-1/+1
2019-09-18Use an associated const for `name`Dylan MacKenzie-2/+2
2019-09-18Fix `Analysis` exampleDylan MacKenzie-2/+4
2019-09-17Add ignore reason to placate `tidy`Dylan MacKenzie-1/+1
2019-09-17Temporarily add `#[allow(unused)]` for CIDylan MacKenzie-0/+2
This can be removed once dataflow-based const validation is merged.
2019-09-17Document new dataflow analysisDylan MacKenzie-0/+50
2019-09-17Add generic dataflow implDylan MacKenzie-0/+445
2019-09-16Remove `dataflow::state_for_location`Dylan MacKenzie-28/+0
2019-09-16Add a getter for the current state to `DataflowResultsCursor`Dylan MacKenzie-0/+4
2019-09-11Make Place Boxed on Statement to reduce size from 64 bytes to 32 bytesSantiago Pastorino-5/+5
2019-09-09Use slice patterns to match projection baseSantiago Pastorino-2/+1
2019-09-09Make move_path_children_matching closure take a PlaceElem instead of a sliceSantiago Pastorino-4/+7
2019-09-09Convert Place's projection to a boxed sliceSantiago Pastorino-92/+85
2019-09-06Make rustc_mir::dataflow module pubShotaro Yamada-9/+9
2019-09-05Auto merge of #62800 - albins:polonius-initialization-1, r=nikomatsakisbors-134/+153
Extend Polonius fact generation for (some) move tracking This PR will extend rustc to emit facts used for tracking moves and initialization in Polonius. It is most likely the final part of my master's thesis work.
2019-09-05Rollup merge of #64005 - ecstatic-morse:is-indirect, r=oli-obkMazdak Farrokhzad-13/+4
Add a `Place::is_indirect` method to determine whether a `Place` contains a `Deref` projection Working on #63860 requires tracking some property about each local. This requires differentiating `Place`s like `x` and `x.field[index]` from ones like `*x` and `*x.field`, since the first two will always access the same region of memory as `x` while the latter two may access any region of memory. This functionality is duplicated in various places across the compiler. This PR adds a helper method to `Place` which determines whether that `Place` has a `Deref` projection at any point and changes some existing code to use the new method. I've not converted `qualify_consts.rs` to use the new method, since it's not a trivial conversion and it will get replaced anyway by #63860. There may be other potential uses besides the two I change in this PR. r? @oli-obk
2019-09-04Rustfmt the files I touchedAlbin Stjerna-135/+147
2019-09-04Polonius: emit initialization/move tracking factsAlbin Stjerna-1/+8
- var_starts_path - parent - initialized_at - moved_out_at This also switches to the intended emission of `var_drop_used` fact emission, where that fact is always emitted on a drop-use of a variable, regardless of its initialization status, as Polonius now handles that.
2019-08-31Kill borrows from assignments after generating new borrowsMatthew Jasper-4/+4
2019-08-30Use new `Place::is_indirect` API where possibleDylan MacKenzie-13/+4