about summary refs log tree commit diff
path: root/tests/mir-opt
AgeCommit message (Collapse)AuthorLines
2023-06-16remove box_free and replace with drop implDrMeepster-12/+17
2023-06-16Ignore the always part of #[inline(always)] in MIR inliningBen Kimock-929/+343
2023-06-15Remove comments from mir-opt MIR dumpsBen Kimock-24071/+21785
2023-06-12bless mir-optPietro Albini-38/+11189
To reproduce the changes in this commit locally: - Run `./x test tidy` and remove all the output files not associated with a test file anymore, as reported by tidy. - Run `./x test tests/mir-opt --bless` to generate the new outputs.
2023-06-12properly mark tests that require panic=abortPietro Albini-104/+108
2023-06-04Auto merge of #112240 - cjgillot:recurse-inline, r=scottmcmbors-265/+386
Only check inlining counter after recursing. This PR aims to reduce the strength of https://github.com/rust-lang/rust/pull/105119 even more. In the current implementation, we check the inline count before recursing. This means that we never actually reach inlining depth 3. This PR checks the counter after recursion, to give a chance to inline at depth >= 3. r? `@scottmcm` cc `@JakobDegen`
2023-06-03Only check inlining counter after recusing.Camille GILLOT-265/+386
2023-06-02Rollup merge of #112168 - scottmcm:lower-div-rem-unchecked-to-mir, r=oli-obkMichael Goulet-29/+95
Lower `unchecked_div`/`_rem` to MIR's `BinOp::Div`/`Rem` As described in <https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.BinOp.html#variant.Div>, the ordinary `BinOp`s for these are already UB for division by zero ([or overflow](https://llvm.org/docs/LangRef.html#sdiv-instruction), [demo](https://rust.godbolt.org/z/71e7P7Exh)), as MIR building is responsible for inserting code to panic for those cases regardless of whether the overflow checks are enabled. So we can lower these in the same arm that lowers `wrapping_add` to MIR `BinOp::Add` and such, as all these cases turn into ordinary `Rvalue::BinaryOp`s.
2023-06-01Rebase fallout.Camille GILLOT-272/+334
2023-06-01Remove brittle test.Camille GILLOT-46/+0
2023-06-01Restrict test to x64.Camille GILLOT-3/+4
2023-06-01Annotate needs-unwind.Camille GILLOT-17/+19
2023-06-01Remove duplication.Camille GILLOT-1406/+541
2023-06-01Remove spurious comments.Camille GILLOT-3/+0
2023-06-01Add chained comparison e2e test.Camille GILLOT-0/+400
2023-06-01Add e2e mir test for checked arithmetic.Camille GILLOT-0/+285
2023-06-01Add loop tests.Camille GILLOT-0/+1585
2023-06-01Make slice_filter a pre-codegen test.Camille GILLOT-1082/+341
2023-06-01Auto merge of #112040 - cjgillot:separate-const-switch, r=oli-obkbors-67/+32
Enable ConstGoto and SeparateConstSwitch passes by default These 2 passes implement a limited form of jump-threading. Filing this PR to see if enabling them would be lighter than https://github.com/rust-lang/rust/pull/107009.
2023-06-01Auto merge of #112002 - saethlin:enable-sroa, r=oli-obk,scottmcmbors-333/+262
Enable ScalarReplacementOfAggregates in optimized builds Like MatchBranchSimplification, this pass is known to produce significant runtime improvements in Cranelift artifacts, and I believe based on the perf runs here that the primary effect of this pass is to empower MatchBranchSimplification. ScalarReplacementOfAggregates on its own has little effect on anything, but when this was rebased up to include https://github.com/rust-lang/rust/pull/112001 we started seeing significant and majority-positive results. Based on the fact that we see most of the regressions in debug builds (https://github.com/rust-lang/rust/pull/112002#issuecomment-1566270144) and some rather significant ones in cycles and wall time, I'm only enabling this in optimized builds at the moment.
2023-06-01Lower unchecked_{div, rem} to BinOp::{Div, Rem}Scott McMurray-29/+95
2023-05-31Enable ScalarReplacementOfAggregatesBen Kimock-333/+262
2023-05-31Only rewrite valtree-constants to patterns and keep other constants opaqueOli Scherer-1/+1
2023-05-29Make `TrustedStep` require `Copy`Scott McMurray-32/+128
All the implementations of the trait already are `Copy`, and this seems to be enough to simplify the implementations enough to make the MIR inliner willing to inline basics like `Range::next`.
2023-05-29Enable SeparateConstSwitch by default.Camille GILLOT-67/+32
2023-05-28Auto merge of #111813 - scottmcm:pretty-mir, r=cjgillotbors-750/+750
MIR: opt-in normalization of `BasicBlock` and `Local` numbering This doesn't matter at all for actual codegen, but after spending some time reading pre-codegen MIR, I was wishing I didn't have to jump around so much in reading post-inlining code. So this add two passes that are off by default for every mir level, but can be enabled (`-Zmir-enable-passes=+ReorderBasicBlocks,+ReorderLocals`) for humans.
2023-05-27Try enabling MatchBranchSimplificationBen Kimock-5/+42
2023-05-23Rollup merge of #111579 - scottmcm:enum-as-signed, r=oli-obkDylan DPC-15/+145
Also assume wrap-around discriminants in `as` MIR building Resolves this FIXME: https://github.com/rust-lang/rust/blob/8d18c32b61476ed16dd15074e71be3970368d6d7/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs#L231 r? `@oli-obk`
2023-05-23Rollup merge of #111501 - WaffleLapkin:drivebycleanupuwu, r=oli-obkDylan DPC-129/+72
MIR drive-by cleanups Some random drive-by cleanups I did while working with MIR/THIR.
2023-05-21Normalize block and local orders in mir-opt testsScott McMurray-750/+750
Since this only affects `PreCodegen MIR, and it would be nice for that to be resilient to permutations of things that don't affect the actual semantic behaviours.
2023-05-20Don't inline functions with unsized argsJakob Degen-0/+65
2023-05-19Drive-by-cleanup: Don't emit `thir::ExprKind::NeverToAny` for `! -> !`Maybe Waffle-129/+72
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-17Auto merge of #111568 - scottmcm:undo-opt, r=WaffleLapkinbors-139/+49
Stop turning transmutes into discriminant reads in mir-opt Partially reverts #109612, as after #109993 these aren't actually equivalent any more, and I'm no longer confident this was ever an improvement in the first place. Having this "simplification" meant that similar-looking code actually did somewhat different things. For example, ```rust pub unsafe fn demo1(x: std::cmp::Ordering) -> u8 { std::mem::transmute(x) } pub unsafe fn demo2(x: std::cmp::Ordering) -> i8 { std::mem::transmute(x) } ``` in nightly today is generating <https://rust.godbolt.org/z/dPK58zW18> ```llvm define noundef i8 `@_ZN7example5demo117h341ef313673d2ee6E(i8` noundef %x) unnamed_addr #0 { %0 = icmp uge i8 %x, -1 %1 = icmp ule i8 %x, 1 %2 = or i1 %0, %1 call void `@llvm.assume(i1` %2) ret i8 %x } define noundef i8 `@_ZN7example5demo217h5ad29f361a3f5700E(i8` noundef %0) unnamed_addr #0 { %x = alloca i8, align 1 store i8 %0, ptr %x, align 1 %1 = load i8, ptr %x, align 1, !range !2, !noundef !3 ret i8 %1 } ``` Which feels too different when the original code is essentially identical. --- Aside: that example is different *after* optimizations too: ```llvm define noundef i8 `@_ZN7example5demo117h341ef313673d2ee6E(i8` noundef returned %x) unnamed_addr #0 { %0 = add i8 %x, 1 %1 = icmp ult i8 %0, 3 tail call void `@llvm.assume(i1` %1) ret i8 %x } define noundef i8 `@_ZN7example5demo217h5ad29f361a3f5700E(i8` noundef returned %0) unnamed_addr #1 { ret i8 %0 } ``` so turning the `Transmute` into a `Discriminant` was arguably just making things worse, so leaving it alone instead -- and thus having less code in rustc -- seems clearly better.
2023-05-17Auto merge of #111630 - BoxyUwU:ty_const_debug_formatting, r=compiler-errorsbors-4/+4
debug format `Const`'s less verbosely Not user visible change only visible to people debugging const generics. Currently debug output for `ty::Const` is super verbose (even for `-Zverbose` lol), things like printing infer vars as `Infer(Var(?0c))` instead of just `?0c`, bound vars and placeholders not using `^0_1` or `!0_1` syntax respectively. With these changes its imo better but not perfect: `Const { ty: usize, kind: ^0_1 }` is still a lot for not much information. not entirely sure what to do about that so not dealing with it yet. Need to do formatting for `ConstKind::Expr` at some point too since rn it sucks (doesn't even print anything with `Display`) not gonna do that in this PR either. r? `@compiler-errors`
2023-05-16Auto merge of #111556 - cjgillot:copy-prop-nrvo, r=oli-obkbors-189/+561
Merge return place with other locals in CopyProp. This reintroduces a limited form of NRVO. r? wg-mir-opt
2023-05-16blessBoxy-4/+4
2023-05-15Address FIXMEAndy Wang-11/+6
2023-05-15Add CopyForDeref to custom MIRAndy Wang-0/+28
2023-05-14Stop turning transmutes into discriminants in mir-optScott McMurray-139/+49
Partially reverts 109612, as after 109993 these aren't actually equivalent any more, and I'm no longer confident this was ever an improvement in the first place.
2023-05-14Merge return place with other locals in CopyProp.Camille GILLOT-189/+561
2023-05-13Add multiple borrow test.Camille GILLOT-55/+81
2023-05-13Do not ICE on deeply nested borrows.Camille GILLOT-0/+13
2023-05-13Iterate ReferencePropagation to fixpoint.Camille GILLOT-398/+797
2023-05-13Add mir-opt test.Camille GILLOT-0/+173
2023-05-13Support ConstantIndex in debuginfo.Camille GILLOT-12/+3
2023-05-13Implement references VarDebugInfo.Camille GILLOT-334/+331
2023-05-12Remove useless `assume`s from `slice::iter(_mut)`Scott McMurray-59/+265
2023-05-12Rollup merge of #111441 - cjgillot:issue-111422, r=JakobDegenMatthias Krüger-4/+170
Verify copies of mutable pointers in 2 stages in ReferencePropagation Fixes #111422 In the first stage, we mark the copies as reborrows, to be checked later. In the second stage, we walk the reborrow chains to verify that all stages are fully replacable. The replacement itself mirrors the check, and iterates through the reborrow chain. r? ``````@RalfJung`````` cc ``````@JakobDegen``````
2023-05-11Bless tests for portable-simd syncJubilee Young-4/+4
API changes resulted in subtle MIR and impl differences