about summary refs log tree commit diff
path: root/tests/mir-opt/inline
AgeCommit message (Collapse)AuthorLines
2025-10-03Auto merge of #142771 - dianqk:mir-stmt-debuginfo, r=cjgillotbors-4/+0
Introduce debuginfo to statements in MIR The PR introduces support for debug information within dead statements. Currently, only the reference statement is supported, which is sufficient to fix rust-lang/rust#128081. I don't modify Stable MIR, as I don't think we need debug information when using it. This PR represents the debug information for the dead reference statement via `#dbg_value`. For example, `let _foo_b = &foo.b` becomes `#dbg_value(ptr %foo, !22, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), !26)`. You can see this here: https://rust.godbolt.org/z/d43js6adv. The general principle for handling debug information is to never provide less debug information than the optimized LLVM IR. The current rules for dropping debug information in this PR are: - If the LLVM IR cannot represent a reference address, it's replaced with poison or simply dropped. For example, see: https://rust.godbolt.org/z/shGqPec8W. I'm using poison in all such cases now. - All debuginfos is dropped when merging multiple successor BBs. An example is available here: https://rust.godbolt.org/z/TE1q3Wq6M. I doesn't drop debuginfos in `MatchBranchSimplification`, because LLVM also pick one branch for it.
2025-10-02Extends `rustc_force_inline` to inherent methodsReuben Cruise-0/+292
- Changes parser to allow application to inherent methods. - Adds tests to confirm extended functionality works just as the existing.
2025-10-02mir-opt: Eliminate dead statements even if they are used by debuginfosdianqk-28/+22
2025-10-02mir-opt: Eliminate trivial unnecessary storage annotationsdianqk-6/+0
2025-10-02mir-opt: Eliminate dead ref statementsdianqk-24/+32
2025-08-18Remove the no_sanitize attribute in favor of sanitizeBastian Kersting-11/+11
This removes the #[no_sanitize] attribute, which was behind an unstable feature named no_sanitize. Instead, we introduce the sanitize attribute which is more powerful and allows to be extended in the future (instead of just focusing on turning sanitizers off). This also makes sanitize(kernel_address = ..) attribute work with -Zsanitize=address To do it the same as how clang disables address sanitizer, we now disable ASAN on sanitize(kernel_address = "off") and KASAN on sanitize(address = "off"). The same was added to clang in https://reviews.llvm.org/D44981.
2025-07-23Give an AllocId to ConstValue::Slice.Camille GILLOT-0/+8
2025-06-22Only inherit local hash for paths.Camille GILLOT-1/+1
2025-06-16tests: `{Meta,Pointee}Sized` in non-minicore testsDavid Wood-1/+7
As before, add `MetaSized` and `PointeeSized` traits to all of the non-minicore `no_core` tests so that they don't fail for lack of language items.
2025-05-21Add some track_caller info to precondition panicsBen Kimock-14/+14
2025-05-10Rollup merge of #140151 - RalfJung:drop_in_place-is-not-an-intrinsic, ↵Matthias Krüger-9/+9
r=Mark-Simulacrum remove intrinsics::drop_in_place This was only ever accidentally stable, and has been marked as deprecated since Rust 1.52, released almost 4 years ago. We've removed the old serialization `derive`s, maybe we can remove this one as well? As suggested by ``@jhpratt,`` let's see what crater says for this one.
2025-04-22remove intrinsics::drop_in_placeRalf Jung-9/+9
2025-04-21mir-opt: execute MatchBranchSimplification after GVNdianqk-44/+44
This can provide more opportunities for MatchBranchSimplification.
2025-04-15Update tests.Mara Bos-2/+2
2025-03-12Allow more top-down inlining for single-BB calleesScott McMurray-0/+15
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-102/+185
2025-01-27Stabilize target_feature_11Caleb Zulawski-1/+0
2025-01-10don't collect `#[rustc_force_inline]` in eager modeDavid Wood-0/+59
2025-01-10mir_transform: implement forced inliningDavid Wood-0/+150
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-08[mir-opt] GVN some more transmute casesScott McMurray-15/+78
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.
2024-12-10We don't need `NonNull::as_ptr` debuginfoScott McMurray-2/+0
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-11-23remove remaining references to `Reveal`lcnr-5/+5
2024-09-24be even more precise about "cast" vs "coercion"Lukas Markeffsky-4/+4
2024-09-16Remove semi-nondeterminism of DefPathHash ordering from inlinerMichael Goulet-62/+4
2024-08-29Add a test for trait solver overflow in MIR inliner cycle detectionBen Kimock-0/+32
2024-08-18Bless *all* the mir-opt testsScott McMurray-109/+109
2024-07-29Perform instsimplify before inline to eliminate some trivial callsDianQK-30/+30
2024-07-01Avoid MIR bloat in inliningScott McMurray-48/+222
In 126578 we ended up with more binary size increases than expected. This change attempts to avoid inlining large things into small things, to avoid that kind of increase, in cases when top-down inlining will still be able to do that inlining later.
2024-06-10Delete `ConstDebugInfo` passScott McMurray-2/+2
2024-06-03rustfmt `tests/mir-opt`.Nicholas Nethercote-12/+19
The only non-obvious changes: - `building/storage_live_dead_in_statics.rs` has a `#[rustfmt::skip]` attribute to avoid reformating a table of data. - Two `.mir` files have slight changes involving line numbers. - In `unusual_item_types.rs` an `EMIT_MIR` annotation is moved to outside a function, which is the usual spot, because `tidy` complains if such a comment is indented. The commit also tweaks the comments in `rustfmt.toml`.
2024-05-29[ACP 362] genericize `ptr::from_raw_parts`Scott McMurray-1/+3
2024-05-25Simplify the `unchecked_sh[lr]` ub-checks a bitScott McMurray-4/+4
2024-05-23Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methodsltdk-12/+92
2024-05-06Avoid a cast in `ptr::slice_from_raw_parts(_mut)`Scott McMurray-10/+46
Casting to `*const ()` or `*mut ()` just bloats the MIR, so let's not. If ACP#362 goes through we can keep calling `ptr::from_raw_parts(_mut)` in these also without the cast, but that hasn't had any libs-api attention yet, so I'm not waiting on it.
2024-04-24Error on using `yield` without also using `#[coroutine]` on the closureOli Scherer-23/+24
And suggest adding the `#[coroutine]` to the closure
2024-04-20mir-opt tests: rename unit-test -> test-mir-passRalf Jung-3/+3
2024-04-18Ensure `[rust] debuginfo-level-std` doesn't change core's MIRScott McMurray-0/+2
2024-04-18At debuginfo=0, don't inline debuginfo when inliningScott McMurray-44/+18
2024-04-03Remove MIR unsafe checkMatthew Jasper-82/+34
This also remove safety information from MIR.
2024-04-02Update tests/mir-opt/inline/unchecked_shifts.rsscottmcm-1/+1
Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
2024-03-30De-LLVM the unchecked shifts [MCP#693]Scott McMurray-328/+11
This is just one part of the MCP, but it's the one that IMHO removes the most noise from the standard library code. Seems net simpler this way, since MIR already supported heterogeneous shifts anyway, and thus it's not more work for backends than before.
2024-03-27Eliminate `UbCheck` for non-standard librariesDianQK-22/+4
2024-03-23Auto merge of #122629 - RalfJung:assert-unsafe-precondition, r=saethlinbors-4/+20
refactor check_{lang,library}_ub: use a single intrinsic This enacts the plan I laid out [here](https://github.com/rust-lang/rust/pull/122282#issuecomment-1996917998): use a single intrinsic, called `ub_checks` (in aniticpation of https://github.com/rust-lang/compiler-team/issues/725), that just exposes the value of `debug_assertions` (consistently implemented in both codegen and the interpreter). Put the language vs library UB logic into the library. This makes it easier to do something like https://github.com/rust-lang/rust/pull/122282 in the future: that just slightly alters the semantics of `ub_checks` (making it more approximating when crates built with different flags are mixed), but it no longer affects whether these checks can happen in Miri or compile-time. The first commit just moves things around; I don't think these macros and functions belong into `intrinsics.rs` as they are not intrinsics. r? `@saethlin`
2024-03-23refactor check_{lang,library}_ub: use a single intrinsic, put policy into ↵Ralf Jung-4/+20
library
2024-03-22Enable more mir-opt tests in debug buildsBen Kimock-3/+1
2024-03-10MIR printing: print the path of uneval'd const; refer to promoteds in a ↵Ralf Jung-6/+6
consistent way
2024-03-08Distinguish between library and lang UB in assert_unsafe_preconditionBen Kimock-4/+4
2024-02-25Auto merge of #121114 - Nilstrieb:no-inline!, r=saethlinbors-0/+83
Add `#[rustc_no_mir_inline]` for standard library UB checks should help with #121110 and also with #120848 Because the MIR inliner cannot know whether the checks are enabled or not, so inlining is an unnecessary compile time pessimization when debug assertions are disabled. LLVM knows whether they are enabled or not, so it can optimize accordingly without wasting time. r? `@saethlin`
2024-02-24Add `#[rustc_no_mir_inline]` for standard library UB checksNilstrieb-0/+83
Co-authored-by: Ben Kimock <kimockb@gmail.com>
2024-02-22[AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives许杰友 Jieyou Xu (Joe)-35/+35