about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/inline.rs
AgeCommit message (Collapse)AuthorLines
2025-10-02mir-opt: Eliminate trivial unnecessary storage annotationsdianqk-2/+6
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-1/+1
2025-07-03Auto merge of #142890 - kornelski:unused-var-debug, r=saethlinbors-2/+4
MIR inliner maintains unused var_debug_info Only `full` debuginfo level promises variable-level debug information, but the MIR inline pass needlessly preserved the local variable debug info for the `limited` level too.
2025-06-29mir: Add a `new` method to `statement`dianqk-31/+25
Avoid introducing a large number of changes when adding optional initialization fields.
2025-06-28Keep inlined var_debug_info only when full debug info is usedKornel-2/+4
2025-06-23Only store the LocalDefId instead of the whole instance.Camille GILLOT-2/+3
2025-06-22Only compute recursive callees once.Camille GILLOT-1/+1
2025-05-09don't depend on rustc_attr_parsing if rustc_data_structures will domejrs-1/+1
2025-04-28AsyncDrop implementation using shim codegen of ↵Andrew Zhogin-5/+26
async_drop_in_place::{closure}, scoped async drop added.
2025-04-19Rollup merge of #139042 - compiler-errors:do-not-optimize-switchint, r=saethlinChris Denton-2/+2
Do not remove trivial `SwitchInt` in analysis MIR This PR ensures that we don't prematurely remove trivial `SwitchInt` terminators which affects both the borrow-checking and runtime semantics (i.e. UB) of the code. Previously the `SimplifyCfg` optimization was removing `SwitchInt` terminators when they was "trivial", i.e. when all arms branched to the same basic block, even if that `SwitchInt` terminator had the side-effect of reading an operand which (for example) may not be initialized or may point to an invalid place in memory. This behavior is unlike all other optimizations, which are only applied after "analysis" (i.e. borrow-checking) is finished, and which Miri disables to make sure the compiler doesn't silently remove UB. Fixing this code "breaks" (i.e. unmasks) code that used to borrow-check but no longer does, like: ```rust fn foo() { let x; let (0 | _) = x; } ``` This match expression should perform a read because `_` does not shadow the `0` literal pattern, and the compiler should have to read the match scrutinee to compare it to 0. I've checked that this behavior does not actually manifest in practice via a crater run which came back clean: https://github.com/rust-lang/rust/pull/139042#issuecomment-2767436367 As a side-note, it may be tempting to suggest that this is actually a good thing or that we should preserve this behavior. If we wanted to make this work (i.e. trivially optimize out reads from matches that are redundant like `0 | _`), then we should be enabling this behavior *after* fixing this. However, I think it's kinda unprincipled, and for example other variations of the code don't even work today, e.g.: ```rust fn foo() { let x; let (0.. | _) = x; } ```
2025-04-14Use `newtype_index!`-generated types more idiomaticallyYotam Ofek-6/+6
2025-04-08Do not optimize out SwitchInt before borrowck, or if Zmir-preserve-ubMichael Goulet-2/+2
2025-03-12Allow more top-down inlining for single-BB calleesScott McMurray-37/+57
This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if we've already done a bunch of inlining to find the calls to them.
2025-03-03Inline FnOnce once againMichael Goulet-13/+10
2025-03-03Better reasons for inline failureMichael Goulet-9/+8
2025-02-18Move methods from `Map` to `TyCtxt`, part 2.Nicholas Nethercote-1/+1
Continuing the work started in #136466. Every method gains a `hir_` prefix, though for the ones that already have a `par_` or `try_par_` prefix I added the `hir_` after that.
2025-02-13Make `-O` mean `-C opt-level=3`clubby789-2/+1
2025-02-09Rollup merge of #136722 - kornelski:visit-spans, r=chenyukangMatthias Krüger-0/+2
Visit all debug info in MIR Visitor I've been experimenting with simplifying debug info in MIR inliner, and discovered that MIR Visitor doesn't reliably visit all spans. This PR adds the missing visitor calls.
2025-02-08Rustfmtbjorn3-4/+7
2025-02-08Visit SourceInfo of all TerminatorsKornel-0/+2
2025-01-31`#[optimize(none)]` implies `#[inline(never)]`clubby789-1/+5
2025-01-23Disable non-required MIR opts with `optimize(none)`clubby789-0/+8
Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>
2025-01-18Consolidate ad-hoc MIR lints into real pass-manager-based MIR lintsMichael Goulet-3/+3
2025-01-11rename `BitSet` to `DenseBitSet`Rémy Rakic-4/+4
This should make it clearer that this bitset is dense, with the advantages and disadvantages that it entails.
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-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-11/+15
2025-01-10mir_transform: implement forced inliningDavid Wood-627/+871
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-04rustc_intrinsic: support functions without body; they are implicitly marked ↵Ralf Jung-1/+2
as must-be-overridden
2024-12-18mir: require `is_cleanup` when creating `BasicBlockData`DianQK-5/+7
2024-12-16rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structuresJonathan Dönszelmann-1/+1
2024-12-02mir validator: don't store mir phaselcnr-9/+1
2024-11-26Remove -Zfuel.Camille GILLOT-6/+0
2024-11-19move `fn is_item_raw` to `TypingEnv`lcnr-4/+1
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-35/+20
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-11-03compiler: Directly use rustc_abi in mir_transformJubilee Young-4/+3
2024-10-31stop using `ParamEnv::reveal` while handling MIRlcnr-6/+21
2024-10-26Effects cleanupDeadbeef-6/+1
- removed extra bits from predicates queries that are no longer needed in the new system - removed the need for `non_erasable_generics` to take in tcx and DefId, removed unused arguments in callers
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-8/+5
2024-09-16Remove semi-nondeterminism of DefPathHash ordering from inlinerMichael Goulet-10/+0
2024-09-10Improve comment formatting.Nicholas Nethercote-1/+2
By reflowing comment lines that are too long, and a few that are very short. Plus some other very minor formatting tweaks.
2024-09-09Make `CallSite` non-`Copy`.Nicholas Nethercote-1/+1
It doesn't need to be, and it's 72 bytes on 64-bit platforms, which is fairly large.
2024-09-09Remove some unnecessary dereferences.Nicholas Nethercote-3/+3
2024-09-09Remove an unnecessary `continue`.Nicholas Nethercote-1/+0
Nothing comes after it within the loop.
2024-09-09Reduce visibilities, and add `warn(unreachable_pub)`.Nicholas Nethercote-0/+2
Lots of unnecessary `pub`s in this crate. Most are downgraded to `pub(super)`, though some don't need any visibility.
2024-09-03Move `MirPass` to `rustc_mir_transform`.Nicholas Nethercote-1/+1
Because that's now the only crate that uses it. Moving stuff out of `rustc_middle` is always welcome. I chose to use `impl crate::MirPass`/`impl crate::MirLint` (with explicit `crate::`) everywhere because that's the only mention of `MirPass`/`MirLint` used in all of these files. (Prior to this change, `MirPass` was mostly imported via `use rustc_middle::mir::*` items.)
2024-08-30Remove `#[macro_use] extern crate tracing` from `rustc_mir_transform`.Nicholas Nethercote-0/+1
2024-08-26Stop using a special inner body for the coroutine by-move body for async ↵Michael Goulet-1/+0
closures