about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform
AgeCommit message (Collapse)AuthorLines
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
2022-12-13Use ty::OpaqueTy everywhereMichael Goulet-1/+1
2022-12-13Don't require owned data in `MaybeStorageLive`Jakob Degen-1/+1
2022-12-13Allow unsafe through inline constGary Guo-3/+32
This is handled similar to closures
2022-12-11Rollup merge of #105537 - kadiwa4:remove_some_imports, r=fee1-deadMatthias Krüger-1/+0
compiler: remove unnecessary imports and qualified paths Some of these imports were necessary before Edition 2021, others were already in the prelude. I hope it's fine that this PR is so spread-out across files :/
2022-12-10compiler: remove unnecessary imports and qualified pathsKaDiWa-1/+0
2022-12-09Remove unneeded field from `SwitchTargets`Jakob Degen-47/+24
2022-12-08Rollup merge of #105317 - RalfJung:retag-rework, r=oli-obkMatthias Krüger-60/+13
make retagging work even with 'unstable' places This is based on top of https://github.com/rust-lang/rust/pull/105301. Only the last two commits are new. While investigating https://github.com/rust-lang/unsafe-code-guidelines/issues/381 I realized that we would have caught this issue much earlier if the add_retag pass wouldn't bail out on assignments of the form `*ptr = ...`. So this PR changes our retag strategy: - When a new reference is created via `Rvalue::Ref` (or a raw ptr via `Rvalue::AddressOf`), we do the retagging as part of just executing that address-taking operation. - For everything else, we still insert retags -- these retags basically serve to ensure that references stored in local variables (and their fields) are always freshly tagged, so skipping this for assignments like `*ptr = ...` is less egregious. r? ```@oli-obk```
2022-12-06Auto merge of #105229 - saethlin:zst-writes-to-unions, r=oli-obkbors-26/+1
Re-enable removal of ZST writes to unions This was previously disabled because Miri was lazily allocating unsized locals. But we aren't doing that anymore since https://github.com/rust-lang/rust/pull/98831, so we can have this optimization back.
2022-12-06make retagging work even with 'unstable' placesRalf Jung-60/+13
2022-12-06Auto merge of #105220 - oli-obk:feeding, r=cjgillotbors-3/+3
feed resolver_for_lowering instead of storing it in a field r? `@cjgillot` opening this as * a discussion for `no_hash` + `feedable` queries. I think we'll want those, but I don't quite understand why they are rejected beyond a double check of the stable hashes for situations where the query is fed but also read from incremental caches. * and a discussion on removing all untracked fields from TyCtxt and setting it up so that they are fed queries instead
2022-12-06Auto merge of #105119 - JakobDegen:inline-experiments, r=cjgillotbors-22/+6
Disable top down MIR inlining The current MIR inliner has exponential behavior in some cases: <https://godbolt.org/z/7jnWah4fE>. The cause of this is top-down inlining, where we repeatedly do inlining like `call_a() => { call_b(); call_b(); }`. Each decision on its own seems to make sense, but the result is exponential. Disabling top-down inlining fundamentally prevents this. Each call site in the original, unoptimized source code is now considered for inlining exactly one time, which means that the total growth in MIR size is limited to number of call sites * inlining threshold. Top down inlining may be worth re-introducing at some point, but it needs to be accompanied with a principled way to prevent this kind of behavior.
2022-12-04Auto merge of #105121 - oli-obk:simpler-cheaper-dump_mir, r=nnethercotebors-41/+22
Cheaper `dump_mir` take two alternative to #105083 r? `@nnethercote`
2022-12-03Re-enable removal of ZST writes to unionsBen Kimock-26/+1
2022-12-03Remove all but one call site of `prepare_outputs` and fetch the value from ↵Oli Scherer-3/+3
the TyCtxt instead
2022-12-03Mark naked functions as never inline in codegen_fn_attrsTomasz Miąsko-4/+0
Use code generation attributes to ensure that naked functions are never inline, replacing separate checks in MIR inliner and LLVM code generation.
2022-12-02Use zero based indexing for pass_countOli Scherer-0/+2
2022-12-02Remove an impl and replace its only use with a method callOli Scherer-1/+1
2022-12-01Disable top-down inliningJakob Degen-22/+6
2022-12-01Create `format_args` as late as possibleOli Scherer-20/+9
2022-12-01Remove needless `Cow`Oli Scherer-20/+10
2022-12-01Don't go through the formatting infrastructure just to get the name of a phaseOli Scherer-1/+1
2022-11-28Rollup merge of #104732 - WaffleLapkin:from_def_idn't, r=compiler-errorsDylan DPC-1/+1
Refactor `ty::ClosureKind` related stuff I've tried to fix all duplication and weirdness, but if I missed something do tell :p r? `@compiler-errors`
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-32/+31
2022-11-27Rename `fn_trait_kind_from_{from_lang=>def_id}` to better convey meaningMaybe Waffle-1/+1
2022-11-26Rewrite dest prop.Jakob Degen-735/+614
This fixes a number of correctness issues from the previous version. Additionally, we use a new strategy which has much better performance charactersitics and also finds more opportunities to apply the optimization.
2022-11-26Rollup merge of #104121 - ↵Matthias Krüger-1/+15
Lokathor:mir-opt-when-instruction-set-missing-on-callee, r=tmiasko Refine `instruction_set` MIR inline rules Previously an exact match of the `instruction_set` attribute was required for an MIR inline to be considered. This change checks for an exact match *only* if the callee sets an `instruction_set` in the first place. When the callee does not declare an instruction set then it is considered to be platform agnostic code and it's allowed to be inline'd into the caller. cc ``@oli-obk`` [Edit] Zulip Context: https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/What.20exactly.20does.20the.20MIR.20optimizer.20do.3F
2022-11-25Refine instruction_set inline rulesLokathor-1/+15
Previously an exact match of the `instruction_set` attribute was required for an MIR inline to be considered. This change checks for an exact match *only* if the callee sets an `instruction_set` in the first place. When the callee does not declare an instruction set then it is considered to be platform agnostic code and it's allowed to be inline'd into the caller.
2022-11-25Introduce PredicateKind::ClauseSantiago Pastorino-1/+1
2022-11-24Auto merge of #103693 - HKalbasi:master, r=oli-obkbors-1/+1
Make rustc_target usable outside of rustc I'm working on showing type size in rust-analyzer (https://github.com/rust-lang/rust-analyzer/pull/13490) and I currently copied rustc code inside rust-analyzer, which works, but is bad. With this change, I would become able to use `rustc_target` and `rustc_index` directly in r-a, reducing the amount of copy needed. This PR contains some feature flag to put nightly features behind them to make crates buildable on the stable compiler + makes layout related types generic over index type + removes interning of nested layouts.
2022-11-24move things from rustc_target::abi to rustc_abihkalbasi-1/+1
2022-11-24Avoid `GenFuture` shim when compiling async constructsArpad Borsos-27/+68
Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through.
2022-11-21Allow iterators instead of requiring slices that will get turned into iteratorsOli Scherer-3/+3
2022-11-20Factor out conservative_is_privately_uninhabitedCameron Steffen-1/+1
2022-11-20Rollup merge of #104564 - RalfJung:either, r=oli-obkMatthias Krüger-9/+17
interpret: use Either over Result when it is not representing an error condition r? `@oli-obk`
2022-11-19Rollup merge of #104411 - lcnr:bivariance-nll, r=compiler-errorsDylan DPC-6/+6
nll: correctly deal with bivariance fixes #104409 when in a bivariant context, relating stuff should always trivially succeed. Also changes the mir validator to correctly deal with higher ranked regions. r? types cc ``@RalfJung``
2022-11-18review feedbackRalf Jung-3/+3
2022-11-18interpret: use Either over Result when it is not representing an error conditionRalf Jung-9/+17
2022-11-17Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-deadbors-6/+5
Record `LocalDefId` in HIR nodes instead of a side table This is part of an attempt to remove the `HirId -> LocalDefId` table from HIR. This attempt is a prerequisite to creation of `LocalDefId` after HIR lowering (https://github.com/rust-lang/rust/pull/96840), by controlling how `def_id` information is accessed. This first part adds the information to HIR nodes themselves instead of a table. The second part is https://github.com/rust-lang/rust/pull/103902 The third part will be to make `hir::Visitor::visit_fn` take a `LocalDefId` as last parameter. The fourth part will be to completely remove the side table.
2022-11-16cleanup and dedupe CTFE and Miri error reportingRalf Jung-16/+4
2022-11-15Auto merge of #102570 - cjgillot:deagg-debuginfo, r=oli-obkbors-0/+351
Perform simple scalar replacement of aggregates (SROA) MIR opt This is a re-open of https://github.com/rust-lang/rust/pull/85796 I copied the debuginfo implementation (first commit) from `@eddyb's` own SROA PR. This pass replaces plain field accesses by simple locals when possible. To be eligible, the replaced locals: - must not be enums or unions; - must not be used whole; - must not have their address taken. The storage and deinit statements are duplicated on each created local. cc `@tmiasko` who reviewed the former version of this PR.
2022-11-15Enable SROA by at mir-opt level 3.Camille GILLOT-1/+1
2022-11-15Flatten aggregates into locals.Camille GILLOT-0/+350