about summary refs log tree commit diff
path: root/src/test/mir-opt
AgeCommit message (Collapse)AuthorLines
2018-12-30Refactor `UserTypeAnnotation`.David Wood-1/+1
This commit refactors the `UserTypeAnnotation` type to be referred to by an index within `UserTypeProjection`. `UserTypeAnnotation` is instead kept in an `IndexVec` within the `Mir` struct. Further, instead of `UserTypeAnnotation` containing canonicalized types, it now contains normal types and the entire `UserTypeAnnotation` is canonicalized. To support this, the type was moved from the `rustc::mir` module to `rustc::ty` module.
2018-12-25Remove licensesMark Rousskov-319/+0
2018-12-20Auto merge of #54125 - varkor:less-conservative-uninhabitedness-check, ↡bors-0/+37
r=nikomatsakis Less conservative uninhabitedness check Extends the uninhabitedness check to structs, non-empty enums, tuples and arrays. Pulled out of #47291 and #50262. Fixes https://github.com/rust-lang/rust/issues/54586. r? @nikomatsakis
2018-12-18treat ref-to-raw cast like a reborrow: do a special kind of retagRalf Jung-1/+1
2018-12-17Auto merge of #56810 - sinkuu:build_match, r=oli-obkbors-0/+85
Improve MIR match generation for ranges Improves MIR match generation to rule out ranges/values distinct from the range that has been tested. e.g., for this code: ```rust match x { 0..=5 if b => 0, 6..=10 => 1, _ => 2, } ``` MIR (before): ```rust bb0: { ...; _4 = Le(const 0i32, _1); switchInt(move _4) -> [false: bb6, otherwise: bb5]; } bb1: { _3 = const 0i32; goto -> bb8; } bb2: { _6 = _2; switchInt(move _6) -> [false: bb6, otherwise: bb1]; } // If `!b`, jumps to test if `6 <= x <= 10`. bb3: { _3 = const 1i32; goto -> bb8; } bb4: { _3 = const 2i32; goto -> bb8; } bb5: { _5 = Le(_1, const 5i32); switchInt(move _5) -> [false: bb6, otherwise: bb2]; } bb6: { _7 = Le(const 6i32, _1); switchInt(move _7) -> [false: bb4, otherwise: bb7]; } bb7: { _8 = Le(_1, const 10i32); switchInt(move _8) -> [false: bb4, otherwise: bb3]; } ``` MIR (after): ```rust bb0: { ...; _4 = Le(const 0i32, _1); switchInt(move _4) -> [false: bb5, otherwise: bb6]; } bb1: { _3 = const 0i32; goto -> bb8; } bb2: { _6 = _2; switchInt(move _6) -> [false: bb4, otherwise: bb1]; } // If `!b`, jumps to `_ =>` arm. bb3: { _3 = const 1i32; goto -> bb8; } bb4: { _3 = const 2i32; goto -> bb8; } bb5: { _7 = Le(const 6i32, _1); switchInt(move _7) -> [false: bb4, otherwise: bb7]; } bb6: { _5 = Le(_1, const 5i32); switchInt(move _5) -> [false: bb5, otherwise: bb2]; } bb7: { _8 = Le(_1, const 10i32); switchInt(move _8) -> [false: bb4, otherwise: bb3]; } ``` cc #29623
2018-12-17tidyShotaro Yamada-1/+1
2018-12-17Add MIR testShotaro Yamada-0/+85
2018-12-13Make SimplifyCfg collapse goto chains from bb0Shotaro Yamada-0/+54
2018-12-11Add a mir-opt testvarkor-0/+37
2018-11-18Simplify MIR drop generationMatthew Jasper-34/+7
Now that EndRegion is gone, we don't need to create as many gotos.
2018-11-18Remove mir::StatementKind::EndRegionMatthew Jasper-1069/+1
Since lexical MIR borrow check is gone, and validation no longer uses these, they can be removed.
2018-11-15Auto merge of #55716 - RalfJung:escape-to-raw, r=oli-obkbors-4/+68
Add escape-to-raw MIR statement Add a new MIR "ghost state statement": Escaping a ptr to permit raw accesses. ~~This includes #55549, [click here](https://github.com/RalfJung/rust/compare/miri-visitor...RalfJung:escape-to-raw) for just the new commits.~~
2018-11-09Don't inline virtual calls (take 2)Wesley Wiser-0/+36
When I fixed the previous mis-optimizations, I didn't realize there were actually two different places where we mutate `callsites` and both of them should have the same behavior. As a result, if a function was inlined and that function contained virtual function calls, they were incorrectly being inlined. I also added a test case which covers this.
2018-11-07array index accesses are stable placesRalf Jung-0/+43
2018-11-07no more action on ref or cast, but add new MIR statement for escaping a ptr ↡Ralf Jung-4/+25
to raw
2018-11-02Auto merge of #55316 - RalfJung:retagging, r=oli-obkbors-349/+151
Add Retagging statements This adds a `Retag` statement kind to MIR, used to perform the retagging operation from [Stacked Borrows](https://www.ralfj.de/blog/2018/08/07/stacked-borrows.html). It also kills the old `Validate` statements that I added last year. NOTE: This includes https://github.com/rust-lang/rust/pull/55270. Only [these commits are new](https://github.com/RalfJung/rust/compare/stacked-borrows-ng...RalfJung:retagging).
2018-11-02Auto merge of #55305 - nikomatsakis:universes-refactor-3, r=scalexmbors-1/+1
universes refactor 3 Some more refactorings from my universe branch. These are getting a bit more "invasive" -- they start to plumb the universe information through the canonicalization process. As of yet though I don't **believe** this branch changes our behavior in any notable way, though I'm marking the branch as `WIP` to give myself a chance to verify this. r? @scalexm
2018-10-29make inliner remove the fn_entry flag on Retag statementsRalf Jung-0/+45
2018-10-29Remove validation test cases; add retagging test caseRalf Jung-349/+106
2018-10-28Rollup merge of #55199 - oli-obk:instance_printing, r=davidtwcokennytm-10/+10
Impl items have generics
2018-10-27allow canonicalized regions to carry universe and track max-universeNiko Matsakis-1/+1
But.. we don't really use it for anything right now.
2018-10-26Update mir-opt tests to reflect change to `AscribeUserType` to carry a ↡Felix S. Klock II-1/+1
`UserTypeProjection`.
2018-10-26Update testsOliver Scherer-10/+10
2018-10-26Fix tests and assertions; add some commentsNick Cameron-133/+133
2018-10-26Fix tests and rustdocNick Cameron-24/+24
2018-10-15fix mir-opt testNiko Matsakis-1/+1
2018-10-14[mir-inlining] Don't inline virtual callsWesley Wiser-0/+31
Prior to this change, the test case would output `1` instead of `2` like it should.
2018-10-10Use the span of the user type for `AscribeUserType`Matthew Jasper-1/+1
Also change the order of the fake read for let and the AscribeUserType, so that we use the better span and message from the fake read in errors.
2018-10-05Stabilize `min_const_fn`Oliver Schneider-4/+0
2018-09-25Auto merge of #53438 - matthewjasper:permissive-match-access, r=pnkfelixbors-81/+210
[NLL] Be more permissive when checking access due to Match Partially addresses #53114. notably, we should now have parity with AST borrowck. Matching on uninitialized values is still forbidden. * ~~Give fake borrows for match their own `BorrowKind`~~ * ~~Allow borrows with this kind to happen on values that are already mutably borrowed.~~ * ~~Track borrows with this type even behind shared reference dereferences and consider all accesses to be deep when checking for conflicts with this borrow type. See [src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.rs](https://github.com/rust-lang/rust/commit/cb5c989598178af505fb215dd97afca8cc2b659f#diff-a2126cd3263a1f5342e2ecd5e699fbc6) for an example soundness issue this fixes (a case of #27282 that wasn't handled correctly).~~ * Create a new `BorrowKind`: `Shallow` (name can be bike-shed) * `Shallow` borrows differ from shared borrows in that * When we check for access we treat them as a `Shallow(Some(_))` read * When we check for conflicts with them, if the borrow place is a strict prefix of the access place then we don't consider that a conflict. * For example, a `Shallow` borrow of `x` does not conflict with any access or borrow of `x.0` or `*x` * Remove the current fake borrow in matches. * When building matches, we take a `Shallow` borrow of any `Place` that we switch on or bind in a match, and any prefix of those places. (There are some optimizations where we do fewer borrows, but this shouldn't change semantics) * `match x { &Some(1) => (), _ => (), }` would `Shallow` borrow `x`, `*x` and `(*x as Some).0` (the `*x` borrow is unnecessary, but I'm not sure how easy it would be to remove.) * Replace the fake discriminant read with a `ReadForMatch`. * Change ReadForMatch to only check for initializedness (to prevent `let x: !; match x {}`), but not conflicting borrows. It is still considered a use for liveness and `unsafe` checking. * Give special cased error messages for this kind of borrow. Table from the above issue after this PR | Thing | AST | MIR | Want | Example | | --- | --- | --- | --- |---| | `let _ = <unsafe-field>` | πŸ’š | πŸ’š | ❌ | [playground](https://play.rust-lang.org/?gist=bb7843e42fa5318c1043d04bd72abfe4&version=nightly&mode=debug&edition=2015) | | `match <unsafe_field> { _ => () }` | ❌ | ❌ | ❌ | [playground](https://play.rust-lang.org/?gist=3e3af05fbf1fae28fab2aaf9412fb2ea&version=nightly&mode=debug&edition=2015) | | `let _ = <moved>` | πŸ’š | πŸ’š | πŸ’š | [playground](https://play.rust-lang.org/?gist=91a6efde8288558e584aaeee0a50558b&version=nightly&mode=debug&edition=2015) | | `match <moved> { _ => () }` | ❌ | ❌ | πŸ’š | [playground](https://play.rust-lang.org/?gist=804f8185040b2fe131f2c4a64b3048ca&version=nightly&mode=debug&edition=2015) | | `let _ = <borrowed>` | πŸ’š | πŸ’š | πŸ’š | [playground](https://play.rust-lang.org/?gist=0e487c2893b89cb772ec2f2b7c5da876&version=nightly&mode=debug&edition=2015) | | `match <borrowed> { _ => () }` | πŸ’š | πŸ’š | πŸ’š | [playground](https://play.rust-lang.org/?gist=0e487c2893b89cb772ec2f2b7c5da876&version=nightly&mode=debug&edition=2015) | r? @nikomatsakis
2018-09-24Update mir opt testsMatthew Jasper-81/+88
2018-09-24Add a MIR transform to remove fake readsMatthew Jasper-0/+122
As we are now creating borrows of places that may not be valid for borrow checking matches, these have to be removed to avoid generating broken code.
2018-09-24Auto merge of #54416 - christianpoveda:master, r=wesleywiserbors-0/+39
Extend MIR inlining to all operand variants This fixes https://github.com/rust-lang/rust/issues/54193 r? @eddyb
2018-09-23Add test to check if inlining works for any operandChristian Poveda-0/+39
2018-09-18Update mir-opt test suiteRémy Rakic-13/+48
2018-09-14Auto merge of #54032 - oli-obk:layout_scalar_ranges, r=eddybbors-7/+7
Add forever unstable attribute to allow specifying arbitrary scalar ranges r? @eddyb for the first commit and @nikomatsakis for the second one
2018-09-11Change debug printing to print in the old concise styleOliver Schneider-7/+7
2018-09-10optimize `let x: T = ..` to avoid a temporaryNiko Matsakis-87/+32
For some weird reason this fixes `intrinsic-move-val`. It also affects various test heuristics. I removed one test (`reborrow_basic`) that didn't seem to really be testing anything in particular anymore, compared to all the other tests we've got.
2018-09-10add the `AscribeUserType` statement kindNiko Matsakis-1/+1
Make it have the semantics of subtype.
2018-09-08Auto merge of #53909 - mikhail-m1:53643, r=nikomatsakisbors-6/+6
Skip a shared borrow of a immutable local variables issue #53643 r? @nikomatsakis
2018-09-06Fix testsWesley Wiser-1/+1
2018-09-06Skip a shared borrow of a immutable local variablesMikhail Modin-6/+6
issue #53643
2018-08-31Restrict most uses of `const_fn` to `min_const_fn`Oliver Schneider-2/+2
2018-08-31Implement the `min_const_fn` feature gateOliver Schneider-95/+57
2018-08-27merge `PointIndexMap` and `RegionValueElements`Niko Matsakis-9/+9
2018-07-26patch up mir-opt testsNiko Matsakis-14/+14
2018-07-23Update mir-opt to promoted changesOliver Schneider-10/+4
2018-07-21delete testsdylan_DPC-110/+0
2018-07-21remove unwanted tests and a reference to it in commentsdylan_DPC-134/+0
2018-07-13Auto merge of #52046 - cramertj:fix-generator-mir, r=eddybbors-1/+149
Ensure StorageDead is created even if variable initialization fails Rebase and slight cleanup of https://github.com/rust-lang/rust/pull/51109 Fixes https://github.com/rust-lang/rust/issues/49232 r? @eddyb