about summary refs log tree commit diff
path: root/src/librustc_mir/dataflow/impls
AgeCommit message (Collapse)AuthorLines
2018-03-09Remove unused field on BorrowDatabobtwinkles-3/+1
2018-03-09Complete re-implementation of 2-phase borrowsbobtwinkles-32/+32
See #48431 for discussion as to why this was necessary and what we hoped to accomplish. A brief summary: - the first implementation of 2-phase borrows was hard to limit in the way we wanted. That is, it was too good at accepting all 2-phase borrows rather than just autorefs =) - Numerous diagnostic regressions were introduced by 2-phase borrow support which were difficult to fix
2018-03-09Finally start down the right pathbobtwinkles-351/+365
2018-03-09Rename BorrowData::location to BorrowData::reserve_locationbobtwinkles-4/+7
in preparation for rewritting two phase borrow support
2018-03-08Fully use miri in transOliver Schneider-1/+1
2018-03-02Replace Rc with Lrc for shared dataJohn Kåre Alsaker-2/+3
2018-02-17fix more typos found by codespell.Matthias Krüger-2/+2
2018-02-09Auto merge of #47802 - bobtwinkles:loop_false_edge, r=nikomatsakisbors-0/+1
[NLL] Add false edges out of infinite loops Resolves #46036 by adding a `cleanup` member to the `FalseEdges` terminator kind. There's also a small doc fix to one of the other comments in `into.rs` which I can pull out in to another PR if desired =) This PR should pass CI but the test suite has been relatively unstable on my system so I'm not 100% sure. r? @nikomatsakis
2018-02-08Encode (in MIR) whether borrows are explicit in source or arise due to autoref.Felix S. Klock II-1/+1
This is foundation for issue 46747 (limit two-phase borrows to method-call autorefs).
2018-02-05mir: Add TerminatorKind::FalseUnwindbobtwinkles-0/+1
Sometimes a simple goto misses the cleanup/unwind edges. Specifically, in the case of infinite loops such as those introduced by a loop statement without any other out edges. Analogous to TerminatorKind::FalseEdges; this new terminator kind is used when we want borrowck to consider an unwind path, but real control flow should never actually take it.
2018-02-03Auto merge of #47845 - Zoxc:gen-fixes, r=nikomatsakisbors-0/+122
Generator bugfixes r? @nikomatsakis
2018-01-30Fix ICE when assigning references to a static mut with NLLAaron Hill-2/+1
is_unsafe_place only filters out statics in the rhs, not the lhs. Since it's possible to reach that 'Place::Static', we handle statics the same way as we do locals. Fixes #47789
2018-01-30Force locals to be live after they are borrowed for immovable generators. ↵John Kåre Alsaker-0/+122
Fixes #47736
2018-01-29rustc: replace "lvalue" terminology with "place" in the code.Eduard-Mihai Burtescu-56/+56
2018-01-27end_point handling multibyte characters correctly.David Wood-2/+2
2018-01-18in which the unused-parens lint comes to cover function and method argsZack M. Davis-1/+1
Resolves #46137.
2018-01-03Auto merge of #46984 - arielb1:pre-statement-effect, r=nikomatsakisbors-0/+28
NLL fixes First, introduce pre-statement effects to dataflow to fix #46875. Edge dataflow effects might make that redundant, but I'm not sure of the best way to integrate them with liveness etc., and if this is a hack, this is one of the cleanest hacks I've seen. And I want a small fix to avoid the torrent of bug reports. Second, fix linking of projections to fix #46974 r? @pnkfelix
2017-12-26Auto merge of #46975 - matthewjasper:mir-moveck-asm, r=arielb1bors-1/+14
[MIR Borrowck] Moveck inline asm statements Closes #45695 New behavior: * Input operands to `asm!` are moved, direct output operands are initialized. * Direct, non-read-write outputs match the assignment changes in #46752 (Shallow writes, end borrows).
2017-12-24Make killing of out-of-scope borrows a pre-statement effectAriel Ben-Yehuda-0/+28
Fixes #46875. Fixes #46917. Fixes #46935.
2017-12-24Auto merge of #46833 - diwic:7c-abort-ffi, r=arielb1bors-0/+1
Prevent unwinding past FFI boundaries Second attempt to write a patch to solve this. r? @nikomatsakis ~~So, my biggest issue with this patch is the way the patch determines *what* functions should have an abort landing pad (in `construct_fn`). I would ideally have this code match [src/librustc_trans/callee.rs::get_fn](https://github.com/rust-lang/rust/blob/master/src/librustc_trans/callee.rs#L107-L115) but couldn't find an id that returns true for `is_foreign_item`. Also tried `tcx.has_attr("unwind")` with no luck.~~ FIXED Other issues: * llvm.trap is an SIGILL on amd64. Ideally we could use panic-abort's version of aborting which is nicer but we don't want to depend on that library... * ~~Mir inlining is a stub currently.~~ FIXED (no-op) Also, when reviewing please take into account that I'm new to the code and only partially know what I'm doing... and that I've mostly made made matches on `TerminatorKind::Abort` match either `TerminatorKind::Resume` or `TerminatorKind::Unreachable` based on what looked best.
2017-12-23Give MIR borrowck a better understanding of inline asmMatthew Jasper-1/+14
2017-12-21Issue #46589 - Kill borrows on a local variable whenever we assign over this ↵David Teller-10/+25
variable
2017-12-21Rollup merge of #46887 - ↵Guillaume Gomez-1/+17
pnkfelix:ensure-activations-are-from-assignments-to-locals, r=arielb1 Ensure separate activations only occur for assignments to locals Ensure separate activations only occur for assignments to locals, not projections. Fix #46746. (I didn't make a regression test because we do not really have a good way to directly express the case that we are trying to catch, because we cannot write MIR directly.)
2017-12-21Mir: Add Terminatorkind::AbortDavid Henningsson-0/+1
The Abort Terminatorkind will cause an llvm.trap function call to be emitted. Signed-off-by: David Henningsson <diwic@ubuntu.com>
2017-12-20use Rc to store nonlexical_regioncx in BorrowsNiko Matsakis-2/+2
2017-12-20Ensure separate activations only occur for assignments to locals, not ↵Felix S. Klock II-1/+17
projections. Fix #46746.
2017-12-19Split PlaceContext::Store into Store & AsmOutputScott McMurray-0/+4
Outputs in InlineAsm can be read-write, so splitting it out is useful for things like Store-Store folding, as it cannot be done for a Store-AsmOutput. This PR is intended to make no changes, just be the mechanical split of the enum. Future changes can use the split, like a MIR pass I'm working on and perhaps two-phase borrows.
2017-12-13After discussion with ariel, replacing a guard within ↵Felix S. Klock II-33/+33
kill_loans_out_of_scope_at_location. Instead we are "just" careful to invoke it (which sets up a bunch of kill bits) before we go into the code that sets up the gen bits. That way, when the gen bits are set up, they will override any previously set kill-bits for those reservations or activations.
2017-12-13Add some doc to `struct Borrows`.Felix S. Klock II-3/+22
2017-12-13New `ActiveBorrows` dataflow for two-phase `&mut`; not yet borrowed-checked.Felix S. Klock II-64/+394
High-level picture: The old `Borrows` analysis is now called `Reservations` (implemented as a newtype wrapper around `Borrows`); this continues to compute whether a `Rvalue::Ref` can reach a statement without an intervening `EndRegion`. In addition, we also track what `Place` each such `Rvalue::Ref` was immediately assigned to in a given borrow (yay for MIR-structural properties!). The new `ActiveBorrows` analysis then tracks the initial use of any of those assigned `Places` for a given borrow. I.e. a borrow becomes "active" immediately after it starts being "used" in some way. (This is conservative in the sense that we will treat a copy `x = y;` as a use of `y`; in principle one might further delay activation in such cases.) The new `ActiveBorrows` analysis needs to take the `Reservations` results as an initial input, because the reservation state influences the gen/kill sets for `ActiveBorrows`. In particular, a use of `a` activates a borrow `a = &b` if and only if there exists a path (in the control flow graph) from the borrow to that use. So we need to know if the borrow reaches a given use to know if it really gets a gen-bit or not. * Incorporating the output from one dataflow analysis into the input of another required more changes to the infrastructure than I had expected, and even after those changes, the resulting code is still a bit subtle. * In particular, Since we need to know the intrablock reservation state, we need to dynamically update a bitvector for the reservations as we are also trying to compute the gen/kills bitvector for the active borrows. * The way I ended up deciding to do this (after also toying with at least two other designs) is to put both the reservation state and the active borrow state into a single bitvector. That is why we now have separate (but related) `BorrowIndex` and `ReserveOrActivateIndex`: each borrow index maps to a pair of neighboring reservation and activation indexes. As noted above, these changes are solely adding the active borrows dataflow analysis (and updating the existing code to cope with the switch from `Borrows` to `Reservations`). The code to process the bitvector in the borrow checker currently just skips over all of the active borrow bits. But atop this commit, one *can* observe the analysis results by looking at the graphviz output, e.g. via ```rust #[rustc_mir(borrowck_graphviz_preflow="pre_two_phase.dot", borrowck_graphviz_postflow="post_two_phase.dot")] ``` Includes doc for `FindPlaceUses`, as well as `Reservations` and `ActiveBorrows` structs, which are wrappers are the `Borrows` struct that dictate which flow analysis should be performed.
2017-12-13Refactoring alpha-rename `place` (`BorrowData` field) to `borrowed_place`.Felix S. Klock II-4/+4
2017-12-13Refactoring: pull bitvector initialization out from other parts of dataflow.Felix S. Klock II-9/+9
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-11Added test for #46472David Wood-0/+2
2017-12-10avoid passing the gen/kill bits to `start_block_effects`Ariel Ben-Yehuda-14/+17
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-06fix borrows across loops, libcore *almost* compilesAriel Ben-Yehuda-2/+29
2017-12-06handle gen/kill sets togetherAriel Ben-Yehuda-50/+16
2017-12-06fix handling of CallScopeDataAriel Ben-Yehuda-3/+26
This fixes the tests for issue #29793
2017-12-04constraint_generation: create liveness constraints more thoroughlyNiko Matsakis-4/+0
We now visit just the stuff in the CFG, and we add liveness constraints for all the random types, regions etc that appear within rvalues and statements.
2017-12-04inform constraint generation using maybe-initPaul Daniel Faria-5/+5
In particular, if we see a variable is DROP-LIVE, but it is not MAYBE-INIT, then we can ignore the drop. This leavess attempt to use more complex refinements of the idea (e.g., for subpaths or subfields) to future work.
2017-12-03don't track borrows for empty regionsAriel Ben-Yehuda-0/+6
Region inference can create borrows for an empty region if the borrow is dead. In that case, there's no reason to track the borrow, but because there's no such thing as an EndRegion(ReEmpty) these borrows used to live for the entire function. Fixes #46161.
2017-12-03fix handling of borrows at a function's endAriel Ben-Yehuda-0/+4
2017-12-01MIR: s/lv(al(ue)?)?/place in function/variable/module names.Eduard-Mihai Burtescu-29/+29
2017-12-01MIR: s/Lvalue/Place in type names.Eduard-Mihai Burtescu-11/+11
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-24Kill the storage for all locals on returning terminatorsKeith Yeung-0/+29
2017-11-18Auto merge of #46032 - KiChjang:ignore-borrowck-statics, r=nikomatsakisbors-8/+50
Ignore borrowck for static lvalues and allow assignment to static muts Fixes #45129. Fixes #45641.
2017-11-17Do not registor borrows for unsafe lvaluesKeith Yeung-8/+50
2017-11-16replace `RegionIndex` with `RegionVid` (which now impls Idx)Niko Matsakis-2/+2
2017-11-15fix comment, remove redundant codeMikhail Modin-1/+4