Skip to content

Commit 950a3b3

Browse files
committed
Add a mir-opt pre-codegen test for dropping a Box<[impl Copy]>
1 parent cb6785f commit 950a3b3

5 files changed

+463
-0
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
// MIR for `generic_in_place` after PreCodegen
2+
3+
fn generic_in_place(_1: *mut Box<[T]>) -> () {
4+
debug ptr => _1;
5+
let mut _0: ();
6+
scope 1 (inlined drop_in_place::<Box<[T]>> - shim(Some(Box<[T]>))) {
7+
scope 2 (inlined <Box<[T]> as Drop>::drop) {
8+
let _2: std::ptr::NonNull<[T]>;
9+
let mut _3: *mut [T];
10+
let mut _4: *const [T];
11+
let _12: ();
12+
scope 3 {
13+
let _8: std::ptr::alignment::AlignmentEnum;
14+
scope 4 {
15+
scope 12 (inlined Layout::size) {
16+
}
17+
scope 13 (inlined Unique::<[T]>::cast::<u8>) {
18+
scope 14 (inlined NonNull::<[T]>::cast::<u8>) {
19+
scope 15 (inlined NonNull::<[T]>::as_ptr) {
20+
}
21+
}
22+
}
23+
scope 16 (inlined <NonNull<u8> as From<Unique<u8>>>::from) {
24+
scope 17 (inlined Unique::<u8>::as_non_null_ptr) {
25+
}
26+
}
27+
scope 18 (inlined <std::alloc::Global as Allocator>::deallocate) {
28+
let mut _9: *mut u8;
29+
scope 19 (inlined Layout::size) {
30+
}
31+
scope 20 (inlined NonNull::<u8>::as_ptr) {
32+
}
33+
scope 21 (inlined std::alloc::dealloc) {
34+
let mut _11: usize;
35+
scope 22 (inlined Layout::size) {
36+
}
37+
scope 23 (inlined Layout::align) {
38+
scope 24 (inlined std::ptr::Alignment::as_usize) {
39+
let mut _10: u32;
40+
}
41+
}
42+
}
43+
}
44+
}
45+
scope 5 (inlined Unique::<[T]>::as_ptr) {
46+
scope 6 (inlined NonNull::<[T]>::as_ptr) {
47+
}
48+
}
49+
scope 7 (inlined Layout::for_value_raw::<[T]>) {
50+
let mut _5: usize;
51+
let mut _6: usize;
52+
scope 8 {
53+
scope 11 (inlined #[track_caller] Layout::from_size_align_unchecked) {
54+
let mut _7: std::ptr::Alignment;
55+
}
56+
}
57+
scope 9 (inlined size_of_val_raw::<[T]>) {
58+
}
59+
scope 10 (inlined align_of_val_raw::<[T]>) {
60+
}
61+
}
62+
}
63+
}
64+
}
65+
66+
bb0: {
67+
StorageLive(_2);
68+
_2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>);
69+
StorageLive(_4);
70+
_3 = copy _2 as *mut [T] (Transmute);
71+
_4 = copy _2 as *const [T] (Transmute);
72+
StorageLive(_6);
73+
_5 = std::intrinsics::size_of_val::<[T]>(copy _4) -> [return: bb1, unwind unreachable];
74+
}
75+
76+
bb1: {
77+
_6 = std::intrinsics::align_of_val::<[T]>(move _4) -> [return: bb2, unwind unreachable];
78+
}
79+
80+
bb2: {
81+
StorageLive(_7);
82+
_7 = copy _6 as std::ptr::Alignment (Transmute);
83+
_8 = move (_7.0: std::ptr::alignment::AlignmentEnum);
84+
StorageDead(_7);
85+
StorageDead(_6);
86+
StorageDead(_4);
87+
switchInt(copy _5) -> [0: bb5, otherwise: bb3];
88+
}
89+
90+
bb3: {
91+
StorageLive(_9);
92+
_9 = copy _3 as *mut u8 (PtrToPtr);
93+
StorageLive(_11);
94+
StorageLive(_10);
95+
_10 = discriminant(_8);
96+
_11 = move _10 as usize (IntToInt);
97+
StorageDead(_10);
98+
_12 = alloc::alloc::__rust_dealloc(move _9, move _5, move _11) -> [return: bb4, unwind unreachable];
99+
}
100+
101+
bb4: {
102+
StorageDead(_11);
103+
StorageDead(_9);
104+
goto -> bb5;
105+
}
106+
107+
bb5: {
108+
StorageDead(_2);
109+
return;
110+
}
111+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
// MIR for `generic_in_place` after PreCodegen
2+
3+
fn generic_in_place(_1: *mut Box<[T]>) -> () {
4+
debug ptr => _1;
5+
let mut _0: ();
6+
scope 1 (inlined drop_in_place::<Box<[T]>> - shim(Some(Box<[T]>))) {
7+
scope 2 (inlined <Box<[T]> as Drop>::drop) {
8+
let _2: std::ptr::NonNull<[T]>;
9+
let mut _3: *mut [T];
10+
let mut _4: *const [T];
11+
let _12: ();
12+
scope 3 {
13+
let _8: std::ptr::alignment::AlignmentEnum;
14+
scope 4 {
15+
scope 12 (inlined Layout::size) {
16+
}
17+
scope 13 (inlined Unique::<[T]>::cast::<u8>) {
18+
scope 14 (inlined NonNull::<[T]>::cast::<u8>) {
19+
scope 15 (inlined NonNull::<[T]>::as_ptr) {
20+
}
21+
}
22+
}
23+
scope 16 (inlined <NonNull<u8> as From<Unique<u8>>>::from) {
24+
scope 17 (inlined Unique::<u8>::as_non_null_ptr) {
25+
}
26+
}
27+
scope 18 (inlined <std::alloc::Global as Allocator>::deallocate) {
28+
let mut _9: *mut u8;
29+
scope 19 (inlined Layout::size) {
30+
}
31+
scope 20 (inlined NonNull::<u8>::as_ptr) {
32+
}
33+
scope 21 (inlined std::alloc::dealloc) {
34+
let mut _11: usize;
35+
scope 22 (inlined Layout::size) {
36+
}
37+
scope 23 (inlined Layout::align) {
38+
scope 24 (inlined std::ptr::Alignment::as_usize) {
39+
let mut _10: u32;
40+
}
41+
}
42+
}
43+
}
44+
}
45+
scope 5 (inlined Unique::<[T]>::as_ptr) {
46+
scope 6 (inlined NonNull::<[T]>::as_ptr) {
47+
}
48+
}
49+
scope 7 (inlined Layout::for_value_raw::<[T]>) {
50+
let mut _5: usize;
51+
let mut _6: usize;
52+
scope 8 {
53+
scope 11 (inlined #[track_caller] Layout::from_size_align_unchecked) {
54+
let mut _7: std::ptr::Alignment;
55+
}
56+
}
57+
scope 9 (inlined size_of_val_raw::<[T]>) {
58+
}
59+
scope 10 (inlined align_of_val_raw::<[T]>) {
60+
}
61+
}
62+
}
63+
}
64+
}
65+
66+
bb0: {
67+
StorageLive(_2);
68+
_2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>);
69+
StorageLive(_4);
70+
_3 = copy _2 as *mut [T] (Transmute);
71+
_4 = copy _2 as *const [T] (Transmute);
72+
StorageLive(_6);
73+
_5 = std::intrinsics::size_of_val::<[T]>(copy _4) -> [return: bb1, unwind unreachable];
74+
}
75+
76+
bb1: {
77+
_6 = std::intrinsics::align_of_val::<[T]>(move _4) -> [return: bb2, unwind unreachable];
78+
}
79+
80+
bb2: {
81+
StorageLive(_7);
82+
_7 = copy _6 as std::ptr::Alignment (Transmute);
83+
_8 = move (_7.0: std::ptr::alignment::AlignmentEnum);
84+
StorageDead(_7);
85+
StorageDead(_6);
86+
StorageDead(_4);
87+
switchInt(copy _5) -> [0: bb5, otherwise: bb3];
88+
}
89+
90+
bb3: {
91+
StorageLive(_9);
92+
_9 = copy _3 as *mut u8 (PtrToPtr);
93+
StorageLive(_11);
94+
StorageLive(_10);
95+
_10 = discriminant(_8);
96+
_11 = move _10 as usize (IntToInt);
97+
StorageDead(_10);
98+
_12 = alloc::alloc::__rust_dealloc(move _9, move _5, move _11) -> [return: bb4, unwind unreachable];
99+
}
100+
101+
bb4: {
102+
StorageDead(_11);
103+
StorageDead(_9);
104+
goto -> bb5;
105+
}
106+
107+
bb5: {
108+
StorageDead(_2);
109+
return;
110+
}
111+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
// MIR for `generic_in_place` after PreCodegen
2+
3+
fn generic_in_place(_1: *mut Box<[T]>) -> () {
4+
debug ptr => _1;
5+
let mut _0: ();
6+
scope 1 (inlined drop_in_place::<Box<[T]>> - shim(Some(Box<[T]>))) {
7+
scope 2 (inlined <Box<[T]> as Drop>::drop) {
8+
let _2: std::ptr::NonNull<[T]>;
9+
let mut _3: *mut [T];
10+
let mut _4: *const [T];
11+
let _12: ();
12+
scope 3 {
13+
let _8: std::ptr::alignment::AlignmentEnum;
14+
scope 4 {
15+
scope 12 (inlined Layout::size) {
16+
}
17+
scope 13 (inlined Unique::<[T]>::cast::<u8>) {
18+
scope 14 (inlined NonNull::<[T]>::cast::<u8>) {
19+
scope 15 (inlined NonNull::<[T]>::as_ptr) {
20+
}
21+
}
22+
}
23+
scope 16 (inlined <NonNull<u8> as From<Unique<u8>>>::from) {
24+
scope 17 (inlined Unique::<u8>::as_non_null_ptr) {
25+
}
26+
}
27+
scope 18 (inlined <std::alloc::Global as Allocator>::deallocate) {
28+
let mut _9: *mut u8;
29+
scope 19 (inlined Layout::size) {
30+
}
31+
scope 20 (inlined NonNull::<u8>::as_ptr) {
32+
}
33+
scope 21 (inlined std::alloc::dealloc) {
34+
let mut _11: usize;
35+
scope 22 (inlined Layout::size) {
36+
}
37+
scope 23 (inlined Layout::align) {
38+
scope 24 (inlined std::ptr::Alignment::as_usize) {
39+
let mut _10: u64;
40+
}
41+
}
42+
}
43+
}
44+
}
45+
scope 5 (inlined Unique::<[T]>::as_ptr) {
46+
scope 6 (inlined NonNull::<[T]>::as_ptr) {
47+
}
48+
}
49+
scope 7 (inlined Layout::for_value_raw::<[T]>) {
50+
let mut _5: usize;
51+
let mut _6: usize;
52+
scope 8 {
53+
scope 11 (inlined #[track_caller] Layout::from_size_align_unchecked) {
54+
let mut _7: std::ptr::Alignment;
55+
}
56+
}
57+
scope 9 (inlined size_of_val_raw::<[T]>) {
58+
}
59+
scope 10 (inlined align_of_val_raw::<[T]>) {
60+
}
61+
}
62+
}
63+
}
64+
}
65+
66+
bb0: {
67+
StorageLive(_2);
68+
_2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>);
69+
StorageLive(_4);
70+
_3 = copy _2 as *mut [T] (Transmute);
71+
_4 = copy _2 as *const [T] (Transmute);
72+
StorageLive(_6);
73+
_5 = std::intrinsics::size_of_val::<[T]>(copy _4) -> [return: bb1, unwind unreachable];
74+
}
75+
76+
bb1: {
77+
_6 = std::intrinsics::align_of_val::<[T]>(move _4) -> [return: bb2, unwind unreachable];
78+
}
79+
80+
bb2: {
81+
StorageLive(_7);
82+
_7 = copy _6 as std::ptr::Alignment (Transmute);
83+
_8 = move (_7.0: std::ptr::alignment::AlignmentEnum);
84+
StorageDead(_7);
85+
StorageDead(_6);
86+
StorageDead(_4);
87+
switchInt(copy _5) -> [0: bb5, otherwise: bb3];
88+
}
89+
90+
bb3: {
91+
StorageLive(_9);
92+
_9 = copy _3 as *mut u8 (PtrToPtr);
93+
StorageLive(_11);
94+
StorageLive(_10);
95+
_10 = discriminant(_8);
96+
_11 = move _10 as usize (IntToInt);
97+
StorageDead(_10);
98+
_12 = alloc::alloc::__rust_dealloc(move _9, move _5, move _11) -> [return: bb4, unwind unreachable];
99+
}
100+
101+
bb4: {
102+
StorageDead(_11);
103+
StorageDead(_9);
104+
goto -> bb5;
105+
}
106+
107+
bb5: {
108+
StorageDead(_2);
109+
return;
110+
}
111+
}

0 commit comments

Comments
 (0)