about summary refs log tree commit diff
path: root/tests/mir-opt/building
AgeCommit message (Collapse)AuthorLines
2023-12-11End locals' live range before suspending coroutineTomasz Miąsko-0/+7
State transforms retains storage statements for locals that are not stored inside a coroutine. It ensures those locals are live when resuming by inserting StorageLive as appropriate. It forgot to end the storage of those locals when suspending, which is fixed here. While the end of live range is implicit when executing return, it is nevertheless useful for inliner which would otherwise extend the live range beyond return.
2023-11-14Auto merge of #117330 - tmiasko:custom-mir-cleanup-blocks, r=cjgillotbors-4/+106
Custom MIR: Support cleanup blocks Cleanup blocks are declared with `bb (cleanup) = { ... }`. `Call` and `Drop` terminators take an additional argument describing the unwind action, which is one of the following: * `UnwindContinue()` * `UnwindUnreachable()` * `UnwindTerminate(reason)`, where reason is `ReasonAbi` or `ReasonInCleanup` * `UnwindCleanup(block)` Also support unwind resume and unwind terminate terminators: * `UnwindResume()` * `UnwindTerminate(reason)`
2023-11-14Custom MIR: Support cleanup blocksTomasz Miąsko-4/+106
Cleanup blocks are declared with `bb (cleanup) = { ... }`. `Call` and `Drop` terminators take an additional argument describing the unwind action, which is one of the following: * `UnwindContinue()` * `UnwindUnreachable()` * `UnwindTerminate(reason)`, where reason is `ReasonAbi` or `ReasonInCleanup` * `UnwindCleanup(block)` Also support unwind resume and unwind terminate terminators: * `UnwindResume()` * `UnwindTerminate(reason)`
2023-11-13Compute layout with spans for better cycle errors in coroutinesMichael Goulet-2/+2
2023-11-08update mir-opt testslcnr-4/+4
2023-10-31FileCheck while_storage.Camille GILLOT-0/+200
2023-10-24Use `PlaceMention` for match scrutinees.Camille GILLOT-8/+14
2023-10-20s/generator/coroutine/Oli Scherer-7/+7
2023-10-20s/Generator/Coroutine/Oli Scherer-8/+8
2023-10-19Allow to run filecheck in mir-opt tests.Camille GILLOT-46/+71
2023-10-16Normalize alloc-id in tests.Camille GILLOT-4/+4
2023-09-28Bless mir-opt testsOli Scherer-40/+46
2023-09-23Bless mir-optCamille GILLOT-12/+24
2023-09-21adjust how closure/generator types and rvalues are printedRalf Jung-14/+14
2023-09-11Disentangle `Debug` and `Display` for `Ty`.Nicholas Nethercote-2/+16
The `Debug` impl for `Ty` just calls the `Display` impl for `Ty`. This is surprising and annoying. In particular, it means `Debug` doesn't show as much information as `Debug` for `TyKind` does. And `Debug` is used in some user-facing error messages, which seems bad. This commit changes the `Debug` impl for `Ty` to call the `Debug` impl for `TyKind`. It also does a number of follow-up changes to preserve existing output, many of which involve inserting `with_no_trimmed_paths!` calls. It also adds `Display` impls for `UserType` and `Canonical`. Some tests have changes to expected output: - Those that use the `rustc_abi(debug)` attribute. - Those that use the `EMIT_MIR` annotation. In each case the output is slightly uglier than before. This isn't ideal, but it's pretty weird (particularly for the attribute) that the output is using `Debug` in the first place. They're fairly obscure attributes (I hadn't heard of them) so I'm not worried by this. For `async-is-unwindsafe.stderr`, there is one line that now lacks a full path. This is a consistency improvement, because all the other mentions of `Context` in this test lack a path.
2023-09-01Support debuginfo for custom MIR.Camille GILLOT-0/+123
2023-08-30lower ExprKind::Use, LogicalOp::Or and UnOp::NotDing Xiang Fei-109/+122
Co-authored-by: Abdulaziz Ghuloum <aghuloum@gmail.com>
2023-08-30mir-opt test before patchDing Xiang Fei-0/+299
2023-08-24make MIR less verboseRalf Jung-7/+7
2023-08-24when terminating during unwinding, show the reason whyRalf Jung-7/+7
2023-08-20Auto merge of #113124 - nbdd0121:eh_frame, r=cjgillotbors-2/+2
Add MIR validation for unwind out from nounwind functions + fixes to make validation pass `@Nilstrieb` This is the MIR validation you asked in https://github.com/rust-lang/rust/pull/112403#discussion_r1222739722. Two passes need to be fixed to get the validation to pass: * `RemoveNoopLandingPads` currently unconditionally introduce a resume block (even there is none to begin with!), changed to not do that * Generator state transform introduces a `assert` which may unwind, and its drop elaboration also introduces many new `UnwindAction`s, so in this case run the AbortUnwindingCalls after the transformation. I believe this PR should also fix Rust-for-Linux/linux#1016, cc `@ojeda` r? `@Nilstrieb`
2023-08-19custom_mir: change Call() terminator syntax to something more readableRalf Jung-2/+2
2023-08-18Run `AbortUnwindingCalls` after generator transformGary Guo-2/+2
2023-07-08Rollup merge of #113217 - ericmarkmartin:lower-type-relative-ctor-to-adt, ↵Matthias Krüger-0/+41
r=cjgillot resolve typerelative ctors to adt Associated issue: #110508 r? ``@spastorino``
2023-07-07Rename `adjustment::PointerCast` and variants using it to `PointerCoercion`Nilstrieb-3/+3
It makes it sound like the `ExprKind` and `Rvalue` are supposed to represent all pointer related casts, when in reality their just used to share a some enum variants. Make it clear there these are only coercion to make it clear why only some pointer related "casts" are in the enum.
2023-07-05rename constants in mir dump testEric Mark Martin-8/+8
2023-07-05add mir dump testEric Mark Martin-0/+41
2023-06-23Bless testsGary Guo-6/+6
2023-06-15Remove comments from mir-opt MIR dumpsBen Kimock-1496/+1415
2023-05-18Also assume wrap-around discriminants in `as` MIR buildingScott McMurray-15/+145
Resolves this FIXME: https://github.com/rust-lang/rust/blob/8d18c32b61476ed16dd15074e71be3970368d6d7/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs#L231
2023-05-15Address FIXMEAndy Wang-11/+6
2023-05-15Add CopyForDeref to custom MIRAndy Wang-0/+28
2023-04-27Make async removal span more resilient to macro expansionsMichael Goulet-1/+1
2023-04-27Tweak await spanMichael Goulet-88/+88
2023-04-26IntoFuture::into_future is no longer unstableMichael Goulet-1/+1
2023-04-11Add Offset binary op to custom mirAndy Wang-0/+21
2023-04-06Bless testsGary Guo-16/+16
2023-04-05Tweak debug outputs to make debugging new solver easierMichael Goulet-6/+6
2023-03-26Auto merge of #106428 - saethlin:inline-diverging-functions, r=cjgillotbors-19/+15
Permit the MIR inliner to inline diverging functions This heuristic prevents inlining of `hint::unreachable_unchecked`, which in turn makes `Option/Result::unwrap_unchecked` a bad inlining candidate. I looked through the changes to `core`, `alloc`, `std`, and `hashbrown` by hand and they all seem reasonable. Let's see how this looks in perf... --- Based on rustc-perf it looks like this regresses ctfe-stress, and the cachegrind diff indicates that this regression is in `InterpCx::statement`. I don't know how to do any deeper analysis because that function is _enormous_ in the try toolchain, which has no debuginfo in it. And a local build produces significantly different codegen for that function, even with LTO.
2023-03-23Rollup merge of #109475 - scottmcm:simpler-shifts, r=WaffleLapkinMatthias Krüger-0/+302
Simpler checked shifts in MIR building Doing masking to check unsigned shift amounts is overcomplicated; just comparing the shift directly saves a statement and a temporary, as well as is much easier to read as a human. And shifting by unsigned is the canonical case -- notably, all the library shifting methods (that don't support every type) take shift RHSs as `u32` -- so we might as well make that simpler since it's easy to do so. This PR also changes *signed* shift amounts to `IntToInt` casts and then uses the same check as for unsigned. The bit-masking is a nice trick, but for example LLVM actually canonicalizes it to an unsigned comparison anyway <https://rust.godbolt.org/z/8h59fMGT4> so I don't think it's worth the effort and the extra `Constant`. (If MIR's `assert` was `assert_nz` then the masking might make sense, but when the `!=` uses another statement I think the comparison is better.) To review, I suggest looking at https://github.com/rust-lang/rust/pull/109475/commits/2ee0468c49be9f8ea68b7b935ea1f4c2555849e9 first -- that's the interesting code change and has a MIR diff. My favourite part of the diff: ```diff - _20 = BitAnd(_19, const 340282366920938463463374607431768211448_u128); // scope 0 at $DIR/shifts.rs:+2:34: +2:44 - _21 = Ne(move _20, const 0_u128); // scope 0 at $DIR/shifts.rs:+2:34: +2:44 - assert(!move _21, "attempt to shift right by `{}`, which would overflow", _19) -> [success: bb3, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+2:34: +2:44 + _18 = Lt(_17, const 8_u128); // scope 0 at $DIR/shifts.rs:+2:34: +2:44 + assert(move _18, "attempt to shift right by `{}`, which would overflow", _17) -> [success: bb3, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+2:34: +2:44 ```
2023-03-22Generate simpler MIR for shiftsScott McMurray-118/+106
2023-03-22Rollup merge of #109392 - cbeuw:composite-ret, r=JakobDegenMatthias Krüger-0/+32
Custom MIR: Allow optional RET type annotation This currently doesn't compile because the type of `RET` is inferred, which fails if RET is a composite type and fields are initialised separately. ```rust #![feature(custom_mir, core_intrinsics)] extern crate core; use core::intrinsics::mir::*; #[custom_mir(dialect = "runtime", phase = "optimized")] fn fn0() -> (i32, bool) { mir! ({ RET.0 = 0; RET.1 = true; Return() }) } ``` ``` error[E0282]: type annotations needed --> src/lib.rs:8:9 | 8 | RET.0 = 0; | ^^^ cannot infer type For more information about this error, try `rustc --explain E0282`. ``` This PR allows the user to manually specify the return type with `type RET = ...;` if required: ```rust #[custom_mir(dialect = "runtime", phase = "optimized")] fn fn0() -> (i32, bool) { mir! ( type RET = (i32, bool); { RET.0 = 0; RET.1 = true; Return() } ) } ``` The syntax is not optimal, I'm happy to see other suggestions. Ideally I wanted it to be a normal type annotation like `let RET: ...;`, but this runs into the multiple parsing options error during macro expansion, as it can be parsed as a normal `let` declaration as well. r? ```@oli-obk``` or ```@tmiasko``` or ```@JakobDegen```
2023-03-22Demonstration test for MIR building of checked shift operatorsScott McMurray-0/+314
2023-03-20Support aggregate expressionsAndy Wang-0/+112
2023-03-20Allow optional RET type annotationAndy Wang-0/+32
2023-03-18Remove duplicate unreachable blocksBen Kimock-19/+15
2023-03-14Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errorsbors-2/+2
Remove `identity_future` indirection This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm. Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]`annotation. Fixes https://github.com/rust-lang/rust/issues/104826.
2023-03-12Remove uses of `box_syntax` in rustc and toolsclubby789-107/+117
2023-03-09Introduce a no-op PlaceMention statement for `let _ =`.Camille GILLOT-0/+5
2023-03-08Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiaskoMatthias Krüger-3/+5
Remove DropAndReplace terminator #107844 made DropAndReplace unused, let's remove it completely from the codebase.