about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform
AgeCommit message (Collapse)AuthorLines
2023-02-19Add an InstCombine for redundant castsBen Kimock-0/+9
2023-02-19Auto merge of #108128 - clubby789:builtin-derived-attr, r=jackh726bors-2/+2
Properly check for builtin derived code Fixes #108122
2023-02-18Replace _with_overflow instrinsics in LowerIntrinsics.Camille GILLOT-3/+23
2023-02-18Remove overflow checks from ConstProp.Camille GILLOT-102/+16
2023-02-18Use the correct place for enum variants.Camille GILLOT-6/+14
2023-02-18Flood aggregate assignments with `Top`.Camille GILLOT-1/+4
2023-02-18Auto merge of #108112 - nnethercote:clarify-iterator-interners, ↵bors-1/+1
r=oli-obk,compiler-errors Clarify iterator interners I found the iterator interners very confusing. This PR clarifies things. r? `@compiler-errors`
2023-02-17Auto merge of #105274 - saethlin:instcombine-mut-ref, r=cjgillotbors-5/+1
Enable instcombine for mutable reborrows `instcombine` used to contain this comment, which is no longer accurate because there it is fine to copy `&mut _` in MIR: ```rust // The dereferenced place must have type `&_`, so that we don't copy `&mut _`. ``` So let's try replacing that check with something much more permissive...
2023-02-17Rollup merge of #108154 - scottmcm:start-block-cleanup, r=compiler-errorsMatthias Krüger-8/+8
`BasicBlock::new(0)` -> `START_BLOCK` [no functional changes]
2023-02-17Replace `mk_foo` calls with `infer_foo` where possible.Nicholas Nethercote-1/+1
There are several `mk_foo`/`intern_foo` pairs, where the former takes an iterator and the latter takes a slice. (This naming convention is bad, but that's a fix for another PR.) This commit changes several `mk_foo` occurrences into `intern_foo`, avoiding the need for some `.iter()`/`.into_iter()` calls. Affected cases: - mk_type_list - mk_tup - mk_substs - mk_const_list
2023-02-16`BasicBlock::new(0)` -> `START_BLOCK` [no functional changes]Scott McMurray-8/+8
2023-02-17Auto merge of #107753 - kylematsuda:type-of, r=BoxyUwUbors-11/+11
Switch to `EarlyBinder` for `type_of` query Part of the work to finish #105779 and implement https://github.com/rust-lang/types-team/issues/78. Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This adds `EarlyBinder` to the return type of the `type_of` query and removes `bound_type_of`. r? `@lcnr`
2023-02-16remove bound_type_of query; make type_of return EarlyBinder; change type_of ↵Kyle Matsuda-11/+11
in metadata
2023-02-16change usages of type_of to bound_type_ofKyle Matsuda-8/+8
2023-02-17Rollup merge of #108104 - matthiaskrgr:into, r=compiler-errorsMatthias Krüger-2/+1
don't into self don't into()-convert types to themselves
2023-02-17Rollup merge of #107489 - compiler-errors:non_lifetime_binders, r=cjgillotMatthias Krüger-1/+1
Implement partial support for non-lifetime binders This implements support for non-lifetime binders. It's pretty useless currently, but I wanted to put this up so the implementation can be discussed. Specifically, this piggybacks off of the late-bound lifetime collection code in `rustc_hir_typeck::collect::lifetimes`. This seems like a necessary step given the fact we don't resolve late-bound regions until this point, and binders are sometimes merged. Q: I'm not sure if I should go along this route, or try to modify the earlier nameres code to compute the right bound var indices for type and const binders eagerly... If so, I'll need to rename all these queries to something more appropriate (I've done this for `resolve_lifetime::Region` -> `resolve_lifetime::ResolvedArg`) cc rust-lang/types-team#81 r? `@ghost`
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