about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2024-09-24Dogfood `feature(file_buffered)`Josh Stone-1/+2
2024-09-24be even more precise about "cast" vs "coercion"Lukas Markeffsky-21/+23
2024-09-24unify dyn* coercions with other pointer coercionsLukas Markeffsky-6/+6
2024-09-24Revert "Auto merge of #129047 - DianQK:early_otherwise_branch_scalar, ↵许杰友 Jieyou Xu (Joe)-175/+85
r=cjgillot" This reverts commit a772336fb3fbd1fe4493077fcfe04e0221296a99, reversing changes made to 702987f75b74f789ba227ee04a3d7bb1680c2309. It seems Apply EarlyOtherwiseBranch to scalar value #129047 may have lead to several nightly regressions: - https://github.com/rust-lang/rust/issues/130769 - https://github.com/rust-lang/rust/issues/130774 - https://github.com/rust-lang/rust/issues/130771 And since this is a mir-opt ICE that seems to quite easy to trigger with real-world crates being affected, let's revert for now and reland the mir-opt later.
2024-09-23Auto merge of #129047 - DianQK:early_otherwise_branch_scalar, r=cjgillotbors-85/+175
Apply `EarlyOtherwiseBranch` to scalar value In the future, I'm thinking of hoisting discriminant via GVN so that we only need to write very little code here. r? `@cjgillot`
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-234/+175
2024-09-18Apply `EarlyOtherwiseBranch` to scalar valueDianQK-85/+175
2024-09-17Rollup merge of #130201 - compiler-errors:foreign-synthetic-body, r=lcnrMatthias Krüger-17/+21
Encode `coroutine_by_move_body_def_id` in crate metadata We synthesize the MIR for a by-move body for the `FnOnce` implementation of async closures. It can be accessed with the `coroutine_by_move_body_def_id` query. We weren't encoding this query in the metadata though, nor were we properly recording that synthetic MIR in `mir_keys`, so the `optimized_mir` wasn't getting encoded either! Stacked on top is a fix to consider `DefKind::SyntheticCoroutineBody` to return true in several places I missed. Specifically, we should consider the def-kind in `fn DefKind::is_fn_like()`, since that's what we were using to make sure we ensure `query mir_inliner_callees` before the MIR gets stolen for the body. This led to some CI failures that were caught by miri but which I added a test for.
2024-09-17Auto merge of #130455 - compiler-errors:inline-ordering, r=saethlinbors-10/+0
Remove semi-nondeterminism of `DefPathHash` ordering from inliner Déjà vu or something because I kinda thought I had put this PR up before. I recall a discussion somewhere where I think it was `@saethlin` mentioning that this check was no longer needed since we have "proper" cycle detection. Putting that up as a PR now. This may slighlty negatively affect inlining, since the cycle breaking here means that we still inlined some cycles when the def path hashes were ordered in certain ways, this leads to really bad nondeterminism that makes minimizing ICEs and putting up inliner bugfixes difficult. r? `@cjgillot` or `@saethlin` or someone else idk
2024-09-16Fix a couple more DefKind discrepancies between DefKind::Closure and ↵Michael Goulet-1/+1
DefKind::SyntheticCoroutineBody
2024-09-17Rollup merge of #130380 - Zalathar:counters, r=jieyouxuMatthias Krüger-151/+170
coverage: Clarify some parts of coverage counter creation This is a series of semi-related changes that are trying to make the `counters` module easier to read, understand, and modify. For example, the existing code happens to avoid ever using the count for a `TerminatorKind::Yield` node as the count for its sole out-edge (since doing so would be incorrect), but doesn't do so explicitly, so seemingly-innocent changes can result in baffling test failures. This PR also takes the opportunity to simplify some debug-logging code that was making its surrounding code disproportionately hard to read. There should be no changes to the resulting coverage instrumentation/mappings, as demonstrated by the absence of changes to the coverage test suite.
2024-09-16Remove semi-nondeterminism of DefPathHash ordering from inlinerMichael Goulet-10/+0
2024-09-16Record synthetic MIR bodies in mir_keysMichael Goulet-16/+20
2024-09-16Don't ICE when generating Fn shim for async closure with borrowck errorMichael Goulet-5/+12
2024-09-15coverage: Remove unnecessary `bcb_successors`Zalathar-7/+1
Given that we directly access the graph predecessors/successors in so many other places, and sometimes must do so to satisfy the borrow checker, there is little value in having this trivial helper method.
2024-09-15coverage: Replace `bcb_has_multiple_in_edges` with `sole_predecessor`Zalathar-35/+30
This does a better job of expressing the special cases that occur when a node in the coverage graph has exactly one in-edge.
2024-09-15coverage: Simplify choosing an out-edge to be given a counter expressionZalathar-69/+48
By building the list of candidate edges up-front, and making the candidate-selection method fallible, we can remove a few pieces of awkward code.
2024-09-15coverage: Track whether a node's count is the sum of its out-edgesZalathar-13/+57
2024-09-15coverage: Streamline creation of physical edge countersZalathar-6/+17
2024-09-15coverage: Streamline creation of physical node countersZalathar-23/+19
- Look up the node's predecessors only once - Get rid of some overly verbose logging - Explain why some nodes need physical counters - Extract a helper method to create and set a physical node counter
2024-09-15coverage: Tweak comments in `graph`Zalathar-4/+4
2024-09-14Auto merge of #130357 - fmease:rollup-j3ej4q0, r=fmeasebors-20/+20
Rollup of 6 pull requests Successful merges: - #130017 (coverage: Extract `executor::block_on` from several async coverage tests) - #130268 (simd_shuffle: require index argument to be a vector) - #130290 (Stabilize entry_insert) - #130294 (Lifetime cleanups) - #130343 (docs: Enable required feature for 'closure_returning_async_block' lint) - #130349 (Fix `Parser::break_up_float`'s right span) r? `@ghost` `@rustbot` modify labels: rollup
2024-09-14Rollup merge of #130294 - nnethercote:more-lifetimes, r=lcnrLeón Orell Valerian Liehr-20/+20
Lifetime cleanups The last commit is very opinionated, let's see how we go. r? `@oli-obk`
2024-09-14Auto merge of #128299 - DianQK:clone-copy, r=cjgillotbors-1/+97
Simplify the canonical clone method and the copy-like forms to copy Fixes #128081. The optimized clone method ends up as the following MIR: ``` _2 = copy ((*_1).0: i32); _3 = copy ((*_1).1: u64); _4 = copy ((*_1).2: [i8; 3]); _0 = Foo { a: move _2, b: move _3, c: move _4 }; ``` We can transform this to: ``` _0 = copy (*_1); ``` r? `@cjgillot`
2024-09-14Simplify the canonical clone method to copyDianQK-1/+97
The optimized clone method ends up as the following MIR: ``` _2 = copy ((*_1).0: i32); _3 = copy ((*_1).1: u64); _4 = copy ((*_1).2: [i8; 3]); _0 = Foo { a: move _2, b: move _3, c: move _4 }; ``` We can transform this to: ``` _0 = copy (*_1); ```
2024-09-14Rollup merge of #130199 - compiler-errors:by-move, r=cjgillotStuart Cook-6/+2
Don't call closure_by_move_body_def_id on FnOnce async closures in MIR validation Refactors the check in #129847 to not unncessarily call the `closure_by_move_body_def_id` query for async closures that don't *need* a by-move body. Fixes #130167
2024-09-13Rollup merge of #130297 - nnethercote:dataflow-cleanups, r=cjgillotMatthias Krüger-9/+9
Dataflow cleanups r? `@cjgillot`
2024-09-13Rename `FlowState` as `Domain`.Nicholas Nethercote-9/+9
Because that's what it is; no point having a different name for it.
2024-09-13Rename and reorder lots of lifetimes.Nicholas Nethercote-20/+20
- Replace non-standard names like 's, 'p, 'rg, 'ck, 'parent, 'this, and 'me with vanilla 'a. These are cases where the original name isn't really any more informative than 'a. - Replace names like 'cx, 'mir, and 'body with vanilla 'a when the lifetime applies to multiple fields and so the original lifetime name isn't really accurate. - Put 'tcx last in lifetime lists, and 'a before 'b.
2024-09-12Rollup merge of #130263 - Zalathar:sums, r=compiler-errorsMatthias Krüger-33/+27
coverage: Simplify creation of sum counters A small and self-contained improvement, extracted from some larger changes that I'm still working on. Ultimately I want to avoid creating these sum counter-expressions in some cases (in favour of just adding physical counters directly to the nodes we care about), so a good incremental move towards that is splitting the “gather edge counters” step out from the ”build a sum of those counters” step. Creating an extra intermediate vector should have negligible cost (and coverage isn't exercised by the benchmark suite anyway). The removed logging is redundant with the `#[instrument(..)]` logging we already have on the underlying method calls.
2024-09-12Rollup merge of #130101 - RalfJung:const-cleanup, r=fee1-deadMatthias Krüger-3/+3
some const cleanup: remove unnecessary attributes, add const-hack indications I learned that we use `FIXME(const-hack)` on top of the "const-hack" label. That seems much better since it marks the right place in the code and moves around with the code. So I went through the PRs with that label and added appropriate FIXMEs in the code. IMO this means we can then remove the label -- Cc ``@rust-lang/wg-const-eval.`` I also noticed some const stability attributes that don't do anything useful, and removed them. r? ``@fee1-dead``
2024-09-12coverage: Simplify creation of sum countersZalathar-17/+13
2024-09-12coverage: Separate creation of edge counters from building their sumZalathar-28/+26
2024-09-11Simplify some nested if statementsMichael Goulet-27/+26
2024-09-10Rollup merge of #130184 - Zalathar:counters, r=compiler-errorsMatthias Krüger-132/+102
coverage: Clean up terminology in counter creation Some of the terminology in this module is confusing, or has drifted out of sync with other parts of the coverage code. This PR therefore renames some variables and methods, and adjusts comments and debug logging statements, to make things clearer and more consistent. No functional changes, other than some small tweaks to debug logging.
2024-09-10Don't call closure_by_move_body_def_id on FnOnce async closures in MIR ↵Michael Goulet-6/+2
validation
2024-09-10coverage: Avoid referring to "operands" in counter creationZalathar-8/+8
2024-09-10coverage: Avoid referring to out-edges as "branches"Zalathar-97/+80
This makes the graph terminology a bit more consistent, and avoids potential confusion with branch coverage.
2024-09-10coverage: Avoid referring to "coverage spans" in counter creationZalathar-28/+15
The counter-creation code needs to know which BCB nodes require counters, but isn't interested in why, so treat that as an opaque detail.
2024-09-10Make `check_live_drops` into a `MirLint`.Nicholas Nethercote-3/+19
It's a thin wrapper around `check_live_drops`, but it's enough to fix the FIXME comment.
2024-09-10Remove references from some structs.Nicholas Nethercote-64/+56
In all cases the struct can own the relevant thing instead of having a reference to it. This makes the code simpler, and in some cases removes a struct lifetime.
2024-09-10Use `IndexVec::from_raw` to construct a const `IndexVec`.Nicholas Nethercote-3/+2
2024-09-10Add a useful comment about `PromoteTemps`.Nicholas Nethercote-0/+1
This was non-obvious to me.
2024-09-10Add a useful comment.Nicholas Nethercote-0/+2
2024-09-10Clarify a comment.Nicholas Nethercote-1/+1
The "as" is equivalent to "because", but I originally read it more like "when", which was confusing.
2024-09-10Inline and remove some functions.Nicholas Nethercote-395/+344
These are all functions with a single callsite, where having a separate function does nothing to help with readability. These changes make the code a little shorter and easier to read.
2024-09-10Improve comment formatting.Nicholas Nethercote-111/+151
By reflowing comment lines that are too long, and a few that are very short. Plus some other very minor formatting tweaks.
2024-09-09Rollup merge of #130022 - nnethercote:dataflow-borrowck-lifetimes, r=oli-obkMatthias Krüger-59/+47
Dataflow/borrowck lifetime cleanups These commits remove a bunch of unnecessary lifetimes from structs involved in dataflow/borrowck. r? ``@lqd``
2024-09-09Remove unnecessary lifetime from `StorageConflictVisitor`.Nicholas Nethercote-8/+8
2024-09-09Remove `Elaborator`.Nicholas Nethercote-36/+24
It's a trivial wrapper around `ElaborateDropsCtxt` that serves no apparent purpose.