about summary refs log tree commit diff
path: root/src/librustc_mir/dataflow/impls
AgeCommit message (Collapse)AuthorLines
2020-02-12Implement `Maybe{Mut,}BorrowedLocals` analysesDylan MacKenzie-60/+208
2020-02-11Use new dataflow framework for drop elaboration and borrow checkingDylan MacKenzie-7/+1
2020-02-10Use new dataflow interface for initialization/borrows analysesDylan MacKenzie-108/+195
2020-02-02Add a resume type parameter to `Generator`Jonas Schievink-8/+12
2020-01-10Remove PlaceBase enum and make Place base field be local: LocalSantiago Pastorino-56/+37
2020-01-10Remove Static from PlaceBaseSantiago Pastorino-36/+38
2020-01-10Remove unused param_env parameterSantiago Pastorino-5/+1
2020-01-06Improve hygiene of `newtype_index`Matthew Jasper-1/+1
Also add unit tests
2020-01-01Rename `syntax_pos` to `rustc_span` in source codeVadim Petrochenkov-1/+1
2019-12-22Format the worldMark Rousskov-275/+232
2019-12-11more privateMark Mansi-8/+4
2019-12-11fix importsMark Mansi-6/+8
2019-12-05rustc: Apply clearer naming to BodyAndCache, fix Deref impl, remove unneeded ↵Paul Daniel Faria-3/+3
Index impl, remove body fn rustc_codegen_ssa: Fix BodyAndCache reborrow to Body and change instances of body() call to derefence rustc_mir: Fix BodyAndCache reborrow to Body and change intances of body() call to derefence
2019-12-02Remove HasLocalDecls impl from BodyCache's, properly reborrow to Body, ↵Paul Daniel Faria-17/+17
rename all body_cache back to body
2019-12-02Fix tidy errorsPaul Daniel Faria-1/+3
2019-12-02Simplify BodyCache impl and fix all remaining type errors in librustc_mir ↵Paul Daniel Faria-4/+4
(lifetime errors still exist)
2019-12-02Add predecessors fn to ReadOnlyBodyCache, fix more Body -> ↵Paul Daniel Faria-11/+11
(ReadOnly)BodyCache type errors
2019-12-02Stop invalidating predecessors cache when accessing unique basic block, ↵Paul Daniel Faria-1/+1
invalidate cache when accessing unique terminator
2019-11-21Track pointers to statics in MIRMatthew Jasper-1/+3
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.