summary refs log tree commit diff
path: root/src/librustc_mir/dataflow/impls
AgeCommit message (Collapse)AuthorLines
2019-10-22Pattern match over PlaceRef rather than PlaceSantiago Pastorino-2/+4
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-13Remove special case for zero-sized arrays from indirectly mut localsDylan MacKenzie-13/+4
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-01Don't mark zero-sized arrays as indirectly mutable when borrowedDylan MacKenzie-15/+31
2019-09-29remove indexed_vec re-export from rustc_data_structurescsmoe-4/+4
2019-09-29remove bit_set re-export from rustc_data_structurescsmoe-2/+2
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/+156
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-11Make Place Boxed on Statement to reduce size from 64 bytes to 32 bytesSantiago Pastorino-4/+4
2019-09-09Convert Place's projection to a boxed sliceSantiago Pastorino-1/+1
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-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
2019-08-05Fiddle param env through to `try_eval_bits` in most placesOliver Scherer-1/+5
2019-07-22Place::as_place_ref is now Place::as_refSantiago Pastorino-3/+3
2019-07-20Avoid cloning Place in report_use_of_moved_or_uninitialized and friendsSantiago Pastorino-3/+3
2019-07-20Migrate from Place enum to Place structSantiago Pastorino-5/+11
2019-07-03Remove needless lifetimesJeremy Stucki-1/+1
2019-07-02Auto merge of #61922 - tmandry:moar-generator-optimization, r=matthewjasperbors-1/+129
Don't store locals that have been moved from in generators This avoids reserving storage in generators for locals that are moved out of (and not re-initialized) prior to yield points. Fixes #59123. This adds a new dataflow analysis, `RequiresStorage`, to determine whether the storage of a local can be destroyed without being observed by the program. The rules are: 1. StorageLive(x) => mark x live 2. StorageDead(x) => mark x dead 3. If a local is moved from, _and has never had its address taken_, mark it dead 4. If (any part of) a local is initialized, mark it live' This is used to determine whether to save a local in the generator object at all, as well as which locals can be overlapped in the generator layout. Here's the size in bytes of all testcases included in the change, before and after the change: async fn test |Size before |Size after -----------------|------------|---------- single | 1028 | 1028 single_with_noop | 2056 | 1032 joined | 5132 | 3084 joined_with_noop | 8208 | 3084 generator test |Size before |Size after ----------------------------|------------|---------- move_before_yield | 1028 | 1028 move_before_yield_with_noop | 2056 | 1032 overlap_move_points | 3080 | 2056 ## Future work Note that there is a possible extension to this optimization, which modifies rule 3 to read: "If a local is moved from, _**and either has never had its address taken, or is Freeze and has never been mutably borrowed**_, mark it dead." This was discussed at length in #59123 and then #61849. Because this would cause some behavior to be UB which was not UB before, it's a step that needs to be taken carefully. A more immediate priority for me is inlining `std::mem::size_of_val(&x)` so it becomes apparent that the address of `x` is not taken. This way, using `size_of_val` to look at the size of your inner futures does not affect the size of your outer future. cc @cramertj @eddyb @Matthias247 @nikomatsakis @RalfJung @Zoxc
2019-07-01Clean up extra lifetime, add assertionsTyler Mandry-12/+16
2019-06-28Use RequiresStorage to determine which locals can overlapTyler Mandry-4/+0
2019-06-28Remove Clone requirementTyler Mandry-1/+0
2019-06-25Add RequiresStorage pass to decide which locals to save in generatorsTyler Mandry-0/+129
This avoids reserving storage in generators for locals that are moved out of (and not re-initialized) prior to yield points.
2019-06-25Implement From<Local> for Place and PlaceBaseSantiago Pastorino-1/+1
2019-06-22Merge `BitSetOperator` and `InitialFlow` into one trait.Dylan MacKenzie-98/+25
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.
2019-06-22rustc_mir: don't pass `on_entry` when building transfer functions.Dylan MacKenzie-66/+75
This commit 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`.
2019-06-20Kill conflicting borrows of places with projections.Dylan MacKenzie-30/+25
Resolves #62007. Due to a bug, the previous version of this check did not actually kill any conflicting borrows unless the borrowed place had no projections. Specifically, `entry_set` will always be empty when `statement_effect` is called. It does not contain the set of borrows which are live at this point in the program.
2019-06-18rustc: remove 'x: 'y bounds (except from comments/strings).Eduard-Mihai Burtescu-13/+13
2019-06-14Run `rustfmt --file-lines ...` for changes from previous commits.Eduard-Mihai Burtescu-21/+4
2019-06-14Unify all uses of 'gcx and 'tcx.Eduard-Mihai Burtescu-50/+50
2019-06-12Run `rustfmt --file-lines ...` for changes from previous commits.Eduard-Mihai Burtescu-20/+20
2019-06-12rustc: replace `TyCtxt<'tcx, 'gcx, 'tcx>` with `TyCtxt<'gcx, 'tcx>`.Eduard-Mihai Burtescu-10/+10
2019-06-12rustc: replace `TyCtxt<'a, 'gcx, 'tcx>` with `TyCtxt<'tcx, 'gcx, 'tcx>`.Eduard-Mihai Burtescu-10/+10
2019-06-09Changed usages of `mir` in librustc::mir and librustc_mir to `body`Jad Ghalayini-56/+56
2019-06-06Auto merge of #61373 - tmandry:emit-storagedead-along-unwind, r=eddybbors-10/+3
Emit StorageDead along unwind paths for generators Completion of the work done in #60840. That PR made a change to implicitly consider a local `StorageDead` after Drop, but that was incorrect for DropAndReplace (see also #61060 which tried to fix this in a different way). This finally enables the optimization implemented in #60187. r? @eddyb cc @Zoxc @cramertj @RalfJung
2019-06-04Revert "Make MaybeStorageLive drop-aware"Tyler Mandry-10/+3
This reverts commit dd2eabc49d415dd30cea0953df5d7659d4d9440f.
2019-06-04Rollup merge of #61069 - Zoxc:drop-borrow-fix, r=pnkfelixPietro Albini-1/+12
Make MIR drop terminators borrow the dropped location r? @eddyb cc @tmandry
2019-05-29Rollup merge of #61249 - spastorino:local-or-deref-local, r=oli-obk,CentrilMazdak Farrokhzad-2/+4
Rename Place::local to Place::local_or_deref_local r? @oli-obk
2019-05-28Changes the type `mir::Mir` into `mir::Body`Claude-Alban RANÉLY-VERGÉ-DÉPRÉ-19/+19
The commit should have changed comments as well. At the time of writting, it passes the tidy and check tool. Revisions asked by eddyb : - Renamed of all the occurences of {visit/super}_mir - Renamed test structures `CachedMir` to `Cached` Fixing the missing import on `AggregateKind`
2019-05-28Rename Place::local to Place::local_or_deref_localSantiago Pastorino-2/+4
2019-05-23Make find_local iterate instead of recurseSantiago Pastorino-8/+11
2019-05-23Auto merge of #60174 - matthewjasper:add-match-arm-scopes, r=pnkfelixbors-31/+8
Add match arm scopes and other scope fixes * Add drop and lint scopes for match arms. * Lint attributes are now respected on match arms. * Make sure we emit a StorageDead if we diverge when initializing a temporary. * Adjust MIR pretty printing of scopes for locals. * Don't generate duplicate lint scopes for `let statements`. * Add some previously missing fake borrows for matches. closes #46525 cc @rust-lang/compiler
2019-05-23Make MIR drop terminators borrow the dropped locationJohn Kåre Alsaker-1/+12
2019-05-21Remove MIR borrowck hack for old match scopesMatthew Jasper-31/+8
2019-05-14Make MaybeStorageLive drop-awareTyler Mandry-3/+8
2019-04-26Remove BasicBlock parameter from mir visitor methodsMatthew Jasper-2/+2