Skip to content

Commit 3a50c1a

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 33cc778 commit 3a50c1a

11 files changed

+116
-269
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-abort.diff

Lines changed: 23 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -8,171 +8,74 @@
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 _23: 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;
2222
let _7: *mut ();
2323
scope 4 {
2424
debug _x => _7;
2525
}
26-
scope 18 (inlined foo) {
26+
scope 7 (inlined foo) {
2727
}
2828
}
29-
scope 16 (inlined slice_from_raw_parts::<()>) {
30-
scope 17 (inlined std::ptr::from_raw_parts::<[()], ()>) {
29+
scope 5 (inlined slice_from_raw_parts::<()>) {
30+
scope 6 (inlined std::ptr::from_raw_parts::<[()], ()>) {
3131
}
3232
}
3333
}
3434
}
35-
scope 5 (inlined Box::<()>::new) {
36-
let mut _11: usize;
37-
let mut _12: usize;
38-
let mut _13: *mut u8;
39-
scope 6 (inlined alloc::alloc::exchange_malloc) {
40-
let _14: std::alloc::Layout;
41-
let mut _15: std::result::Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError>;
42-
let mut _16: isize;
43-
let mut _18: !;
44-
scope 7 {
45-
let _17: std::ptr::NonNull<[u8]>;
46-
scope 8 {
47-
scope 11 (inlined NonNull::<[u8]>::as_mut_ptr) {
48-
scope 12 (inlined NonNull::<[u8]>::as_non_null_ptr) {
49-
scope 13 (inlined NonNull::<[u8]>::cast::<u8>) {
50-
let mut _22: *mut [u8];
51-
scope 14 (inlined NonNull::<[u8]>::as_ptr) {
52-
}
53-
}
54-
}
55-
scope 15 (inlined NonNull::<u8>::as_ptr) {
56-
}
57-
}
58-
}
59-
scope 10 (inlined <std::alloc::Global as Allocator>::allocate) {
60-
}
61-
}
62-
scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) {
63-
let mut _19: bool;
64-
let _20: ();
65-
let mut _21: std::ptr::Alignment;
66-
}
67-
}
68-
}
6935

7036
bb0: {
7137
StorageLive(_1);
7238
StorageLive(_2);
7339
StorageLive(_3);
74-
StorageLive(_11);
75-
StorageLive(_12);
76-
StorageLive(_13);
77-
- _11 = SizeOf(());
78-
- _12 = AlignOf(());
79-
+ _11 = const 0_usize;
80-
+ _12 = const 1_usize;
81-
StorageLive(_14);
82-
StorageLive(_16);
83-
StorageLive(_17);
84-
StorageLive(_19);
85-
_19 = const false;
86-
- switchInt(move _19) -> [0: bb6, otherwise: bb5];
87-
+ switchInt(const false) -> [0: bb6, otherwise: bb5];
40+
_3 = Box::<()>::new(const ()) -> [return: bb1, unwind unreachable];
8841
}
8942

9043
bb1: {
91-
StorageDead(_3);
92-
StorageDead(_1);
93-
return;
94-
}
95-
96-
bb2: {
97-
unreachable;
98-
}
99-
100-
bb3: {
101-
- _18 = handle_alloc_error(move _14) -> unwind unreachable;
102-
+ _18 = handle_alloc_error(const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}) -> unwind unreachable;
103-
}
104-
105-
bb4: {
106-
_17 = copy ((_15 as Ok).0: std::ptr::NonNull<[u8]>);
107-
StorageLive(_22);
108-
_22 = copy _17 as *mut [u8] (Transmute);
109-
_13 = copy _22 as *mut u8 (PtrToPtr);
110-
StorageDead(_22);
111-
StorageDead(_15);
112-
StorageDead(_17);
113-
StorageDead(_16);
114-
StorageDead(_14);
115-
_3 = ShallowInitBox(copy _13, ());
116-
StorageDead(_13);
117-
StorageDead(_12);
118-
StorageDead(_11);
11944
_2 = &_3;
12045
_1 = copy _2;
12146
StorageDead(_2);
12247
StorageLive(_4);
123-
- _9 = deref_copy _3;
124-
+ _9 = copy _3;
125-
_10 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute);
126-
_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;
12751
- StorageLive(_5);
12852
+ nop;
12953
StorageLive(_6);
13054
- _6 = copy _4;
131-
+ _6 = copy _10;
132-
StorageLive(_23);
133-
_23 = const 1_usize;
134-
- _5 = *const [()] from (copy _6, copy _23);
135-
+ _5 = *const [()] from (copy _10, const 1_usize);
136-
StorageDead(_23);
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);
13761
StorageDead(_6);
13862
StorageLive(_7);
13963
StorageLive(_8);
14064
_8 = copy _5;
14165
- _7 = copy _8 as *mut () (PtrToPtr);
142-
+ _7 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *mut () (Transmute);
66+
+ _7 = copy _11 as *mut () (Transmute);
14367
StorageDead(_8);
14468
StorageDead(_7);
14569
- StorageDead(_5);
14670
+ nop;
14771
StorageDead(_4);
148-
drop(_3) -> [return: bb1, unwind unreachable];
149-
}
150-
151-
bb5: {
152-
- _20 = Layout::from_size_align_unchecked::precondition_check(copy _11, copy _12) -> [return: bb6, unwind unreachable];
153-
+ _20 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable];
72+
drop(_3) -> [return: bb2, unwind unreachable];
15473
}
15574

156-
bb6: {
157-
StorageDead(_19);
158-
StorageLive(_21);
159-
- _21 = copy _12 as std::ptr::Alignment (Transmute);
160-
- _14 = Layout { size: copy _11, align: move _21 };
161-
+ _21 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0);
162-
+ _14 = const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }};
163-
StorageDead(_21);
164-
StorageLive(_15);
165-
- _15 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], copy _14, const false) -> [return: bb7, unwind unreachable];
166-
+ _15 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}, const false) -> [return: bb7, unwind unreachable];
167-
}
168-
169-
bb7: {
170-
_16 = discriminant(_15);
171-
switchInt(move _16) -> [0: bb4, 1: bb3, otherwise: bb2];
75+
bb2: {
76+
StorageDead(_3);
77+
StorageDead(_1);
78+
return;
17279
}
173-
+ }
174-
+
175-
+ ALLOC0 (size: 16, align: 8) {
176-
+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
17780
}
17881

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-abort.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: bb2, unwind unreachable];
2929
}
3030

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-abort.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: bb2, unwind unreachable];
3030
}
3131

0 commit comments

Comments
 (0)