about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2024-12-13Rollup merge of #133938 - nnethercote:rustc_mir_dataflow-renamings, r=oli-obkMatthias Krüger-24/+24
`rustc_mir_dataflow` cleanups, including some renamings Some opinionated commits in this collection, let's see how we go. r? `@cjgillot`
2024-12-13Auto merge of #133899 - scottmcm:strip-mir-debuginfo, r=oli-obkbors-0/+37
We don't need `NonNull::as_ptr` debuginfo In order to stop pessimizing the use of local variables in core, skip debug info for MIR temporaries in tiny (single-BB) functions. For functions as simple as this -- `Pin::new`, etc -- nobody every actually wants debuginfo for them in the first place. They're more like intrinsics than real functions, and stepping over them is good.
2024-12-13Stabilize async closuresMichael Goulet-2/+0
2024-12-10Implement projection and shim for AFIDTMichael Goulet-3/+53
2024-12-10We don't need `NonNull::as_ptr` debuginfoScott McMurray-0/+37
Stop pessimizing the use of local variables in core by skipping debug info for MIR temporaries in tiny (single-BB) functions. For functions as simple as this -- `Pin::new`, etc -- nobody every actually wants debuginfo for them in the first place. They're more like intrinsics than real functions, and stepping over them is good.
2024-12-10Rollup merge of #134029 - Zalathar:zero, r=oli-obkLeón Orell Valerian Liehr-5/+102
coverage: Use a query to find counters/expressions that must be zero As of #133446, this query (`coverage_ids_info`) determines which counter/expression IDs are unused. So with only a little extra work, we can take the code that was using that information to determine which coverage counters/expressions must be zero, and move that inside the query as well. There should be no change in compiler output.
2024-12-10Rollup merge of #133946 - Zalathar:ready-first, r=oli-obkLeón Orell Valerian Liehr-146/+125
coverage: Prefer to visit nodes whose predecessors have been visited In coverage instrumentation, we need to traverse the control-flow graph and decide what kind of counter (physical counter or counter-expression) should be used for each node that needs a counter. The existing traversal order is complex and hard to tweak. This new traversal order tries to be a bit more principled, by always preferring to visit nodes whose predecessors have already been visited, which is a good match for how the counter-creation code ends up dealing with a node's in-edges and out-edges. For several of the coverage tests, this ends up being a strict improvement in reducing the size of the coverage metadata, and also reducing the number of physical counters needed. (The new traversal should hopefully also allow some further code simplifications in the future.) --- This is made possible by the separate simplification pass introduced by #133849. Without that, almost any change to the traversal order ends up increasing the size of the expression table or the number of physical counters.
2024-12-10Rename some `Analysis` and `ResultsVisitor` methods.Nicholas Nethercote-8/+8
The words "before" and "after" have an obvious temporal meaning, e.g. `seek_before_primary_effect`, `visit_statement_{before,after}_primary_effect`. But "before" is also used to name the effect that occurs before the primary effect of a statement/terminator; this is `Effect::Before`. This leads to the confusing possibility of talking about things happening "before/after the before event". This commit removes this awkward overloading of "before" by renaming `Effect::Before` as `Effect::Early`. It also renames some of the `Analysis` and `ResultsVisitor` methods to be more consistent. Here are the before and after names: - `Effect::{Before,Primary}` -> `Effect::{Early,Primary}` - `apply_before_statement_effect` -> `apply_early_statement_effect` - `apply_statement_effect` -> `apply_primary_statement_effect` - `visit_statement_before_primary_effect` -> `visit_after_early_statement_effect` - `visit_statement_after_primary_effect` -> `visit_after_primary_statement_effect` (And s/statement/terminator/ for all the terminator events.)
2024-12-10Improve terminology in `elaborate_drops.rs`.Nicholas Nethercote-16/+16
It uses `MaybeInitializedPlaces` and `MaybeUninitializedPlaces`, but calls the results `live` and `dead`. This is very confusing given that there are also analyses called `MaybeLiveLocals` and `MaybeStorageLive` and `MaybeStorageDead`. This commit changes it to use `maybe_init` and `maybe_uninit`.
2024-12-09Rollup merge of #134073 - DianQK:fix-131227, r=oli-obkLeón Orell Valerian Liehr-2/+7
dataflow_const_prop: do not eval a ptr address in SwitchInt Fixes #131227.
2024-12-09dataflow_const_prop: do not eval a ptr address in SwitchIntDianQK-2/+7
2024-12-09Auto merge of #133891 - nnethercote:MixedBitSet, r=Mark-Simulacrumbors-26/+29
Introduce `MixedBitSet` `ChunkedBitSet` is good at avoiding excessive memory usage for programs with very large functgions where dataflow bitsets have very large domain sizes. But it's overly heavyweight for small bitsets, because any non-empty `ChunkedBitSet` takes up at least 256 bytes. This PR introduces `MixedBitSet`, which is a simple bitset that uses `BitSet` for small/medium bitsets and `ChunkedBitSet` for large bitsets. It's a speed and memory usage win. r? `@Mark-Simulacrum`
2024-12-08coverage: Use a query to find counters/expressions that must be zeroZalathar-4/+101
This query (`coverage_ids_info`) already determines which counter/expression IDs are unused, so it only takes a little extra effort to also determine which counters/expressions must have a value of zero.
2024-12-08coverage: Move `CoverageIdsInfo` into `mir::coverage`Zalathar-2/+2
2024-12-07coverage: Prefer to visit nodes whose predecessors have been visitedZalathar-146/+125
2024-12-05Change `ChunkedBitSet<MovePathIndex>`s to `MixedBitSet`.Nicholas Nethercote-26/+29
It's a performance win because `MixedBitSet` is faster and uses less memory than `ChunkedBitSet`. Also reflow some overlong comment lines in `lint_tail_expr_drop_order.rs`.
2024-12-04fn_sig_for_fn_abi should return a ty::FnSig, no need for a binderMichael Goulet-2/+2
2024-12-04coverage: Remove the expression simplifier from `CoverageCounters`Zalathar-51/+4
These simplifications are now handled by the transcribe step.
2024-12-04coverage: Use a separate counter type during counter creationZalathar-73/+94
2024-12-04coverage: Add an extra "transcribe" step after counter creationZalathar-3/+170
2024-12-04coverage: Use a single `make_phys_counter` methodZalathar-19/+4
This is more convenient for subsequent patches.
2024-12-04coverage: Rename `CounterIncrementSite` to just `Site`Zalathar-13/+14
A "site" is a node or edge in the coverage graph.
2024-12-04coverage: Extract `subtracted_sum` in counter creationZalathar-8/+8
2024-12-02Rollup merge of #133732 - nnethercote:fix-Z-dump-mir-dataflow, r=compiler-errorsGuillaume Gomez-1/+1
Fix `-Zdump-mir-dataflow` r? `@cjgillot`
2024-12-02Rollup merge of #133751 - lcnr:no-trait-solving-on-type, r=compiler-errorsGuillaume Gomez-1/+1
remove `Ty::is_copy_modulo_regions` Using these functions is likely incorrect if an `InferCtxt` is available, I moved this function to `TyCtxt` (and added it to `LateContext`) and added a note to the documentation that one should prefer `Infer::type_is_copy_modulo_regions` instead. I didn't yet move `is_sized` and `is_freeze`, though I think we should move these as well. r? `@compiler-errors` cc #132279
2024-12-02remove `Ty::is_copy_modulo_regions`lcnr-1/+1
2024-12-02mir validator: don't store mir phaselcnr-57/+34
2024-12-02Simplify `ResultsHandle`.Nicholas Nethercote-1/+1
The `Borrowed` variant is no longer used. This commit removes it, along with the `as_results_cursor` method that produces it, and renames `as_results_cursor_mut` as `as_results_cursor`.
2024-11-30coverage: Use a query to identify which counter/expression IDs are usedZalathar-9/+38
2024-11-29Revert "Rollup merge of #133418 - Zalathar:spans, r=jieyouxu"Zalathar-18/+148
This reverts commit adf9b5fcd1de43eaf0a779e10612caee8b47bede, reversing changes made to af1ca153d4aed5ffe22445273aa388a8d3f8f4ae. Reverting due to <https://github.com/rust-lang/rust/issues/133606>.
2024-11-27Rollup merge of #133418 - Zalathar:spans, r=jieyouxuMatthias Krüger-148/+18
coverage: Store coverage source regions as `Span` until codegen Historically, coverage spans were converted into line/column coordinates during the MIR instrumentation pass. This PR moves that conversion step into codegen, so that coverage spans spend most of their time stored as `Span` instead. In addition to being conceptually nicer, this also reduces the size of coverage mappings in MIR, because `Span` is smaller than 4x u32. --- There should be no changes to coverage output.
2024-11-27Auto merge of #133474 - RalfJung:gvn-miscompile, r=compiler-errorsbors-1/+3
Do not unify dereferences of shared borrows in GVN Repost of https://github.com/rust-lang/rust/pull/132461, the last commit applies my suggestions. Fixes https://github.com/rust-lang/rust/issues/130853
2024-11-26Rollup merge of #133475 - nnethercote:MaybeStorage-improvements, r=lcnrMichael Goulet-7/+4
`MaybeStorage` improvements Minor dataflow improvements. r? `@tmiasko`
2024-11-26Rollup merge of #115293 - cjgillot:no-fuel, r=wesleywiser,DianQKMichael Goulet-108/+17
Remove -Zfuel. I'm not sure this feature is used. I only found 2 references in a google search, both referring to its introduction. Meanwhile, it's a global mutable state, untracked by incremental compilation, so incompatible with it.
2024-11-26Remove -Zfuel.Camille GILLOT-108/+17
2024-11-26Streamline a `BitSet` creation.Nicholas Nethercote-2/+1
2024-11-26Move `always_storage_live_locals`.Nicholas Nethercote-5/+3
It's very closely related to `MaybeStorageLive` and `MaybeStorageDead`. It's weird that it's currently in a different module.
2024-11-26Make it possible for `ResultsCursor` to borrow a `Results`.Nicholas Nethercote-6/+5
`ResultsCursor` currently owns its `Results`. But sometimes the `Results` is needed again afterwards. So there is `ResultsCursor::into_results` for extracting the `Results`, which leads to some awkwardness. This commit adds `ResultsHandle`, a `Cow`-like type that can either borrow or own a a `Results`. `ResultsCursor` now uses it. This is good because some `ResultsCursor`s really want to own their `Results`, while others just want to borrow it. We end with with a few more lines of code, but get some nice cleanups. - `ResultsCursor::into_results` and `Formatter::into_results` are removed. - `write_graphviz_results` now just borrows a `Results`, instead of the awkward "take ownership of a `Results` and then return it unchanged" pattern. This reinstates the cursor flexibility that was lost in #118230 -- which removed the old `ResultsRefCursor` and `ResultsCloneCursor` types -- but in a much simpler way. Hooray!
2024-11-25Do not unify dereferences in GVN.Camille GILLOT-1/+3
2024-11-24coverage: Store coverage source regions as `Span` until codegenZalathar-148/+18
2024-11-23rebaselcnr-19/+14
2024-11-23reviewlcnr-2/+3
2024-11-23remove remaining references to `Reveal`lcnr-14/+16
2024-11-23`ElaborateDrops`: use typing_env directlylcnr-14/+4
2024-11-20Auto merge of #131326 - dingxiangfei2009:issue-130836-attempt-2, r=nikomatsakisbors-5/+734
Reduce false positives of tail-expr-drop-order from consumed values (attempt #2) r? `@nikomatsakis` Tracked by #123739. Related to #129864 but not replacing, yet. Related to #130836. This is an implementation of the approach suggested in the [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/temporary.20drop.20order.20changes). A new MIR statement `BackwardsIncompatibleDrop` is added to the MIR syntax. The lint now works by inspecting possibly live move paths before at the `BackwardsIncompatibleDrop` location and the actual drop under the current edition, which should be one before Edition 2024 in practice.
2024-11-20reduce false positives of tail-expr-drop-order from consumed valuesDing Xiang Fei-5/+734
take 2 open up coroutines tweak the wordings the lint works up until 2021 We were missing one case, for ADTs, which was causing `Result` to yield incorrect results. only include field spans with significant types deduplicate and eliminate field spans switch to emit spans to impl Drops Co-authored-by: Niko Matsakis <nikomat@amazon.com> collect drops instead of taking liveness diff apply some suggestions and add explantory notes small fix on the cache let the query recurse through coroutine new suggestion format with extracted variable name fine-tune the drop span and messages bugfix on runtime borrows tweak message wording filter out ecosystem types earlier apply suggestions clippy check lint level at session level further restrict applicability of the lint translate bid into nop for stable mir detect cycle in type structure
2024-11-20interpret: make typing_env field privateRalf Jung-2/+2
2024-11-19additional `TypingEnv` cleanupslcnr-10/+4
2024-11-19`InterpCx` store `TypingEnv` instead of a `ParamEnv`lcnr-8/+7
2024-11-19move `fn is_item_raw` to `TypingEnv`lcnr-33/+29