Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
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-12 00:13:15 +00:00
|
|
|
- // MIR for `<impl at $DIR/simplify_try_if_let.rs:15:1: 34:2>::append` before SimplifyArmIdentity
|
|
|
|
+ // MIR for `<impl at $DIR/simplify_try_if_let.rs:15:1: 34:2>::append` after SimplifyArmIdentity
|
|
|
|
|
|
|
|
fn <impl at $DIR/simplify_try_if_let.rs:15:1: 34:2>::append(_1: &mut LinkedList, _2: &mut LinkedList) -> () {
|
|
|
|
debug self => _1; // in scope 0 at $DIR/simplify_try_if_let.rs:20:19: 20:28
|
|
|
|
debug other => _2; // in scope 0 at $DIR/simplify_try_if_let.rs:20:30: 20:35
|
|
|
|
let mut _0: (); // return place in scope 0 at $DIR/simplify_try_if_let.rs:20:48: 20:48
|
|
|
|
let mut _3: isize; // in scope 0 at $DIR/simplify_try_if_let.rs:22:13: 22:17
|
|
|
|
let mut _4: std::ptr::NonNull<Node>; // in scope 0 at $DIR/simplify_try_if_let.rs:23:18: 23:26
|
|
|
|
let mut _5: std::option::Option<std::ptr::NonNull<Node>>; // in scope 0 at $DIR/simplify_try_if_let.rs:26:43: 26:60
|
|
|
|
let mut _6: &mut std::option::Option<std::ptr::NonNull<Node>>; // in scope 0 at $DIR/simplify_try_if_let.rs:26:43: 26:53
|
|
|
|
let mut _7: isize; // in scope 0 at $DIR/simplify_try_if_let.rs:26:24: 26:40
|
|
|
|
let mut _9: std::option::Option<std::ptr::NonNull<Node>>; // in scope 0 at $DIR/simplify_try_if_let.rs:28:46: 28:62
|
|
|
|
let mut _10: std::ptr::NonNull<Node>; // in scope 0 at $DIR/simplify_try_if_let.rs:28:51: 28:61
|
|
|
|
let mut _11: &mut Node; // in scope 0 at $DIR/simplify_try_if_let.rs:28:25: 28:38
|
|
|
|
let mut _12: &mut std::ptr::NonNull<Node>; // in scope 0 at $DIR/simplify_try_if_let.rs:28:25: 28:29
|
|
|
|
scope 1 {
|
|
|
|
debug tail => _4; // in scope 1 at $DIR/simplify_try_if_let.rs:23:18: 23:26
|
|
|
|
let _8: std::ptr::NonNull<Node>; // in scope 1 at $DIR/simplify_try_if_let.rs:26:29: 26:39
|
|
|
|
scope 2 {
|
2020-09-04 01:15:50 +00:00
|
|
|
- debug other_head => _8; // in scope 2 at $DIR/simplify_try_if_let.rs:26:29: 26:39
|
|
|
|
+ debug other_head => ((_9 as Some).0: std::ptr::NonNull<Node>); // in scope 2 at $DIR/simplify_try_if_let.rs:26:29: 26:39
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
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-12 00:13:15 +00:00
|
|
|
scope 3 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bb0: {
|
|
|
|
_3 = discriminant(((*_1).1: std::option::Option<std::ptr::NonNull<Node>>)); // scope 0 at $DIR/simplify_try_if_let.rs:22:13: 22:17
|
2020-06-19 16:57:15 +00:00
|
|
|
switchInt(move _3) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_try_if_let.rs:22:13: 22:17
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
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-12 00:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bb1: {
|
|
|
|
StorageLive(_4); // scope 0 at $DIR/simplify_try_if_let.rs:23:18: 23:26
|
|
|
|
_4 = ((((*_1).1: std::option::Option<std::ptr::NonNull<Node>>) as Some).0: std::ptr::NonNull<Node>); // scope 0 at $DIR/simplify_try_if_let.rs:23:18: 23:26
|
|
|
|
StorageLive(_5); // scope 1 at $DIR/simplify_try_if_let.rs:26:43: 26:60
|
|
|
|
StorageLive(_6); // scope 1 at $DIR/simplify_try_if_let.rs:26:43: 26:53
|
|
|
|
_6 = &mut ((*_2).0: std::option::Option<std::ptr::NonNull<Node>>); // scope 1 at $DIR/simplify_try_if_let.rs:26:43: 26:53
|
2020-09-02 07:40:56 +00:00
|
|
|
_5 = Option::<NonNull<Node>>::take(move _6) -> bb4; // scope 1 at $DIR/simplify_try_if_let.rs:26:43: 26:60
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
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-12 00:13:15 +00:00
|
|
|
// mir::Constant
|
|
|
|
// + span: $DIR/simplify_try_if_let.rs:26:54: 26:58
|
|
|
|
// + literal: Const { ty: for<'r> fn(&'r mut std::option::Option<std::ptr::NonNull<Node>>) -> std::option::Option<std::ptr::NonNull<Node>> {std::option::Option::<std::ptr::NonNull<Node>>::take}, val: Value(Scalar(<ZST>)) }
|
|
|
|
}
|
|
|
|
|
|
|
|
bb2: {
|
|
|
|
unreachable; // scope 0 at $DIR/simplify_try_if_let.rs:21:15: 21:24
|
|
|
|
}
|
|
|
|
|
|
|
|
bb3: {
|
|
|
|
_0 = const (); // scope 0 at $DIR/simplify_try_if_let.rs:22:21: 22:24
|
|
|
|
goto -> bb9; // scope 0 at $DIR/simplify_try_if_let.rs:21:9: 32:10
|
|
|
|
}
|
|
|
|
|
|
|
|
bb4: {
|
|
|
|
StorageDead(_6); // scope 1 at $DIR/simplify_try_if_let.rs:26:59: 26:60
|
|
|
|
_7 = discriminant(_5); // scope 1 at $DIR/simplify_try_if_let.rs:26:24: 26:40
|
2020-06-19 16:57:15 +00:00
|
|
|
switchInt(move _7) -> [1_isize: bb6, otherwise: bb5]; // scope 1 at $DIR/simplify_try_if_let.rs:26:24: 26:40
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
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-12 00:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bb5: {
|
|
|
|
_0 = const (); // scope 1 at $DIR/simplify_try_if_let.rs:26:17: 30:18
|
|
|
|
goto -> bb8; // scope 1 at $DIR/simplify_try_if_let.rs:26:17: 30:18
|
|
|
|
}
|
|
|
|
|
|
|
|
bb6: {
|
|
|
|
StorageLive(_8); // scope 1 at $DIR/simplify_try_if_let.rs:26:29: 26:39
|
|
|
|
_8 = ((_5 as Some).0: std::ptr::NonNull<Node>); // scope 1 at $DIR/simplify_try_if_let.rs:26:29: 26:39
|
|
|
|
StorageLive(_9); // scope 3 at $DIR/simplify_try_if_let.rs:28:46: 28:62
|
2020-09-04 01:15:50 +00:00
|
|
|
- StorageLive(_10); // scope 3 at $DIR/simplify_try_if_let.rs:28:51: 28:61
|
|
|
|
- _10 = _8; // scope 3 at $DIR/simplify_try_if_let.rs:28:51: 28:61
|
|
|
|
- ((_9 as Some).0: std::ptr::NonNull<Node>) = move _10; // scope 3 at $DIR/simplify_try_if_let.rs:28:46: 28:62
|
|
|
|
- discriminant(_9) = 1; // scope 3 at $DIR/simplify_try_if_let.rs:28:46: 28:62
|
|
|
|
- StorageDead(_10); // scope 3 at $DIR/simplify_try_if_let.rs:28:61: 28:62
|
|
|
|
+ _9 = move _5; // scope 3 at $DIR/simplify_try_if_let.rs:28:46: 28:62
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
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-12 00:13:15 +00:00
|
|
|
StorageLive(_11); // scope 3 at $DIR/simplify_try_if_let.rs:28:25: 28:38
|
|
|
|
StorageLive(_12); // scope 3 at $DIR/simplify_try_if_let.rs:28:25: 28:29
|
|
|
|
_12 = &mut _4; // scope 3 at $DIR/simplify_try_if_let.rs:28:25: 28:29
|
2020-09-02 07:40:56 +00:00
|
|
|
_11 = NonNull::<Node>::as_mut(move _12) -> bb7; // scope 3 at $DIR/simplify_try_if_let.rs:28:25: 28:38
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
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-12 00:13:15 +00:00
|
|
|
// mir::Constant
|
|
|
|
// + span: $DIR/simplify_try_if_let.rs:28:30: 28:36
|
|
|
|
// + literal: Const { ty: for<'r> unsafe fn(&'r mut std::ptr::NonNull<Node>) -> &'r mut Node {std::ptr::NonNull::<Node>::as_mut}, val: Value(Scalar(<ZST>)) }
|
|
|
|
}
|
|
|
|
|
|
|
|
bb7: {
|
|
|
|
StorageDead(_12); // scope 3 at $DIR/simplify_try_if_let.rs:28:37: 28:38
|
|
|
|
((*_11).0: std::option::Option<std::ptr::NonNull<Node>>) = move _9; // scope 3 at $DIR/simplify_try_if_let.rs:28:25: 28:62
|
|
|
|
StorageDead(_9); // scope 3 at $DIR/simplify_try_if_let.rs:28:61: 28:62
|
|
|
|
StorageDead(_11); // scope 3 at $DIR/simplify_try_if_let.rs:28:62: 28:63
|
|
|
|
_0 = const (); // scope 3 at $DIR/simplify_try_if_let.rs:27:21: 29:22
|
|
|
|
StorageDead(_8); // scope 1 at $DIR/simplify_try_if_let.rs:30:17: 30:18
|
|
|
|
goto -> bb8; // scope 1 at $DIR/simplify_try_if_let.rs:26:17: 30:18
|
|
|
|
}
|
|
|
|
|
|
|
|
bb8: {
|
|
|
|
StorageDead(_5); // scope 1 at $DIR/simplify_try_if_let.rs:31:13: 31:14
|
2020-07-07 14:50:49 +00:00
|
|
|
StorageDead(_4); // scope 0 at $DIR/simplify_try_if_let.rs:31:13: 31:14
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
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-12 00:13:15 +00:00
|
|
|
goto -> bb9; // scope 0 at $DIR/simplify_try_if_let.rs:21:9: 32:10
|
|
|
|
}
|
|
|
|
|
|
|
|
bb9: {
|
|
|
|
return; // scope 0 at $DIR/simplify_try_if_let.rs:33:6: 33:6
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|