File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ - // MIR for `option_field` before GVN
2+ + // MIR for `option_field` after GVN
3+
4+ fn option_field(_1: Option<NonNull<()>>) -> *const () {
5+ debug x => _1;
6+ let mut _0: *const ();
7+ let mut _2: isize;
8+ let mut _4: std::ptr::NonNull<()>;
9+ scope 1 {
10+ debug x => _3;
11+ let _3: std::ptr::NonNull<()>;
12+ }
13+
14+ bb0: {
15+ _2 = discriminant(_1);
16+ switchInt(move _2) -> [1: bb1, otherwise: bb2];
17+ }
18+
19+ bb1: {
20+ - StorageLive(_3);
21+ + nop;
22+ _3 = copy ((_1 as Some).0: std::ptr::NonNull<()>);
23+ StorageLive(_4);
24+ _4 = copy _3;
25+ - _0 = move _4 as *const () (Transmute);
26+ + _0 = copy _3 as *const () (Transmute);
27+ StorageDead(_4);
28+ - StorageDead(_3);
29+ + nop;
30+ goto -> bb3;
31+ }
32+
33+ bb2: {
34+ _0 = const 0_usize as *const () (PointerWithExposedProvenance);
35+ goto -> bb3;
36+ }
37+
38+ bb3: {
39+ return;
40+ }
41+ }
42+
Original file line number Diff line number Diff line change 1+ - // MIR for `option_field` before GVN
2+ + // MIR for `option_field` after GVN
3+
4+ fn option_field(_1: Option<NonNull<()>>) -> *const () {
5+ debug x => _1;
6+ let mut _0: *const ();
7+ let mut _2: isize;
8+ let mut _4: std::ptr::NonNull<()>;
9+ scope 1 {
10+ debug x => _3;
11+ let _3: std::ptr::NonNull<()>;
12+ }
13+
14+ bb0: {
15+ _2 = discriminant(_1);
16+ switchInt(move _2) -> [1: bb1, otherwise: bb2];
17+ }
18+
19+ bb1: {
20+ - StorageLive(_3);
21+ + nop;
22+ _3 = copy ((_1 as Some).0: std::ptr::NonNull<()>);
23+ StorageLive(_4);
24+ _4 = copy _3;
25+ - _0 = move _4 as *const () (Transmute);
26+ + _0 = copy _3 as *const () (Transmute);
27+ StorageDead(_4);
28+ - StorageDead(_3);
29+ + nop;
30+ goto -> bb3;
31+ }
32+
33+ bb2: {
34+ _0 = const 0_usize as *const () (PointerWithExposedProvenance);
35+ goto -> bb3;
36+ }
37+
38+ bb3: {
39+ return;
40+ }
41+ }
42+
Original file line number Diff line number Diff line change @@ -84,4 +84,12 @@ pub unsafe fn unreachable_box() -> ! {
8484 match * x { }
8585}
8686
87+ // EMIT_MIR transmute.option_field.GVN.diff
88+ pub unsafe fn option_field ( x : Option < std:: ptr:: NonNull < ( ) > > ) -> * const ( ) {
89+ // CHECK-LABEL: fn option_field(
90+ // CHECK: _3 = copy ((_1 as Some).0: std::ptr::NonNull<()>)
91+ // CHECK: _0 = copy _3 as *const () (Transmute)
92+ if let Some ( x) = x { unsafe { transmute ( x) } } else { 0 as * const ( ) }
93+ }
94+
8795enum Never { }
You can’t perform that action at this time.
0 commit comments