Skip to content

Commit 1bd4901

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 1bd4901

10 files changed

+176
-180
lines changed

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

Lines changed: 59 additions & 60 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 _23: usize;
11+
let mut _9: *const ();
12+
let mut _22: usize;
13+
let mut _23: 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;
@@ -33,21 +33,21 @@
3333
}
3434
}
3535
scope 5 (inlined Box::<()>::new) {
36+
let mut _10: usize;
3637
let mut _11: usize;
37-
let mut _12: usize;
38-
let mut _13: *mut u8;
38+
let mut _12: *mut u8;
3939
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: !;
40+
let _13: std::alloc::Layout;
41+
let mut _14: std::result::Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError>;
42+
let mut _15: isize;
43+
let mut _17: !;
4444
scope 7 {
45-
let _17: std::ptr::NonNull<[u8]>;
45+
let _16: std::ptr::NonNull<[u8]>;
4646
scope 8 {
4747
scope 11 (inlined NonNull::<[u8]>::as_mut_ptr) {
4848
scope 12 (inlined NonNull::<[u8]>::as_non_null_ptr) {
4949
scope 13 (inlined NonNull::<[u8]>::cast::<u8>) {
50-
let mut _22: *mut [u8];
50+
let mut _21: *mut [u8];
5151
scope 14 (inlined NonNull::<[u8]>::as_ptr) {
5252
}
5353
}
@@ -60,9 +60,9 @@
6060
}
6161
}
6262
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;
63+
let mut _18: bool;
64+
let _19: ();
65+
let mut _20: std::ptr::Alignment;
6666
}
6767
}
6868
}
@@ -71,19 +71,19 @@
7171
StorageLive(_1);
7272
StorageLive(_2);
7373
StorageLive(_3);
74+
StorageLive(_10);
7475
StorageLive(_11);
7576
StorageLive(_12);
77+
- _10 = SizeOf(());
78+
- _11 = AlignOf(());
79+
+ _10 = const 0_usize;
80+
+ _11 = const 1_usize;
7681
StorageLive(_13);
77-
- _11 = SizeOf(());
78-
- _12 = AlignOf(());
79-
+ _11 = const 0_usize;
80-
+ _12 = const 1_usize;
81-
StorageLive(_14);
82+
StorageLive(_15);
8283
StorageLive(_16);
83-
StorageLive(_17);
84-
StorageLive(_19);
85-
_19 = const false;
86-
- switchInt(move _19) -> [0: bb6, otherwise: bb5];
84+
StorageLive(_18);
85+
_18 = const false;
86+
- switchInt(move _18) -> [0: bb6, otherwise: bb5];
8787
+ switchInt(const false) -> [0: bb6, otherwise: bb5];
8888
}
8989

@@ -98,48 +98,47 @@
9898
}
9999

100100
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;
101+
- _17 = handle_alloc_error(move _13) -> unwind unreachable;
102+
+ _17 = handle_alloc_error(const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}) -> unwind unreachable;
103103
}
104104

105105
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);
106+
_16 = copy ((_14 as Ok).0: std::ptr::NonNull<[u8]>);
107+
StorageLive(_21);
108+
_21 = copy _16 as *mut [u8] (Transmute);
109+
_12 = copy _21 as *mut u8 (PtrToPtr);
110+
StorageDead(_21);
114111
StorageDead(_14);
115-
_3 = ShallowInitBox(copy _13, ());
112+
StorageDead(_16);
113+
StorageDead(_15);
116114
StorageDead(_13);
115+
_3 = ShallowInitBox(copy _12, ());
117116
StorageDead(_12);
118117
StorageDead(_11);
118+
StorageDead(_10);
119119
_2 = &_3;
120120
_1 = copy _2;
121121
StorageDead(_2);
122122
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;
123+
_23 = copy ((_3.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>);
124+
_9 = copy _23 as *const () (Transmute);
125+
_4 = copy _9;
127126
- StorageLive(_5);
128127
+ nop;
129128
StorageLive(_6);
130129
- _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);
130+
+ _6 = copy _9;
131+
StorageLive(_22);
132+
_22 = const 1_usize;
133+
- _5 = *const [()] from (copy _6, copy _22);
134+
+ _5 = *const [()] from (copy _9, const 1_usize);
135+
StorageDead(_22);
137136
StorageDead(_6);
138137
StorageLive(_7);
139138
StorageLive(_8);
140139
_8 = copy _5;
141140
- _7 = copy _8 as *mut () (PtrToPtr);
142-
+ _7 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *mut () (Transmute);
141+
+ _7 = copy _23 as *mut () (Transmute);
143142
StorageDead(_8);
144143
StorageDead(_7);
145144
- StorageDead(_5);
@@ -149,26 +148,26 @@
149148
}
150149

151150
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];
151+
- _19 = Layout::from_size_align_unchecked::precondition_check(copy _10, copy _11) -> [return: bb6, unwind unreachable];
152+
+ _19 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable];
154153
}
155154

156155
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];
156+
StorageDead(_18);
157+
StorageLive(_20);
158+
- _20 = copy _11 as std::ptr::Alignment (Transmute);
159+
- _13 = Layout { size: copy _10, align: move _20 };
160+
+ _20 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0);
161+
+ _13 = const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }};
162+
StorageDead(_20);
163+
StorageLive(_14);
164+
- _14 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], copy _13, const false) -> [return: bb7, unwind unreachable];
165+
+ _14 = 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];
167166
}
168167

169168
bb7: {
170-
_16 = discriminant(_15);
171-
switchInt(move _16) -> [0: bb4, 1: bb3, otherwise: bb2];
169+
_15 = discriminant(_14);
170+
switchInt(move _15) -> [0: bb4, 1: bb3, otherwise: bb2];
172171
}
173172
+ }
174173
+

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);

0 commit comments

Comments
 (0)