about summary refs log tree commit diff
path: root/src/test/mir-opt
AgeCommit message (Collapse)AuthorLines
2020-05-25Avoid `Operand::Copy` with `&mut T`Jonas Schievink-2/+2
2020-05-25Auto merge of #72520 - jonas-schievink:cleanup-userty, r=matthewjasperbors-16/+16
Clear MIR local type annotations after borrowck
2020-05-24Clear MIR local type annotations after borrowckJonas Schievink-16/+16
2020-05-23bless mir-opt testsRalf Jung-2/+2
2020-05-21Auto merge of #72205 - ecstatic-morse:nrvo, r=oli-obkbors-15/+54
Dumb NRVO This is a very simple version of an NRVO pass, which scans backwards from the `return` terminator to see if there is an an assignment like `_0 = _1`. If a basic block with two or more predecessors is encountered during this scan without first seeing an assignment to the return place, we bail out. This avoids running a full "reaching definitions" dataflow analysis. I wanted to see how much `rustc` would benefit from even a very limited version of this optimization. We should be able to use this as a point of comparison for more advanced versions that are based on live ranges. r? @ghost
2020-05-17Auto merge of #72135 - oli-obk:const_prop_deaggregates, r=wesleywiserbors-0/+165
Propagate locals, even if they have unpropagatable assignments somewhere Second try for https://github.com/rust-lang/rust/pull/71946#discussion_r422967292 r? @wesleywiser cc @rust-lang/wg-mir-opt @RalfJung
2020-05-16Bless mir-opt tests to account for #72220Wesley Wiser-4/+2
2020-05-16Add simple NRVO testDylan MacKenzie-0/+51
2020-05-16Bless MIR tests that inline functions qualifying for NRVODylan MacKenzie-15/+3
2020-05-14[const-prop] Don't replace Rvalues that are already constantsWesley Wiser-6/+4
2020-05-14Auto merge of #72187 - RalfJung:rollup-a7a9jdi, r=RalfJungbors-75/+75
Rollup of 12 pull requests Successful merges: - #71525 (`prefix` should not be mutable.) - #71741 (Pointer printing: do not print 0 offset) - #71870 (Be slightly more precise about any::type_name()'s guarantees.) - #71909 (Document From trait for Option implementations) - #71964 (Fix bootstrap failing on win32) - #72137 (Clean up E0581 explanation) - #72138 (Add doc comment for `rustc_middle::mir::mono::Linkage`) - #72150 (Remove UnnormalizedProjection) - #72151 (Update books) - #72163 (docs: remove comment referencing non-existent method) - #72169 (Clean up E0582 explanation) - #72183 (Fix Arc::decr_strong_count doc test) Failed merges: r? @ghost
2020-05-12Pointer printing: do not print 0 offsetRalf Jung-75/+75
2020-05-12Add some more sanity tests and add a debug log message for itOliver Scherer-0/+89
2020-05-12Propagate locals, even if they have unpropagatable assignments somewhere.Oliver Scherer-3/+12
2020-05-12Add a repro example for not propagating constants of partially const ↵Oliver Scherer-0/+69
initialized variables
2020-05-11Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1Wesley Wiser-32/+717
I also added test cases to make sure the optimization can fire on all of these cases: ```rust fn case_1(o: Option<u8>) -> Option<u8> { match o { Some(u) => Some(u), None => None, } } fn case2(r: Result<u8, i32>) -> Result<u8, i32> { match r { Ok(u) => Ok(u), Err(i) => Err(i), } } fn case3(r: Result<u8, i32>) -> Result<u8, i32> { let u = r?; Ok(u) } ``` Without MIR inlining, this still does not completely optimize away the `?` operator because the `Try::into_result()`, `From::from()` and `Try::from_error()` calls still exist. This does move us a bit closer to that goal though because: - We can now run the pass on mir-opt-level=1 - We no longer depend on the copy propagation pass running which is unlikely to stabilize anytime soon.
2020-05-11Auto merge of #71953 - oli-obk:const_prop_deaggregates, r=wesleywiserbors-0/+284
Const prop aggregates even if partially or fully modified r? @wesleywiser cc @rust-lang/wg-mir-opt I'm moderately scared of this change, but I'm confident in having reviewed all the cases.
2020-05-09Bless mir-opt testsMatthew Jasper-974/+820
2020-05-07Renamed "undef" stuff to "uninit"Hanif Bin Ariffin-28/+28
1. InvalidUndefBytes -> InvalidUninitBytes 2. ScalarMaybeUndef -> ScalarMaybeUninit 3. UndefMask -> InitMask Related issue #71193
2020-05-06Const prop aggregates even if partially or fully modifiedOliver Scherer-0/+284
2020-05-04Rollup merge of #71697 - felix91gr:new_prop_into_fn_call, r=wesleywiserDylan DPC-5/+30
Added MIR constant propagation of Scalars into function call arguments Now for the function call arguments! Caveats: 1. It's only being enabled at `mir-opt-2` or higher, because currently codegen gives performance regressions with this optimization. 2. Only propagates Scalars. Tuples and references (references are `Indirect`, right??) are not being propagated into as of this PR. 3. Maybe more tests would be nice? 4. I need (shamefully) to ask @wesleywiser to write in his words (or explain to me, and then I can write it down) why we want to ignore propagation into `ScalarPairs` and `Indirect` arguments. r? @wesleywiser
2020-05-02Added MIR constant propagation of Scalars into function call argumentsFélix Fischer-5/+30
- Documented rationale of current solution - Polished documentation
2020-04-30Rollup merge of #71590 - RalfJung:mir-dump-pointers, r=oli-obkTyler Mandry-36/+36
MIR dump: print pointers consistently with Miri output This makes MIR allocation dump pointer printing consistent with Miri output: both use hexadecimal offsets with a `0x` prefix. To save some space, MIR dump replaces the `alloc` prefix by `a` when necessary. I also made AllocId/Pointer printing more consistent in their Debug/Display handling, and adjusted Display printing for Scalar a bit to avoid using decimal printing when we do not know the sign with which to interpret the value (IMO using decimal then is misleading).
2020-04-30Rollup merge of #70950 - nikomatsakis:leak-check-nll-2, r=matthewjasperDylan DPC-161/+167
extend NLL checker to understand `'empty` combined with universes This PR extends the NLL region checker to understand `'empty` combined with universes. In particular, it means that the NLL region checker no longer considers `exists<R2> { forall<R1> { R1: R2 } }` to be provable. This is work towards https://github.com/rust-lang/rust/issues/59490, but we're not all the way there. One thing in particular it does not address is error messages. The modifications to the NLL region inference code turned out to be simpler than expected. The main change is to require that if `R1: R2` then `universe(R1) <= universe(R2)`. This constraint follows from the region lattice (shown below), because we assume then that `R2` is "at least" `empty(Universe(R2))`, and hence if `R1: R2` (i.e., `R1 >= R2` on the lattice) then `R1` must be in some universe that can name `'empty(Universe(R2))`, which requires that `Universe(R1) <= Universe(R2)`. ``` static ----------+-----...------+ (greatest) | | | early-bound and | | free regions | | | | | scope regions | | | | | empty(root) placeholder(U1) | | / | | / placeholder(Un) empty(U1) -- / | / ... / | / empty(Un) -------- (smallest) ``` I also made what turned out to be a somewhat unrelated change to add a special region to represent `'empty(U0)`, which we use (somewhat hackily) to indicate well-formedness checks in some parts of the compiler. This fixes #68550. I did some investigation into fixing the error message situation. That's a bit trickier: the existing "nice region error" code around placeholders relies on having better error tracing than NLL currently provides, so that it knows (e.g.) that the constraint arose from applying a trait impl and things like that. I feel like I was hoping *not* to do such fine-grained tracing in NLL, and it seems like we...largely...got away with that. I'm not sure yet if we'll have to add more tracing information or if there is some sort of alternative. It's worth pointing out though that I've not kind of shifted my opinion on whose job it should be to enforce lifetimes: I tend to think we ought to be moving back towards *something like* the leak-check (just not the one we *had*). If we took that approach, it would actually resolve this aspect of the error message problem, because we would be resolving 'higher-ranked errors' in the trait solver itself, and hence we wouldn't have to thread as much causal information back to the region checker. I think it would also help us with removing the leak check while not breaking some of the existing crates out there. Regardless, I think it's worth landing this change, because it was relatively simple and it aligns the set of programs that NLL accepts with those that are accepted by the main region checker, and hence should at least *help* us in migration (though I guess we still also have to resolve the existing crates that rely on leak check for coherence). r? @matthewjasper
2020-04-30Auto merge of #70175 - Amanieu:remove_nlp, r=pnkfelixbors-42/+43
Remove -Z no-landing-pads flag Since #67502, `-Z no-landing-pads` will cause all attempted unwinds to abort since we don't generate a `try` / `catch`. This previously worked because `__rust_try` was located in libpanic_unwind which is always compiled with `-C panic=unwind`, but `__rust_try` is now directly inline into the crate that uses `catch_unwind`. As such, `-Z no-landing-pads` is now mostly useless and people should use `-C panic=abort` instead.
2020-04-29Fix testAmanieu d'Antras-41/+42
2020-04-29Remove -Z no-landing-pads flagAmanieu d'Antras-1/+1
2020-04-28Changed `simplify_match` output query because it had become outdatedFélix Fischer-11/+19
2020-04-28Added MIR const-prop diff tests to show why some assertions now fail at ↵Félix Fischer-0/+421
compile-time
2020-04-28Allow Locals to be propagated into and from, but restricted to their own blockFélix Fischer-16/+148
2020-04-27Added regression test for literal propagation and for scalar pair propagationFélix Fischer-0/+121
2020-04-27Emit basic block ids for statements and terminators in MIR only in -Zverbose ↵Oliver Scherer-3062/+2999
mode
2020-04-26print pointers more compactly when they are too bigRalf Jung-17/+17
2020-04-26sync alloc dump and pointer printingRalf Jung-36/+36
2020-04-26check that `AsRef` and `AsMut` are inlinedBastian Kauschke-0/+139
2020-04-25Rollup merge of #71494 - flip1995:while_let_span, r=petrochenkovDylan DPC-2/+2
Fix span of while (let) expressions after lowering Credit goes to @alex-700 who found this while trying to fix a suggestion in Clippy. While `if`, `try`, `for` and `await` expressions get the span of the original expression when desugared, `while` loops got the span of the scrutinee, which lead to weird code, when building the suggestion, that randomly worked: https://github.com/rust-lang/rust-clippy/pull/5511/files#diff-df4e9d2bf840a5f2e3b580bef73da3bcR106-R108 I'm wondering, if `DesugaringKind` should get a variant `WhileLoop` and instead of using the span of the `ast::ExprKind::While` expr directly, a new span with `self.mark_span_with_reason` should be used, like it is done with `for` loops. There was some fallout, but I think that is acceptable. If not, I need some help to find out where this can be fixed.
2020-04-24Auto merge of #70820 - spastorino:replace-fragile-erroneous-const-sys, r=oli-obkbors-54/+45
Replace fragile erroneous const sys Closes #67191 r? @oli-obk
2020-04-24Rollup merge of #71459 - divergentdave:pointer-offset-0x, r=RalfJungDylan DPC-38/+38
Add leading 0x to offset in Debug fmt of Pointer Currently the `Debug` format for `Pointer` prints its offset in hexadecimal, for example, `alloc38657819+e2` or `alloc35122748+64`. This PR adds a leading `0x` to the offset, in order to make it apparent that it is indeed a hexadecimal number. This came up during discussion of rust-lang/miri#1354. r? @RalfJung
2020-04-24update_testsflip1995-2/+2
2020-04-23Adjust name of never typed const testSantiago Pastorino-4/+5
2020-04-23Bless mir-opt testsSantiago Pastorino-42/+32
2020-04-23Add leading 0x to offset in Debug fmt of PointerDavid Cook-38/+38
2020-04-21update ref testNiko Matsakis-71/+72
2020-04-20Bless 32-bit test outputJonas Schievink-15/+15
2020-04-20Fix codegen and mir-opt testsJonas Schievink-16/+16
Mostly renamed allocations, but I'm not sure about the const prop tests
2020-04-20Auto merge of #71232 - eddyb:print-const-adts, r=oli-obkbors-35/+35
ty/print: pretty-print constant aggregates (arrays, tuples and ADTs). Oddly enough, we don't have any UI tests showing this off in types, only `mir-opt` tests. However, the pretty form should show up in the test output diff of #71018, if this PR is merged first. <hr/> Examples of before/after: |`Option<bool>`| |:-:| |`{transmute(0x01): std::option::Option<bool>}`| | :sparkles: ↓↓↓ :sparkles: | |`std::option::Option::<bool>::Some(true)`| | `RawVec<u32>` | |:-:| | `ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }: alloc::raw_vec::RawVec::<u32>`| | :sparkles: ↓↓↓ :sparkles: | |`alloc::raw_vec::RawVec::<u32> { ptr: std::ptr::Unique::<u32> { pointer: {0x4 as *const u32}, _marker: std::marker::PhantomData::<u32> }, cap: 0usize, alloc: std::alloc::Global }`| <hr/> This PR is a prerequisite for #61486, *sort of*, in that we need to be able to pretty-print values in order to even consider how we might mangle them. We still don't have pretty-printing for constants of reference types, @oli-obk has the necessary support logic in a PR but I didn't want to interfere with that. <hr/> Each commit should be reviewed separately, as I've fixed a couple deficiencies along the way. r? @oli-obk cc @rust-lang/wg-mir-opt @varkor @yodaldevoid
2020-04-17Ignore generator-drop-cleanup on wasm32-bareJonas Schievink-31/+33
2020-04-17Adjust mir-opt test and make it drop somethingJonas Schievink-26/+54
2020-04-17ty/print: pretty-print constant aggregates (arrays, tuples and ADTs).Eduard-Mihai Burtescu-8/+8
2020-04-17mir: pretty-print `Rvalue::Aggregate` correctly.Eduard-Mihai Burtescu-27/+27