about summary refs log tree commit diff
path: root/src/librustc_mir/dataflow/generic
AgeCommit message (Collapse)AuthorLines
2020-03-26Rename `dataflow::generic` to `dataflow::framework`Dylan MacKenzie-2592/+0
2020-03-22remove redundant closures (clippy::redundant_closure)Matthias Krüger-1/+1
2020-03-14Auto merge of #69716 - jonas-schievink:generator-size, r=tmandrybors-27/+70
Don't store locals in generators that are immediately overwritten with the resume argument This fixes https://github.com/rust-lang/rust/issues/69672 and makes https://github.com/rust-lang/rust/pull/69033 pass the async fn size tests again (in other words, there will be no size regression of async fn if both this and https://github.com/rust-lang/rust/pull/69033 land). ~~This is a small botch and I'd rather have a more precise analysis, but that seems much harder to pull off, so this special-cases `Yield` terminators that store the resume argument into a simple local (ie. without any field projections) and explicitly marks that local as "not live" in the suspend point of that yield. We know that this local does not need to be stored in the generator for this suspend point because the next resume would immediately overwrite it with the passed-in resume argument anyways. The local might still end up in the state if it is used across another yield.~~ (this now properly updates the dataflow framework to handle this case)
2020-03-07Auto merge of #69676 - ecstatic-morse:fix-enum-discr-effect, r=oli-obkbors-20/+28
Pass correct place to `discriminant_switch_effect` PR #69562, which fixed a bug that was causing clippy to ICE, mistakenly passed the place holding the *result* of `Rvalue::Discriminant` instead of the place holding its *operand* to `apply_discriminant_switch_effect` as the enum place. As a result, no effect was applied at all, and we lost the perf benefits from marking inactive enum variants as uninitialized. **edit:** The regression test has been split into #69744. r? @oli-obk
2020-03-06Model generator resumption in dataflowJonas Schievink-27/+70
We now have a way to apply an effect only *after* a `yield` resumes, similar to calls (which can either return or unwind).
2020-03-05Don't pass &mut where immutable reference (&) is sufficient ↵Matthias Krüger-4/+4
(clippy::unnecessary_mut_passed)
2020-03-05Const items have by default a static lifetime, there's no need to annotate ↵Matthias Krüger-2/+2
it. (clippy::redundant_static_lifetimes)
2020-03-03Use correct place for `enum_place`Dylan MacKenzie-20/+28
PR #69562, which fixed a bug that was causing clippy to ICE, passed the place for the *result* of `Rvalue::Discriminant` instead of the *operand* to `apply_discriminant_switch_effect`. As a result, no effect was applied at all, and we lost the perf benefits from marking inactive enum variants as uninitialized.
2020-03-01Auto merge of #69606 - JohnTitor:rollup-i3nrrcf, r=JohnTitorbors-54/+72
Rollup of 7 pull requests Successful merges: - #69397 (bootstrap: Remove commit hash from LLVM version suffix to avoid rebuilds) - #69549 (Improve MinGW detection when cross compiling ) - #69562 (Don't `bug` when taking discriminant of generator during dataflow) - #69579 (parser: Remove `Parser::prev_span`) - #69580 (use .copied() instead of .map(|x| *x) on iterators) - #69583 (Do not ICE on invalid type node after parse recovery) - #69605 (Use `opt_def_id()` over `def_id()`) Failed merges: r? @ghost
2020-03-01Rollup merge of #69562 - ecstatic-morse:dataflow-generator-discriminant, ↵Yuki Okushi-54/+72
r=oli-obk Don't `bug` when taking discriminant of generator during dataflow The proper fix for rust-lang/rust-clippy#5239. `Rvalue::Discriminant` is used on generators as well as `enum`s. This didn't cause a test failure in `rustc` since we don't need to do any dataflow passes until after the generator transform that adds the `Rvalue::Discriminant`. This required a small refactoring. `diff -w` is beneficial. r? @oli-obk cc @JohnTitor
2020-03-01Auto merge of #69295 - ecstatic-morse:unified-dataflow-generators, r=tmandrybors-11/+18
Use new dataflow framework for generators #65672 introduced a new dataflow framework that can handle arbitrarily complex transfer functions as well as ones expressed as a series of gen/kill operations. This PR ports the analyses used to implement generators to the new framework so that we can remove the old one. See #68241 for a prior example of this. The new framework has some superficial API changes, but this shouldn't alter the generator passes in any way. r? @tmandry
2020-03-01Auto merge of #69592 - petrochenkov:nosyntax, r=Centrilbors-1/+1
Rename `libsyntax` to `librustc_ast` This was the last rustc crate that wasn't following the `rustc_*` naming convention. Follow-up to https://github.com/rust-lang/rust/pull/67763.
2020-02-29Rename `syntax` to `rustc_ast` in source codeVadim Petrochenkov-1/+1
2020-02-29use .iter() instead of .into_iter() on references.Matthias Krüger-1/+1
2020-02-28Don't bug when taking discriminant of generatorDylan MacKenzie-54/+72
2020-02-27Remove now unused `GenKill` impl for old `GenKillSet`Dylan MacKenzie-11/+0
2020-02-27Add inherent `visit_with` method to `dataflow::Results`Dylan MacKenzie-0/+18
This is more ergonomic than importing `dataflow::visit_results`
2020-02-27Auto merge of #68528 - ecstatic-morse:maybe-init-variants, r=oli-obkbors-7/+110
Mark other variants as uninitialized after switch on discriminant During drop elaboration, which builds the drop ladder that handles destruction during stack unwinding, we attempt to remove MIR `Drop` terminators that will never be reached in practice. This reduces the number of basic blocks that are passed to LLVM, which should improve performance. In #66753, a user pointed out that unreachable `Drop` terminators are common in functions like `Option::unwrap`, which move out of an `enum`. While discussing possible remedies for that issue, @eddyb suggested moving const-checking after drop elaboration. This would allow the former, which looks for `Drop` terminators and replicates a small amount of drop elaboration to determine whether a dropped local has been moved out, leverage the work done by the latter. However, it turns out that drop elaboration is not as precise as it could be when it comes to eliminating useless drop terminators. For example, let's look at the code for `unwrap_or`. ```rust fn unwrap_or<T>(opt: Option<T>, default: T) -> T { match opt { Some(inner) => inner, None => default, } } ``` `opt` never needs to be dropped, since it is either moved out of (if it is `Some`) or has no drop glue (if it is `None`), and `default` only needs to be dropped if `opt` is `Some`. This is not reflected in the MIR we currently pass to codegen. ![pasted_image](https://user-images.githubusercontent.com/29463364/73384403-109a0d80-4280-11ea-8500-0637b368f2dc.png) @eddyb also suggested the solution to this problem. When we switch on an enum discriminant, we should be marking all fields in other variants as definitely uninitialized. I implemented this on top of alongside a small optimization (split out into #68943) that suppresses drop terminators for enum variants with no fields (e.g. `Option::None`). This is the resulting MIR for `unwrap_or`. ![after](https://user-images.githubusercontent.com/29463364/73384823-e432c100-4280-11ea-84bd-d0bcc3b777b4.png) In concert with #68943, this change speeds up many [optimized and debug builds](https://perf.rust-lang.org/compare.html?start=d55f3e9f1da631c636b54a7c22c1caccbe4bf0db&end=0077a7aa11ebc2462851676f9f464d5221b17d6a). We need to carefully investigate whether I have introduced any miscompilations before merging this. Code that never drops anything would be very fast indeed until memory is exhausted.
2020-02-24don't explicitly compare against true or falseMatthias Krüger-1/+1
2020-02-19Auto merge of #69113 - ecstatic-morse:unified-dataflow-borrowed, r=wesleywiserbors-0/+11
Combine `HaveBeenBorrowedLocals` and `IndirectlyMutableLocals` into one dataflow analysis This PR began as an attempt to port `HaveBeenBorrowedLocals` to the new dataflow framework (see #68241 for prior art). Along the way, I noticed that it could share most of its code with `IndirectlyMutableLocals` and then found a few bugs in the two analyses: - Neither one marked locals as borrowed after an `Rvalue::AddressOf`. - `IndirectlyMutableLocals` was missing a minor fix that `HaveBeenBorrowedLocals` got in #61069. This is not a problem today since it is only used during const-checking, where custom drop glue is forbidden. However, this may change some day. I decided to combine the two analyses so that they wouldn't diverge in the future while ensuring that they remain distinct types (called `MaybeBorrowedLocals` and `MaybeMutBorrowedLocals` to be consistent with the `Maybe{Un,}InitializedPlaces` naming scheme). I fixed the bugs and switched to exhaustive matching where possible to make them less likely in the future. Finally, I added comments explaining some of the finer points of the transfer function for these analyses (see #61069 and #65006).
2020-02-13Don't print block exit state if unchangedDylan MacKenzie-20/+35
2020-02-13Support effects for particular edges of `SwitchInt`Dylan MacKenzie-7/+110
2020-02-12Impl `GenKill` for old dataflow framework's `GenKillSet`Dylan MacKenzie-0/+11
This impl is temporary and will be removed along with the old dataflow framework. It allows us to reuse the transfer function of new dataflow analyses when defining old ones
2020-02-11Clarify why you shouldn't override `Analysis::into_engine`Dylan MacKenzie-3/+11
2020-02-11Skip caching block transfer functions for acyclic MIRDylan MacKenzie-10/+14
2020-02-10Add a `Visitor` for dataflow resultsDylan MacKenzie-0/+275
2020-02-10Add an `into_engine` method to `Analysis`Dylan MacKenzie-0/+30
This makes it more ergonomic to create a dataflow engine and obviates the need to pick between `new_gen_kill` and `new_generic`.
2020-02-10Add a `contains` method to `ResultsCursor`Dylan MacKenzie-0/+7
2020-02-09Use nicer alignment when printing state vectorsDylan MacKenzie-15/+29
2020-02-09Don't break first lineDylan MacKenzie-12/+12
2020-02-09Remove unnecessary allowsDylan MacKenzie-3/+0
2020-02-09Add option to `dot::render` for monospace fontDylan MacKenzie-1/+1
2020-02-09Print `after` effect in default graphviz formatterDylan MacKenzie-4/+4
Now the line for each statement will show the diff resulting from the combination of `before_statement_effect` and `statement_effect`. It's still possible to observe each in isolation via `borrowck_graphviz_format = "two_phase"`.
2020-01-19Document all methodsDylan MacKenzie-4/+15
2020-01-19Explain motivation for `GenKill` traitDylan MacKenzie-4/+12
2020-01-15Use trailing underscore for helper methodsDylan MacKenzie-4/+4
2020-01-14Fix testDylan MacKenzie-11/+14
2020-01-14Improve docs for `GenKill` and `GenKillSet`Dylan MacKenzie-6/+8
2020-01-14Improve docs for new frameworkDylan MacKenzie-3/+35
2020-01-14Add test for `ResultsCursor`Dylan MacKenzie-0/+331
This is a unit test that ensures the `seek` functions work correctly.
2020-01-14Implement new dataflow framework and cursorDylan MacKenzie-0/+995
2020-01-14Improve graphviz visualization for new frameworkDylan MacKenzie-116/+402
2020-01-05Remove rustc_hir reexports in rustc::hir.Mazdak Farrokhzad-1/+1
2019-12-22Format the worldMark Rousskov-38/+9
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-09-30Add graphviz debug output for generic dataflowDylan MacKenzie-0/+412