about summary refs log tree commit diff
path: root/tests/mir-opt
AgeCommit message (Collapse)AuthorLines
2023-04-30Codegen fewer instructions in `mem::replace`Scott McMurray-25/+54
2023-05-01Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naberMatthias Krüger-89/+89
Tweak await span to not contain dot Fixes a discrepancy between method calls and await expressions where the latter are desugared to have a span that *contains* the dot (i.e. `.await`) but method call identifiers don't contain the dot. This leads to weird suggestions suggestions in borrowck -- see linked issue. Fixes #110761 This mostly touches a bunch of tests to tighten their `await` span.
2023-04-30MIR pre-codegen test for `mem::replace`Scott McMurray-0/+98
2023-04-30Rollup merge of #110732 - cjgillot:unit-const-prop, r=tmiaskoMatthias Krüger-75/+79
Make ConstProp some tests unit. Part of the effort to tidy up mir-opt test suite.
2023-04-29Make PlaceMention a non-mutating use.Camille GILLOT-7/+7
2023-04-29Add test.Camille GILLOT-0/+34
2023-04-29Rollup merge of #110962 - cjgillot:no-hash-drops, r=compiler-errorsDylan DPC-1/+1
Make drop_flags an IndexVec. Fixes https://github.com/rust-lang/rust/issues/91943
2023-04-28Make drop_flags an IndexVec.Camille GILLOT-1/+1
2023-04-28handle cfg(bootstrap)Pietro Albini-4/+3
2023-04-28Auto merge of #110837 - scottmcm:offset-for-add, r=compiler-errorsbors-2/+314
Use MIR's `Offset` for pointer `add` too ~~Status: draft while waiting for #110822 to land, since this is built atop that.~~ ~~r? `@ghost~~` Canonical Rust code has mostly moved to `add`/`sub` on pointers, which take `usize`, instead of `offset` which takes `isize`. (And, relatedly, when `sub_ptr` was added it turned out it replaced every single in-tree use of `offset_from`, because `usize` is just so much more useful than `isize` in Rust.) Unfortunately, `intrinsics::offset` could only accept `*const` and `isize`, so there's a *huge* amount of type conversions back and forth being done. They're identity conversions in the backend, but still end up producing quite a lot of unhelpful MIR. This PR changes `intrinsics::offset` to accept `*const` *and* `*mut` along with `isize` *and* `usize`. Conveniently, the backends and CTFE already handle this, since MIR's `BinOp::Offset` [already supports all four combinations](https://github.com/rust-lang/rust/blob/adaac6b166df57ea5a20d56e4cce503b55aca927/compiler/rustc_const_eval/src/transform/validate.rs#L523-L528). To demonstrate the difference, I added some `mir-opt/pre-codegen/` tests around slice indexing. Here's the difference to `[T]::get_mut`, since it uses `<*mut _>::add` internally: ```diff `@@` -79,30 +70,21 `@@` fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { StorageLive(_12); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL StorageLive(_9); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL _9 = _8 as *mut u32 (PtrToPtr); // scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - StorageLive(_13); // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - _13 = _2 as isize (IntToInt); // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - StorageLive(_14); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - StorageLive(_15); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - _15 = _9 as *const u32 (Pointer(MutToConstPointer)); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - _14 = Offset(move _15, _13); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - StorageDead(_15); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - _7 = move _14 as *mut u32 (PtrToPtr); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - StorageDead(_14); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - StorageDead(_13); // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + _7 = Offset(_9, _2); // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL StorageDead(_9); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL StorageDead(_12); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL StorageDead(_11); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL ``` https://github.com/rust-lang/rust/pull/110837/commits/1c1c8e442add0f46905a57a25a6cba52b8b0c54d#diff-a841b6a4538657add3f39bc895744331453d0625e7aace128b1f604f0b63c8fdR80
2023-04-27Also use `mir::Offset` for pointer `add`Scott McMurray-66/+30
2023-04-28Rollup merge of #110766 - m-ou-se:fmt-rt, r=jyn514Matthias Krüger-12/+12
More core::fmt::rt cleanup. - Removes the `V1` suffix from the `Argument` and `Flag` types. - Moves more of the format_args lang items into the `core::fmt::rt` module. (The only remaining lang item in `core::fmt` is `Arguments` itself, which is a public type.) Part of https://github.com/rust-lang/rust/issues/99012 Follow-up to https://github.com/rust-lang/rust/pull/110616
2023-04-27Make async removal span more resilient to macro expansionsMichael Goulet-1/+1
2023-04-27Tweak await spanMichael Goulet-88/+88
2023-04-27Rollup merge of #110864 - compiler-errors:into-future-stable, r=jackh726Matthias Krüger-1/+1
`IntoFuture::into_future` is no longer unstable We don't need to gate the `IntoFuture::into_future` call in `.await` lowering anymore. ``@bors`` rollup
2023-04-27Use EMIT_MIR_FOR_EACH_BIT_WIDTH in transmute mir-opt testTomasz Miąsko-0/+217
2023-04-26IntoFuture::into_future is no longer unstableMichael Goulet-1/+1
2023-04-27Remove workaround for CastKind::Transmute from const propTomasz Miąsko-5/+19
Since constants are no longer validated before propagation the workaround is obsolete. Remove it.
2023-04-26Add some MIR pre-codegen tests for slice indexingScott McMurray-0/+348
2023-04-26Auto merge of #110822 - scottmcm:lower-offset-to-mir, r=compiler-errorsbors-0/+35
Lower `intrinsics::offset` to `mir::BinOp::Offset` They're [semantically the same](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.Rvalue.html#variant.BinaryOp), so this means the backends don't need to handle the intrinsic and means fewer MIR basic blocks in pointer arithmetic code.
2023-04-25Lower `intrinsics::offset` to `mir::BinOp::Offset`Scott McMurray-0/+35
They're semantically the same, so this means the backends don't need to handle the intrinsic and means fewer MIR basic blocks in pointer arithmetic code.
2023-04-25vars are ?Michael Goulet-73/+73
2023-04-24Auto merge of #110713 - cjgillot:track-mir-opt, r=scottmcmbors-170/+757
Add mir-opt tests to track MIR quality. cc `@scottmcm` `@saethlin` If you have other ideas, please say so.
2023-04-24Update tests.Mara Bos-12/+12
2023-04-23Make some tests unit.Camille GILLOT-75/+79
2023-04-23Add mir-opt tests to track MIR quality.Camille GILLOT-170/+757
2023-04-23Auto merge of #110705 - saethlin:ignore-locals-cost, r=cjgillotbors-48/+450
Remove the size of locals heuristic in MIR inlining This heuristic doesn't necessarily correlate to complexity of the MIR Body. In particular, a lot of straight-line code in MIR tends to never reuse a local, even though any optimizer would effectively reuse the storage or just put everything in registers. So it doesn't even necessarily make sense that this would be a stack size heuristic. So... what happens if we just delete the heuristic? The benchmark suite improves significantly. Less heuristics better? r? `@cjgillot`
2023-04-23Auto merge of #108118 - oli-obk:lazy_typeck, r=cjgillotbors-6/+6
Run various queries from other queries instead of explicitly in phases These are just legacy leftovers from when rustc didn't have a query system. While there are more cleanups of this sort that can be done here, I want to land them in smaller steps. This phased order of query invocations was already a lie, as any query that looks at types (e.g. the wf checks run before) can invoke e.g. const eval which invokes borrowck, which invokes typeck, ...
2023-04-22Remove the size of locals heuristic in MIR inliningBen Kimock-48/+450
2023-04-22Turn on ConstDebugInfo pass.Wesley Wiser-66/+32
2023-04-22Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkinbors-0/+131
Add offset_of! macro (RFC 3308) Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented: * Nested field accesses (without array indexing) * DST support (for `Sized` fields) I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it. cc `@thomcc` (RFC author)
2023-04-21Run `check_match` and `check_liveness` when MIR is built instead of having ↵Oli Scherer-6/+6
an explicit phase for them
2023-04-21Auto merge of #110569 - saethlin:mir-pass-cooperation, r=cjgillotbors-1/+44
Deduplicate unreachable blocks, for real this time In https://github.com/rust-lang/rust/pull/106428 (in particular https://github.com/rust-lang/rust/pull/106428/commits/41eda69516dd3ee217ae07c0efa369d31f630405) we noticed that inlining `unreachable_unchecked` can produce duplicate unreachable blocks. So we improved two MIR optimizations: `SimplifyCfg` was given a simplify to deduplicate unreachable blocks, then `InstCombine` was given a combiner to deduplicate switch targets that point at the same block. The problem is that change doesn't actually work. Our current pass order is ``` SimplifyCfg (does nothing relevant to this situation) Inline (produces multiple unreachable blocks) InstCombine (doesn't do anything here, oops) SimplifyCfg (produces the duplicate SwitchTargets that InstCombine is looking for) ``` So in here, I have factored out the specific function from `InstCombine` and placed it inside the simplify that produces the case it is looking for. This should ensure that it runs in the scenario it was designed for. Fixes https://github.com/rust-lang/rust/issues/110551 r? `@cjgillot`
2023-04-21test improvementsDrMeepster-22/+85
2023-04-21offset_ofDrMeepster-0/+68
2023-04-20Run combine_duplicate_switch_targets after the simplification that produces themBen Kimock-2/+2
2023-04-20Bless mir-opt.Camille GILLOT-1/+1
2023-04-19Demonstrate the bugBen Kimock-0/+43
2023-04-19Auto merge of #110393 - fee1-dead-contrib:rm-const-traits, r=oli-obkbors-426/+56
Rm const traits in libcore See [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60const.20Trait.60.20removal.20or.20rework) * [x] Bless ui tests * [ ] Re constify some unstable functions with workarounds if they are needed
2023-04-17fix codegen differenceDeadbeef-26/+66
2023-04-17bless mir-optDeadbeef-438/+28
2023-04-15Add some reasons why tests are ignored.Eric Huss-4/+2
2023-04-15Remove obsolete test.Camille GILLOT-47/+0
2023-04-13Rollup merge of #110233 - nbdd0121:intrinsic, r=tmiaskoMatthias Krüger-10/+50
Make rust-intrinsic ABI unwindable Fix #104451, fix https://github.com/rust-lang/miri/issues/2839 r? `@RalfJung`
2023-04-13Add regression testGary Guo-0/+39
2023-04-12Bless testsGary Guo-10/+11
2023-04-11Add Offset binary op to custom mirAndy Wang-0/+21
2023-04-07./x.py test --blessTomasz Miąsko-182/+296
2023-04-07Auto merge of #102906 - nbdd0121:mir, r=wesleywiser,tmiaskobors-369/+453
Refactor unwind in MIR This makes unwinding from current `Option<BasicBlock>` into ```rust enum UnwindAction { Continue, Cleanup(BasicBlock), Unreachable, Terminate, } ``` cc `@JakobDegen` `@RalfJung` `@Amanieu`
2023-04-06Auto merge of #108504 - cjgillot:thir-pattern, r=compiler-errors,Nilstriebbors-6/+6
Check pattern refutability on THIR The current `check_match` query is based on HIR, but partially re-lowers HIR into THIR. This PR proposed to use the results of the `thir_body` query to check matches, instead of re-building THIR. Most of the diagnostic changes are spans getting shorter, or commas/semicolons not getting removed. This PR degrades the diagnostic for confusing constants in patterns (`let A = foo()` where `A` resolves to a `const A` somewhere): it does not point ot the definition of `const A` any more.