about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2023-02-16Properly check for builtin derivesclubby789-2/+2
2023-02-16Auto merge of #108127 - matthiaskrgr:rollup-kpzfc6j, r=matthiaskrgrbors-5/+3
Rollup of 7 pull requests Successful merges: - #106347 (More accurate spans for arg removal suggestion) - #108057 (Prevent some attributes from being merged with others on reexports) - #108090 (`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`) - #108092 (note issue for feature(packed_bundled_libs)) - #108099 (use chars instead of strings where applicable) - #108115 (Do not ICE on unmet trait alias bounds) - #108125 (Add new people to the compiletest review rotation) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-16don't into selfMatthias Krüger-2/+1
don't into()-convert types to themselves
2023-02-16Auto merge of #108020 - nnethercote:opt-mk_region, r=compiler-errorsbors-5/+2
Optimize `mk_region` PR #107869 avoiding some interning under `mk_ty` by special-casing `Ty` variants with simple (integer) bodies. This PR does something similar for regions. r? `@compiler-errors`
2023-02-16`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`Maybe Waffle-5/+3
2023-02-16Enable instcombine for mutable reborrowsBen Kimock-5/+1
2023-02-16Auto merge of #107449 - saethlin:enable-copyprop, r=oli-obkbors-6/+41
Enable CopyProp r? `@tmiasko` `@rustbot` label +A-mir-opt
2023-02-16Rename some region-specific stuffMichael Goulet-1/+1
2023-02-15Auto merge of #108012 - compiler-errors:issue-107999, r=oli-obkbors-20/+24
Don't ICE in `might_permit_raw_init` if reference is polymorphic Emitting optimized MIR for a polymorphic function may require computing layout of a type that isn't (yet) known. This happens in the instcombine pass, for example. Let's fail gracefully in that condition. cc `@saethlin` fixes #107999
2023-02-15Rollup merge of #107411 - cjgillot:dataflow-discriminant, r=oli-obkDylan DPC-40/+105
Handle discriminant in DataflowConstProp cc ``@jachris`` r? ``@JakobDegen`` This PR attempts to extend the DataflowConstProp pass to handle propagation of discriminants. We handle this by adding 2 new variants to `TrackElem`: `TrackElem::Variant` for enum variants and `TrackElem::Discriminant` for the enum discriminant pseudo-place. The difficulty is that the enum discriminant and enum variants may alias each another. This is the issue of the `Option<NonZeroUsize>` test, which is the equivalent of https://github.com/rust-lang/unsafe-code-guidelines/issues/84 with a direct write. To handle that, we generalize the flood process to flood all the potentially aliasing places. In particular: - any write to `(PLACE as Variant)`, either direct or through a projection, floods `(PLACE as OtherVariant)` for all other variants and `discriminant(PLACE)`; - `SetDiscriminant(PLACE)` floods `(PLACE as Variant)` for each variant. This implies that flooding is not hierarchical any more, and that an assignment to a non-tracked place may need to flood a tracked place. This is handled by `for_each_aliasing_place` which generalizes `preorder_invoke`. As we deaggregate enums by putting `SetDiscriminant` last, this allows to propagate the value of the discriminant. This refactor will allow to make https://github.com/rust-lang/rust/pull/107009 able to handle discriminants too.
2023-02-14Make permit_uninit/zero_init fallibleMichael Goulet-20/+24
2023-02-15Replace an unnecessary `mk_ty` call with `mk_array`.Nicholas Nethercote-5/+2
2023-02-14s/eval_usize/eval_target_usize/ for clarityOli Scherer-2/+2
2023-02-13Typo.Camille GILLOT-3/+3
2023-02-12Enable CopyProp by default, tune the impl a bitBen Kimock-6/+41
2023-02-11Auto merge of #107851 - cjgillot:sroa-const, r=oli-obkbors-0/+2
Put deaggregated statements after original constant. Fixes https://github.com/rust-lang/rust/issues/107818
2023-02-10Auto merge of #85158 - JulianKnodt:array_const_val, r=cjgillotbors-0/+301
Mir-Opt for copying enums with large discrepancies I have been meaning to make this for quite a while, based off of this [hackmd](https://hackmd.io/`@ft4bxUsFT5CEUBmRKYHr7w/rJM8BBPzD).` I'm not sure where to put this opt now that I've made it, so I'd appreciate suggestions on that! It's also one long chain of statements, not sure if there's a more friendly format to make it. r? `@tmiasko` I would `r` oli but he's on leave so he suggested I `r` tmiasko or wesleywiser.
2023-02-09Put deaggregated statements after original constant.Camille GILLOT-0/+2
2023-02-08Rollup merge of #107271 - Zeegomo:drop-rmw, r=oli-obkMatthias Krüger-0/+29
Treat Drop as a rmw operation Previously, a Drop terminator was considered a move in MIR. This commit changes the behavior to only treat Drop as a mutable access to the dropped place. In order for this change to be correct, we need to guarantee that 1. A dropped value won't be used again 2. Places that appear in a drop won't be used again before a subsequent initialization. We can ensure this to be correct at MIR construction because Drop will only be emitted when a variable goes out of scope, thus having: * (1) as there is no way of reaching the old value. drop-elaboration will also remove any uninitialized drop. * (2) as the place can't be named following the end of the scope. However, the initialization status, previously tracked by moves, should also be tied to the execution of a Drop, hence the additional logic in the dataflow analyses. From discussion in [this thread](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/.60DROP.60.20to.20.60DROP_IF.60.20compiler-team.23558), originating from https://github.com/rust-lang/compiler-team/issues/558. See also https://github.com/rust-lang/rust/pull/104488#discussion_r1085556010
2023-02-08Add de-init to destination placekadmin-8/+11
2023-02-07Rollup merge of #107662 - cjgillot:copy-projection, r=oli-obkMatthias Krüger-2/+3
Turn projections into copies in CopyProp. The current implementation can leave behind projections that are moved out several times. This PR widens the check to turn such moves into copies: a move out of a projection of a copy is equivalent to a copy of the original projection.
2023-02-07Leave FIXME for wasm layout difference.kadmin-16/+28
There is a distinction between running this on wasm and i686, even though they should be identical. This technically is not _incorrect_, it's just an unexpected difference, which is worth investigating, but not for correctness.
2023-02-07Rm allocation in candidatekadmin-1/+285
Instead of storing an extra array for discriminant values, create an allocation there and store those in an allocation immediately.
2023-02-07Clean up MIR transformkadmin-0/+2
2023-02-06Rename assign_idx methods.Camille GILLOT-8/+7
2023-02-06Limit creation of tracked place directly.Camille GILLOT-7/+4
2023-02-06Handle discriminants in dataflow-const-prop.Camille GILLOT-18/+85
2023-02-06Only exclude locals if the place is not indirect.Camille GILLOT-8/+10
2023-02-06Comment move->copy transform.Camille Gillot-0/+1
2023-02-05Simplify ReplacementMap.Camille GILLOT-84/+109
2023-02-05Run SROA to fixpoint.Camille GILLOT-41/+33
2023-02-05Simplify construction of replacement map.Camille GILLOT-89/+69
2023-02-05Introduce helper.Camille GILLOT-24/+23
2023-02-05Make SROA expand assignments.Camille GILLOT-23/+65
2023-02-05Fix SROA without deaggregation.Camille GILLOT-45/+82
2023-02-04Turn projections into copies in CopyProp.Camille GILLOT-2/+2
2023-02-02Stop deaggegating MIR.Camille GILLOT-53/+0
2023-02-02Stop deaggregating enums in MIR.Camille GILLOT-39/+40
2023-02-02Handle aggregates in DataflowConstProp.Camille GILLOT-0/+25
2023-02-02Put a DefId in AggregateKind.Camille GILLOT-0/+1
2023-02-02Rollup merge of #107524 - cjgillot:both-storage, r=RalfJungMatthias Krüger-11/+14
Remove both StorageLive and StorageDead in CopyProp. Fixes https://github.com/rust-lang/rust/issues/107511 https://github.com/rust-lang/rust/pull/106908 removed StorageDead without the accompanying StorageLive. In loops, execution would see repeated StorageLive, without any StorageDead, which is UB. So when removing storage statements, we have to remove both StorageLive and StorageDead. ~I also added a MIR validation pass for StorageLive. It may be a bit overzealous.~
2023-02-01Auto merge of #107536 - GuillaumeGomez:rollup-xv7dx2h, r=GuillaumeGomezbors-6/+8
Rollup of 12 pull requests Successful merges: - #106898 (Include both md and yaml ICE ticket templates) - #107331 (Clean up eslint annotations and remove unused JS function) - #107348 (small refactor to new projection code) - #107354 (rustdoc: update Source Serif 4 from 4.004 to 4.005) - #107412 (avoid needless checks) - #107467 (Improve enum checks) - #107486 (Track bound types like bound regions) - #107491 (rustdoc: remove unused CSS from `.setting-check`) - #107508 (`Edition` micro refactor) - #107525 (PointeeInfo is advisory only) - #107527 (rustdoc: stop making unstable items transparent) - #107535 (Replace unwrap with ? in TcpListener doc) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-01-31Rollup merge of #107467 - WaffleLapkin:uneq, r=oli-obkGuillaume Gomez-6/+8
Improve enum checks Some light refactoring.
2023-01-31make unaligned_reference a hard errorRalf Jung-26/+17
2023-01-31Remove both StorageLive and StorageDead in CopyProp.Camille GILLOT-11/+14
2023-01-31Auto merge of #107443 - cjgillot:generator-less-query, r=compiler-errorsbors-1/+4
Test drop_tracking_mir before querying generator. r? `@ghost`
2023-01-30Rollup merge of #107172 - cjgillot:no-nal, r=nagisaMatthias Krüger-254/+70
Reimplement NormalizeArrayLen based on SsaLocals Based on https://github.com/rust-lang/rust/pull/106908 Fixes https://github.com/rust-lang/rust/issues/105929 Only the last commit "Reimplement NormalizeArrayLen" is relevant.
2023-01-30Replace some `_ == _ || _ == _`s with `matches!(_, _ | _)`sMaybe Waffle-2/+2
2023-01-30Use `Mutability::{is_mut, is_not}`Maybe Waffle-3/+2
2023-01-30Replace enum `==`s with `match`es where it makes senseMaybe Waffle-1/+4