about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2025-04-14Auto merge of #139766 - jhpratt:rollup-afrfmnk, r=jhprattbors-77/+51
Rollup of 10 pull requests Successful merges: - #137043 (Initial `UnsafePinned` implementation [Part 1: Libs]) - #138962 (Expect an array when expected and acutal types are both arrays during cast) - #139001 (add `naked_functions_rustic_abi` feature gate) - #139379 (Use delayed bug for normalization errors in drop elaboration) - #139582 (Various coercion cleanups) - #139628 (Suggest remove redundant `$()?` around `vis`) - #139644 (Micro-optimize `InstSimplify`'s `simplify_primitive_clone`) - #139674 (In `rustc_mir_transform`, iterate over index newtypes instead of ints) - #139740 (Convert `tests/ui/lint/dead-code/self-assign.rs` to a known-bug test) - #139741 (fix smir's run! doc and import) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-13Visit place in BackwardIncompatibleDropHint statementMichael Goulet-15/+2
2025-04-13Rollup merge of #139674 - yotamofek:pr/mir_transform/index-iterators, ↵Jacob Pratt-53/+39
r=compiler-errors In `rustc_mir_transform`, iterate over index newtypes instead of ints Just makes code more idiomatic/easier to read, IMHO. Also, some drive-by simplifications and cleanups.
2025-04-13Rollup merge of #139644 - ↵Jacob Pratt-17/+8
yotamofek:pr/mir_transform/instsimplify/simplify_primitive_clone, r=compiler-errors Micro-optimize `InstSimplify`'s `simplify_primitive_clone` r? ````@compiler-errors```` , since you already did #139411 and got randomly selected for #139638 (feel free to reassign!) Another one similar in spirit to #139411, but this time for `simplify_primitive_clone`, which is doing a bit of redundant work. Might not show up in benches, but probably worth micro-optimizing since the transformation is run even for debug builds. See inline comments for my reasoning for making these changes.
2025-04-13Rollup merge of #139379 - matthewjasper:drop-elab-normalization, ↵Jacob Pratt-7/+4
r=compiler-errors Use delayed bug for normalization errors in drop elaboration Normalization can fail due to a lot of different earlier errors, so just use span_delayed_bug if normalization failed. Closes #137287 Closes #135668 r? compiler-errors
2025-04-13JumpThreading: Bail out on interp errorsclubby789-67/+91
2025-04-13JumpThreading: Re-enable and fix Not ops on non-booleansclubby789-18/+11
2025-04-12Proactively update coroutine drop shim's phase to account for later passes ↵Michael Goulet-0/+7
applied during shim query
2025-04-12In `rustc_mir_tranform`, iterate over index newtypes instead of intsYotam Ofek-53/+39
2025-04-11Use delayed bug for normalization errors in drop elaborationMatthew Jasper-7/+4
Normalization can fail from errors from other items so use a delayed bug instead of checking the body.
2025-04-10Cleanup the `InstSimplify` MIR transformationYotam Ofek-106/+86
2025-04-10Micro-optimize `InstSimplify`'s `simplify_primitive_clone`Yotam Ofek-17/+8
2025-04-09Auto merge of #139327 - cjgillot:gvn-place, r=oli-obkbors-27/+47
Allow GVN to produce places and not just locals. That may be too big of a hammer, as we may introduce new deref projections (possible UB footgun + probably not good for perf). The second commit opts out of introducing projections that don't have a stable offset, which is probably what we want. Hence no new Deref and no new Index projections. Fixes https://github.com/rust-lang/rust/issues/138936 cc `@scottmcm` `@dianqk`
2025-04-08Do not optimize out SwitchInt before borrowck, or if Zmir-preserve-ubMichael Goulet-15/+32
2025-04-08borrowck typeck children together with their parentlcnr-3/+6
2025-04-07check_align: we can still check low alignments on MSVCRalf Jung-3/+27
2025-04-07mitigate MSVC unsoundness by not emitting alignment attributes on win32-msvc ↵Ralf Jung-2/+2
targets also mention the MSVC alignment issue in platform-support.md
2025-04-05In `simplify_repeated_aggregate`, don't test first element against itselfYotam Ofek-3/+3
2025-04-04Only introduce stable projections.Camille GILLOT-4/+12
2025-04-04Allow GVN to produce places and not just locals.Camille GILLOT-27/+39
2025-04-03Auto merge of #132527 - DianQK:gvn-stmt-iter, r=oli-obkbors-130/+110
gvn: Invalid dereferences for all non-local mutations Fixes #132353. This PR removes the computation value by traversing SSA locals through `for_each_assignment_mut`. Because the `for_each_assignment_mut` traversal skips statements which have side effects, such as dereference assignments, the computation may be unsound. Instead of `for_each_assignment_mut`, we compute values by traversing in reverse postorder. Because we compute and use the symbolic representation of values on the fly, I invalidate all old values when encountering a dereference assignment. The current approach does not prevent the optimization of a clone to a copy. In the future, we may add an alias model, or dominance information for dereference assignments, or SSA form to help GVN. r? cjgillot cc `@jieyouxu` #132356 cc `@RalfJung` #133474
2025-04-03Invalid dereferences for all non-local mutationsdianqk-14/+16
2025-04-03Only preserving derefs for trivial terminators like SwitchInt and Gotodianqk-2/+8
2025-04-03Remove `unsound-mir-opts` for `simplify_aggregate_to_copy`dianqk-3/+1
2025-04-03Auto merge of #139234 - compiler-errors:query-tweak, r=oli-obkbors-1/+1
Misc query tweaks Remove some redundant work around `cache_on_disk` and `ensure_ok`, since `Result<(), ErrorGuaranteed>` queries don't need to cache or recompute their "value" if they are only used for their result.
2025-04-02Partially revert "Do not unify dereferences in GVN."dianqk-3/+1
This reverts commit 917dd826286bd85e26310e4db4a125d4038c277e.
2025-04-02Invalidate all dereferences for non-local assignmentsdianqk-8/+30
2025-04-02`next_opaque` is no longer an `Option`dianqk-37/+32
2025-04-02Do not use `for_each_assignment_mut` to iterate over assignment statementsdianqk-78/+37
`for_each_assignment_mut` can skip assignment statements with side effects, which can result in some assignment statements retrieving outdated value. For example, it may skip a dereference assignment statement.
2025-04-02Auto merge of #139018 - oli-obk:incremental-trait-impls, r=compiler-errorsbors-3/+7
Various local trait item iteration cleanups Adding a trait impl for `Foo` unconditionally affected all queries that are interested in a completely independent trait `Bar`. Perf has no effect on this. We probably don't have a good perf test for this tho. r? `@compiler-errors` I am unsure about https://github.com/rust-lang/rust/pull/139018/commits/9d05efb66f7b599eeacb5d2456f844fe4768e865 as it doesn't improve anything wrt incremental, because we still do all the checks for valid `Drop` impls, which subsequently will still invoke many queries and basically keep the depgraph the same. I want to do https://github.com/rust-lang/rust/blob/9549077a47099dc826039c051b528d1013740e6f/compiler/rustc_middle/src/ty/trait_def.rs#L141 but would leave that to a follow-up PR, this one changes enough things as it is
2025-04-02Only look at trait impls in the current crate when looking for `Drop` implsOli Scherer-3/+7
2025-04-02Remove `recursion_limit` increases.Nicholas Nethercote-1/+0
These are no longer needed now that `Nonterminal` is gone.
2025-04-02Use return_result_from_ensure_ok a bit moreMichael Goulet-1/+1
2025-04-02Rollup merge of #139102 - Zalathar:no-split, r=oli-obkStuart Cook-89/+39
coverage: Avoid splitting spans during span extraction/refinement This PR removes or simplifies some of the steps involved in extracting coverage-relevant spans from MIR, and preparing them for use in coverage instrumentation metadata. A common theme is that we now try harder to avoid modifying or combining spans in non-trivial ways, because those modifications present the most risk for weird behaviour or ICEs. The main changes are: - When extracting spans from MIR call terminators, try to restrict them to just the function name. - Instead of splitting spans around “holes”, just discard any span that overlaps with a hole. - Instead of splitting macro-invocation spans into two parts, truncate them to just the macro name and subsequent `!`. --- This results in a lot of tiny changes to the spans that end up in coverage metadata, and a few changes to coverage reports. Judging by test snapshots, these changes appear to be quite minor in practice.
2025-04-01Remove an unnecessary dtor computation and use the cached query result insteadOli Scherer-1/+1
2025-04-01coverage: Don't split bang-macro spans, just truncate themZalathar-32/+15
2025-04-01coverage: Instead of splitting, just discard any span that overlaps a holeZalathar-46/+17
2025-04-01coverage: Shrink call spans to just the function nameZalathar-11/+7
This is a way to shrink call spans that doesn't involve mixing different spans, and avoids overlap with argument spans. This patch also removes some low-value comments that were causing rustfmt to ignore the match arms.
2025-03-31Feed HIR for by-move coroutine body def, since the inliner tries to read its ↵Michael Goulet-0/+2
attrs
2025-03-27Drive-by get rid of a bunch of unnecessary :?Michael Goulet-25/+23
2025-03-27Do not trim paths in MIR validatorMichael Goulet-1/+8
2025-03-21coverage: Defer the filtering of hole spansZalathar-15/+15
2025-03-21coverage: Separate span-extraction from unexpansionZalathar-75/+66
2025-03-19Rollup merge of #138670 - compiler-errors:remove-afidt, r=oli-obkMatthias Krüger-48/+2
Remove existing AFIDT implementation This experiment will need to be reworked differently; I don't think we'll be going with the `dyn* Future` approach that is currently implemented. r? oli-obk Fixes #136286 Fixes #137706 Fixes #137895 Tracking: * #133119
2025-03-18Remove existing AFIDT implementationMichael Goulet-48/+2
2025-03-18coverage: Don't store a body span in `FunctionCoverageInfo`Zalathar-1/+0
2025-03-15Don't drop Rvalue::WrapUnsafeBinder during GVNMichael Goulet-2/+8
2025-03-15Auto merge of #138532 - matthiaskrgr:rollup-mgcynqu, r=matthiaskrgrbors-2/+39
Rollup of 5 pull requests Successful merges: - #138283 (Enforce type of const param correctly in MIR typeck) - #138439 (feat: check ARG_MAX on Unix platforms) - #138502 (resolve: Avoid some unstable iteration) - #138514 (Remove fake borrows of refs that are converted into non-refs in `MakeByMoveBody`) - #138524 (Mark myself as unavailable for reviews temporarily) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-15Rollup merge of #138514 - compiler-errors:fake-borrow-ref-to-value, r=oli-obkMatthias Krüger-2/+39
Remove fake borrows of refs that are converted into non-refs in `MakeByMoveBody` Remove fake borrows of closure captures if that capture has been replaced with a by-move version of that capture. For example, given an async closure that looks like: ``` let f: Foo; let c = async move || { match f { ... } }; ``` ... in this pair of coroutine-closure + coroutine, we capture `Foo` in the parent and `&Foo` in the child. We will emit two fake borrows like: ``` _2 = &fake shallow (*(_1.0: &Foo)); _3 = &fake shallow (_1.0: &Foo); ``` However, since the by-move-body transform is responsible for replacing `_1.0: &Foo` with `_1.0: Foo` (since the `AsyncFnOnce` coroutine will own `Foo` by value), that makes the second fake borrow obsolete since we never have an upvar of type `&Foo`, and we should replace it with a `nop`. As a side-note, we don't actually even care about fake borrows here at all since they're fully a MIR borrowck artifact, and we don't need to borrowck by-move MIR bodies. But it's best to preserve as much as we can between these two bodies :) Fixes #138501 r? oli-obk
2025-03-15Stop relying on rustc_type_ir in non-type-system cratesMichael Goulet-15/+12