about summary refs log tree commit diff
path: root/src/librustc_mir/transform
AgeCommit message (Collapse)AuthorLines
2020-05-13add spans to `require_lang_items`Bastian Kauschke-1/+1
2020-05-13use `require_lang_item` over `unwrap`.Bastian Kauschke-2/+3
2020-05-12Add some more sanity tests and add a debug log message for itOliver Scherer-0/+5
2020-05-12Propagate locals, even if they have unpropagatable assignments somewhere.Oliver Scherer-1/+19
2020-05-12Rollup merge of #72048 - jonas-schievink:visit-return, r=oli-obkDylan DPC-2/+21
Visit move out of `_0` when visiting `return` Closes https://github.com/rust-lang/rust/issues/72032
2020-05-11Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1Wesley Wiser-41/+315
I also added test cases to make sure the optimization can fire on all of these cases: ```rust fn case_1(o: Option<u8>) -> Option<u8> { match o { Some(u) => Some(u), None => None, } } fn case2(r: Result<u8, i32>) -> Result<u8, i32> { match r { Ok(u) => Ok(u), Err(i) => Err(i), } } fn case3(r: Result<u8, i32>) -> Result<u8, i32> { let u = r?; Ok(u) } ``` Without MIR inlining, this still does not completely optimize away the `?` operator because the `Try::into_result()`, `From::from()` and `Try::from_error()` calls still exist. This does move us a bit closer to that goal though because: - We can now run the pass on mir-opt-level=1 - We no longer depend on the copy propagation pass running which is unlikely to stabilize anytime soon.
2020-05-11Auto merge of #71953 - oli-obk:const_prop_deaggregates, r=wesleywiserbors-42/+58
Const prop aggregates even if partially or fully modified r? @wesleywiser cc @rust-lang/wg-mir-opt I'm moderately scared of this change, but I'm confident in having reviewed all the cases.
2020-05-10avoid raising interpreter errors from interningRalf Jung-2/+1
2020-05-09Visit move out of `_0` when visiting `return`Jonas Schievink-2/+21
2020-05-09Rollup merge of #71555 - cjgillot:nameless, r=matthewjasperRalf Jung-3/+2
Remove ast::{Ident, Name} reexports. The reexport of `Symbol` into `Name` confused me.
2020-05-09Auto merge of #72036 - Dylan-DPC:rollup-ca8b0ql, r=Dylan-DPCbors-58/+29
Rollup of 8 pull requests Successful merges: - #70834 (Add core::future::{pending,ready}) - #71839 (Make BTreeMap::new and BTreeSet::new const) - #71890 (Simplify the error Registry methods a little) - #71942 (Shrink `LocalDecl`) - #71947 (Dead-code pass highlights too much of impl functions) - #71981 (Fix `strip-priv-imports` pass name in the rustdoc documentation) - #72018 (Fix canonicalization links) - #72031 (Better documentation for io::Read::read() return value) Failed merges: r? @ghost
2020-05-09Rollup merge of #71942 - nnethercote:shrink-LocalDecl, r=matthewjasperDylan DPC-58/+29
Shrink `LocalDecl` `LocalDecl` contributes 4-8% of peak heap memory usage on a range of benchmarks. This PR reduces its size from 128 bytes to 56 bytes on 64-bit, and does some clean-ups as well. r? @matthewjasper
2020-05-08Auto merge of #71418 - hbina:rename_miri_undef, r=RalfJungbors-13/+13
Renamed "undef" -> "uninit" 1. InvalidUndefBytes -> InvalidUninitBytes 2. ScalarMaybeUndef -> ScalarMaybeUninit 3. UndefMask -> InitMask Related issue #71193
2020-05-08Rollup merge of #71989 - ecstatic-morse:const-context-enum, r=oli-obkDylan DPC-86/+27
Use a single enum for the kind of a const context This adds a `ConstContext` enum to the `rustc_hir` crate and method that can be called via `tcx.hir()` to get the `ConstContext` for a given body owner. This arose from discussion in #71824. r? @oli-obk
2020-05-08Remove ast::{Ident, Name} reexports.Camille GILLOT-3/+2
2020-05-07Use `hir::ConstContext` instead of local enumsDylan MacKenzie-86/+27
2020-05-07Renamed "undef" stuff to "uninit"Hanif Bin Ariffin-13/+13
1. InvalidUndefBytes -> InvalidUninitBytes 2. ScalarMaybeUndef -> ScalarMaybeUninit 3. UndefMask -> InitMask Related issue #71193
2020-05-06Const prop aggregates even if partially or fully modifiedOliver Scherer-42/+58
2020-05-06Rollup merge of #71893 - ecstatic-morse:dataflow-impls-import, r=jonas-schievinkDylan DPC-8/+8
Use the `impls` module to import pre-existing dataflow analyses Currently, existing analyses live in the same module as the traits and types used to define new dataflow analyses. This muddles the [documentation for the `dataflow` module](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/dataflow/index.html). After this PR, `dataflow::impls` will refer to concrete dataflow analyses, and `dataflow` to the generic interface.
2020-05-06Shrink `LocalDecl` by 56 bytes.Nicholas Nethercote-2/+2
By boxing `local_info`.
2020-05-06Improve `LocalDecl` creation.Nicholas Nethercote-35/+12
This commit adds some new `LocalDecl` methods: - `with_source_info`, a most general constructor. - `new`, a variant of `with_source_info` which represents the most common use case. - `internal` a modifying method (like the already present `immutable`). It removes some old `LocalDecl` methods: - `new_internal` and `new_local`, because they're subsumed by the new methods. - `new_return_place`, because it was identical to `new_temp`. Finally, it cleans up all the use sites.
2020-05-06Add `SourceInfo::outermost`.Nicholas Nethercote-22/+16
2020-05-05Rollup merge of #71902 - mibac138:const-feature-diag, r=varkorDylan DPC-0/+3
Suggest to add missing feature when using gated const features Fixes #71797
2020-05-04Suggest to add missing feature when using gated const featuresmibac138-0/+3
2020-05-04Import dataflow impls via the `impls` submoduleDylan MacKenzie-8/+8
2020-05-04Rollup merge of #71697 - felix91gr:new_prop_into_fn_call, r=wesleywiserDylan DPC-5/+51
Added MIR constant propagation of Scalars into function call arguments Now for the function call arguments! Caveats: 1. It's only being enabled at `mir-opt-2` or higher, because currently codegen gives performance regressions with this optimization. 2. Only propagates Scalars. Tuples and references (references are `Indirect`, right??) are not being propagated into as of this PR. 3. Maybe more tests would be nice? 4. I need (shamefully) to ask @wesleywiser to write in his words (or explain to me, and then I can write it down) why we want to ignore propagation into `ScalarPairs` and `Indirect` arguments. r? @wesleywiser
2020-05-03Auto merge of #71631 - RalfJung:miri-unleash-the-gates, r=oli-obkbors-4/+4
Miri: unleash all feature gates IMO it is silly to unleash features that do not even have a feature gate yet, but not unleash features that do. The only thing this achieves is making unleashed mode annoying to use as we have to figure out the feature flags to enable (and not always do the error messages say what that flag is). Given that the point of `-Z unleash-the-miri-inside-of-you` is to debug the Miri internals, I see no good reason for this extra hurdle. I cannot imagine a situation where we'd use that flag, realize the program also requires some feature gate, and then be like "oh I guess if this feature is unstable I will do something else". Instead, we'll always just add that flag to the code as well, so requiring the flag achieves nothing. r? @oli-obk @ecstatic-morse Fixes https://github.com/rust-lang/rust/issues/71630
2020-05-03Auto merge of #71006 - ecstatic-morse:dataflow-bidi, r=ecstatic-morsebors-59/+93
Use existing framework for backward dataflow analyses This PR adds support for backward analyses to the dataflow framework and adds a new live variable analysis (based on the existing one in `librustc_mir/util/liveness.rs`). By adding these to the framework instead of having a separate API, all newly implemented backward dataflow analyses get cursors/visitors, `rustc_peek` tests, and graphviz visualizations for free. In the near-term, this makes it much easier to implement global dead-store elimination, and I believe that this will enable even more MIR optimizations in the future. This PR makes many changes to the dataflow API, since some concepts and terminology only make sense in forward dataflow. Below is a list of the important changes. - ~~`entry_set` -> `fixpoint` (the fixpoint for backward dataflow problems is after the block's terminator)~~ - `seek_{before,after}` -> `seek_{before,after}_primary_effect` (the unprefixed dataflow effect is now referred to as the "primary" effect instead of the "after" effect. The "before" effect remains the same, although I considered changing it to the "antecedent" effect. In both backward and forward dataflow, the "before" effect is applied prior to the "primary" effect. I feel very strongly that this is the correct choice, as it means consumers don't have to switch between `seek_before` and `seek_after` based on the direction of their analysis. - `seek_after_assume_call_returns` is now gone. Users can use `ResultsCursor::apply_custom_effect` to emulate it. - `visit_{statement,terminator}_exit` -> `visit_{statement,terminator}_after_primary_effect` - `visit_{statement,terminator}` -> `visit_{statement,terminator}_before_primary_effect` Implementing this also required refactoring the dataflow cursor implementation so it could work in both directions. This is a large percentage of the diff, since the cursor code is rather complex. The fact that the cursor is exhaustively tested in both directions should reassure whomever is unlucky enough to review this :rofl:. In order to avoid computing the reverse CFG for forward dataflow analyses, I've added some hacks to the existing `mir::BodyAndCache` interface. I've requested changes to this interface that would let me implement this more efficiently. r? @eddyb (feel free to reassign) cc @rust-lang/wg-mir-opt
2020-05-03Reflect API changes on current masterDylan MacKenzie-1/+1
2020-05-03Support liveness in `rustc_peek` testsDylan MacKenzie-14/+50
2020-05-03Use new liveness analysis during generator transformDylan MacKenzie-22/+24
2020-05-03Support backward dataflow analysesDylan MacKenzie-16/+11
2020-05-03Rename `live_locals` -> `live_locals_at_any_suspension_point`Dylan MacKenzie-11/+12
2020-05-03Rollup merge of #71663 - jumbatm:caller-handles-validation-error, r=RalfJungDylan DPC-5/+5
Fix exceeding bitshifts not emitting for assoc. consts (properly this time, I swear!) Fixes #69021 and fixes #71353. As described in https://github.com/rust-lang/rust/issues/71353#issuecomment-617901923, this PR: - adds a variant of `try_validation!` called `try_validation_pat!` that allows specific failures to be turned into validation failures (but returns the rest, unchanged), and - allows `InvalidProgram` to be returned out of validation r? @RalfJung
2020-05-03warn about each skipped feature gateRalf Jung-7/+1
2020-05-02Rollup merge of #71787 - tshepang:rustdoc-warnings, r=varkorDylan DPC-2/+4
fix rustdoc warnings
2020-05-02Rollup merge of #71772 - cjgillot:ensure, r=petrochenkovDylan DPC-1/+1
Mark query function as must_use. And use the `ensure()` version when the result is not needed.
2020-05-02Rollup merge of #69274 - LeSeulArtichaut:target-feature-11, r=hanna-kruppeDylan DPC-1/+25
Implement RFC 2396: `#[target_feature]` 1.1 Tracking issue: #69098 r? @nikomatsakis cc @gnzlbg @joshtriplett
2020-05-02fix miri-unleash delayed sanity checkingRalf Jung-0/+2
2020-05-02explain why we use def_spanRalf Jung-0/+1
2020-05-02make sure the miri-unleash-flag is not used to circumvent feature gatesRalf Jung-0/+3
2020-05-02fix rustdoc warningsTshepang Lekhonkhobe-2/+4
2020-05-02Added MIR constant propagation of Scalars into function call argumentsFélix Fischer-5/+51
- Documented rationale of current solution - Polished documentation
2020-05-01Mark query function as must_use.Camille GILLOT-1/+1
2020-05-01Prevent calls to functions with `#[target_feature]` in safe contextsLeSeulArtichaut-1/+25
2020-05-01Partially unrevert #70566.jumbatm-5/+5
This partially reverts commit 4b5b6cbe60a8dd1822cfa46c41cf1ad58c113e18, reversing some changes made to 62b362472dbf8bdf43b252ac5ea53b527a8dbee3.
2020-05-01InterpError printing really is more Display than DebugRalf Jung-2/+2
also tweak InvalidDiscriminant message
2020-05-01Auto merge of #70674 - cjgillot:query-arena-all, r=matthewjasperbors-9/+9
Have the per-query caches store the results on arenas This PR leverages the cache for each query to serve as storage area for the query results. It introduces a new cache `ArenaCache`, which moves the result to an arena, and only stores the reference in the hash map. This allows to remove a sizeable part of the usage of the global `TyCtxt` arena. I only migrated queries that already used arenas before.
2020-04-30Rollup merge of #71691 - ecstatic-morse:const-unreachable, r=oli-obk,RalfJungTyler Mandry-7/+3
Allow `Unreachable` terminators unconditionally in const-checking If we ever actually reach an `Unreachable` terminator while executing, the MIR is ill-formed or the user's program is UB due to something like `unreachable_unchecked`. I don't think we need to forbid these in `qualify_min_const_fn`. r? @oli-obk
2020-04-30Rollup merge of #71688 - ecstatic-morse:const-downcast, r=oli-obkTyler Mandry-18/+2
Allow `Downcast` projections unconditionally in const-checking `ProjectionElem::Downcast` sounds scary, but it's really just the projection we use to access a particular enum variant. They usually appear in the lowering of a `match` statement, so they have been associated with control flow in const-checking, but they don't do any control flow by themselves. We already have a HIR pass that looks for `if` and `match` (even ones that have 1 or fewer reachable branches). That pass is double-checked by a MIR pass that looks for `SwitchInt`s and `FakeRead`s for match scrutinees. In my opinion, there's no need to look for `Downcast` as well. r? @oli-obk