Skip to content

Commit 6e5b3ec

Browse files
committed
slightly less trivial blessings
some optimization is behaving slightly differently on box derefs after this change, but the difference is irrelevant
1 parent 7e17cf1 commit 6e5b3ec

6 files changed

+48
-50
lines changed

tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-unwind.diff

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
let _3: std::boxed::Box<()>;
99
let mut _6: *const ();
1010
let mut _8: *const [()];
11-
let mut _9: std::boxed::Box<()>;
12-
let mut _10: *const ();
13-
let mut _11: usize;
11+
let mut _9: *const ();
12+
let mut _10: usize;
13+
let mut _11: std::ptr::NonNull<()>;
1414
scope 1 {
1515
debug vp_ctx => _1;
1616
let _4: *const ();
1717
scope 2 {
18-
debug slf => _10;
18+
debug slf => _9;
1919
let _5: *const [()];
2020
scope 3 {
2121
debug bytes => _5;
@@ -45,26 +45,25 @@
4545
_1 = copy _2;
4646
StorageDead(_2);
4747
StorageLive(_4);
48-
- _9 = deref_copy _3;
49-
+ _9 = copy _3;
50-
_10 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute);
51-
_4 = copy _10;
48+
_11 = copy ((_3.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>);
49+
_9 = copy _11 as *const () (Transmute);
50+
_4 = copy _9;
5251
- StorageLive(_5);
5352
+ nop;
5453
StorageLive(_6);
5554
- _6 = copy _4;
56-
+ _6 = copy _10;
57-
StorageLive(_11);
58-
_11 = const 1_usize;
59-
- _5 = *const [()] from (copy _6, copy _11);
60-
+ _5 = *const [()] from (copy _10, const 1_usize);
61-
StorageDead(_11);
55+
+ _6 = copy _9;
56+
StorageLive(_10);
57+
_10 = const 1_usize;
58+
- _5 = *const [()] from (copy _6, copy _10);
59+
+ _5 = *const [()] from (copy _9, const 1_usize);
60+
StorageDead(_10);
6261
StorageDead(_6);
6362
StorageLive(_7);
6463
StorageLive(_8);
6564
_8 = copy _5;
6665
- _7 = copy _8 as *mut () (PtrToPtr);
67-
+ _7 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *mut () (Transmute);
66+
+ _7 = copy _11 as *mut () (Transmute);
6867
StorageDead(_8);
6968
StorageDead(_7);
7069
- StorageDead(_5);

tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-unwind.diff

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
let _3: std::boxed::Box<()>;
99
let mut _6: *const ();
1010
let mut _8: *const [()];
11-
let mut _9: std::boxed::Box<()>;
12-
let mut _10: *const ();
13-
let mut _11: usize;
11+
let mut _9: *const ();
12+
let mut _10: usize;
13+
let mut _11: std::ptr::NonNull<()>;
1414
scope 1 {
1515
debug vp_ctx => _1;
1616
let _4: *const ();
1717
scope 2 {
18-
debug slf => _10;
18+
debug slf => _9;
1919
let _5: *const [()];
2020
scope 3 {
2121
debug bytes => _5;
@@ -45,26 +45,25 @@
4545
_1 = copy _2;
4646
StorageDead(_2);
4747
StorageLive(_4);
48-
- _9 = deref_copy _3;
49-
+ _9 = copy _3;
50-
_10 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute);
51-
_4 = copy _10;
48+
_11 = copy ((_3.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>);
49+
_9 = copy _11 as *const () (Transmute);
50+
_4 = copy _9;
5251
- StorageLive(_5);
5352
+ nop;
5453
StorageLive(_6);
5554
- _6 = copy _4;
56-
+ _6 = copy _10;
57-
StorageLive(_11);
58-
_11 = const 1_usize;
59-
- _5 = *const [()] from (copy _6, copy _11);
60-
+ _5 = *const [()] from (copy _10, const 1_usize);
61-
StorageDead(_11);
55+
+ _6 = copy _9;
56+
StorageLive(_10);
57+
_10 = const 1_usize;
58+
- _5 = *const [()] from (copy _6, copy _10);
59+
+ _5 = *const [()] from (copy _9, const 1_usize);
60+
StorageDead(_10);
6261
StorageDead(_6);
6362
StorageLive(_7);
6463
StorageLive(_8);
6564
_8 = copy _5;
6665
- _7 = copy _8 as *mut () (PtrToPtr);
67-
+ _7 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *mut () (Transmute);
66+
+ _7 = copy _11 as *mut () (Transmute);
6867
StorageDead(_8);
6968
StorageDead(_7);
7069
- StorageDead(_5);

tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
let mut _4: I;
1010
+ scope 1 (inlined <Box<dyn FnMut<I, Output = ()>> as FnMut<I>>::call_mut) {
1111
+ let mut _5: &mut dyn std::ops::FnMut<I, Output = ()>;
12-
+ let mut _6: std::boxed::Box<dyn std::ops::FnMut<I, Output = ()>>;
13-
+ let mut _7: *const dyn std::ops::FnMut<I, Output = ()>;
12+
+ let mut _6: *const dyn std::ops::FnMut<I, Output = ()>;
13+
+ let mut _7: std::ptr::NonNull<dyn std::ops::FnMut<I, Output = ()>>;
1414
+ }
1515

1616
bb0: {
@@ -22,9 +22,9 @@
2222
+ StorageLive(_6);
2323
+ StorageLive(_7);
2424
+ StorageLive(_5);
25-
+ _6 = copy (*_3);
26-
+ _7 = copy ((_6.0: std::ptr::Unique<dyn std::ops::FnMut<I, Output = ()>>).0: std::ptr::NonNull<dyn std::ops::FnMut<I, Output = ()>>) as *const dyn std::ops::FnMut<I, Output = ()> (Transmute);
27-
+ _5 = &mut (*_7);
25+
+ _7 = copy (((*_3).0: std::ptr::Unique<dyn std::ops::FnMut<I, Output = ()>>).0: std::ptr::NonNull<dyn std::ops::FnMut<I, Output = ()>>);
26+
+ _6 = copy _7 as *const dyn std::ops::FnMut<I, Output = ()> (Transmute);
27+
+ _5 = &mut (*_6);
2828
+ _0 = <dyn FnMut<I, Output = ()> as FnMut<I>>::call_mut(move _5, move _4) -> [return: bb4, unwind: bb2];
2929
}
3030

tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
let mut _4: (i32,);
1010
+ scope 1 (inlined <Box<dyn Fn(i32)> as Fn<(i32,)>>::call) {
1111
+ let mut _5: &dyn std::ops::Fn(i32);
12-
+ let mut _6: std::boxed::Box<dyn std::ops::Fn(i32)>;
13-
+ let mut _7: *const dyn std::ops::Fn(i32);
12+
+ let mut _6: *const dyn std::ops::Fn(i32);
13+
+ let mut _7: std::ptr::NonNull<dyn std::ops::Fn(i32)>;
1414
+ }
1515

1616
bb0: {
@@ -23,9 +23,9 @@
2323
+ StorageLive(_6);
2424
+ StorageLive(_7);
2525
+ StorageLive(_5);
26-
+ _6 = copy (*_3);
27-
+ _7 = copy ((_6.0: std::ptr::Unique<dyn std::ops::Fn(i32)>).0: std::ptr::NonNull<dyn std::ops::Fn(i32)>) as *const dyn std::ops::Fn(i32) (Transmute);
28-
+ _5 = &(*_7);
26+
+ _7 = copy (((*_3).0: std::ptr::Unique<dyn std::ops::Fn(i32)>).0: std::ptr::NonNull<dyn std::ops::Fn(i32)>);
27+
+ _6 = copy _7 as *const dyn std::ops::Fn(i32) (Transmute);
28+
+ _5 = &(*_6);
2929
+ _2 = <dyn Fn(i32) as Fn<(i32,)>>::call(move _5, move _4) -> [return: bb4, unwind: bb2];
3030
}
3131

tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ fn b(_1: &mut Box<T>) -> &mut T {
88
let mut _4: &mut std::boxed::Box<T>;
99
scope 1 (inlined <Box<T> as AsMut<T>>::as_mut) {
1010
debug self => _4;
11-
let mut _5: std::boxed::Box<T>;
12-
let mut _6: *const T;
11+
let mut _5: *const T;
12+
let mut _6: std::ptr::NonNull<T>;
1313
}
1414

1515
bb0: {
@@ -19,9 +19,9 @@ fn b(_1: &mut Box<T>) -> &mut T {
1919
_4 = copy _1;
2020
StorageLive(_5);
2121
StorageLive(_6);
22-
_5 = copy (*_4);
23-
_6 = copy ((_5.0: std::ptr::Unique<T>).0: std::ptr::NonNull<T>) as *const T (Transmute);
24-
_3 = &mut (*_6);
22+
_6 = copy (((*_4).0: std::ptr::Unique<T>).0: std::ptr::NonNull<T>);
23+
_5 = copy _6 as *const T (Transmute);
24+
_3 = &mut (*_5);
2525
StorageDead(_6);
2626
StorageDead(_5);
2727
_2 = copy _3;

tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ fn d(_1: &Box<T>) -> &T {
77
let mut _3: &std::boxed::Box<T>;
88
scope 1 (inlined <Box<T> as AsRef<T>>::as_ref) {
99
debug self => _3;
10-
let mut _4: std::boxed::Box<T>;
11-
let mut _5: *const T;
10+
let mut _4: *const T;
11+
let mut _5: std::ptr::NonNull<T>;
1212
}
1313

1414
bb0: {
@@ -17,9 +17,9 @@ fn d(_1: &Box<T>) -> &T {
1717
_3 = copy _1;
1818
StorageLive(_4);
1919
StorageLive(_5);
20-
_4 = copy (*_3);
21-
_5 = copy ((_4.0: std::ptr::Unique<T>).0: std::ptr::NonNull<T>) as *const T (Transmute);
22-
_2 = &(*_5);
20+
_5 = copy (((*_3).0: std::ptr::Unique<T>).0: std::ptr::NonNull<T>);
21+
_4 = copy _5 as *const T (Transmute);
22+
_2 = &(*_4);
2323
StorageDead(_5);
2424
StorageDead(_4);
2525
_0 = copy _2;

0 commit comments

Comments
 (0)