about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2023-07-05Move `TyCtxt::mk_x` to `Ty::new_x` where applicableBoxy-27/+40
2023-07-03Auto merge of #112882 - DrMeepster:new_un_derefer, r=oli-obkbors-20/+7
Rewrite `UnDerefer` Currently, `UnDerefer` is used by drop elaboration to undo the effects of the `Derefer` pass. However, it just recreates the original places with derefs in the middle of the projection. Because `ProjectionElem::Deref` is intended to be removed completely in the future, this will not work forever. This PR introduces a `deref_chain` method that returns the places behind `DerefTemp` locals in a place and rewrites the move path code to use this. In the process, `UnDerefer` was merged into `MovePathLookup`. Now that move paths use the same places as in the MIR, the other uses of `UnDerefer` no longer require it. See #98145 cc `@ouz-a` r? `@oli-obk`
2023-06-29Merge `un_derefer` into `MovePathLookup`DrMeepster-20/+7
2023-06-30Auto merge of #113116 - nnethercote:codegen-opts, r=oli-obkbors-5/+5
A mish-mash of micro-optimizations These were aimed at speeding up LLVM codegen, but ended up affecting other places as well. r? `@bjorn3`
2023-06-29Avoid cloning `LocalDecls`.Nicholas Nethercote-5/+5
`DerefChecker` can just hold a reference instead. This avoids quite a lot of allocations for some benchmarks.
2023-06-28Auto merge of #112307 - lcnr:operand-ref, r=compiler-errorsbors-9/+48
mir opt + codegen: handle subtyping fixes #107205 the same issue was caused in multiple places: - mir opts: both copy and destination propagation - codegen: assigning operands to locals (which also propagates values) I changed codegen to always update the type in the operands used for locals which should guard against any new occurrences of this bug going forward. I don't know how to make mir optimizations more resilient here. Hopefully the added tests will be enough to detect any trivially wrong optimizations going forward.
2023-06-27Auto merge of #113105 - matthiaskrgr:rollup-rci0uym, r=matthiaskrgrbors-4/+5
Rollup of 8 pull requests Successful merges: - #112207 (Add trustzone and virtualization target features for aarch32.) - #112454 (Make compiletest aware of targets without dynamic linking) - #112628 (Allow comparing `Box`es with different allocators) - #112692 (Provide more context for `rustc +nightly -Zunstable-options` on stable) - #112972 (Make `UnwindAction::Continue` explicit in MIR dump) - #113020 (Add tests impl via obj unless denied) - #113084 (Simplify some conditions) - #113103 (Normalize types when applying uninhabited predicate.) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-27Rollup merge of #113084 - WaffleLapkin:less_map_or, r=NilstriebMatthias Krüger-4/+5
Simplify some conditions r? `@Nilstrieb` Some things taken out of my `is_none_or` pr.
2023-06-27Rollup merge of #113079 - Zalathar:as-operand-id, r=oli-obkMatthias Krüger-15/+2
Use `CoverageKind::as_operand_id` instead of manually reimplementing it These two pieces of code are functionally equivalent to the `CoverageKind::as_operand_id` method that already exists, and is already used elsewhere in this file. This slightly reduces the amount of code that manually pattern-matches on `CoverageKind`.
2023-06-27Auto merge of #113078 - saethlin:mention-the-function, r=RalfJungbors-3/+3
Mention the panic function in CheckAlignment Per https://github.com/rust-lang/rust/pull/112599#discussion_r1242333935 r? `@RalfJung`
2023-06-27Simplify some conditionsMaybe Waffle-4/+5
2023-06-27Auto merge of #112938 - compiler-errors:clause-3, r=oli-obkbors-4/+4
Migrate `TyCtxt::predicates_of` and `ParamEnv::caller_bounds` to `Clause` The last big change in the series. I will follow-up with additional filed issues once this PR lands: - [ ] Investigate making `TypeFoldable<TyCtxt<'tcx>> for ty::Clause<'tcx>` implementation less weird: https://github.com/rust-lang/rust/blob/2efe09170530fa18e42ff05b8d9dd23f00b5c430/compiler/rustc_middle/src/ty/structural_impls.rs#L672 - [ ] Clean up the elaborator since it should only be emitting child clauses, not predicates - [ ] Rename identifiers like `pred` and `predicates` to `clause` if they're actually clauses around the codebase - [ ] Validate that all of the `ToPredicate` impls are acutally still needed, or prune them if they're not r? `@ghost` until the other branch lands
2023-06-27Use `CoverageKind::as_operand_id` instead of manually reimplementing itZalathar-15/+2
2023-06-26Mention the panic function in CheckAlignmentBen Kimock-3/+3
2023-06-27Auto merge of #112693 - ericmarkmartin:use-more-placeref, r=spastorinobors-5/+3
Use PlaceRef abstractions more often Associated issue: https://github.com/rust-lang/rust/issues/80647 r? `@spastorino`
2023-06-26Migrate predicates_of and caller_bounds to ClauseMichael Goulet-4/+4
2023-06-25use PlaceRef abstractions more consistentlyEric Mark Martin-5/+3
2023-06-22Migrate item_bounds to ty::ClauseMichael Goulet-1/+1
2023-06-21Auto merge of #112834 - oli-obk:mir_opts_considered_unsound, r=cjgillotbors-2/+6
Disable two mir opts that are known to be unsound closes #112460 (does not fix the underlying issue) r? `@cjgillot`
2023-06-21Disable two mir opts that are known to be unsoundOli Scherer-2/+6
2023-06-21Rollup merge of #112844 - Vanille-N:unique, r=RalfJungNilstrieb-0/+1
Add retag in MIR transform: `Adt` for `Unique` may contain a reference Following #112662 , `may_contain_reference` in `rustc_mir_transform::add_retag` underapproximates too much the types that require retagging. r? ``@RalfJung``
2023-06-21Rollup merge of #112772 - compiler-errors:clauses-1, r=lcnrNilstrieb-2/+2
Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind` Does two basic things before I put up a more delicate set of PRs (along the lines of #112714, but hopefully much cleaner) that migrate existing usages of `ty::Predicate` to `ty::Clause` (`predicates_of`/`item_bounds`/`ParamEnv::caller_bounds`). 1. Rename `Clause` to `ClauseKind`, so it's parallel with `PredicateKind`. 2. Add a new `Clause` type which is parallel to `Predicate`. * This type exposes `Clause::kind(self) -> Binder<'tcx, ClauseKind<'tcx>>` which is parallel to `Predicate::kind` 😸 The new `Clause` type essentially acts as a newtype wrapper around `Predicate` that asserts that it is specifically a `PredicateKind::Clause`. Turns out from experimentation[^1] that this is not negative performance-wise, which is wonderful, since this a much simpler design than something that requires encoding the discriminant into the alignment bits of a predicate kind, or something else like that... r? ``@lcnr`` or ``@oli-obk`` [^1]: https://github.com/rust-lang/rust/pull/112714#issuecomment-1595653910
2023-06-21Rollup merge of #112759 - cjgillot:closure-names, r=oli-obkNilstrieb-6/+22
Make closure_saved_names_of_captured_variables a query. As we will start removing debuginfo during MIR optimizations, we need to keep them somewhere.
2023-06-20`Adt` for `Unique` may contain a referenceNeven Villani-0/+1
2023-06-20merge `BorrowKind::Unique` into `BorrowKind::Mut`Ziru Niu-3/+3
2023-06-19Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naberMichael Goulet-9/+9
Better error for non const `PartialEq` call generated by `match` Resolves #90237
2023-06-19Store generator field names in GeneratorLayout.Camille GILLOT-6/+22
2023-06-19s/Clause/ClauseKindMichael Goulet-2/+2
2023-06-19Promote unchecked_add/sub/mul/shl/shr to mir::BinOpScott McMurray-1/+11
2023-06-19add FIXME's for a later refactoringlcnr-3/+6
2023-06-19mir opt: fix subtype handlinglcnr-0/+20
2023-06-19fix types in shim buildinglcnr-7/+23
2023-06-18Auto merge of #112638 - lqd:rpo, r=cjgillotbors-3/+3
Switch the BB CFG cache from postorder to RPO The `BasicBlocks` CFG cache is interesting: - it stores a postorder, but `traversal::postorder` doesn't use it - `traversal::reverse_postorder` does traverse the postorder cache backwards - we do more RPO traversals than postorder traversals (around 20x on the perf.rlo benchmarks IIRC) but it's not cached - a couple places here and there were manually reversing the non-cached postorder traversal This PR switches the order of the cache, and makes a bit more use of it. This is a tiny win locally, but it's also for consistency and aesthetics. r? `@ghost`
2023-06-18Better error for non const `PartialEq` call generated by `match`Deadbeef-9/+9
2023-06-18Auto merge of #112599 - saethlin:cleaner-panics, r=thomccbors-6/+4
Launch a non-unwinding panic for misaligned pointer deref This panic already never unwinds, but that's only because it always hits the unwind guard that's created by our `UnwindAction::Terminate`. Hitting the unwind guard generates a huge double-panic backtrace. Now we generate a normal-looking panic message when this check is hit. r? `@thomcc`
2023-06-16Auto merge of #112716 - compiler-errors:rollup-h77daia, r=compiler-errorsbors-0/+4
Rollup of 7 pull requests Successful merges: - #111074 (Relax implicit `T: Sized` bounds on `BufReader<T>`, `BufWriter<T>` and `LineWriter<T>`) - #112226 (std: available_parallelism using native netbsd api first) - #112474 (Support 128-bit enum variant in debuginfo codegen) - #112662 (`#[lang_item]` for `core::ptr::Unique`) - #112665 (Make assumption functions in new solver take `Binder<'tcx, Clause<'tcx>>`) - #112684 (Disable alignment checks on i686-pc-windows-msvc) - #112706 (Add `SyntaxContext::is_root`) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-16Ignore the always part of #[inline(always)] in MIR inliningBen Kimock-4/+5
2023-06-16Update compiler/rustc_mir_transform/src/check_alignment.rsWesley Wiser-0/+1
2023-06-16Launch a non-unwinding panic for misaligned pointer derefBen Kimock-6/+4
2023-06-16Disable alignment checks on i686-pc-windows-msvcBen Kimock-0/+3
2023-06-15Rollup merge of #112403 - nbdd0121:eh_frame, r=NilstriebGuillaume Gomez-1/+6
Prevent `.eh_frame` from being emitted for `-C panic=abort` Since `CheckAlignment` pass is after the `AbortUnwindingCalls` pass, the `UnwindAction::Terminate` inserted in it has no chance to be converted to `UnwindAction::Unreachable` anymore, causing us to emit landing pads that are not necessary. Although these landing pads can themselves be eliminated by LLVM, `.eh_frame` sections are still generated. This causes trouble for Rust-for-Linux project recently. This PR changes it to generate `UnwindAction::Terminate` when we opt for `-Cpanic=unwind`, and `UnwindAction::Unreachable` for `-Cpanic=abort`. `@ojeda`
2023-06-14make reorder BB pass use cached RPORémy Rakic-1/+1
2023-06-14make const-prop use cached RPORémy Rakic-2/+2
2023-06-14s/drain_filter/extract_if/ for Vec, Btree{Map,Set} and LinkedListThe 8472-9/+6
2023-06-13Auto merge of #112017 - Nemo157:unsafe-block-rustfix, r=eholkbors-11/+45
Add MVP suggestion for `unsafe_op_in_unsafe_fn` Rebase of https://github.com/rust-lang/rust/pull/99827 cc tracking issue https://github.com/rust-lang/rust/issues/71668 No real changes since the original PR, just migrated the new suggestion to use fluent messages and added a couple more testcases, AFAICT from the discussion there were no outstanding changes requested.
2023-06-13Add note about unsafe functions body not being unsafeWim Looman-3/+14
2023-06-13Hide suggestion to wrap function in unsafe blockWim Looman-1/+1
2023-06-13Add MVP suggestion for `unsafe_op_in_unsafe_fn`Léo Lanteri Thauvin-11/+34
Nemo157 rebase notes: Migrated the changes to the lint into fluent
2023-06-09Auto merge of #111626 - pjhades:output, r=b-naberbors-4/+11
Write to stdout if `-` is given as output file With this PR, if `-o -` or `--emit KIND=-` is provided, output will be written to stdout instead. Binary output (those of type `obj`, `llvm-bc`, `link` and `metadata`) being written this way will result in an error unless stdout is not a tty. Multiple output types going to stdout will trigger an error too, as they will all be mixded together. This implements https://github.com/rust-lang/compiler-team/issues/431 The idea behind the changes is to introduce an `OutFileName` enum that represents the output - be it a real path or stdout - and to use this enum along the code paths that handle different output types.
2023-06-08Auto merge of #108293 - Jarcho:mut_analyses, r=eholkbors-32/+47
Take MIR dataflow analyses by mutable reference The main motivation here is any analysis requiring dynamically sized scratch memory to work. One concrete example would be pointer target tracking, where tracking the results of a dereference can result in multiple possible targets. This leads to processing multi-level dereferences requiring the ability to handle a changing number of potential targets per step. A (simplified) function for this would be `fn apply_deref(potential_targets: &mut Vec<Target>)` which would use the scratch space contained in the analysis to send arguments and receive the results. The alternative to this would be to wrap everything in a `RefCell`, which is what `MaybeRequiresStorage` currently does. This comes with a small perf cost and loses the compiler's guarantee that we don't try to take multiple borrows at the same time. For the implementation: * `AnalysisResults` is an unfortunate requirement to avoid an unconstrained type parameter error. * `CloneAnalysis` could just be `Clone` instead, but that would result in more work than is required to have multiple cursors over the same result set. * `ResultsVisitor` now takes the results type on in each function as there's no other way to have access to the analysis without cloning it. This could use an associated type rather than a type parameter, but the current approach makes it easier to not care about the type when it's not necessary. * `MaybeRequiresStorage` now no longer uses a `RefCell`, but the graphviz formatter now does. It could be removed, but that would require even more changes and doesn't really seem necessary.