about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2025-01-28Rollup merge of #135748 - compiler-errors:len-2, r=RalfJung,oli-obkMatthias Krüger-34/+9
Lower index bounds checking to `PtrMetadata`, this time with the right fake borrow semantics 😸 Change `Rvalue::RawRef` to take a `RawRefKind` instead of just a `Mutability`. Then introduce `RawRefKind::FakeForPtrMetadata` and use that for lowering index bounds checking to a `PtrMetadata`. This new `RawRefKind::FakeForPtrMetadata` acts like a shallow fake borrow in borrowck, which mimics the semantics of the old `Rvalue::Len` operation we're replacing. We can then use this `RawRefKind` instead of using a span desugaring hack in CTFE. cc ``@scottmcm`` ``@RalfJung``
2025-01-28Represent the raw pointer for a array length check as a new kind of fake borrowMichael Goulet-13/+9
2025-01-27Reapply "Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, ↵Michael Goulet-21/+0
r=davidtwco,RalfJung" This reverts commit 122a55bb442bd1995df9cf9b36e6f65ed3ef4a1d.
2025-01-27Rollup merge of #136114 - compiler-errors:more-idents, r=jieyouxuGuillaume Gomez-4/+4
Use identifiers more in diagnostics code This should make the diagnostics code slightly more correct when rendering idents in mixed crate edition situations. Kinda a no-op, but a cleanup regardless. r? oli-obk or reassign
2025-01-27Rollup merge of #136082 - Zalathar:iter-nodes, r=oli-obkGuillaume Gomez-21/+0
Incorporate `iter_nodes` into `graph::DirectedGraph` This helper method iterates over all node IDs in the dense range `0..num_nodes`. In practice, we have a lot of graph-algorithm code that already assumes that nodes are densely numbered, by using `num_nodes` to allocate per-node indexed data structures. So I don't think this is actually a substantial change to the de-facto semantics of `graph::DirectedGraph`. --- Resolves a FIXME from #135481.
2025-01-27Remove redundant to_ident_string callsMichael Goulet-4/+4
2025-01-26Auto merge of #135753 - compiler-errors:from-ty-const, r=oli-obkbors-16/+4
Get rid of `mir::Const::from_ty_const` This function is strange, because it turns valtrees into `mir::Const::Value`, but the rest of the const variants stay as type system consts. All of the callsites except for one in `instsimplify` (array length simplification of `ptr_metadata` call) just go through the valtree arm of the function, so it's easier to just create a `mir::Const` directly for those. For the instsimplify case, if we have a type system const we should *keep* having a type system const, rather than turning it into a `mir::Const::Value`; it doesn't really matter in practice, though, bc `usize` has no padding, but it feels more principled.
2025-01-26Incorporate `iter_nodes` into `graph::DirectedGraph`Zalathar-21/+0
This assumes that the set of valid node IDs is exactly `0..num_nodes`. In practice, we have a lot of graph-algorithm code that already assumes that nodes are densely numbered, by using `num_nodes` to allocate per-node indexed data structures.
2025-01-25Auto merge of #128657 - clubby789:optimize-none, r=fee1-dead,WaffleLapkinbors-10/+281
Add `#[optimize(none)]` cc #54882 This extends the `optimize` attribute to add `none`, which corresponds to the LLVM `OptimizeNone` attribute. Not sure if an MCP is required for this, happy to file one if so.
2025-01-24coverage: Treat the "merged node flow graph" as a plain data structZalathar-83/+89
By removing all methods from this struct and treating it as a collection of data fields, we make it easier for a future PR to store that data in a query result, without having to move all of its methods into `rustc_middle`.
2025-01-24coverage: Replace `FrozenUnionFind` with a plain IndexVecZalathar-31/+11
This dedicated type seemed like a good idea at the time, but if we want to store this information in a query result then a plainer data type is more convenient.
2025-01-24coverage: Simplify how counter terms are storedZalathar-30/+20
Using `SmallVec` here was fine when it was a module-private detail, but if we want to pass these terms across query boundaries then it's not worth the extra hassle. Replacing a method call with direct field access is slightly simpler. Using the name `counter_terms` is more consistent with other code that tries to maintain a distinction between (physical) "counters" and "expressions".
2025-01-24coverage: Make query `coverage_ids_info` return an OptionZalathar-9/+3
This reflects the fact that we can't compute meaningful info for a function that wasn't instrumented and therefore doesn't have `function_coverage_info`.
2025-01-24coverage: Remove some dead code from MC/DC branch mapping conversionZalathar-19/+13
2025-01-23Disable non-required MIR opts with `optimize(none)`clubby789-10/+281
Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>
2025-01-20Get rid of mir::Const::from_ty_constMichael Goulet-16/+4
2025-01-19Run `clippy --fix` for `unnecessary_map_or` lintYotam Ofek-1/+1
2025-01-19Auto merge of #135709 - lqd:bring-back-len, r=compiler-errorsbors-1/+111
Temporarily bring back `Rvalue::Len` r? `@compiler-errors` as requested in https://github.com/rust-lang/rust/issues/135671#issuecomment-2599580364 > However, in the mean time, I'd rather we not crunch trying to find and more importantly validate the soundness of a solution 🤔 Agreed. To fix the IMO P-critical #135671 for which we somehow didn't have test coverage, this PR temporarily reverts: - https://github.com/rust-lang/rust/pull/133734 - its bugfix https://github.com/rust-lang/rust/pull/134371 - https://github.com/rust-lang/rust/pull/134330 cc `@scottmcm` I added the few samples from that issue as a test, but we can add more in the future, in particular it seems `@steffahn` [will work on that](https://github.com/rust-lang/rust/issues/135671#issuecomment-2599714354). Fixes #135671. And if we want to land this, it should also be nominated for beta backport.
2025-01-19Auto merge of #135715 - matthiaskrgr:rollup-9a18sxj, r=matthiaskrgrbors-7/+388
Rollup of 4 pull requests Successful merges: - #135641 ([rustdoc] Replace module list items `ul`/`li` with `dl`/`dd`/`dt` elements) - #135703 (Disallow `A { .. }` if `A` has no fields) - #135705 (Consolidate ad-hoc MIR lints into real pass-manager-based MIR lints) - #135708 (Some random compiler nits) Failed merges: - #135685 (Remove unused `item-row` CSS class) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-18Revert "Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, ↵Rémy Rakic-0/+21
r=davidtwco,RalfJung" This reverts commit b57d93d8b9525fa261404b4cd9c0670eeb1264b8, reversing changes made to 0aeaa5eb22180fdf12a8489e63c4daa18da6f236.
2025-01-18Revert "Auto merge of #134330 - scottmcm:no-more-rvalue-len, r=matthewjasper"Rémy Rakic-1/+90
This reverts commit e108481f74ff123ad98a63bd107a18d13035b275, reversing changes made to 303e8bd768526a5812bb1776e798e829ddb7d3ca.
2025-01-18Consolidate ad-hoc MIR lints into real pass-manager-based MIR lintsMichael Goulet-7/+388
2025-01-18coverage: Add a few more comments to counter creationZalathar-0/+15
2025-01-18coverage: Remove `BcbCounter` and `BcbExpression`Zalathar-64/+16
Making these separate types from `CovTerm` and `Expression` was historically very helpful, but now that most of the counter-creation work is handled by `node_flow` they are no longer needed.
2025-01-18coverage: Flatten top-level counter creation into plain functionsZalathar-95/+91
- Move `make_bcb_counters` out of `CoverageCounters` - Split out `make_node_counter_priority_list` - Flatten `Transcriber` into the function `transcribe_counters`
2025-01-18coverage: Move `phys_counter_for_node` into `CoverageCounters`Zalathar-19/+18
2025-01-18coverage: Remove the `Site` enum now that we only instrument nodesZalathar-35/+16
2025-01-16coverage: Make `yank_to_spantree_root` iterative instead of recursiveZalathar-19/+36
This avoids having to worry about stack space when traversing very long spantree paths, e.g. when instrumenting a long sequence of if/else statements.
2025-01-16coverage: Completely overhaul counter assignment, using node-flow graphsZalathar-632/+723
2025-01-12Rollup merge of #135377 - compiler-errors:impossible-step, r=oli-obkMatthias Krüger-46/+59
Make MIR cleanup for functions with impossible predicates into a real MIR pass It's a bit jarring to see the body of a function with an impossible-to-satisfy where clause suddenly go to a single `unreachable` terminator when looking at the MIR dump output in order, and I discovered it's because we manually replace the body outside of a MIR pass. Let's make it into a fully flegded MIR pass so it's more clear what it's doing and when it's being applied.
2025-01-11Address PR feedbackScott McMurray-9/+11
2025-01-11[mir-opt] simplify `Repeat`s that don't actually repeat the operandScott McMurray-11/+30
2025-01-11Make MIR cleanup for functions with impossible predicates into a real MIR passMichael Goulet-46/+59
2025-01-11rename `BitSet` to `DenseBitSet`Rémy Rakic-125/+131
This should make it clearer that this bitset is dense, with the advantages and disadvantages that it entails.
2025-01-11Auto merge of #135274 - saethlin:array-repeats, r=compiler-errorsbors-0/+30
Add an InstSimplify for repetitive array expressions I noticed in https://github.com/rust-lang/rust/pull/135068#issuecomment-2569955426 that GVN's implementation of this same transform was quite profitable on the deep-vector benchmark. But of course GVN doesn't run in unoptimized builds, so this is my attempt to write a version of this transform that benefits the deep-vector case and is fast enough to run in InstSimplify. The benchmark suite indicates that this is effective.
2025-01-10mir_build: check annotated functions w/out callersDavid Wood-45/+7
2025-01-10inline: move should inline checkDavid Wood-5/+5
2025-01-10validator: move force inline checkDavid Wood-23/+10
2025-01-10inline: remove unnecessary promoted checkDavid Wood-4/+0
2025-01-10inline: re-introduce some callee body checksDavid Wood-2/+29
2025-01-10inline: force inlining shimsDavid Wood-12/+18
2025-01-10mir_transform: implement forced inliningDavid Wood-634/+941
Adds `#[rustc_force_inline]` which is similar to always inlining but reports an error if the inlining was not possible, and which always attempts to inline annotated items, regardless of optimisation levels. It can only be applied to free functions to guarantee that the MIR inliner will be able to resolve calls.
2025-01-10remove more redundant into() conversionsMatthias Krüger-4/+3
2025-01-09Add an InstSimplify for repetitive array expressionsBen Kimock-0/+30
2025-01-08Make the aggregate-then-transmute handling more generalScott McMurray-13/+9
2025-01-08Refactor the cast-then-cast cases together, and support transmute-then-transmuteScott McMurray-89/+113
2025-01-08Use layout information to detect transparent transmutesScott McMurray-9/+34
2025-01-08Apply suggestions from code reviewscottmcm-2/+2
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2025-01-08[mir-opt] GVN some more transmute casesScott McMurray-24/+55
We already did `Transmute`-then-`PtrToPtr`; this adds the nearly-identical `PtrToPtr`-then-`Transmute`. It also adds `transmute(Foo(x))` → `transmute(x)`, when `Foo` is a single-field transparent type. That's useful for things like `NonNull { pointer: p }.as_ptr()`. Found these as I was looking at MCP807-related changes.
2025-01-08Don't create cycles by normalizing opaques defined in the body we're checkingMichael Goulet-1/+6