Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dfe3188

Browse files
committedMay 8, 2023
Auto merge of rust-lang#111007 - JakobDegen:nrvo, r=tmiasko
Disable nrvo mir opt See rust-lang#111005 and rust-lang#110902 . The ICE can definitely be hit on stable, the miscompilation I'm not sure about. The pass makes some pretty sketchy assumptions though, and we should not have it on while that's the case. I'm not going to work on actually fixing this, it's probably not excessively difficult though. r? rust-lang/mir-opt
2 parents a0111af + 8e2da80 commit dfe3188

20 files changed

+247
-574
lines changed
 

‎compiler/rustc_mir_transform/src/nrvo.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ pub struct RenameReturnPlace;
3434

3535
impl<'tcx> MirPass<'tcx> for RenameReturnPlace {
3636
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
37-
sess.mir_opt_level() > 0
37+
// #111005
38+
sess.mir_opt_level() > 0 && sess.opts.unstable_opts.unsound_mir_opts
3839
}
3940

4041
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut mir::Body<'tcx>) {

‎tests/codegen/fewer-names.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
#[no_mangle]
99
pub fn sum(x: u32, y: u32) -> u32 {
10-
// YES-LABEL: define{{.*}}i32 @sum(i32 noundef %0, i32 noundef %1)
11-
// YES-NEXT: %3 = add i32 %1, %0
12-
// YES-NEXT: ret i32 %3
10+
// YES-LABEL: define{{.*}}i32 @sum(i32 noundef %0, i32 noundef %1)
11+
// YES-NEXT: %3 = add i32 %1, %0
12+
// YES-NEXT: ret i32 %3
1313

14-
// NO-LABEL: define{{.*}}i32 @sum(i32 noundef %x, i32 noundef %y)
15-
// NO-NEXT: start:
16-
// NO-NEXT: %0 = add i32 %y, %x
17-
// NO-NEXT: ret i32 %0
14+
// NO-LABEL: define{{.*}}i32 @sum(i32 noundef %x, i32 noundef %y)
15+
// NO-NEXT: start:
16+
// NO-NEXT: %z = add i32 %y, %x
17+
// NO-NEXT: ret i32 %z
1818
let z = x + y;
1919
z
2020
}

‎tests/codegen/mem-replace-big-type.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ pub struct Big([u64; 7]);
1313
pub fn replace_big(dst: &mut Big, src: Big) -> Big {
1414
// Back in 1.68, this emitted six `memcpy`s.
1515
// `read_via_copy` in 1.69 got that down to three.
16-
// `write_via_move` has it down to just the two essential ones.
16+
// `write_via_move` it was originally down to the essential two, however
17+
// with nrvo disabled it is back at 3
1718
std::mem::replace(dst, src)
1819
}
1920

@@ -22,13 +23,14 @@ pub fn replace_big(dst: &mut Big, src: Big) -> Big {
2223

2324
// CHECK-NOT: call void @llvm.memcpy
2425

25-
// For a large type, we expect exactly two `memcpy`s
26+
// For a large type, we expect exactly three `memcpy`s
2627
// CHECK-LABEL: define internal void @{{.+}}mem{{.+}}replace{{.+}}sret(%Big)
27-
// CHECK-NOT: alloca
28-
// CHECK-NOT: call void @llvm.memcpy
29-
// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %0, {{i8\*|ptr}} align 8 %dest, i{{.*}} 56, i1 false)
30-
// CHECK-NOT: call void @llvm.memcpy
31-
// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %dest, {{i8\*|ptr}} align 8 %src, i{{.*}} 56, i1 false)
32-
// CHECK-NOT: call void @llvm.memcpy
28+
// CHECK-NOT: call void @llvm.memcpy
29+
// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %result, {{i8\*|ptr}} align 8 %dest, i{{.*}} 56, i1 false)
30+
// CHECK-NOT: call void @llvm.memcpy
31+
// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %dest, {{i8\*|ptr}} align 8 %src, i{{.*}} 56, i1 false)
32+
// CHECK-NOT: call void @llvm.memcpy
33+
// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %0, {{i8\*|ptr}} align 8 %result, i{{.*}} 56, i1 false)
34+
// CHECK-NOT: call void @llvm.memcpy
3335

3436
// CHECK-NOT: call void @llvm.memcpy

‎tests/codegen/nrvo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
pub fn nrvo(init: fn(&mut [u8; 4096])) -> [u8; 4096] {
99
// CHECK-LABEL: nrvo
1010
// CHECK: @llvm.memset
11-
// CHECK-NOT: @llvm.memcpy
11+
// FIXME: turn on nrvo then check-not: @llvm.memcpy
1212
// CHECK: ret
1313
// CHECK-EMPTY
1414
let mut buf = [0; 4096];

‎tests/codegen/var-names.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub fn test(a: u32, b: u32) -> u32 {
99
// CHECK: %c = add i32 %a, %b
1010
let d = c;
1111
let e = d * a;
12-
// CHECK-NEXT: %0 = mul i32 %c, %a
12+
// CHECK-NEXT: %e = mul i32 %c, %a
1313
e
14-
// CHECK-NEXT: ret i32 %0
14+
// CHECK-NEXT: ret i32 %e
1515
}

‎tests/mir-opt/inline/inline_into_box_place.main.Inline.diff

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
+ let mut _4: usize; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
1717
+ let mut _5: usize; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
1818
+ let mut _6: *mut u8; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
19-
+ let mut _7: *const std::vec::Vec<u32>; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
19+
+ let mut _7: std::boxed::Box<std::vec::Vec<u32>>; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
20+
+ let mut _8: *const std::vec::Vec<u32>; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
2021
+ scope 4 {
2122
+ }
2223
+ }
@@ -65,9 +66,12 @@
6566
bb3: {
6667
- StorageDead(_1); // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2
6768
- return; // scope 0 at $DIR/inline_into_box_place.rs:+2:2: +2:2
68-
+ _1 = ShallowInitBox(move _6, std::vec::Vec<u32>); // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
69-
+ _7 = (((_1.0: std::ptr::Unique<std::vec::Vec<u32>>).0: std::ptr::NonNull<std::vec::Vec<u32>>).0: *const std::vec::Vec<u32>); // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
70-
+ (*_7) = move _2; // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
69+
+ StorageLive(_7); // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
70+
+ _7 = ShallowInitBox(move _6, std::vec::Vec<u32>); // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
71+
+ _8 = (((_7.0: std::ptr::Unique<std::vec::Vec<u32>>).0: std::ptr::NonNull<std::vec::Vec<u32>>).0: *const std::vec::Vec<u32>); // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
72+
+ (*_8) = move _2; // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
73+
+ _1 = move _7; // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
74+
+ StorageDead(_7); // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
7175
+ StorageDead(_2); // scope 0 at $DIR/inline_into_box_place.rs:+1:48: +1:49
7276
+ _0 = const (); // scope 0 at $DIR/inline_into_box_place.rs:+0:11: +2:2
7377
+ drop(_1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2

‎tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@ fn b(_1: &mut Box<T>) -> &mut T {
88
let mut _4: &mut std::boxed::Box<T>; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
99
scope 1 (inlined <Box<T> as AsMut<T>>::as_mut) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:8:7: 8:15
1010
debug self => _4; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
11-
let mut _5: std::boxed::Box<T>; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
12-
let mut _6: *const T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
11+
let mut _5: &mut T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
12+
let mut _6: std::boxed::Box<T>; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
13+
let mut _7: *const T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
1314
}
1415

1516
bb0: {
1617
StorageLive(_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
1718
StorageLive(_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
1819
StorageLive(_4); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
1920
_4 = &mut (*_1); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
20-
_5 = deref_copy (*_4); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
21-
_6 = (((_5.0: std::ptr::Unique<T>).0: std::ptr::NonNull<T>).0: *const T); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
22-
_3 = &mut (*_6); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
21+
StorageLive(_5); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:7: +1:15
22+
_6 = deref_copy (*_4); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
23+
_7 = (((_6.0: std::ptr::Unique<T>).0: std::ptr::NonNull<T>).0: *const T); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
24+
_5 = &mut (*_7); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
25+
_3 = _5; // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
26+
StorageDead(_5); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:7: +1:15
2327
_2 = &mut (*_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
2428
StorageDead(_4); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:14: +1:15
2529
_0 = &mut (*_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15

‎tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,21 @@ fn d(_1: &Box<T>) -> &T {
77
let mut _3: &std::boxed::Box<T>; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
88
scope 1 (inlined <Box<T> as AsRef<T>>::as_ref) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:18:7: 18:15
99
debug self => _3; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
10-
let mut _4: std::boxed::Box<T>; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
11-
let mut _5: *const T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
10+
let _4: &T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
11+
let mut _5: std::boxed::Box<T>; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
12+
let mut _6: *const T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
1213
}
1314

1415
bb0: {
1516
StorageLive(_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
1617
StorageLive(_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
1718
_3 = &(*_1); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
18-
_4 = deref_copy (*_3); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
19-
_5 = (((_4.0: std::ptr::Unique<T>).0: std::ptr::NonNull<T>).0: *const T); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
20-
_2 = &(*_5); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
19+
StorageLive(_4); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
20+
_5 = deref_copy (*_3); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
21+
_6 = (((_5.0: std::ptr::Unique<T>).0: std::ptr::NonNull<T>).0: *const T); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
22+
_4 = &(*_6); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
23+
_2 = _4; // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
24+
StorageDead(_4); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
2125
_0 = &(*_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
2226
StorageDead(_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:14: +1:15
2327
StorageDead(_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:1: +2:2

‎tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff

Lines changed: 14 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -12,51 +12,7 @@
1212
+ debug rhs => _4; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
1313
+ let mut _5: u16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL
1414
+ let mut _6: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL
15-
+ let mut _7: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL
1615
+ scope 2 {
17-
+ scope 3 (inlined core::num::<impl u16>::unchecked_shl::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
18-
+ debug x => _7; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL
19-
+ let mut _8: std::option::Option<u16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL
20-
+ let mut _9: std::result::Result<u16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL
21-
+ scope 4 {
22-
+ scope 5 (inlined <u32 as TryInto<u16>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
23-
+ debug self => _7; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
24-
+ scope 6 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL
25-
+ debug u => _7; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
26-
+ let mut _10: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
27-
+ let mut _11: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
28-
+ let mut _12: u16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
29-
+ }
30-
+ }
31-
+ scope 7 (inlined Result::<u16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
32-
+ debug self => _9; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
33-
+ let mut _13: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
34-
+ let _14: u16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
35-
+ scope 8 {
36-
+ debug x => _14; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL
37-
+ }
38-
+ }
39-
+ scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
40-
+ debug self => _8; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
41-
+ let mut _15: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
42-
+ let mut _16: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
43-
+ scope 10 {
44-
+ debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL
45-
+ }
46-
+ scope 11 {
47-
+ scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL
48-
+ scope 14 {
49-
+ scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
50-
+ }
51-
+ }
52-
+ }
53-
+ }
54-
+ scope 12 (inlined Option::<u16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL
55-
+ debug self => _15; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL
56-
+ }
57-
+ }
58-
+ }
59-
+ }
6016
+ }
6117
+ }
6218

@@ -66,87 +22,30 @@
6622
StorageLive(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22
6723
_4 = _2; // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22
6824
- _0 = core::num::<impl u16>::unchecked_shl(move _3, move _4) -> bb1; // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:23
69-
- // mir::Constant
70-
- // + span: $DIR/unchecked_shifts.rs:11:7: 11:20
71-
- // + literal: Const { ty: unsafe fn(u16, u32) -> u16 {core::num::<impl u16>::unchecked_shl}, val: Value(<ZST>) }
7225
+ StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
7326
+ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
7427
+ _6 = (_4,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
75-
+ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
76-
+ _7 = move (_6.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
77-
+ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
78-
+ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
79-
+ StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
80-
+ StorageLive(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
81-
+ _11 = const 65535_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
82-
+ _10 = Gt(_7, move _11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
83-
+ StorageDead(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
84-
+ switchInt(move _10) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
28+
+ _5 = core::num::<impl u16>::unchecked_shl::conv(move (_6.0: u32)) -> bb1; // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
29+
// mir::Constant
30+
- // + span: $DIR/unchecked_shifts.rs:11:7: 11:20
31+
- // + literal: Const { ty: unsafe fn(u16, u32) -> u16 {core::num::<impl u16>::unchecked_shl}, val: Value(<ZST>) }
32+
+ // + span: $SRC_DIR/core/src/num/mod.rs:LL:COL
33+
+ // + literal: Const { ty: fn(u32) -> u16 {core::num::<impl u16>::unchecked_shl::conv}, val: Value(<ZST>) }
8534
}
8635

8736
bb1: {
88-
+ StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
89-
StorageDead(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23
90-
StorageDead(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23
91-
return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2
92-
+ }
93-
+
94-
+ bb2: {
95-
+ _9 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
96-
+ // mir::Constant
97-
+ // + span: no-location
98-
+ // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) }
99-
+ goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
100-
+ }
101-
+
102-
+ bb3: {
103-
+ StorageLive(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
104-
+ _12 = _7 as u16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
105-
+ _9 = Result::<u16, TryFromIntError>::Ok(move _12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
106-
+ StorageDead(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
107-
+ goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
108-
+ }
109-
+
110-
+ bb4: {
111-
+ StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
112-
+ StorageLive(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
113-
+ _13 = discriminant(_9); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
114-
+ switchInt(move _13) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
115-
+ }
116-
+
117-
+ bb5: {
118-
+ _8 = Option::<u16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
119-
+ goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
120-
+ }
121-
+
122-
+ bb6: {
123-
+ unreachable; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
124-
+ }
125-
+
126-
+ bb7: {
127-
+ _14 = move ((_9 as Ok).0: u16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
128-
+ _8 = Option::<u16>::Some(move _14); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL
129-
+ goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
130-
+ }
131-
+
132-
+ bb8: {
133-
+ StorageDead(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
134-
+ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
135-
+ StorageLive(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
136-
+ _16 = discriminant(_8); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
137-
+ switchInt(move _16) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
138-
+ }
139-
+
140-
+ bb9: {
141-
+ _5 = move ((_8 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
142-
+ StorageDead(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
143-
+ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
144-
+ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
14537
+ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
146-
+ _0 = unchecked_shl::<u16>(_3, move _5) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
38+
+ _0 = unchecked_shl::<u16>(_3, move _5) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
14739
+ // mir::Constant
14840
+ // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
14941
+ // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u16, u16) -> u16 {unchecked_shl::<u16>}, val: Value(<ZST>) }
42+
+ }
43+
+
44+
+ bb2: {
45+
+ StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
46+
StorageDead(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23
47+
StorageDead(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23
48+
return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2
15049
}
15150
}
15251

‎tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir

Lines changed: 10 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -9,130 +9,30 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 {
99
debug rhs => _2; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
1010
let mut _3: u16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL
1111
let mut _4: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL
12-
let mut _5: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL
1312
scope 2 {
14-
scope 3 (inlined core::num::<impl u16>::unchecked_shl::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
15-
debug x => _5; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL
16-
let mut _6: std::option::Option<u16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL
17-
let mut _7: std::result::Result<u16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL
18-
scope 4 {
19-
scope 5 (inlined <u32 as TryInto<u16>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
20-
debug self => _5; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
21-
scope 6 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL
22-
debug u => _5; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
23-
let mut _8: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
24-
let mut _9: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
25-
let mut _10: u16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
26-
}
27-
}
28-
scope 7 (inlined Result::<u16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
29-
debug self => _7; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
30-
let mut _11: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
31-
let _12: u16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
32-
scope 8 {
33-
debug x => _12; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL
34-
}
35-
}
36-
scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
37-
debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
38-
let mut _13: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
39-
let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
40-
scope 10 {
41-
debug val => _3; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL
42-
}
43-
scope 11 {
44-
scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL
45-
scope 14 {
46-
scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
47-
}
48-
}
49-
}
50-
}
51-
scope 12 (inlined Option::<u16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL
52-
debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL
53-
}
54-
}
55-
}
56-
}
5713
}
5814
}
5915

6016
bb0: {
6117
StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
6218
StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
6319
_4 = (_2,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
64-
StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
65-
_5 = move (_4.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
66-
StorageLive(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
67-
StorageLive(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
68-
StorageLive(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
69-
StorageLive(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
70-
_9 = const 65535_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
71-
_8 = Gt(_5, move _9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
72-
StorageDead(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
73-
switchInt(move _8) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
74-
}
75-
76-
bb1: {
77-
StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
78-
return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2
79-
}
80-
81-
bb2: {
82-
_7 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
20+
_3 = core::num::<impl u16>::unchecked_shl::conv(move (_4.0: u32)) -> bb1; // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
8321
// mir::Constant
84-
// + span: no-location
85-
// + literal: Const { ty: TryFromIntError, val: Value(<ZST>) }
86-
goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
87-
}
88-
89-
bb3: {
90-
StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
91-
_10 = _5 as u16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
92-
_7 = Result::<u16, TryFromIntError>::Ok(move _10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
93-
StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
94-
goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
95-
}
96-
97-
bb4: {
98-
StorageDead(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
99-
StorageLive(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
100-
_11 = discriminant(_7); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
101-
switchInt(move _11) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
102-
}
103-
104-
bb5: {
105-
_6 = Option::<u16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
106-
goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
107-
}
108-
109-
bb6: {
110-
unreachable; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
111-
}
112-
113-
bb7: {
114-
_12 = move ((_7 as Ok).0: u16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
115-
_6 = Option::<u16>::Some(move _12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL
116-
goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
117-
}
118-
119-
bb8: {
120-
StorageDead(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
121-
StorageDead(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
122-
StorageLive(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
123-
_14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
124-
switchInt(move _14) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
22+
// + span: $SRC_DIR/core/src/num/mod.rs:LL:COL
23+
// + literal: Const { ty: fn(u32) -> u16 {core::num::<impl u16>::unchecked_shl::conv}, val: Value(<ZST>) }
12524
}
12625

127-
bb9: {
128-
_3 = move ((_6 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
129-
StorageDead(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
130-
StorageDead(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
131-
StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
26+
bb1: {
13227
StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
133-
_0 = unchecked_shl::<u16>(_1, move _3) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
28+
_0 = unchecked_shl::<u16>(_1, move _3) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
13429
// mir::Constant
13530
// + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
13631
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u16, u16) -> u16 {unchecked_shl::<u16>}, val: Value(<ZST>) }
13732
}
33+
34+
bb2: {
35+
StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
36+
return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2
37+
}
13838
}

‎tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff

Lines changed: 14 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -12,51 +12,7 @@
1212
+ debug rhs => _4; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL
1313
+ let mut _5: i16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL
1414
+ let mut _6: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL
15-
+ let mut _7: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL
1615
+ scope 2 {
17-
+ scope 3 (inlined core::num::<impl i16>::unchecked_shr::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
18-
+ debug x => _7; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL
19-
+ let mut _8: std::option::Option<i16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL
20-
+ let mut _9: std::result::Result<i16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL
21-
+ scope 4 {
22-
+ scope 5 (inlined <u32 as TryInto<i16>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
23-
+ debug self => _7; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
24-
+ scope 6 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL
25-
+ debug u => _7; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
26-
+ let mut _10: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
27-
+ let mut _11: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
28-
+ let mut _12: i16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
29-
+ }
30-
+ }
31-
+ scope 7 (inlined Result::<i16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
32-
+ debug self => _9; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
33-
+ let mut _13: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
34-
+ let _14: i16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
35-
+ scope 8 {
36-
+ debug x => _14; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL
37-
+ }
38-
+ }
39-
+ scope 9 (inlined #[track_caller] Option::<i16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
40-
+ debug self => _8; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
41-
+ let mut _15: &std::option::Option<i16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
42-
+ let mut _16: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
43-
+ scope 10 {
44-
+ debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL
45-
+ }
46-
+ scope 11 {
47-
+ scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL
48-
+ scope 14 {
49-
+ scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
50-
+ }
51-
+ }
52-
+ }
53-
+ }
54-
+ scope 12 (inlined Option::<i16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL
55-
+ debug self => _15; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL
56-
+ }
57-
+ }
58-
+ }
59-
+ }
6016
+ }
6117
+ }
6218

@@ -66,87 +22,30 @@
6622
StorageLive(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22
6723
_4 = _2; // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22
6824
- _0 = core::num::<impl i16>::unchecked_shr(move _3, move _4) -> bb1; // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:23
69-
- // mir::Constant
70-
- // + span: $DIR/unchecked_shifts.rs:17:7: 17:20
71-
- // + literal: Const { ty: unsafe fn(i16, u32) -> i16 {core::num::<impl i16>::unchecked_shr}, val: Value(<ZST>) }
7225
+ StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
7326
+ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
7427
+ _6 = (_4,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
75-
+ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
76-
+ _7 = move (_6.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
77-
+ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
78-
+ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
79-
+ StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
80-
+ StorageLive(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
81-
+ _11 = const 32767_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
82-
+ _10 = Gt(_7, move _11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
83-
+ StorageDead(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
84-
+ switchInt(move _10) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
28+
+ _5 = core::num::<impl i16>::unchecked_shr::conv(move (_6.0: u32)) -> bb1; // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
29+
// mir::Constant
30+
- // + span: $DIR/unchecked_shifts.rs:17:7: 17:20
31+
- // + literal: Const { ty: unsafe fn(i16, u32) -> i16 {core::num::<impl i16>::unchecked_shr}, val: Value(<ZST>) }
32+
+ // + span: $SRC_DIR/core/src/num/mod.rs:LL:COL
33+
+ // + literal: Const { ty: fn(u32) -> i16 {core::num::<impl i16>::unchecked_shr::conv}, val: Value(<ZST>) }
8534
}
8635

8736
bb1: {
88-
+ StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL
89-
StorageDead(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23
90-
StorageDead(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23
91-
return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2
92-
+ }
93-
+
94-
+ bb2: {
95-
+ _9 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
96-
+ // mir::Constant
97-
+ // + span: no-location
98-
+ // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) }
99-
+ goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
100-
+ }
101-
+
102-
+ bb3: {
103-
+ StorageLive(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
104-
+ _12 = _7 as i16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
105-
+ _9 = Result::<i16, TryFromIntError>::Ok(move _12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
106-
+ StorageDead(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
107-
+ goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
108-
+ }
109-
+
110-
+ bb4: {
111-
+ StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
112-
+ StorageLive(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
113-
+ _13 = discriminant(_9); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
114-
+ switchInt(move _13) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
115-
+ }
116-
+
117-
+ bb5: {
118-
+ _8 = Option::<i16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
119-
+ goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
120-
+ }
121-
+
122-
+ bb6: {
123-
+ unreachable; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
124-
+ }
125-
+
126-
+ bb7: {
127-
+ _14 = move ((_9 as Ok).0: i16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
128-
+ _8 = Option::<i16>::Some(move _14); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL
129-
+ goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
130-
+ }
131-
+
132-
+ bb8: {
133-
+ StorageDead(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
134-
+ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
135-
+ StorageLive(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
136-
+ _16 = discriminant(_8); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
137-
+ switchInt(move _16) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
138-
+ }
139-
+
140-
+ bb9: {
141-
+ _5 = move ((_8 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
142-
+ StorageDead(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
143-
+ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
144-
+ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
14537
+ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
146-
+ _0 = unchecked_shr::<i16>(_3, move _5) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL
38+
+ _0 = unchecked_shr::<i16>(_3, move _5) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL
14739
+ // mir::Constant
14840
+ // + span: $SRC_DIR/core/src/num/int_macros.rs:LL:COL
14941
+ // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(i16, i16) -> i16 {unchecked_shr::<i16>}, val: Value(<ZST>) }
42+
+ }
43+
+
44+
+ bb2: {
45+
+ StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL
46+
StorageDead(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23
47+
StorageDead(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23
48+
return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2
15049
}
15150
}
15251

‎tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir

Lines changed: 10 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -9,130 +9,30 @@ fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 {
99
debug rhs => _2; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL
1010
let mut _3: i16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL
1111
let mut _4: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL
12-
let mut _5: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL
1312
scope 2 {
14-
scope 3 (inlined core::num::<impl i16>::unchecked_shr::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
15-
debug x => _5; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL
16-
let mut _6: std::option::Option<i16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL
17-
let mut _7: std::result::Result<i16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL
18-
scope 4 {
19-
scope 5 (inlined <u32 as TryInto<i16>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
20-
debug self => _5; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
21-
scope 6 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL
22-
debug u => _5; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
23-
let mut _8: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
24-
let mut _9: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
25-
let mut _10: i16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
26-
}
27-
}
28-
scope 7 (inlined Result::<i16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
29-
debug self => _7; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
30-
let mut _11: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
31-
let _12: i16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
32-
scope 8 {
33-
debug x => _12; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL
34-
}
35-
}
36-
scope 9 (inlined #[track_caller] Option::<i16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
37-
debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
38-
let mut _13: &std::option::Option<i16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
39-
let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
40-
scope 10 {
41-
debug val => _3; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL
42-
}
43-
scope 11 {
44-
scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL
45-
scope 14 {
46-
scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
47-
}
48-
}
49-
}
50-
}
51-
scope 12 (inlined Option::<i16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL
52-
debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL
53-
}
54-
}
55-
}
56-
}
5713
}
5814
}
5915

6016
bb0: {
6117
StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
6218
StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
6319
_4 = (_2,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
64-
StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
65-
_5 = move (_4.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
66-
StorageLive(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
67-
StorageLive(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
68-
StorageLive(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
69-
StorageLive(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
70-
_9 = const 32767_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
71-
_8 = Gt(_5, move _9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
72-
StorageDead(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
73-
switchInt(move _8) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
74-
}
75-
76-
bb1: {
77-
StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL
78-
return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2
79-
}
80-
81-
bb2: {
82-
_7 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
20+
_3 = core::num::<impl i16>::unchecked_shr::conv(move (_4.0: u32)) -> bb1; // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
8321
// mir::Constant
84-
// + span: no-location
85-
// + literal: Const { ty: TryFromIntError, val: Value(<ZST>) }
86-
goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
87-
}
88-
89-
bb3: {
90-
StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
91-
_10 = _5 as i16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
92-
_7 = Result::<i16, TryFromIntError>::Ok(move _10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
93-
StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
94-
goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
95-
}
96-
97-
bb4: {
98-
StorageDead(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL
99-
StorageLive(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
100-
_11 = discriminant(_7); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
101-
switchInt(move _11) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
102-
}
103-
104-
bb5: {
105-
_6 = Option::<i16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
106-
goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
107-
}
108-
109-
bb6: {
110-
unreachable; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
111-
}
112-
113-
bb7: {
114-
_12 = move ((_7 as Ok).0: i16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
115-
_6 = Option::<i16>::Some(move _12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL
116-
goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
117-
}
118-
119-
bb8: {
120-
StorageDead(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
121-
StorageDead(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
122-
StorageLive(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
123-
_14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
124-
switchInt(move _14) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
22+
// + span: $SRC_DIR/core/src/num/mod.rs:LL:COL
23+
// + literal: Const { ty: fn(u32) -> i16 {core::num::<impl i16>::unchecked_shr::conv}, val: Value(<ZST>) }
12524
}
12625

127-
bb9: {
128-
_3 = move ((_6 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
129-
StorageDead(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
130-
StorageDead(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL
131-
StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
26+
bb1: {
13227
StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
133-
_0 = unchecked_shr::<i16>(_1, move _3) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL
28+
_0 = unchecked_shr::<i16>(_1, move _3) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL
13429
// mir::Constant
13530
// + span: $SRC_DIR/core/src/num/int_macros.rs:LL:COL
13631
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(i16, i16) -> i16 {unchecked_shr::<i16>}, val: Value(<ZST>) }
13732
}
33+
34+
bb2: {
35+
StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL
36+
return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2
37+
}
13838
}

‎tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
+ debug self => _2; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL
1010
+ let mut _3: &std::option::Option<T>; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL
1111
+ let mut _4: isize; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL
12+
+ let _5: T; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL
1213
+ scope 2 {
13-
+ debug val => _0; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL
14+
+ debug val => _5; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL
1415
+ }
1516
+ scope 3 {
1617
+ scope 5 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL
@@ -46,7 +47,10 @@
4647
- bb2 (cleanup): {
4748
- resume; // scope 0 at $DIR/unwrap_unchecked.rs:+0:1: +2:2
4849
+ bb2: {
49-
+ _0 = move ((_2 as Some).0: T); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL
50+
+ StorageLive(_5); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL
51+
+ _5 = move ((_2 as Some).0: T); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL
52+
+ _0 = move _5; // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL
53+
+ StorageDead(_5); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL
5054
+ StorageDead(_3); // scope 0 at $DIR/unwrap_unchecked.rs:+1:9: +1:27
5155
+ StorageDead(_2); // scope 0 at $DIR/unwrap_unchecked.rs:+1:26: +1:27
5256
+ return; // scope 0 at $DIR/unwrap_unchecked.rs:+2:2: +2:2

‎tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.mir

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ fn unwrap_unchecked(_1: Option<T>) -> T {
77
debug self => _1; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL
88
let mut _2: &std::option::Option<T>; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL
99
let mut _3: isize; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL
10+
let _4: T; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL
1011
scope 2 {
11-
debug val => _0; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL
12+
debug val => _4; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL
1213
}
1314
scope 3 {
1415
scope 5 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL
@@ -34,7 +35,10 @@ fn unwrap_unchecked(_1: Option<T>) -> T {
3435
}
3536

3637
bb2: {
37-
_0 = move ((_1 as Some).0: T); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL
38+
StorageLive(_4); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL
39+
_4 = move ((_1 as Some).0: T); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL
40+
_0 = move _4; // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL
41+
StorageDead(_4); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL
3842
StorageDead(_2); // scope 0 at $DIR/unwrap_unchecked.rs:+1:9: +1:27
3943
return; // scope 0 at $DIR/unwrap_unchecked.rs:+2:2: +2:2
4044
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// This is a miscompilation, #111005 to track
2+
3+
// unit-test: RenameReturnPlace
4+
5+
#![feature(custom_mir, core_intrinsics)]
6+
extern crate core;
7+
use core::intrinsics::mir::*;
8+
9+
// EMIT_MIR nrvo_miscompile_111005.wrong.RenameReturnPlace.diff
10+
#[custom_mir(dialect = "runtime", phase = "initial")]
11+
pub fn wrong(arg: char) -> char {
12+
mir!({
13+
let temp = arg;
14+
RET = temp;
15+
temp = 'b';
16+
Return()
17+
})
18+
}
19+
20+
fn main() {
21+
assert_eq!(wrong('a'), 'a');
22+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
- // MIR for `wrong` before RenameReturnPlace
2+
+ // MIR for `wrong` after RenameReturnPlace
3+
4+
fn wrong(_1: char) -> char {
5+
- let mut _0: char; // return place in scope 0 at $DIR/nrvo_miscompile_111005.rs:+0:28: +0:32
6+
+ let mut _0: char; // return place in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
7+
let mut _2: char; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
8+
9+
bb0: {
10+
- _2 = _1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
11+
- _0 = _2; // scope 0 at $DIR/nrvo_miscompile_111005.rs:+3:9: +3:19
12+
- _2 = const 'b'; // scope 0 at $DIR/nrvo_miscompile_111005.rs:+4:9: +4:19
13+
+ _0 = _1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
14+
+ _0 = const 'b'; // scope 0 at $DIR/nrvo_miscompile_111005.rs:+4:9: +4:19
15+
return; // scope 0 at $DIR/nrvo_miscompile_111005.rs:+5:9: +5:17
16+
}
17+
}
18+

‎tests/mir-opt/pre-codegen/mem_replace.manual_replace.PreCodegen.after.mir

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
fn manual_replace(_1: &mut u32, _2: u32) -> u32 {
44
debug r => _1; // in scope 0 at $DIR/mem_replace.rs:+0:23: +0:24
55
debug v => _2; // in scope 0 at $DIR/mem_replace.rs:+0:36: +0:37
6-
let mut _0: u32; // return place in scope 0 at $DIR/mem_replace.rs:+1:9: +1:13
6+
let mut _0: u32; // return place in scope 0 at $DIR/mem_replace.rs:+0:47: +0:50
7+
let _3: u32; // in scope 0 at $DIR/mem_replace.rs:+1:9: +1:13
78
scope 1 {
8-
debug temp => _0; // in scope 1 at $DIR/mem_replace.rs:+1:9: +1:13
9+
debug temp => _3; // in scope 1 at $DIR/mem_replace.rs:+1:9: +1:13
910
}
1011

1112
bb0: {
12-
_0 = (*_1); // scope 0 at $DIR/mem_replace.rs:+1:16: +1:18
13+
StorageLive(_3); // scope 0 at $DIR/mem_replace.rs:+1:9: +1:13
14+
_3 = (*_1); // scope 0 at $DIR/mem_replace.rs:+1:16: +1:18
1315
(*_1) = _2; // scope 1 at $DIR/mem_replace.rs:+2:5: +2:11
16+
_0 = _3; // scope 1 at $DIR/mem_replace.rs:+3:5: +3:9
17+
StorageDead(_3); // scope 0 at $DIR/mem_replace.rs:+4:1: +4:2
1418
return; // scope 0 at $DIR/mem_replace.rs:+4:2: +4:2
1519
}
1620
}

‎tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,29 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 {
77
scope 1 (inlined std::mem::replace::<u32>) { // at $DIR/mem_replace.rs:16:5: 16:28
88
debug dest => _1; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
99
debug src => _2; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
10-
let mut _3: *const u32; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
11-
let mut _4: *mut u32; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
10+
let mut _4: *const u32; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
11+
let mut _5: *mut u32; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
1212
scope 2 {
13+
let _3: u32; // in scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
1314
scope 3 {
14-
debug result => _0; // in scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
15+
debug result => _3; // in scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
1516
scope 7 (inlined std::ptr::write::<u32>) { // at $SRC_DIR/core/src/mem/mod.rs:LL:COL
16-
debug dst => _4; // in scope 7 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
17+
debug dst => _5; // in scope 7 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
1718
debug src => _2; // in scope 7 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
18-
let mut _6: *mut u32; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
19+
let mut _7: *mut u32; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
1920
scope 8 {
2021
scope 9 (inlined std::ptr::write::runtime::<u32>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
21-
debug dst => _6; // in scope 9 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
22+
debug dst => _7; // in scope 9 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
2223
}
2324
}
2425
}
2526
}
2627
scope 4 (inlined std::ptr::read::<u32>) { // at $SRC_DIR/core/src/mem/mod.rs:LL:COL
27-
debug src => _3; // in scope 4 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
28-
let mut _5: *const u32; // in scope 4 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
28+
debug src => _4; // in scope 4 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
29+
let mut _6: *const u32; // in scope 4 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
2930
scope 5 {
3031
scope 6 (inlined std::ptr::read::runtime::<u32>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
31-
debug src => _5; // in scope 6 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
32+
debug src => _6; // in scope 6 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
3233
}
3334
}
3435
}
@@ -37,17 +38,20 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 {
3738

3839
bb0: {
3940
StorageLive(_3); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
40-
_3 = &raw const (*_1); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
41-
StorageLive(_5); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
42-
_0 = (*_3); // scope 5 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
43-
StorageDead(_5); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
41+
StorageLive(_4); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
42+
_4 = &raw const (*_1); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
43+
StorageLive(_6); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
44+
_3 = (*_4); // scope 5 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
45+
StorageDead(_6); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
46+
StorageDead(_4); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
47+
StorageLive(_5); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
48+
_5 = &raw mut (*_1); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
49+
StorageLive(_7); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
50+
(*_5) = _2; // scope 8 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
51+
StorageDead(_7); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
52+
StorageDead(_5); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
53+
_0 = move _3; // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
4454
StorageDead(_3); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
45-
StorageLive(_4); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
46-
_4 = &raw mut (*_1); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
47-
StorageLive(_6); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
48-
(*_4) = _2; // scope 8 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
49-
StorageDead(_6); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
50-
StorageDead(_4); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL
5155
return; // scope 0 at $DIR/mem_replace.rs:+2:2: +2:2
5256
}
5357
}

‎tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir

Lines changed: 63 additions & 61 deletions
Large diffs are not rendered by default.

‎tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.mir

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,26 @@
33
fn slice_index_range(_1: &[u32], _2: std::ops::Range<usize>) -> &[u32] {
44
debug slice => _1; // in scope 0 at $DIR/slice_index.rs:+0:26: +0:31
55
debug index => _2; // in scope 0 at $DIR/slice_index.rs:+0:41: +0:46
6-
let mut _0: &[u32]; // return place in scope 0 at $DIR/slice_index.rs:+1:5: +1:18
6+
let mut _0: &[u32]; // return place in scope 0 at $DIR/slice_index.rs:+0:65: +0:71
77
let _3: &[u32]; // in scope 0 at $DIR/slice_index.rs:+1:6: +1:18
88
scope 1 (inlined #[track_caller] core::slice::index::<impl Index<std::ops::Range<usize>> for [u32]>::index) { // at $DIR/slice_index.rs:21:6: 21:18
99
debug self => _1; // in scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL
1010
debug index => _2; // in scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL
11+
let _4: &[u32]; // in scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL
1112
}
1213

1314
bb0: {
14-
StorageLive(_3); // scope 0 at $DIR/slice_index.rs:+1:6: +1:18
15-
_3 = <std::ops::Range<usize> as SliceIndex<[u32]>>::index(move _2, _1) -> bb1; // scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL
15+
StorageLive(_4); // scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL
16+
_4 = <std::ops::Range<usize> as SliceIndex<[u32]>>::index(move _2, _1) -> bb1; // scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL
1617
// mir::Constant
1718
// + span: $SRC_DIR/core/src/slice/index.rs:LL:COL
1819
// + literal: Const { ty: for<'a> fn(std::ops::Range<usize>, &'a [u32]) -> &'a <std::ops::Range<usize> as SliceIndex<[u32]>>::Output {<std::ops::Range<usize> as SliceIndex<[u32]>>::index}, val: Value(<ZST>) }
1920
}
2021

2122
bb1: {
23+
_3 = _4; // scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL
24+
StorageDead(_4); // scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL
2225
_0 = _3; // scope 0 at $DIR/slice_index.rs:+1:5: +1:18
23-
StorageDead(_3); // scope 0 at $DIR/slice_index.rs:+2:1: +2:2
2426
return; // scope 0 at $DIR/slice_index.rs:+2:2: +2:2
2527
}
2628
}

0 commit comments

Comments
 (0)
This repository has been archived.