summary refs log tree commit diff
path: root/src/librustc_mir/dataflow/generic/engine.rs
AgeCommit message (Collapse)AuthorLines
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-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 #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-27Auto merge of #68528 - ecstatic-morse:maybe-init-variants, r=oli-obkbors-5/+70
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-13Support effects for particular edges of `SwitchInt`Dylan MacKenzie-5/+70
2020-02-11Skip caching block transfer functions for acyclic MIRDylan MacKenzie-10/+14
2020-02-09Add option to `dot::render` for monospace fontDylan MacKenzie-1/+1
2020-01-19Document all methodsDylan MacKenzie-0/+6
2020-01-14Implement new dataflow framework and cursorDylan MacKenzie-0/+421