summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2023-01-19Rollup merge of #107037 - tmiasko:rank, r=oli-obkGuillaume Gomez-5/+5
Fix Dominators::rank_partial_cmp to match documentation The only use site is also updated accordingly and there is no change in end-to-end behaviour.
2023-01-19Transform async ResumeTy in generator transformArpad Borsos-7/+111
- Eliminates all the `get_context` calls that async lowering created. - Replace all `Local` `ResumeTy` types with `&mut Context<'_>`. The `Local`s that have their types replaced are: - The `resume` argument itself. - The argument to `get_context`. - The yielded value of a `yield`. The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the `get_context` function is being used to convert that back to a `&mut Context<'_>`. Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection, but rather directly use `&mut Context<'_>`, however that would currently lead to higher-kinded lifetime errors. See <https://github.com/rust-lang/rust/issues/105501>. The async lowering step and the type / lifetime inference / checking are still using the `ResumeTy` indirection for the time being, and that indirection is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.
2023-01-18Fix Dominators::rank_partial_cmp to match documentationTomasz Miąsko-5/+5
The only use site is also updated accordingly and there is no change in end-to-end behaviour.
2023-01-17Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726Matthias Krüger-2/+2
Remove double spaces after dots in comments Most of the comments do not have double spaces, so I assume these are typos.
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-2/+2
2023-01-16Remove ineffective run of SimplifyConstConditionTomasz Miąsko-1/+0
There are no constant conditions at this stage.
2023-01-14Remove visit_place.Camille GILLOT-6/+0
2023-01-14Make the inlining destination a `Local`.Camille GILLOT-18/+28
2023-01-11Change `src/test` to `tests` in source files, fix tidy and testsAlbert Larsan-1/+1
2023-01-09Auto merge of #106340 - saethlin:propagate-operands, r=oli-obkbors-5/+1
Always permit ConstProp to exploit arithmetic identities Fixes https://github.com/rust-lang/rust/issues/72751 Initially, I thought I would need to enable operand propagation then do something else, but actually https://github.com/rust-lang/rust/pull/74491 already has the fix for the issue in question! It looks like this optimization was put under MIR opt level 3 due to possible soundness/stability implications, then demoted further to MIR opt level 4 when MIR opt level 2 became associated with `--release`. Perhaps in the past we were doing CTFE on optimized MIR? We aren't anymore, so this optimization has no stability implications. r? `@oli-obk`
2023-01-07Auto merge of #105323 - cjgillot:simplify-const-prop, r=davidtwcobors-3/+17
Perform SimplifyLocals before ConstProp. MIR before `ConstProp` may have a lot of dead writes, this makes `ConstProp` do unnecessary work. r? `@ghost`
2023-01-03Remove duplicated elaborate box derefs passTomasz Miąsko-5/+2
The pass runs earlier as a part of `run_runtime_lowering_passes`.
2023-01-01Reenable limited top-down MIR inliningJakob Degen-6/+36
2023-01-01Always take advantage of arithmetic identitiesBen Kimock-5/+1
2022-12-25Give the correct track-caller location with MIR inlining.Camille GILLOT-8/+3
2022-12-25Remove Nop in simplify_locals.Camille GILLOT-0/+1
It's cheap and does not change anything.
2022-12-25Move SimplifyLocals before ConstProp.Camille GILLOT-3/+16
2022-12-24Rollup merge of #105975 - jeremystucki:rustc-remove-needless-lifetimes, r=eholkMatthias Krüger-31/+25
rustc: Remove needless lifetimes
2022-12-21Retag argument to `drop_in_place` unconditionallyJakob Degen-28/+29
2022-12-21Retag as FnEntry on `drop_in_place`Jakob Degen-1/+27
2022-12-20Add missing anonymous lifetimeJeremy Stucki-1/+1
2022-12-20rustc: Remove needless lifetimesJeremy Stucki-31/+25
2022-12-20Rollup merge of #105930 - JakobDegen:nal-unsound, r=oli-obkMatthias Krüger-1/+2
Disable `NormalizeArrayLen` cc #105929 r? mir-opt
2022-12-20Rollup merge of #105835 - tmiasko:cleanup-post-borrowck, r=JakobDegenMatthias Krüger-71/+28
Refactor post borrowck cleanup passes
2022-12-20Auto merge of #105880 - Nilstrieb:make-newtypes-less-not-rust, r=oli-obkbors-2/+2
Improve syntax of `newtype_index` This makes it more like proper Rust and also makes the implementation a lot simpler. Mostly just turns weird flags in the body into proper attributes. It should probably also be converted to an attribute macro instead of function-like, but that can be done in a future PR.
2022-12-19Disable `NormalizeArrayLen`Jakob Degen-1/+2
2022-12-19Rollup merge of #105864 - matthiaskrgr:compl, r=NilstriebDylan DPC-1/+1
clippy::complexity fixes filter_next needless_question_mark bind_instead_of_map manual_find derivable_impls map_identity redundant_slicing skip_while_next unnecessary_unwrap needless_bool r? `@compiler-errors`
2022-12-19clippy::complexity fixesMatthias Krüger-1/+1
filter_next needless_question_mark bind_instead_of_map manual_find derivable_impls map_identity redundant_slicing skip_while_next unnecessary_unwrap needless_bool
2022-12-18A few small cleanups for `newtype_index`Nilstrieb-1/+1
Remove the `..` from the body, only a few invocations used it and it's inconsistent with rust syntax. Use `;` instead of `,` between consts. As the Rust syntax gods inteded.
2022-12-18Make `#[debug_format]` an attribute in `newtype_index`Nilstrieb-1/+1
This removes the `custom` format functionality as its only user was trivially migrated to using a normal format. If a new use case for a custom formatting impl pops up, you can add it back.
2022-12-18Rollup merge of #105870 - matthiaskrgr:useless_conv, r=oli-obkMatthias Krüger-2/+2
avoid .into() conversion to identical types
2022-12-18avoid .into() conversion to identical typesMatthias Krüger-2/+2
2022-12-17Remove false edges in CleanupPostBorrowckTomasz Miąsko-46/+16
2022-12-17Rename CleanupNonCodegenStatements to CleanupPostBorrowckTomasz Miąsko-3/+3
2022-12-17Replace visitor with a loop over blocks and statementsTomasz Miąsko-26/+13
2022-12-16Remove dead code after destination propagationTomasz Miąsko-0/+7
2022-12-15Auto merge of #105356 - JakobDegen:more-custom-mir, r=oli-obkbors-1/+1
Custom MIR: Many more improvements Commits are each atomic changes, best reviewed one at a time, with the exception that the last commit includes all the documentation. ### First commit Unsafetyck was not correctly disabled before for `dialect = "built"` custom MIR. This is fixed and a regression test is added. ### Second commit Implements `Discriminant`, `SetDiscriminant`, and `SwitchInt`. ### Third commit Implements indexing, field, and variant projections. ### Fourth commit Documents the previous commits and everything else. There is some amount of weirdness here due to having to beat Rust syntax into cooperating with MIR concepts, but it hopefully should not be too much. All of it is documented. r? `@oli-obk`
2022-12-15Auto merge of #104616 - RalfJung:ctfe-alignment, r=oli-obk,RalfJungbors-4/+26
always check alignment during CTFE We originally disabled alignment checks because they got in the way -- there are some things we do with the interpreter during CTFE which does not correspond to actually running user-written code, but is purely administrative, and we didn't want alignment checks there, so we just disabled them entirely. But with `-Zextra-const-ub-checks` we anyway had to figure out how to disable those alignment checks while doing checks in regular code. So now it is easy to enable CTFE alignment checking by default. Let's see what the perf consequences of that are. r? `@oli-obk`
2022-12-15Move alignment failure error reporting to machineOli Scherer-1/+21
2022-12-15Make alignment checks a future incompat lintOli Scherer-3/+5
2022-12-15Rollup merge of #105683 - JakobDegen:dest-prop-storage, r=tmiaskoMatthias Krüger-83/+88
Various cleanups to dest prop This makes fixing the issues identified in #105577 easier. A couple changes - Use an enum with names instead of a bool - Only call `remove_candidates_if` from one place instead of two. Doing it from two places is far too fragile, since any divergence in the behavior between those callsites is likely to be unsound. - Remove `is_constant`. Right now we only merge locals, so this doesn't do anything, and the logic would be wrong if it did. r? `@tmiasko`
2022-12-14Various cleanups to dest propJakob Degen-83/+88
2022-12-14Ensure no one constructs `AliasTy`s themselvesOli Scherer-1/+1
2022-12-14Remove many more cases of `mk_substs_trait` that can now use the iterator ↵Oli Scherer-5/+3
scheme`
2022-12-14Let `mk_fn_def` take an iterator instead to simplify some call sitesOli Scherer-3/+1
2022-12-14Fix unsafetyck disabling for custom MIRJakob Degen-1/+1
2022-12-14Auto merge of #104986 - compiler-errors:opaques, r=oli-obkbors-2/+6
Combine `ty::Projection` and `ty::Opaque` into `ty::Alias` Implements https://github.com/rust-lang/types-team/issues/79. This PR consolidates `ty::Projection` and `ty::Opaque` into a single `ty::Alias`, with an `AliasKind` and `AliasTy` type (renamed from `ty::ProjectionTy`, which is the inner data of `ty::Projection`) defined as so: ``` enum AliasKind { Projection, Opaque, } struct AliasTy<'tcx> { def_id: DefId, substs: SubstsRef<'tcx>, } ``` Since we don't have access to `TyCtxt` in type flags computation, and because repeatedly calling `DefKind` on the def-id is expensive, these two types are distinguished with `ty::AliasKind`, conveniently glob-imported into `ty::{Projection, Opaque}`. For example: ```diff match ty.kind() { - ty::Opaque(..) => + ty::Alias(ty::Opaque, ..) => {} _ => {} } ``` This PR also consolidates match arms that treated `ty::Opaque` and `ty::Projection` identically. r? `@ghost`
2022-12-13Rollup merge of #105659 - JakobDegen:storage-live-borrow, r=davidtwcoMatthias Krüger-1/+1
Don't require owned data in `MaybeStorageLive` Small improvement that avoids a clone. I don't expect this to have any noticeable perf effects, but better to have it than not to. r? ``@tmiasko``
2022-12-13Combine projection and opaque into aliasMichael Goulet-2/+6
2022-12-13squash OpaqueTy and ProjectionTy into AliasTyMichael Goulet-1/+1