Skip to content

Commit cdec87c

Browse files
committed
Add mir opt test for min_align_of -> AlignOf lowering
1 parent 1c3409f commit cdec87c

8 files changed

+180
-151
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
- // MIR for `align_of` before LowerIntrinsics
2+
+ // MIR for `align_of` after LowerIntrinsics
3+
4+
fn align_of() -> usize {
5+
let mut _0: usize; // return place in scope 0 at $DIR/lower_intrinsics.rs:18:25: 18:30
6+
7+
bb0: {
8+
- _0 = std::intrinsics::min_align_of::<T>() -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:19:5: 19:42
9+
- // mir::Constant
10+
- // + span: $DIR/lower_intrinsics.rs:19:5: 19:40
11+
- // + literal: Const { ty: extern "rust-intrinsic" fn() -> usize {std::intrinsics::min_align_of::<T>}, val: Value(Scalar(<ZST>)) }
12+
+ _0 = AlignOf(T); // scope 0 at $DIR/lower_intrinsics.rs:19:5: 19:42
13+
+ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:19:5: 19:42
14+
}
15+
16+
bb1: {
17+
return; // scope 0 at $DIR/lower_intrinsics.rs:20:2: 20:2
18+
}
19+
20+
bb2 (cleanup): {
21+
resume; // scope 0 at $DIR/lower_intrinsics.rs:18:1: 20:2
22+
}
23+
}
24+

src/test/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff

+81-81
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
// MIR for `f_u64` before PreCodegen
22

33
fn f_u64() -> () {
4-
let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics.rs:34:16: 34:16
5-
let mut _1: u64; // in scope 0 at $DIR/lower_intrinsics.rs:35:5: 35:21
6-
scope 1 (inlined f_dispatch::<u64>) { // at $DIR/lower_intrinsics.rs:35:5: 35:21
7-
debug t => _1; // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21
8-
let _2: (); // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21
9-
let mut _3: u64; // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21
10-
scope 2 (inlined std::mem::size_of::<u64>) { // at $DIR/lower_intrinsics.rs:35:5: 35:21
4+
let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics.rs:39:16: 39:16
5+
let mut _1: u64; // in scope 0 at $DIR/lower_intrinsics.rs:40:5: 40:21
6+
scope 1 (inlined f_dispatch::<u64>) { // at $DIR/lower_intrinsics.rs:40:5: 40:21
7+
debug t => _1; // in scope 1 at $DIR/lower_intrinsics.rs:40:5: 40:21
8+
let _2: (); // in scope 1 at $DIR/lower_intrinsics.rs:40:5: 40:21
9+
let mut _3: u64; // in scope 1 at $DIR/lower_intrinsics.rs:40:5: 40:21
10+
scope 2 (inlined std::mem::size_of::<u64>) { // at $DIR/lower_intrinsics.rs:40:5: 40:21
1111
}
1212
}
1313

1414
bb0: {
15-
StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:35:5: 35:21
16-
_1 = const 0_u64; // scope 0 at $DIR/lower_intrinsics.rs:35:5: 35:21
17-
StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21
18-
StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21
19-
_3 = move _1; // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21
20-
_2 = f_non_zst::<u64>(move _3) -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21
15+
StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:40:5: 40:21
16+
_1 = const 0_u64; // scope 0 at $DIR/lower_intrinsics.rs:40:5: 40:21
17+
StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:40:5: 40:21
18+
StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:40:5: 40:21
19+
_3 = move _1; // scope 1 at $DIR/lower_intrinsics.rs:40:5: 40:21
20+
_2 = f_non_zst::<u64>(move _3) -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:40:5: 40:21
2121
// mir::Constant
22-
// + span: $DIR/lower_intrinsics.rs:35:5: 35:21
22+
// + span: $DIR/lower_intrinsics.rs:40:5: 40:21
2323
// + literal: Const { ty: fn(u64) {f_non_zst::<u64>}, val: Value(Scalar(<ZST>)) }
2424
}
2525

2626
bb1: {
27-
StorageDead(_3); // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21
28-
StorageDead(_2); // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21
29-
StorageDead(_1); // scope 0 at $DIR/lower_intrinsics.rs:35:5: 35:21
30-
return; // scope 0 at $DIR/lower_intrinsics.rs:36:2: 36:2
27+
StorageDead(_3); // scope 1 at $DIR/lower_intrinsics.rs:40:5: 40:21
28+
StorageDead(_2); // scope 1 at $DIR/lower_intrinsics.rs:40:5: 40:21
29+
StorageDead(_1); // scope 0 at $DIR/lower_intrinsics.rs:40:5: 40:21
30+
return; // scope 0 at $DIR/lower_intrinsics.rs:41:2: 41:2
3131
}
3232
}
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
// MIR for `f_unit` before PreCodegen
22

33
fn f_unit() -> () {
4-
let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics.rs:28:17: 28:17
5-
let mut _1: (); // in scope 0 at $DIR/lower_intrinsics.rs:29:16: 29:18
6-
scope 1 (inlined f_dispatch::<()>) { // at $DIR/lower_intrinsics.rs:29:5: 29:19
7-
debug t => _1; // in scope 1 at $DIR/lower_intrinsics.rs:29:5: 29:19
8-
let _2: (); // in scope 1 at $DIR/lower_intrinsics.rs:29:5: 29:19
9-
scope 2 (inlined std::mem::size_of::<()>) { // at $DIR/lower_intrinsics.rs:29:5: 29:19
4+
let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics.rs:33:17: 33:17
5+
let mut _1: (); // in scope 0 at $DIR/lower_intrinsics.rs:34:16: 34:18
6+
scope 1 (inlined f_dispatch::<()>) { // at $DIR/lower_intrinsics.rs:34:5: 34:19
7+
debug t => _1; // in scope 1 at $DIR/lower_intrinsics.rs:34:5: 34:19
8+
let _2: (); // in scope 1 at $DIR/lower_intrinsics.rs:34:5: 34:19
9+
scope 2 (inlined std::mem::size_of::<()>) { // at $DIR/lower_intrinsics.rs:34:5: 34:19
1010
}
1111
}
1212

1313
bb0: {
14-
StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:29:16: 29:18
15-
StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:29:5: 29:19
16-
_2 = f_zst::<()>(const ()) -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:29:5: 29:19
14+
StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:34:16: 34:18
15+
StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:34:5: 34:19
16+
_2 = f_zst::<()>(const ()) -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:34:5: 34:19
1717
// mir::Constant
18-
// + span: $DIR/lower_intrinsics.rs:29:5: 29:19
18+
// + span: $DIR/lower_intrinsics.rs:34:5: 34:19
1919
// + literal: Const { ty: fn(()) {f_zst::<()>}, val: Value(Scalar(<ZST>)) }
2020
}
2121

2222
bb1: {
23-
StorageDead(_2); // scope 1 at $DIR/lower_intrinsics.rs:29:5: 29:19
24-
StorageDead(_1); // scope 0 at $DIR/lower_intrinsics.rs:29:18: 29:19
25-
return; // scope 0 at $DIR/lower_intrinsics.rs:30:2: 30:2
23+
StorageDead(_2); // scope 1 at $DIR/lower_intrinsics.rs:34:5: 34:19
24+
StorageDead(_1); // scope 0 at $DIR/lower_intrinsics.rs:34:18: 34:19
25+
return; // scope 0 at $DIR/lower_intrinsics.rs:35:2: 35:2
2626
}
2727
}

src/test/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff

+13-13
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,32 @@
22
+ // MIR for `forget` after LowerIntrinsics
33

44
fn forget(_1: T) -> () {
5-
debug t => _1; // in scope 0 at $DIR/lower_intrinsics.rs:18:18: 18:19
6-
let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics.rs:18:24: 18:24
7-
let mut _2: T; // in scope 0 at $DIR/lower_intrinsics.rs:19:30: 19:31
5+
debug t => _1; // in scope 0 at $DIR/lower_intrinsics.rs:23:18: 23:19
6+
let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics.rs:23:24: 23:24
7+
let mut _2: T; // in scope 0 at $DIR/lower_intrinsics.rs:24:30: 24:31
88

99
bb0: {
10-
StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:19:30: 19:31
11-
_2 = move _1; // scope 0 at $DIR/lower_intrinsics.rs:19:30: 19:31
12-
- _0 = std::intrinsics::forget::<T>(move _2) -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:19:5: 19:32
10+
StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:24:30: 24:31
11+
_2 = move _1; // scope 0 at $DIR/lower_intrinsics.rs:24:30: 24:31
12+
- _0 = std::intrinsics::forget::<T>(move _2) -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:24:5: 24:32
1313
- // mir::Constant
14-
- // + span: $DIR/lower_intrinsics.rs:19:5: 19:29
14+
- // + span: $DIR/lower_intrinsics.rs:24:5: 24:29
1515
- // + literal: Const { ty: extern "rust-intrinsic" fn(T) {std::intrinsics::forget::<T>}, val: Value(Scalar(<ZST>)) }
16-
+ _0 = const (); // scope 0 at $DIR/lower_intrinsics.rs:19:5: 19:32
17-
+ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:19:5: 19:32
16+
+ _0 = const (); // scope 0 at $DIR/lower_intrinsics.rs:24:5: 24:32
17+
+ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:24:5: 24:32
1818
}
1919

2020
bb1: {
21-
StorageDead(_2); // scope 0 at $DIR/lower_intrinsics.rs:19:31: 19:32
22-
goto -> bb2; // scope 0 at $DIR/lower_intrinsics.rs:20:1: 20:2
21+
StorageDead(_2); // scope 0 at $DIR/lower_intrinsics.rs:24:31: 24:32
22+
goto -> bb2; // scope 0 at $DIR/lower_intrinsics.rs:25:1: 25:2
2323
}
2424

2525
bb2: {
26-
return; // scope 0 at $DIR/lower_intrinsics.rs:20:2: 20:2
26+
return; // scope 0 at $DIR/lower_intrinsics.rs:25:2: 25:2
2727
}
2828

2929
bb3 (cleanup): {
30-
resume; // scope 0 at $DIR/lower_intrinsics.rs:18:1: 20:2
30+
resume; // scope 0 at $DIR/lower_intrinsics.rs:23:1: 25:2
3131
}
3232
}
3333

src/test/mir-opt/lower_intrinsics.non_const.LowerIntrinsics.diff

+16-16
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,34 @@
22
+ // MIR for `non_const` after LowerIntrinsics
33

44
fn non_const() -> usize {
5-
let mut _0: usize; // return place in scope 0 at $DIR/lower_intrinsics.rs:55:26: 55:31
6-
let _1: extern "rust-intrinsic" fn() -> usize {std::intrinsics::size_of::<T>}; // in scope 0 at $DIR/lower_intrinsics.rs:57:9: 57:18
7-
let mut _2: extern "rust-intrinsic" fn() -> usize {std::intrinsics::size_of::<T>}; // in scope 0 at $DIR/lower_intrinsics.rs:58:5: 58:14
5+
let mut _0: usize; // return place in scope 0 at $DIR/lower_intrinsics.rs:60:26: 60:31
6+
let _1: extern "rust-intrinsic" fn() -> usize {std::intrinsics::size_of::<T>}; // in scope 0 at $DIR/lower_intrinsics.rs:62:9: 62:18
7+
let mut _2: extern "rust-intrinsic" fn() -> usize {std::intrinsics::size_of::<T>}; // in scope 0 at $DIR/lower_intrinsics.rs:63:5: 63:14
88
scope 1 {
9-
debug size_of_t => _1; // in scope 1 at $DIR/lower_intrinsics.rs:57:9: 57:18
9+
debug size_of_t => _1; // in scope 1 at $DIR/lower_intrinsics.rs:62:9: 62:18
1010
}
1111

1212
bb0: {
13-
StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:57:9: 57:18
14-
_1 = std::intrinsics::size_of::<T>; // scope 0 at $DIR/lower_intrinsics.rs:57:21: 57:51
13+
StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:62:9: 62:18
14+
_1 = std::intrinsics::size_of::<T>; // scope 0 at $DIR/lower_intrinsics.rs:62:21: 62:51
1515
// mir::Constant
16-
// + span: $DIR/lower_intrinsics.rs:57:21: 57:51
16+
// + span: $DIR/lower_intrinsics.rs:62:21: 62:51
1717
// + literal: Const { ty: extern "rust-intrinsic" fn() -> usize {std::intrinsics::size_of::<T>}, val: Value(Scalar(<ZST>)) }
18-
StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:58:5: 58:14
19-
_2 = _1; // scope 1 at $DIR/lower_intrinsics.rs:58:5: 58:14
20-
- _0 = move _2() -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:58:5: 58:16
21-
+ _0 = SizeOf(T); // scope 1 at $DIR/lower_intrinsics.rs:58:5: 58:16
22-
+ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:58:5: 58:16
18+
StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:63:5: 63:14
19+
_2 = _1; // scope 1 at $DIR/lower_intrinsics.rs:63:5: 63:14
20+
- _0 = move _2() -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:63:5: 63:16
21+
+ _0 = SizeOf(T); // scope 1 at $DIR/lower_intrinsics.rs:63:5: 63:16
22+
+ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:63:5: 63:16
2323
}
2424

2525
bb1: {
26-
StorageDead(_2); // scope 1 at $DIR/lower_intrinsics.rs:58:15: 58:16
27-
StorageDead(_1); // scope 0 at $DIR/lower_intrinsics.rs:59:1: 59:2
28-
return; // scope 0 at $DIR/lower_intrinsics.rs:59:2: 59:2
26+
StorageDead(_2); // scope 1 at $DIR/lower_intrinsics.rs:63:15: 63:16
27+
StorageDead(_1); // scope 0 at $DIR/lower_intrinsics.rs:64:1: 64:2
28+
return; // scope 0 at $DIR/lower_intrinsics.rs:64:2: 64:2
2929
}
3030

3131
bb2 (cleanup): {
32-
resume; // scope 0 at $DIR/lower_intrinsics.rs:55:1: 59:2
32+
resume; // scope 0 at $DIR/lower_intrinsics.rs:60:1: 64:2
3333
}
3434
}
3535

src/test/mir-opt/lower_intrinsics.rs

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ pub fn size_of<T>() -> usize {
1414
core::intrinsics::size_of::<T>()
1515
}
1616

17+
// EMIT_MIR lower_intrinsics.align_of.LowerIntrinsics.diff
18+
pub fn align_of<T>() -> usize {
19+
core::intrinsics::min_align_of::<T>()
20+
}
21+
1722
// EMIT_MIR lower_intrinsics.forget.LowerIntrinsics.diff
1823
pub fn forget<T>(t: T) {
1924
core::intrinsics::forget(t)

src/test/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
+ // MIR for `unreachable` after LowerIntrinsics
33

44
fn unreachable() -> ! {
5-
let mut _0: !; // return place in scope 0 at $DIR/lower_intrinsics.rs:23:25: 23:26
6-
let mut _1: !; // in scope 0 at $DIR/lower_intrinsics.rs:23:27: 25:2
7-
let _2: (); // in scope 0 at $DIR/lower_intrinsics.rs:24:14: 24:45
8-
let mut _3: !; // in scope 0 at $DIR/lower_intrinsics.rs:24:14: 24:45
5+
let mut _0: !; // return place in scope 0 at $DIR/lower_intrinsics.rs:28:25: 28:26
6+
let mut _1: !; // in scope 0 at $DIR/lower_intrinsics.rs:28:27: 30:2
7+
let _2: (); // in scope 0 at $DIR/lower_intrinsics.rs:29:14: 29:45
8+
let mut _3: !; // in scope 0 at $DIR/lower_intrinsics.rs:29:14: 29:45
99
scope 1 {
1010
}
1111

1212
bb0: {
13-
StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:24:5: 24:47
14-
StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:24:14: 24:45
15-
- std::intrinsics::unreachable(); // scope 1 at $DIR/lower_intrinsics.rs:24:14: 24:45
13+
StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:29:5: 29:47
14+
StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:29:14: 29:45
15+
- std::intrinsics::unreachable(); // scope 1 at $DIR/lower_intrinsics.rs:29:14: 29:45
1616
- // mir::Constant
17-
- // + span: $DIR/lower_intrinsics.rs:24:14: 24:43
17+
- // + span: $DIR/lower_intrinsics.rs:29:14: 29:43
1818
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn() -> ! {std::intrinsics::unreachable}, val: Value(Scalar(<ZST>)) }
19-
+ unreachable; // scope 1 at $DIR/lower_intrinsics.rs:24:14: 24:45
19+
+ unreachable; // scope 1 at $DIR/lower_intrinsics.rs:29:14: 29:45
2020
}
2121

2222
bb1 (cleanup): {
23-
resume; // scope 0 at $DIR/lower_intrinsics.rs:23:1: 25:2
23+
resume; // scope 0 at $DIR/lower_intrinsics.rs:28:1: 30:2
2424
}
2525
}
2626

0 commit comments

Comments
 (0)