diff options
Diffstat (limited to 'tests/mir-opt')
328 files changed, 4462 insertions, 1659 deletions
diff --git a/tests/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir b/tests/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir index 5f8b2f931..b1d34a196 100644 --- a/tests/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir @@ -1,36 +1,36 @@ // MIR for `address_of_reborrow` after SimplifyCfg-initial | User Type Annotations -| 0: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:7:5: 7:18, inferred_ty: *const [i32; 10] -| 1: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:9:5: 9:25, inferred_ty: *const dyn std::marker::Send -| 2: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:13:12: 13:20, inferred_ty: *const [i32; 10] -| 3: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:13:12: 13:20, inferred_ty: *const [i32; 10] -| 4: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address_of.rs:14:12: 14:28, inferred_ty: *const [i32; 10] -| 5: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address_of.rs:14:12: 14:28, inferred_ty: *const [i32; 10] -| 6: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:15:12: 15:27, inferred_ty: *const dyn std::marker::Send -| 7: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:15:12: 15:27, inferred_ty: *const dyn std::marker::Send -| 8: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address_of.rs:16:12: 16:24, inferred_ty: *const [i32] -| 9: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address_of.rs:16:12: 16:24, inferred_ty: *const [i32] -| 10: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:18:5: 18:18, inferred_ty: *const [i32; 10] -| 11: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:20:5: 20:25, inferred_ty: *const dyn std::marker::Send -| 12: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:23:12: 23:20, inferred_ty: *const [i32; 10] -| 13: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:23:12: 23:20, inferred_ty: *const [i32; 10] -| 14: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address_of.rs:24:12: 24:28, inferred_ty: *const [i32; 10] -| 15: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address_of.rs:24:12: 24:28, inferred_ty: *const [i32; 10] -| 16: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:25:12: 25:27, inferred_ty: *const dyn std::marker::Send -| 17: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:25:12: 25:27, inferred_ty: *const dyn std::marker::Send -| 18: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address_of.rs:26:12: 26:24, inferred_ty: *const [i32] -| 19: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address_of.rs:26:12: 26:24, inferred_ty: *const [i32] -| 20: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) }, span: $DIR/address_of.rs:28:5: 28:16, inferred_ty: *mut [i32; 10] -| 21: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) }, span: $DIR/address_of.rs:30:5: 30:23, inferred_ty: *mut dyn std::marker::Send -| 22: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) }, span: $DIR/address_of.rs:33:12: 33:18, inferred_ty: *mut [i32; 10] -| 23: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) }, span: $DIR/address_of.rs:33:12: 33:18, inferred_ty: *mut [i32; 10] -| 24: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32; 10]) }, span: $DIR/address_of.rs:34:12: 34:26, inferred_ty: *mut [i32; 10] -| 25: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32; 10]) }, span: $DIR/address_of.rs:34:12: 34:26, inferred_ty: *mut [i32; 10] -| 26: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) }, span: $DIR/address_of.rs:35:12: 35:25, inferred_ty: *mut dyn std::marker::Send -| 27: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) }, span: $DIR/address_of.rs:35:12: 35:25, inferred_ty: *mut dyn std::marker::Send -| 28: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32]) }, span: $DIR/address_of.rs:36:12: 36:22, inferred_ty: *mut [i32] -| 29: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32]) }, span: $DIR/address_of.rs:36:12: 36:22, inferred_ty: *mut [i32] +| 0: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:7:5: 7:18, inferred_ty: *const [i32; 10] +| 1: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:9:5: 9:25, inferred_ty: *const dyn std::marker::Send +| 2: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:13:12: 13:20, inferred_ty: *const [i32; 10] +| 3: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:13:12: 13:20, inferred_ty: *const [i32; 10] +| 4: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:14:12: 14:28, inferred_ty: *const [i32; 10] +| 5: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:14:12: 14:28, inferred_ty: *const [i32; 10] +| 6: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:15:12: 15:27, inferred_ty: *const dyn std::marker::Send +| 7: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:15:12: 15:27, inferred_ty: *const dyn std::marker::Send +| 8: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:16:12: 16:24, inferred_ty: *const [i32] +| 9: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:16:12: 16:24, inferred_ty: *const [i32] +| 10: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:18:5: 18:18, inferred_ty: *const [i32; 10] +| 11: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:20:5: 20:25, inferred_ty: *const dyn std::marker::Send +| 12: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:23:12: 23:20, inferred_ty: *const [i32; 10] +| 13: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:23:12: 23:20, inferred_ty: *const [i32; 10] +| 14: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:24:12: 24:28, inferred_ty: *const [i32; 10] +| 15: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:24:12: 24:28, inferred_ty: *const [i32; 10] +| 16: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:25:12: 25:27, inferred_ty: *const dyn std::marker::Send +| 17: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:25:12: 25:27, inferred_ty: *const dyn std::marker::Send +| 18: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:26:12: 26:24, inferred_ty: *const [i32] +| 19: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:26:12: 26:24, inferred_ty: *const [i32] +| 20: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:28:5: 28:16, inferred_ty: *mut [i32; 10] +| 21: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:30:5: 30:23, inferred_ty: *mut dyn std::marker::Send +| 22: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:33:12: 33:18, inferred_ty: *mut [i32; 10] +| 23: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:33:12: 33:18, inferred_ty: *mut [i32; 10] +| 24: user_ty: Canonical { value: Ty(*mut [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:34:12: 34:26, inferred_ty: *mut [i32; 10] +| 25: user_ty: Canonical { value: Ty(*mut [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:34:12: 34:26, inferred_ty: *mut [i32; 10] +| 26: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:35:12: 35:25, inferred_ty: *mut dyn std::marker::Send +| 27: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:35:12: 35:25, inferred_ty: *mut dyn std::marker::Send +| 28: user_ty: Canonical { value: Ty(*mut [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:36:12: 36:22, inferred_ty: *mut [i32] +| 29: user_ty: Canonical { value: Ty(*mut [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:36:12: 36:22, inferred_ty: *mut [i32] | fn address_of_reborrow() -> () { let mut _0: (); // return place in scope 0 at $DIR/address_of.rs:+0:26: +0:26 diff --git a/tests/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir b/tests/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir index af5178d40..4be382fac 100644 --- a/tests/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir +++ b/tests/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir @@ -38,7 +38,7 @@ fn main() -> () { _6 = _3; // scope 4 at $DIR/array_index_is_temporary.rs:+4:25: +4:26 _5 = foo(move _6) -> bb1; // scope 4 at $DIR/array_index_is_temporary.rs:+4:21: +4:27 // mir::Constant - // + span: $DIR/array_index_is_temporary.rs:16:21: 16:24 + // + span: $DIR/array_index_is_temporary.rs:17:21: 17:24 // + literal: Const { ty: unsafe fn(*mut usize) -> u32 {foo}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/array_index_is_temporary.rs b/tests/mir-opt/array_index_is_temporary.rs index e7bde81d4..702b9c70e 100644 --- a/tests/mir-opt/array_index_is_temporary.rs +++ b/tests/mir-opt/array_index_is_temporary.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // Retagging (from Stacked Borrows) relies on the array index being a fresh // temporary, so that side-effects cannot change it. // Test that this is indeed the case. diff --git a/tests/mir-opt/asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir b/tests/mir-opt/asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir index 2487ef5c2..f6954ab35 100644 --- a/tests/mir-opt/asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir +++ b/tests/mir-opt/asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir @@ -9,7 +9,7 @@ fn main() -> () { bb0: { StorageLive(_1); // scope 1 at $DIR/asm_unwind_panic_abort.rs:+2:9: +2:49 _1 = const (); // scope 1 at $DIR/asm_unwind_panic_abort.rs:+2:9: +2:49 - asm!("", options(MAY_UNWIND)) -> [return: bb1, unwind: bb2]; // scope 1 at $DIR/asm_unwind_panic_abort.rs:+2:9: +2:49 + asm!("", options(MAY_UNWIND)) -> [return: bb1, unwind terminate]; // scope 1 at $DIR/asm_unwind_panic_abort.rs:+2:9: +2:49 } bb1: { @@ -17,8 +17,4 @@ fn main() -> () { _0 = const (); // scope 1 at $DIR/asm_unwind_panic_abort.rs:+1:5: +3:6 return; // scope 0 at $DIR/asm_unwind_panic_abort.rs:+4:2: +4:2 } - - bb2 (cleanup): { - abort; // scope 0 at $DIR/asm_unwind_panic_abort.rs:+0:1: +4:2 - } } diff --git a/tests/mir-opt/basic_assignment.main.ElaborateDrops.diff b/tests/mir-opt/basic_assignment.main.ElaborateDrops.diff new file mode 100644 index 000000000..d663c3435 --- /dev/null +++ b/tests/mir-opt/basic_assignment.main.ElaborateDrops.diff @@ -0,0 +1,89 @@ +- // MIR for `main` before ElaborateDrops ++ // MIR for `main` after ElaborateDrops + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/basic_assignment.rs:+0:11: +0:11 + let _1: bool; // in scope 0 at $DIR/basic_assignment.rs:+1:9: +1:17 + let mut _3: bool; // in scope 0 at $DIR/basic_assignment.rs:+6:16: +6:24 + let mut _6: std::option::Option<std::boxed::Box<u32>>; // in scope 0 at $DIR/basic_assignment.rs:+13:14: +13:20 + scope 1 { + debug nodrop_x => _1; // in scope 1 at $DIR/basic_assignment.rs:+1:9: +1:17 + let _2: bool; // in scope 1 at $DIR/basic_assignment.rs:+2:9: +2:17 + scope 2 { + debug nodrop_y => _2; // in scope 2 at $DIR/basic_assignment.rs:+2:9: +2:17 + let _4: std::option::Option<std::boxed::Box<u32>>; // in scope 2 at $DIR/basic_assignment.rs:+8:9: +8:15 + scope 3 { + debug drop_x => _4; // in scope 3 at $DIR/basic_assignment.rs:+8:9: +8:15 + let _5: std::option::Option<std::boxed::Box<u32>>; // in scope 3 at $DIR/basic_assignment.rs:+9:9: +9:15 + scope 4 { + debug drop_y => _5; // in scope 4 at $DIR/basic_assignment.rs:+9:9: +9:15 + } + } + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/basic_assignment.rs:+1:9: +1:17 + _1 = const false; // scope 0 at $DIR/basic_assignment.rs:+1:20: +1:25 + StorageLive(_2); // scope 1 at $DIR/basic_assignment.rs:+2:9: +2:17 + StorageLive(_3); // scope 2 at $DIR/basic_assignment.rs:+6:16: +6:24 + _3 = _1; // scope 2 at $DIR/basic_assignment.rs:+6:16: +6:24 + _2 = move _3; // scope 2 at $DIR/basic_assignment.rs:+6:5: +6:24 + StorageDead(_3); // scope 2 at $DIR/basic_assignment.rs:+6:23: +6:24 + StorageLive(_4); // scope 2 at $DIR/basic_assignment.rs:+8:9: +8:15 + _4 = Option::<Box<u32>>::None; // scope 2 at $DIR/basic_assignment.rs:+8:36: +8:40 + StorageLive(_5); // scope 3 at $DIR/basic_assignment.rs:+9:9: +9:15 + StorageLive(_6); // scope 4 at $DIR/basic_assignment.rs:+13:14: +13:20 + _6 = move _4; // scope 4 at $DIR/basic_assignment.rs:+13:14: +13:20 +- drop(_5) -> [return: bb1, unwind: bb2]; // scope 4 at $DIR/basic_assignment.rs:+13:5: +13:11 ++ goto -> bb1; // scope 4 at $DIR/basic_assignment.rs:+13:5: +13:11 + } + + bb1: { + _5 = move _6; // scope 4 at $DIR/basic_assignment.rs:+13:5: +13:11 +- drop(_6) -> [return: bb3, unwind: bb6]; // scope 4 at $DIR/basic_assignment.rs:+13:19: +13:20 ++ goto -> bb3; // scope 4 at $DIR/basic_assignment.rs:+13:19: +13:20 + } + + bb2 (cleanup): { + _5 = move _6; // scope 4 at $DIR/basic_assignment.rs:+13:5: +13:11 + drop(_6) -> [return: bb6, unwind terminate]; // scope 4 at $DIR/basic_assignment.rs:+13:19: +13:20 + } + + bb3: { + StorageDead(_6); // scope 4 at $DIR/basic_assignment.rs:+13:19: +13:20 + _0 = const (); // scope 0 at $DIR/basic_assignment.rs:+0:11: +14:2 + drop(_5) -> [return: bb4, unwind: bb7]; // scope 3 at $DIR/basic_assignment.rs:+14:1: +14:2 + } + + bb4: { + StorageDead(_5); // scope 3 at $DIR/basic_assignment.rs:+14:1: +14:2 +- drop(_4) -> bb5; // scope 2 at $DIR/basic_assignment.rs:+14:1: +14:2 ++ goto -> bb5; // scope 2 at $DIR/basic_assignment.rs:+14:1: +14:2 + } + + bb5: { + StorageDead(_4); // scope 2 at $DIR/basic_assignment.rs:+14:1: +14:2 + StorageDead(_2); // scope 1 at $DIR/basic_assignment.rs:+14:1: +14:2 + StorageDead(_1); // scope 0 at $DIR/basic_assignment.rs:+14:1: +14:2 + return; // scope 0 at $DIR/basic_assignment.rs:+14:2: +14:2 + } + + bb6 (cleanup): { + drop(_5) -> [return: bb7, unwind terminate]; // scope 3 at $DIR/basic_assignment.rs:+14:1: +14:2 + } + + bb7 (cleanup): { +- drop(_4) -> [return: bb8, unwind terminate]; // scope 2 at $DIR/basic_assignment.rs:+14:1: +14:2 ++ goto -> bb8; // scope 2 at $DIR/basic_assignment.rs:+14:1: +14:2 + } + + bb8 (cleanup): { + resume; // scope 0 at $DIR/basic_assignment.rs:+0:1: +14:2 ++ } ++ ++ bb9 (cleanup): { ++ unreachable; // scope 0 at $DIR/basic_assignment.rs:+0:1: +14:2 + } + } + diff --git a/tests/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir b/tests/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir index 1f099cd5e..d63497e3a 100644 --- a/tests/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir @@ -1,8 +1,8 @@ // MIR for `main` after SimplifyCfg-initial | User Type Annotations -| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option<std::boxed::Box<u32>>) }, span: $DIR/basic_assignment.rs:18:17: 18:33, inferred_ty: std::option::Option<std::boxed::Box<u32>> -| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option<std::boxed::Box<u32>>) }, span: $DIR/basic_assignment.rs:18:17: 18:33, inferred_ty: std::option::Option<std::boxed::Box<u32>> +| 0: user_ty: Canonical { value: Ty(std::option::Option<std::boxed::Box<u32>>), max_universe: U0, variables: [] }, span: $DIR/basic_assignment.rs:20:17: 20:33, inferred_ty: std::option::Option<std::boxed::Box<u32>> +| 1: user_ty: Canonical { value: Ty(std::option::Option<std::boxed::Box<u32>>), max_universe: U0, variables: [] }, span: $DIR/basic_assignment.rs:20:17: 20:33, inferred_ty: std::option::Option<std::boxed::Box<u32>> | fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/basic_assignment.rs:+0:11: +0:11 @@ -41,41 +41,43 @@ fn main() -> () { StorageLive(_5); // scope 3 at $DIR/basic_assignment.rs:+9:9: +9:15 StorageLive(_6); // scope 4 at $DIR/basic_assignment.rs:+13:14: +13:20 _6 = move _4; // scope 4 at $DIR/basic_assignment.rs:+13:14: +13:20 - replace(_5 <- move _6) -> [return: bb1, unwind: bb5]; // scope 4 at $DIR/basic_assignment.rs:+13:5: +13:11 + drop(_5) -> [return: bb1, unwind: bb2]; // scope 4 at $DIR/basic_assignment.rs:+13:5: +13:11 } bb1: { - drop(_6) -> [return: bb2, unwind: bb6]; // scope 4 at $DIR/basic_assignment.rs:+13:19: +13:20 + _5 = move _6; // scope 4 at $DIR/basic_assignment.rs:+13:5: +13:11 + drop(_6) -> [return: bb3, unwind: bb6]; // scope 4 at $DIR/basic_assignment.rs:+13:19: +13:20 } - bb2: { + bb2 (cleanup): { + _5 = move _6; // scope 4 at $DIR/basic_assignment.rs:+13:5: +13:11 + drop(_6) -> [return: bb6, unwind terminate]; // scope 4 at $DIR/basic_assignment.rs:+13:19: +13:20 + } + + bb3: { StorageDead(_6); // scope 4 at $DIR/basic_assignment.rs:+13:19: +13:20 _0 = const (); // scope 0 at $DIR/basic_assignment.rs:+0:11: +14:2 - drop(_5) -> [return: bb3, unwind: bb7]; // scope 3 at $DIR/basic_assignment.rs:+14:1: +14:2 + drop(_5) -> [return: bb4, unwind: bb7]; // scope 3 at $DIR/basic_assignment.rs:+14:1: +14:2 } - bb3: { + bb4: { StorageDead(_5); // scope 3 at $DIR/basic_assignment.rs:+14:1: +14:2 - drop(_4) -> [return: bb4, unwind: bb8]; // scope 2 at $DIR/basic_assignment.rs:+14:1: +14:2 + drop(_4) -> [return: bb5, unwind: bb8]; // scope 2 at $DIR/basic_assignment.rs:+14:1: +14:2 } - bb4: { + bb5: { StorageDead(_4); // scope 2 at $DIR/basic_assignment.rs:+14:1: +14:2 StorageDead(_2); // scope 1 at $DIR/basic_assignment.rs:+14:1: +14:2 StorageDead(_1); // scope 0 at $DIR/basic_assignment.rs:+14:1: +14:2 return; // scope 0 at $DIR/basic_assignment.rs:+14:2: +14:2 } - bb5 (cleanup): { - drop(_6) -> bb6; // scope 4 at $DIR/basic_assignment.rs:+13:19: +13:20 - } - bb6 (cleanup): { - drop(_5) -> bb7; // scope 3 at $DIR/basic_assignment.rs:+14:1: +14:2 + drop(_5) -> [return: bb7, unwind terminate]; // scope 3 at $DIR/basic_assignment.rs:+14:1: +14:2 } bb7 (cleanup): { - drop(_4) -> bb8; // scope 2 at $DIR/basic_assignment.rs:+14:1: +14:2 + drop(_4) -> [return: bb8, unwind terminate]; // scope 2 at $DIR/basic_assignment.rs:+14:1: +14:2 } bb8 (cleanup): { diff --git a/tests/mir-opt/basic_assignment.rs b/tests/mir-opt/basic_assignment.rs index ac350271e..92434e44a 100644 --- a/tests/mir-opt/basic_assignment.rs +++ b/tests/mir-opt/basic_assignment.rs @@ -1,5 +1,7 @@ +// needs-unwind // this tests move up progration, which is not yet implemented +// EMIT_MIR basic_assignment.main.ElaborateDrops.diff // EMIT_MIR basic_assignment.main.SimplifyCfg-initial.after.mir // Check codegen for assignments (`a = b`) where the left-hand-side is diff --git a/tests/mir-opt/box_expr.main.ElaborateDrops.before.mir b/tests/mir-opt/box_expr.main.ElaborateDrops.before.mir index 49133138d..bac5b21df 100644 --- a/tests/mir-opt/box_expr.main.ElaborateDrops.before.mir +++ b/tests/mir-opt/box_expr.main.ElaborateDrops.before.mir @@ -3,12 +3,12 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/box_expr.rs:+0:11: +0:11 let _1: std::boxed::Box<S>; // in scope 0 at $DIR/box_expr.rs:+1:9: +1:10 - let mut _2: usize; // in scope 0 at $DIR/box_expr.rs:+1:13: +1:25 - let mut _3: usize; // in scope 0 at $DIR/box_expr.rs:+1:13: +1:25 - let mut _4: *mut u8; // in scope 0 at $DIR/box_expr.rs:+1:13: +1:25 - let mut _5: std::boxed::Box<S>; // in scope 0 at $DIR/box_expr.rs:+1:13: +1:25 - let _6: (); // in scope 0 at $DIR/box_expr.rs:+2:5: +2:12 - let mut _7: std::boxed::Box<S>; // in scope 0 at $DIR/box_expr.rs:+2:10: +2:11 + let mut _2: usize; // in scope 0 at $DIR/box_expr.rs:+2:5: +2:23 + let mut _3: usize; // in scope 0 at $DIR/box_expr.rs:+2:5: +2:23 + let mut _4: *mut u8; // in scope 0 at $DIR/box_expr.rs:+2:5: +2:23 + let mut _5: std::boxed::Box<S>; // in scope 0 at $DIR/box_expr.rs:+2:5: +2:23 + let _6: (); // in scope 0 at $DIR/box_expr.rs:+3:5: +3:12 + let mut _7: std::boxed::Box<S>; // in scope 0 at $DIR/box_expr.rs:+3:10: +3:11 scope 1 { debug x => _1; // in scope 1 at $DIR/box_expr.rs:+1:9: +1:10 } @@ -17,64 +17,64 @@ fn main() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/box_expr.rs:+1:9: +1:10 - _2 = SizeOf(S); // scope 2 at $DIR/box_expr.rs:+1:13: +1:25 - _3 = AlignOf(S); // scope 2 at $DIR/box_expr.rs:+1:13: +1:25 - _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 2 at $DIR/box_expr.rs:+1:13: +1:25 + _2 = SizeOf(S); // scope 2 at $DIR/box_expr.rs:+2:5: +2:23 + _3 = AlignOf(S); // scope 2 at $DIR/box_expr.rs:+2:5: +2:23 + _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 2 at $DIR/box_expr.rs:+2:5: +2:23 // mir::Constant - // + span: $DIR/box_expr.rs:7:13: 7:25 + // + span: $DIR/box_expr.rs:8:5: 8:23 // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) } } bb1: { - StorageLive(_5); // scope 0 at $DIR/box_expr.rs:+1:13: +1:25 - _5 = ShallowInitBox(move _4, S); // scope 0 at $DIR/box_expr.rs:+1:13: +1:25 - (*_5) = S::new() -> [return: bb2, unwind: bb8]; // scope 0 at $DIR/box_expr.rs:+1:17: +1:25 + StorageLive(_5); // scope 0 at $DIR/box_expr.rs:+2:5: +2:23 + _5 = ShallowInitBox(move _4, S); // scope 0 at $DIR/box_expr.rs:+2:5: +2:23 + (*_5) = S::new() -> [return: bb2, unwind: bb8]; // scope 0 at $DIR/box_expr.rs:+2:14: +2:22 // mir::Constant - // + span: $DIR/box_expr.rs:7:17: 7:23 + // + span: $DIR/box_expr.rs:8:14: 8:20 // + literal: Const { ty: fn() -> S {S::new}, val: Value(<ZST>) } } bb2: { - _1 = move _5; // scope 0 at $DIR/box_expr.rs:+1:13: +1:25 - drop(_5) -> bb3; // scope 0 at $DIR/box_expr.rs:+1:24: +1:25 + _1 = move _5; // scope 0 at $DIR/box_expr.rs:+2:5: +2:23 + drop(_5) -> bb3; // scope 0 at $DIR/box_expr.rs:+2:22: +2:23 } bb3: { - StorageDead(_5); // scope 0 at $DIR/box_expr.rs:+1:24: +1:25 - StorageLive(_6); // scope 1 at $DIR/box_expr.rs:+2:5: +2:12 - StorageLive(_7); // scope 1 at $DIR/box_expr.rs:+2:10: +2:11 - _7 = move _1; // scope 1 at $DIR/box_expr.rs:+2:10: +2:11 - _6 = std::mem::drop::<Box<S>>(move _7) -> [return: bb4, unwind: bb6]; // scope 1 at $DIR/box_expr.rs:+2:5: +2:12 + StorageDead(_5); // scope 0 at $DIR/box_expr.rs:+2:22: +2:23 + StorageLive(_6); // scope 1 at $DIR/box_expr.rs:+3:5: +3:12 + StorageLive(_7); // scope 1 at $DIR/box_expr.rs:+3:10: +3:11 + _7 = move _1; // scope 1 at $DIR/box_expr.rs:+3:10: +3:11 + _6 = std::mem::drop::<Box<S>>(move _7) -> [return: bb4, unwind: bb6]; // scope 1 at $DIR/box_expr.rs:+3:5: +3:12 // mir::Constant - // + span: $DIR/box_expr.rs:8:5: 8:9 + // + span: $DIR/box_expr.rs:9:5: 9:9 // + literal: Const { ty: fn(Box<S>) {std::mem::drop::<Box<S>>}, val: Value(<ZST>) } } bb4: { - StorageDead(_7); // scope 1 at $DIR/box_expr.rs:+2:11: +2:12 - StorageDead(_6); // scope 1 at $DIR/box_expr.rs:+2:12: +2:13 - _0 = const (); // scope 0 at $DIR/box_expr.rs:+0:11: +3:2 - drop(_1) -> bb5; // scope 0 at $DIR/box_expr.rs:+3:1: +3:2 + StorageDead(_7); // scope 1 at $DIR/box_expr.rs:+3:11: +3:12 + StorageDead(_6); // scope 1 at $DIR/box_expr.rs:+3:12: +3:13 + _0 = const (); // scope 0 at $DIR/box_expr.rs:+0:11: +4:2 + drop(_1) -> bb5; // scope 0 at $DIR/box_expr.rs:+4:1: +4:2 } bb5: { - StorageDead(_1); // scope 0 at $DIR/box_expr.rs:+3:1: +3:2 - return; // scope 0 at $DIR/box_expr.rs:+3:2: +3:2 + StorageDead(_1); // scope 0 at $DIR/box_expr.rs:+4:1: +4:2 + return; // scope 0 at $DIR/box_expr.rs:+4:2: +4:2 } bb6 (cleanup): { - drop(_7) -> bb7; // scope 1 at $DIR/box_expr.rs:+2:11: +2:12 + drop(_7) -> [return: bb7, unwind terminate]; // scope 1 at $DIR/box_expr.rs:+3:11: +3:12 } bb7 (cleanup): { - drop(_1) -> bb9; // scope 0 at $DIR/box_expr.rs:+3:1: +3:2 + drop(_1) -> [return: bb9, unwind terminate]; // scope 0 at $DIR/box_expr.rs:+4:1: +4:2 } bb8 (cleanup): { - drop(_5) -> bb9; // scope 0 at $DIR/box_expr.rs:+1:24: +1:25 + drop(_5) -> [return: bb9, unwind terminate]; // scope 0 at $DIR/box_expr.rs:+2:22: +2:23 } bb9 (cleanup): { - resume; // scope 0 at $DIR/box_expr.rs:+0:1: +3:2 + resume; // scope 0 at $DIR/box_expr.rs:+0:1: +4:2 } } diff --git a/tests/mir-opt/box_expr.rs b/tests/mir-opt/box_expr.rs index a214504f6..ad3670b5d 100644 --- a/tests/mir-opt/box_expr.rs +++ b/tests/mir-opt/box_expr.rs @@ -1,17 +1,20 @@ // ignore-wasm32-bare compiled with panic=abort by default -#![feature(box_syntax)] +#![feature(rustc_attrs, stmt_expr_attributes)] // EMIT_MIR box_expr.main.ElaborateDrops.before.mir fn main() { - let x = box S::new(); + let x = #[rustc_box] + Box::new(S::new()); drop(x); } struct S; impl S { - fn new() -> Self { S } + fn new() -> Self { + S + } } impl Drop for S { diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir index ad4e5c6fc..7cce3415f 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir @@ -4,7 +4,7 @@ _0: GeneratorSavedTy { ty: impl std::future::Future<Output = ()>, source_info: SourceInfo { - span: $DIR/async_await.rs:15:8: 15:14 (#9), + span: $DIR/async_await.rs:15:8: 15:14 (#8), scope: scope[0], }, ignore_for_traits: false, @@ -12,7 +12,7 @@ _1: GeneratorSavedTy { ty: impl std::future::Future<Output = ()>, source_info: SourceInfo { - span: $DIR/async_await.rs:16:8: 16:14 (#12), + span: $DIR/async_await.rs:16:8: 16:14 (#11), scope: scope[0], }, ignore_for_traits: false, @@ -90,7 +90,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, bb0: { _39 = discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))); // scope 0 at $DIR/async_await.rs:+0:18: +3:2 - switchInt(move _39) -> [0: bb1, 1: bb29, 3: bb27, 4: bb28, otherwise: bb30]; // scope 0 at $DIR/async_await.rs:+0:18: +3:2 + switchInt(move _39) -> [0: bb1, 1: bb28, 3: bb26, 4: bb27, otherwise: bb29]; // scope 0 at $DIR/async_await.rs:+0:18: +3:2 } bb1: { @@ -98,14 +98,14 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, StorageLive(_3); // scope 0 at $DIR/async_await.rs:+1:5: +1:14 StorageLive(_4); // scope 0 at $DIR/async_await.rs:+1:8: +1:14 StorageLive(_5); // scope 0 at $DIR/async_await.rs:+1:5: +1:8 - _5 = a() -> bb2; // scope 0 at $DIR/async_await.rs:+1:5: +1:8 + _5 = a() -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+1:5: +1:8 // mir::Constant // + span: $DIR/async_await.rs:15:5: 15:6 // + literal: Const { ty: fn() -> impl Future<Output = ()> {a}, val: Value(<ZST>) } } bb2: { - _4 = <impl Future<Output = ()> as IntoFuture>::into_future(move _5) -> bb3; // scope 0 at $DIR/async_await.rs:+1:8: +1:14 + _4 = <impl Future<Output = ()> as IntoFuture>::into_future(move _5) -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+1:8: +1:14 // mir::Constant // + span: $DIR/async_await.rs:15:8: 15:14 // + literal: Const { ty: fn(impl Future<Output = ()>) -> <impl Future<Output = ()> as IntoFuture>::IntoFuture {<impl Future<Output = ()> as IntoFuture>::into_future}, val: Value(<ZST>) } @@ -126,7 +126,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, StorageLive(_12); // scope 2 at $DIR/async_await.rs:+1:8: +1:14 _12 = &mut (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#3).0: impl std::future::Future<Output = ()>); // scope 2 at $DIR/async_await.rs:+1:8: +1:14 _11 = &mut (*_12); // scope 2 at $DIR/async_await.rs:+1:8: +1:14 - _10 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _11) -> bb5; // scope 2 at $DIR/async_await.rs:+1:8: +1:14 + _10 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _11) -> [return: bb5, unwind unreachable]; // scope 2 at $DIR/async_await.rs:+1:8: +1:14 // mir::Constant // + span: $DIR/async_await.rs:15:8: 15:14 // + literal: Const { ty: unsafe fn(&mut impl Future<Output = ()>) -> Pin<&mut impl Future<Output = ()>> {Pin::<&mut impl Future<Output = ()>>::new_unchecked}, val: Value(<ZST>) } @@ -145,7 +145,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, bb6: { _13 = &mut (*_14); // scope 2 at $DIR/async_await.rs:+1:5: +1:14 StorageDead(_15); // scope 2 at $DIR/async_await.rs:+1:13: +1:14 - _9 = <impl Future<Output = ()> as Future>::poll(move _10, move _13) -> bb7; // scope 2 at $DIR/async_await.rs:+1:8: +1:14 + _9 = <impl Future<Output = ()> as Future>::poll(move _10, move _13) -> [return: bb7, unwind unreachable]; // scope 2 at $DIR/async_await.rs:+1:8: +1:14 // mir::Constant // + span: $DIR/async_await.rs:15:8: 15:14 // + literal: Const { ty: for<'a, 'b, 'c> fn(Pin<&'a mut impl Future<Output = ()>>, &'b mut Context<'c>) -> Poll<<impl Future<Output = ()> as Future>::Output> {<impl Future<Output = ()> as Future>::poll}, val: Value(<ZST>) } @@ -206,14 +206,14 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, StorageDead(_3); // scope 0 at $DIR/async_await.rs:+1:14: +1:15 StorageLive(_21); // scope 0 at $DIR/async_await.rs:+2:8: +2:14 StorageLive(_22); // scope 0 at $DIR/async_await.rs:+2:5: +2:8 - _22 = a() -> bb14; // scope 0 at $DIR/async_await.rs:+2:5: +2:8 + _22 = a() -> [return: bb14, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+2:5: +2:8 // mir::Constant // + span: $DIR/async_await.rs:16:5: 16:6 // + literal: Const { ty: fn() -> impl Future<Output = ()> {a}, val: Value(<ZST>) } } bb14: { - _21 = <impl Future<Output = ()> as IntoFuture>::into_future(move _22) -> bb15; // scope 0 at $DIR/async_await.rs:+2:8: +2:14 + _21 = <impl Future<Output = ()> as IntoFuture>::into_future(move _22) -> [return: bb15, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+2:8: +2:14 // mir::Constant // + span: $DIR/async_await.rs:16:8: 16:14 // + literal: Const { ty: fn(impl Future<Output = ()>) -> <impl Future<Output = ()> as IntoFuture>::IntoFuture {<impl Future<Output = ()> as IntoFuture>::into_future}, val: Value(<ZST>) } @@ -234,7 +234,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, StorageLive(_28); // scope 5 at $DIR/async_await.rs:+2:8: +2:14 _28 = &mut (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#4).0: impl std::future::Future<Output = ()>); // scope 5 at $DIR/async_await.rs:+2:8: +2:14 _27 = &mut (*_28); // scope 5 at $DIR/async_await.rs:+2:8: +2:14 - _26 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _27) -> bb17; // scope 5 at $DIR/async_await.rs:+2:8: +2:14 + _26 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _27) -> [return: bb17, unwind unreachable]; // scope 5 at $DIR/async_await.rs:+2:8: +2:14 // mir::Constant // + span: $DIR/async_await.rs:16:8: 16:14 // + literal: Const { ty: unsafe fn(&mut impl Future<Output = ()>) -> Pin<&mut impl Future<Output = ()>> {Pin::<&mut impl Future<Output = ()>>::new_unchecked}, val: Value(<ZST>) } @@ -253,7 +253,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, bb18: { _29 = &mut (*_30); // scope 5 at $DIR/async_await.rs:+2:5: +2:14 StorageDead(_31); // scope 5 at $DIR/async_await.rs:+2:13: +2:14 - _25 = <impl Future<Output = ()> as Future>::poll(move _26, move _29) -> bb19; // scope 5 at $DIR/async_await.rs:+2:8: +2:14 + _25 = <impl Future<Output = ()> as Future>::poll(move _26, move _29) -> [return: bb19, unwind unreachable]; // scope 5 at $DIR/async_await.rs:+2:8: +2:14 // mir::Constant // + span: $DIR/async_await.rs:16:8: 16:14 // + literal: Const { ty: for<'a, 'b, 'c> fn(Pin<&'a mut impl Future<Output = ()>>, &'b mut Context<'c>) -> Poll<<impl Future<Output = ()> as Future>::Output> {<impl Future<Output = ()> as Future>::poll}, val: Value(<ZST>) } @@ -263,7 +263,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, StorageDead(_29); // scope 5 at $DIR/async_await.rs:+2:13: +2:14 StorageDead(_26); // scope 5 at $DIR/async_await.rs:+2:13: +2:14 _32 = discriminant(_25); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - switchInt(move _32) -> [0: bb22, 1: bb20, otherwise: bb21]; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 + switchInt(move _32) -> [0: bb21, 1: bb20, otherwise: bb9]; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 } bb20: { @@ -281,10 +281,6 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, } bb21: { - unreachable; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - } - - bb22: { StorageLive(_33); // scope 4 at $DIR/async_await.rs:+2:5: +2:14 _33 = ((_25 as Ready).0: ()); // scope 4 at $DIR/async_await.rs:+2:5: +2:14 _37 = _33; // scope 6 at $DIR/async_await.rs:+2:5: +2:14 @@ -293,10 +289,10 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, StorageDead(_28); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 StorageDead(_25); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 StorageDead(_24); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 - goto -> bb24; // scope 0 at $DIR/async_await.rs:+2:13: +2:14 + goto -> bb23; // scope 0 at $DIR/async_await.rs:+2:13: +2:14 } - bb23: { + bb22: { StorageDead(_36); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 _38 = move _35; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 StorageDead(_35); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 @@ -304,23 +300,23 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, goto -> bb16; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 } - bb24: { + bb23: { nop; // scope 0 at $DIR/async_await.rs:+2:13: +2:14 - goto -> bb25; // scope 0 at $DIR/async_await.rs:+3:1: +3:2 + goto -> bb24; // scope 0 at $DIR/async_await.rs:+3:1: +3:2 } - bb25: { + bb24: { StorageDead(_21); // scope 0 at $DIR/async_await.rs:+3:1: +3:2 - goto -> bb26; // scope 0 at $DIR/async_await.rs:+3:1: +3:2 + goto -> bb25; // scope 0 at $DIR/async_await.rs:+3:1: +3:2 } - bb26: { + bb25: { _0 = Poll::<()>::Ready(move _37); // scope 0 at $DIR/async_await.rs:+3:2: +3:2 discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))) = 1; // scope 0 at $DIR/async_await.rs:+3:2: +3:2 return; // scope 0 at $DIR/async_await.rs:+3:2: +3:2 } - bb27: { + bb26: { StorageLive(_3); // scope 0 at $DIR/async_await.rs:+0:18: +3:2 StorageLive(_4); // scope 0 at $DIR/async_await.rs:+0:18: +3:2 StorageLive(_19); // scope 0 at $DIR/async_await.rs:+0:18: +3:2 @@ -329,19 +325,19 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, goto -> bb11; // scope 0 at $DIR/async_await.rs:+0:18: +3:2 } - bb28: { + bb27: { StorageLive(_21); // scope 0 at $DIR/async_await.rs:+0:18: +3:2 StorageLive(_35); // scope 0 at $DIR/async_await.rs:+0:18: +3:2 StorageLive(_36); // scope 0 at $DIR/async_await.rs:+0:18: +3:2 _35 = move _2; // scope 0 at $DIR/async_await.rs:+0:18: +3:2 - goto -> bb23; // scope 0 at $DIR/async_await.rs:+0:18: +3:2 + goto -> bb22; // scope 0 at $DIR/async_await.rs:+0:18: +3:2 } - bb29: { - assert(const false, "`async fn` resumed after completion") -> bb29; // scope 0 at $DIR/async_await.rs:+0:18: +3:2 + bb28: { + assert(const false, "`async fn` resumed after completion") -> bb28; // scope 0 at $DIR/async_await.rs:+0:18: +3:2 } - bb30: { + bb29: { unreachable; // scope 0 at $DIR/async_await.rs:+0:18: +3:2 } } diff --git a/tests/mir-opt/building/custom/aggregate_exprs.adt.built.after.mir b/tests/mir-opt/building/custom/aggregate_exprs.adt.built.after.mir new file mode 100644 index 000000000..49e8c812c --- /dev/null +++ b/tests/mir-opt/building/custom/aggregate_exprs.adt.built.after.mir @@ -0,0 +1,16 @@ +// MIR for `adt` after built + +fn adt() -> Onion { + let mut _0: Onion; // return place in scope 0 at $DIR/aggregate_exprs.rs:+0:13: +0:18 + let mut _1: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _2: Foo; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _3: Bar; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + _1 = const 1_i32; // scope 0 at $DIR/aggregate_exprs.rs:+6:13: +6:20 + _2 = Foo { a: const 1_i32, b: const 2_i32 }; // scope 0 at $DIR/aggregate_exprs.rs:+7:13: +10:14 + _3 = Bar::Foo(move _2, _1); // scope 0 at $DIR/aggregate_exprs.rs:+11:13: +11:39 + _0 = Onion { neon: ((_3 as variant#0).1: i32) }; // scope 0 at $DIR/aggregate_exprs.rs:+12:13: +12:58 + return; // scope 0 at $DIR/aggregate_exprs.rs:+13:13: +13:21 + } +} diff --git a/tests/mir-opt/building/custom/aggregate_exprs.array.built.after.mir b/tests/mir-opt/building/custom/aggregate_exprs.array.built.after.mir new file mode 100644 index 000000000..30d128973 --- /dev/null +++ b/tests/mir-opt/building/custom/aggregate_exprs.array.built.after.mir @@ -0,0 +1,15 @@ +// MIR for `array` after built + +fn array() -> [i32; 2] { + let mut _0: [i32; 2]; // return place in scope 0 at $DIR/aggregate_exprs.rs:+0:15: +0:23 + let mut _1: [i32; 2]; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _2: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + _1 = [const 42_i32, const 43_i32]; // scope 0 at $DIR/aggregate_exprs.rs:+5:13: +5:25 + _2 = const 1_i32; // scope 0 at $DIR/aggregate_exprs.rs:+6:13: +6:20 + _1 = [_2, const 2_i32]; // scope 0 at $DIR/aggregate_exprs.rs:+7:13: +7:25 + _0 = move _1; // scope 0 at $DIR/aggregate_exprs.rs:+8:13: +8:26 + return; // scope 0 at $DIR/aggregate_exprs.rs:+9:13: +9:21 + } +} diff --git a/tests/mir-opt/building/custom/aggregate_exprs.rs b/tests/mir-opt/building/custom/aggregate_exprs.rs new file mode 100644 index 000000000..554c9c03b --- /dev/null +++ b/tests/mir-opt/building/custom/aggregate_exprs.rs @@ -0,0 +1,71 @@ +#![feature(custom_mir, core_intrinsics)] + +extern crate core; +use core::intrinsics::mir::*; + +// EMIT_MIR aggregate_exprs.tuple.built.after.mir +#[custom_mir(dialect = "built")] +fn tuple() -> (i32, bool) { + mir!( + { + RET = (1, true); + Return() + } + ) +} + +// EMIT_MIR aggregate_exprs.array.built.after.mir +#[custom_mir(dialect = "built")] +fn array() -> [i32; 2] { + mir!( + let x: [i32; 2]; + let one: i32; + { + x = [42, 43]; + one = 1; + x = [one, 2]; + RET = Move(x); + Return() + } + ) +} + +struct Foo { + a: i32, + b: i32, +} + +enum Bar { + Foo(Foo, i32), +} + +union Onion { + neon: i32, + noun: f32, +} + +// EMIT_MIR aggregate_exprs.adt.built.after.mir +#[custom_mir(dialect = "built")] +fn adt() -> Onion { + mir!( + let one: i32; + let x: Foo; + let y: Bar; + { + one = 1; + x = Foo { + a: 1, + b: 2, + }; + y = Bar::Foo(Move(x), one); + RET = Onion { neon: Field(Variant(y, 0), 1) }; + Return() + } + ) +} + +fn main() { + assert_eq!(tuple(), (1, true)); + assert_eq!(array(), [1, 2]); + assert_eq!(unsafe { adt().neon }, 1); +} diff --git a/tests/mir-opt/building/custom/aggregate_exprs.tuple.built.after.mir b/tests/mir-opt/building/custom/aggregate_exprs.tuple.built.after.mir new file mode 100644 index 000000000..5fe45ccc9 --- /dev/null +++ b/tests/mir-opt/building/custom/aggregate_exprs.tuple.built.after.mir @@ -0,0 +1,10 @@ +// MIR for `tuple` after built + +fn tuple() -> (i32, bool) { + let mut _0: (i32, bool); // return place in scope 0 at $DIR/aggregate_exprs.rs:+0:15: +0:26 + + bb0: { + _0 = (const 1_i32, const true); // scope 0 at $DIR/aggregate_exprs.rs:+3:13: +3:28 + return; // scope 0 at $DIR/aggregate_exprs.rs:+4:13: +4:21 + } +} diff --git a/tests/mir-opt/building/custom/as_cast.float_to_int.built.after.mir b/tests/mir-opt/building/custom/as_cast.float_to_int.built.after.mir new file mode 100644 index 000000000..d0b770783 --- /dev/null +++ b/tests/mir-opt/building/custom/as_cast.float_to_int.built.after.mir @@ -0,0 +1,10 @@ +// MIR for `float_to_int` after built + +fn float_to_int(_1: f32) -> i32 { + let mut _0: i32; // return place in scope 0 at $DIR/as_cast.rs:+0:28: +0:31 + + bb0: { + _0 = _1 as i32 (FloatToInt); // scope 0 at $DIR/as_cast.rs:+3:13: +3:27 + return; // scope 0 at $DIR/as_cast.rs:+4:13: +4:21 + } +} diff --git a/tests/mir-opt/building/custom/as_cast.int_to_int.built.after.mir b/tests/mir-opt/building/custom/as_cast.int_to_int.built.after.mir new file mode 100644 index 000000000..aaebff0d7 --- /dev/null +++ b/tests/mir-opt/building/custom/as_cast.int_to_int.built.after.mir @@ -0,0 +1,10 @@ +// MIR for `int_to_int` after built + +fn int_to_int(_1: u32) -> i32 { + let mut _0: i32; // return place in scope 0 at $DIR/as_cast.rs:+0:26: +0:29 + + bb0: { + _0 = _1 as i32 (IntToInt); // scope 0 at $DIR/as_cast.rs:+3:13: +3:27 + return; // scope 0 at $DIR/as_cast.rs:+4:13: +4:21 + } +} diff --git a/tests/mir-opt/building/custom/as_cast.int_to_ptr.built.after.mir b/tests/mir-opt/building/custom/as_cast.int_to_ptr.built.after.mir new file mode 100644 index 000000000..f040cf53d --- /dev/null +++ b/tests/mir-opt/building/custom/as_cast.int_to_ptr.built.after.mir @@ -0,0 +1,10 @@ +// MIR for `int_to_ptr` after built + +fn int_to_ptr(_1: usize) -> *const i32 { + let mut _0: *const i32; // return place in scope 0 at $DIR/as_cast.rs:+0:28: +0:38 + + bb0: { + _0 = _1 as *const i32 (PointerFromExposedAddress); // scope 0 at $DIR/as_cast.rs:+3:13: +3:34 + return; // scope 0 at $DIR/as_cast.rs:+4:13: +4:21 + } +} diff --git a/tests/mir-opt/building/custom/as_cast.rs b/tests/mir-opt/building/custom/as_cast.rs new file mode 100644 index 000000000..b4b5ac6aa --- /dev/null +++ b/tests/mir-opt/building/custom/as_cast.rs @@ -0,0 +1,43 @@ +#![feature(custom_mir, core_intrinsics)] + +extern crate core; +use core::intrinsics::mir::*; + +// EMIT_MIR as_cast.int_to_int.built.after.mir +#[custom_mir(dialect = "built")] +fn int_to_int(x: u32) -> i32 { + mir!( + { + RET = x as i32; + Return() + } + ) +} + +// EMIT_MIR as_cast.float_to_int.built.after.mir +#[custom_mir(dialect = "built")] +fn float_to_int(x: f32) -> i32 { + mir!( + { + RET = x as i32; + Return() + } + ) +} + +// EMIT_MIR as_cast.int_to_ptr.built.after.mir +#[custom_mir(dialect = "built")] +fn int_to_ptr(x: usize) -> *const i32 { + mir!( + { + RET = x as *const i32; + Return() + } + ) +} + +fn main() { + assert_eq!(int_to_int(5), 5); + assert_eq!(float_to_int(5.), 5); + assert_eq!(int_to_ptr(0), std::ptr::null()); +} diff --git a/tests/mir-opt/building/custom/composite_return.rs b/tests/mir-opt/building/custom/composite_return.rs new file mode 100644 index 000000000..701d6b1ab --- /dev/null +++ b/tests/mir-opt/building/custom/composite_return.rs @@ -0,0 +1,21 @@ +#![feature(custom_mir, core_intrinsics)] + +extern crate core; +use core::intrinsics::mir::*; + +// EMIT_MIR composite_return.tuple.built.after.mir +#[custom_mir(dialect = "runtime", phase = "optimized")] +fn tuple() -> (i32, bool) { + mir!( + type RET = (i32, bool); + { + RET.0 = 1; + RET.1 = true; + Return() + } + ) +} + +fn main() { + assert_eq!(tuple(), (1, true)); +} diff --git a/tests/mir-opt/building/custom/composite_return.tuple.built.after.mir b/tests/mir-opt/building/custom/composite_return.tuple.built.after.mir new file mode 100644 index 000000000..d159c1a65 --- /dev/null +++ b/tests/mir-opt/building/custom/composite_return.tuple.built.after.mir @@ -0,0 +1,11 @@ +// MIR for `tuple` after built + +fn tuple() -> (i32, bool) { + let mut _0: (i32, bool); // return place in scope 0 at $DIR/composite_return.rs:+0:15: +0:26 + + bb0: { + (_0.0: i32) = const 1_i32; // scope 0 at $DIR/composite_return.rs:+4:13: +4:22 + (_0.1: bool) = const true; // scope 0 at $DIR/composite_return.rs:+5:13: +5:25 + return; // scope 0 at $DIR/composite_return.rs:+6:13: +6:21 + } +} diff --git a/tests/mir-opt/building/custom/references.raw_pointer_offset.built.after.mir b/tests/mir-opt/building/custom/references.raw_pointer_offset.built.after.mir new file mode 100644 index 000000000..f614aef40 --- /dev/null +++ b/tests/mir-opt/building/custom/references.raw_pointer_offset.built.after.mir @@ -0,0 +1,10 @@ +// MIR for `raw_pointer_offset` after built + +fn raw_pointer_offset(_1: *const i32) -> *const i32 { + let mut _0: *const i32; // return place in scope 0 at $DIR/references.rs:+0:45: +0:55 + + bb0: { + _0 = Offset(_1, const 1_isize); // scope 0 at $DIR/references.rs:+2:9: +2:33 + return; // scope 0 at $DIR/references.rs:+3:9: +3:17 + } +} diff --git a/tests/mir-opt/building/custom/references.rs b/tests/mir-opt/building/custom/references.rs index a1c896de0..f87f6664c 100644 --- a/tests/mir-opt/building/custom/references.rs +++ b/tests/mir-opt/building/custom/references.rs @@ -45,11 +45,22 @@ pub fn raw_pointer(x: *const i32) -> *const i32 { }) } +// EMIT_MIR references.raw_pointer_offset.built.after.mir +#[custom_mir(dialect = "built")] +pub fn raw_pointer_offset(x: *const i32) -> *const i32 { + mir!({ + RET = Offset(x, 1_isize); + Return() + }) +} + fn main() { let mut x = 5; + let arr = [1, 2]; assert_eq!(*mut_ref(&mut x), 5); assert_eq!(*immut_ref(&x), 5); unsafe { assert_eq!(*raw_pointer(addr_of!(x)), 5); + assert_eq!(*raw_pointer_offset(addr_of!(arr[0])), 2); } } diff --git a/tests/mir-opt/building/custom/terminators.drop_first.built.after.mir b/tests/mir-opt/building/custom/terminators.drop_first.built.after.mir index c903e5946..ada78c0fc 100644 --- a/tests/mir-opt/building/custom/terminators.drop_first.built.after.mir +++ b/tests/mir-opt/building/custom/terminators.drop_first.built.after.mir @@ -4,10 +4,11 @@ fn drop_first(_1: WriteOnDrop<'_>, _2: WriteOnDrop<'_>) -> () { let mut _0: (); // return place in scope 0 at $DIR/terminators.rs:+0:59: +0:59 bb0: { - replace(_1 <- move _2) -> bb1; // scope 0 at $DIR/terminators.rs:+3:13: +3:49 + drop(_1) -> bb1; // scope 0 at $DIR/terminators.rs:+3:13: +3:30 } bb1: { - return; // scope 0 at $DIR/terminators.rs:+7:13: +7:21 + _1 = move _2; // scope 0 at $DIR/terminators.rs:+7:13: +7:24 + return; // scope 0 at $DIR/terminators.rs:+8:13: +8:21 } } diff --git a/tests/mir-opt/building/custom/terminators.rs b/tests/mir-opt/building/custom/terminators.rs index c23233fcf..f12405661 100644 --- a/tests/mir-opt/building/custom/terminators.rs +++ b/tests/mir-opt/building/custom/terminators.rs @@ -48,10 +48,11 @@ impl<'a> Drop for WriteOnDrop<'a> { fn drop_first<'a>(a: WriteOnDrop<'a>, b: WriteOnDrop<'a>) { mir!( { - DropAndReplace(a, Move(b), retblock) + Drop(a, retblock) } retblock = { + a = Move(b); Return() } ) diff --git a/tests/mir-opt/building/enum_cast.droppy.built.after.mir b/tests/mir-opt/building/enum_cast.droppy.built.after.mir index 5231c2eab..1112177fb 100644 --- a/tests/mir-opt/building/enum_cast.droppy.built.after.mir +++ b/tests/mir-opt/building/enum_cast.droppy.built.after.mir @@ -63,7 +63,7 @@ fn droppy() -> () { } bb4 (cleanup): { - drop(_2) -> bb5; // scope 0 at $DIR/enum_cast.rs:+6:5: +6:6 + drop(_2) -> [return: bb5, unwind terminate]; // scope 0 at $DIR/enum_cast.rs:+6:5: +6:6 } bb5 (cleanup): { diff --git a/tests/mir-opt/building/issue_101867.main.built.after.mir b/tests/mir-opt/building/issue_101867.main.built.after.mir index 628a33f10..44c25ce67 100644 --- a/tests/mir-opt/building/issue_101867.main.built.after.mir +++ b/tests/mir-opt/building/issue_101867.main.built.after.mir @@ -1,8 +1,8 @@ // MIR for `main` after built | User Type Annotations -| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option<u8>) }, span: $DIR/issue_101867.rs:3:12: 3:22, inferred_ty: std::option::Option<u8> -| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option<u8>) }, span: $DIR/issue_101867.rs:3:12: 3:22, inferred_ty: std::option::Option<u8> +| 0: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [] }, span: $DIR/issue_101867.rs:3:12: 3:22, inferred_ty: std::option::Option<u8> +| 1: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [] }, span: $DIR/issue_101867.rs:3:12: 3:22, inferred_ty: std::option::Option<u8> | fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/issue_101867.rs:+0:11: +0:11 diff --git a/tests/mir-opt/building/issue_49232.main.built.after.mir b/tests/mir-opt/building/issue_49232.main.built.after.mir index de5e4c0f6..cc135f417 100644 --- a/tests/mir-opt/building/issue_49232.main.built.after.mir +++ b/tests/mir-opt/building/issue_49232.main.built.after.mir @@ -17,7 +17,7 @@ fn main() -> () { } bb1: { - falseUnwind -> [real: bb2, cleanup: bb11]; // scope 0 at $DIR/issue_49232.rs:+1:5: +9:6 + falseUnwind -> [real: bb2, unwind: bb11]; // scope 0 at $DIR/issue_49232.rs:+1:5: +9:6 } bb2: { diff --git a/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir b/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir index cb36bc64d..0e6de839d 100644 --- a/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir +++ b/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir @@ -100,6 +100,7 @@ fn full_tested_match() -> () { } bb11: { + PlaceMention(_1); // scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6 StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7 StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7 _0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:28: +6:2 diff --git a/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir b/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir index 7f8755faa..37e6b1cd4 100644 --- a/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir +++ b/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir @@ -100,6 +100,7 @@ fn full_tested_match2() -> () { } bb11: { + PlaceMention(_1); // scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6 StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7 StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7 _0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:29: +6:2 diff --git a/tests/mir-opt/building/match_false_edges.main.built.after.mir b/tests/mir-opt/building/match_false_edges.main.built.after.mir index e8b93f437..7b8983138 100644 --- a/tests/mir-opt/building/match_false_edges.main.built.after.mir +++ b/tests/mir-opt/building/match_false_edges.main.built.after.mir @@ -162,6 +162,7 @@ fn main() -> () { } bb19: { + PlaceMention(_1); // scope 0 at $DIR/match_false_edges.rs:+1:13: +6:6 StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+6:6: +6:7 StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+6:6: +6:7 _0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:11: +7:2 diff --git a/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir b/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir index 41eb00363..7a6944dee 100644 --- a/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir +++ b/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir @@ -1,10 +1,10 @@ // MIR for `main` after built | User Type Annotations -| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut Test) }, span: $DIR/receiver_ptr_mutability.rs:14:14: 14:23, inferred_ty: *mut Test -| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut Test) }, span: $DIR/receiver_ptr_mutability.rs:14:14: 14:23, inferred_ty: *mut Test -| 2: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], value: Ty(&&&&*mut Test) }, span: $DIR/receiver_ptr_mutability.rs:18:18: 18:31, inferred_ty: &&&&*mut Test -| 3: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], value: Ty(&&&&*mut Test) }, span: $DIR/receiver_ptr_mutability.rs:18:18: 18:31, inferred_ty: &&&&*mut Test +| 0: user_ty: Canonical { value: Ty(*mut Test), max_universe: U0, variables: [] }, span: $DIR/receiver_ptr_mutability.rs:14:14: 14:23, inferred_ty: *mut Test +| 1: user_ty: Canonical { value: Ty(*mut Test), max_universe: U0, variables: [] }, span: $DIR/receiver_ptr_mutability.rs:14:14: 14:23, inferred_ty: *mut Test +| 2: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/receiver_ptr_mutability.rs:18:18: 18:31, inferred_ty: &&&&*mut Test +| 3: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/receiver_ptr_mutability.rs:18:18: 18:31, inferred_ty: &&&&*mut Test | fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/receiver_ptr_mutability.rs:+0:11: +0:11 diff --git a/tests/mir-opt/building/shifts.rs b/tests/mir-opt/building/shifts.rs new file mode 100644 index 000000000..4b63a00a3 --- /dev/null +++ b/tests/mir-opt/building/shifts.rs @@ -0,0 +1,20 @@ +// compile-flags: -C debug-assertions=yes + +// EMIT_MIR shifts.shift_signed.built.after.mir +fn shift_signed(small: i8, big: u128, a: i8, b: i32, c: i128) -> ([i8; 3], [u128; 3]) { + ( + [small >> a, small >> b, small >> c], + [big << a, big << b, big << c], + ) +} + +// EMIT_MIR shifts.shift_unsigned.built.after.mir +fn shift_unsigned(small: u8, big: i128, a: u8, b: u32, c: u128) -> ([u8; 3], [i128; 3]) { + ( + [small >> a, small >> b, small >> c], + [big << a, big << b, big << c], + ) +} + +fn main() { +} diff --git a/tests/mir-opt/building/shifts.shift_signed.built.after.mir b/tests/mir-opt/building/shifts.shift_signed.built.after.mir new file mode 100644 index 000000000..028777cef --- /dev/null +++ b/tests/mir-opt/building/shifts.shift_signed.built.after.mir @@ -0,0 +1,147 @@ +// MIR for `shift_signed` after built + +fn shift_signed(_1: i8, _2: u128, _3: i8, _4: i32, _5: i128) -> ([i8; 3], [u128; 3]) { + debug small => _1; // in scope 0 at $DIR/shifts.rs:+0:17: +0:22 + debug big => _2; // in scope 0 at $DIR/shifts.rs:+0:28: +0:31 + debug a => _3; // in scope 0 at $DIR/shifts.rs:+0:39: +0:40 + debug b => _4; // in scope 0 at $DIR/shifts.rs:+0:46: +0:47 + debug c => _5; // in scope 0 at $DIR/shifts.rs:+0:54: +0:55 + let mut _0: ([i8; 3], [u128; 3]); // return place in scope 0 at $DIR/shifts.rs:+0:66: +0:86 + let mut _6: [i8; 3]; // in scope 0 at $DIR/shifts.rs:+2:9: +2:45 + let mut _7: i8; // in scope 0 at $DIR/shifts.rs:+2:10: +2:20 + let mut _8: i8; // in scope 0 at $DIR/shifts.rs:+2:10: +2:15 + let mut _9: i8; // in scope 0 at $DIR/shifts.rs:+2:19: +2:20 + let mut _10: u8; // in scope 0 at $DIR/shifts.rs:+2:10: +2:20 + let mut _11: bool; // in scope 0 at $DIR/shifts.rs:+2:10: +2:20 + let mut _12: i8; // in scope 0 at $DIR/shifts.rs:+2:22: +2:32 + let mut _13: i8; // in scope 0 at $DIR/shifts.rs:+2:22: +2:27 + let mut _14: i32; // in scope 0 at $DIR/shifts.rs:+2:31: +2:32 + let mut _15: u32; // in scope 0 at $DIR/shifts.rs:+2:22: +2:32 + let mut _16: bool; // in scope 0 at $DIR/shifts.rs:+2:22: +2:32 + let mut _17: i8; // in scope 0 at $DIR/shifts.rs:+2:34: +2:44 + let mut _18: i8; // in scope 0 at $DIR/shifts.rs:+2:34: +2:39 + let mut _19: i128; // in scope 0 at $DIR/shifts.rs:+2:43: +2:44 + let mut _20: u128; // in scope 0 at $DIR/shifts.rs:+2:34: +2:44 + let mut _21: bool; // in scope 0 at $DIR/shifts.rs:+2:34: +2:44 + let mut _22: [u128; 3]; // in scope 0 at $DIR/shifts.rs:+3:9: +3:39 + let mut _23: u128; // in scope 0 at $DIR/shifts.rs:+3:10: +3:18 + let mut _24: u128; // in scope 0 at $DIR/shifts.rs:+3:10: +3:13 + let mut _25: i8; // in scope 0 at $DIR/shifts.rs:+3:17: +3:18 + let mut _26: u8; // in scope 0 at $DIR/shifts.rs:+3:10: +3:18 + let mut _27: bool; // in scope 0 at $DIR/shifts.rs:+3:10: +3:18 + let mut _28: u128; // in scope 0 at $DIR/shifts.rs:+3:20: +3:28 + let mut _29: u128; // in scope 0 at $DIR/shifts.rs:+3:20: +3:23 + let mut _30: i32; // in scope 0 at $DIR/shifts.rs:+3:27: +3:28 + let mut _31: u32; // in scope 0 at $DIR/shifts.rs:+3:20: +3:28 + let mut _32: bool; // in scope 0 at $DIR/shifts.rs:+3:20: +3:28 + let mut _33: u128; // in scope 0 at $DIR/shifts.rs:+3:30: +3:38 + let mut _34: u128; // in scope 0 at $DIR/shifts.rs:+3:30: +3:33 + let mut _35: i128; // in scope 0 at $DIR/shifts.rs:+3:37: +3:38 + let mut _36: u128; // in scope 0 at $DIR/shifts.rs:+3:30: +3:38 + let mut _37: bool; // in scope 0 at $DIR/shifts.rs:+3:30: +3:38 + + bb0: { + StorageLive(_6); // scope 0 at $DIR/shifts.rs:+2:9: +2:45 + StorageLive(_7); // scope 0 at $DIR/shifts.rs:+2:10: +2:20 + StorageLive(_8); // scope 0 at $DIR/shifts.rs:+2:10: +2:15 + _8 = _1; // scope 0 at $DIR/shifts.rs:+2:10: +2:15 + StorageLive(_9); // scope 0 at $DIR/shifts.rs:+2:19: +2:20 + _9 = _3; // scope 0 at $DIR/shifts.rs:+2:19: +2:20 + _10 = _9 as u8 (IntToInt); // scope 0 at $DIR/shifts.rs:+2:10: +2:20 + _11 = Lt(move _10, const 8_u8); // scope 0 at $DIR/shifts.rs:+2:10: +2:20 + assert(move _11, "attempt to shift right by `{}`, which would overflow", _9) -> [success: bb1, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+2:10: +2:20 + } + + bb1: { + _7 = Shr(move _8, move _9); // scope 0 at $DIR/shifts.rs:+2:10: +2:20 + StorageDead(_9); // scope 0 at $DIR/shifts.rs:+2:19: +2:20 + StorageDead(_8); // scope 0 at $DIR/shifts.rs:+2:19: +2:20 + StorageLive(_12); // scope 0 at $DIR/shifts.rs:+2:22: +2:32 + StorageLive(_13); // scope 0 at $DIR/shifts.rs:+2:22: +2:27 + _13 = _1; // scope 0 at $DIR/shifts.rs:+2:22: +2:27 + StorageLive(_14); // scope 0 at $DIR/shifts.rs:+2:31: +2:32 + _14 = _4; // scope 0 at $DIR/shifts.rs:+2:31: +2:32 + _15 = _14 as u32 (IntToInt); // scope 0 at $DIR/shifts.rs:+2:22: +2:32 + _16 = Lt(move _15, const 8_u32); // scope 0 at $DIR/shifts.rs:+2:22: +2:32 + assert(move _16, "attempt to shift right by `{}`, which would overflow", _14) -> [success: bb2, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+2:22: +2:32 + } + + bb2: { + _12 = Shr(move _13, move _14); // scope 0 at $DIR/shifts.rs:+2:22: +2:32 + StorageDead(_14); // scope 0 at $DIR/shifts.rs:+2:31: +2:32 + StorageDead(_13); // scope 0 at $DIR/shifts.rs:+2:31: +2:32 + StorageLive(_17); // scope 0 at $DIR/shifts.rs:+2:34: +2:44 + StorageLive(_18); // scope 0 at $DIR/shifts.rs:+2:34: +2:39 + _18 = _1; // scope 0 at $DIR/shifts.rs:+2:34: +2:39 + StorageLive(_19); // scope 0 at $DIR/shifts.rs:+2:43: +2:44 + _19 = _5; // scope 0 at $DIR/shifts.rs:+2:43: +2:44 + _20 = _19 as u128 (IntToInt); // scope 0 at $DIR/shifts.rs:+2:34: +2:44 + _21 = Lt(move _20, const 8_u128); // scope 0 at $DIR/shifts.rs:+2:34: +2:44 + assert(move _21, "attempt to shift right by `{}`, which would overflow", _19) -> [success: bb3, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+2:34: +2:44 + } + + bb3: { + _17 = Shr(move _18, move _19); // scope 0 at $DIR/shifts.rs:+2:34: +2:44 + StorageDead(_19); // scope 0 at $DIR/shifts.rs:+2:43: +2:44 + StorageDead(_18); // scope 0 at $DIR/shifts.rs:+2:43: +2:44 + _6 = [move _7, move _12, move _17]; // scope 0 at $DIR/shifts.rs:+2:9: +2:45 + StorageDead(_17); // scope 0 at $DIR/shifts.rs:+2:44: +2:45 + StorageDead(_12); // scope 0 at $DIR/shifts.rs:+2:44: +2:45 + StorageDead(_7); // scope 0 at $DIR/shifts.rs:+2:44: +2:45 + StorageLive(_22); // scope 0 at $DIR/shifts.rs:+3:9: +3:39 + StorageLive(_23); // scope 0 at $DIR/shifts.rs:+3:10: +3:18 + StorageLive(_24); // scope 0 at $DIR/shifts.rs:+3:10: +3:13 + _24 = _2; // scope 0 at $DIR/shifts.rs:+3:10: +3:13 + StorageLive(_25); // scope 0 at $DIR/shifts.rs:+3:17: +3:18 + _25 = _3; // scope 0 at $DIR/shifts.rs:+3:17: +3:18 + _26 = _25 as u8 (IntToInt); // scope 0 at $DIR/shifts.rs:+3:10: +3:18 + _27 = Lt(move _26, const 128_u8); // scope 0 at $DIR/shifts.rs:+3:10: +3:18 + assert(move _27, "attempt to shift left by `{}`, which would overflow", _25) -> [success: bb4, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+3:10: +3:18 + } + + bb4: { + _23 = Shl(move _24, move _25); // scope 0 at $DIR/shifts.rs:+3:10: +3:18 + StorageDead(_25); // scope 0 at $DIR/shifts.rs:+3:17: +3:18 + StorageDead(_24); // scope 0 at $DIR/shifts.rs:+3:17: +3:18 + StorageLive(_28); // scope 0 at $DIR/shifts.rs:+3:20: +3:28 + StorageLive(_29); // scope 0 at $DIR/shifts.rs:+3:20: +3:23 + _29 = _2; // scope 0 at $DIR/shifts.rs:+3:20: +3:23 + StorageLive(_30); // scope 0 at $DIR/shifts.rs:+3:27: +3:28 + _30 = _4; // scope 0 at $DIR/shifts.rs:+3:27: +3:28 + _31 = _30 as u32 (IntToInt); // scope 0 at $DIR/shifts.rs:+3:20: +3:28 + _32 = Lt(move _31, const 128_u32); // scope 0 at $DIR/shifts.rs:+3:20: +3:28 + assert(move _32, "attempt to shift left by `{}`, which would overflow", _30) -> [success: bb5, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+3:20: +3:28 + } + + bb5: { + _28 = Shl(move _29, move _30); // scope 0 at $DIR/shifts.rs:+3:20: +3:28 + StorageDead(_30); // scope 0 at $DIR/shifts.rs:+3:27: +3:28 + StorageDead(_29); // scope 0 at $DIR/shifts.rs:+3:27: +3:28 + StorageLive(_33); // scope 0 at $DIR/shifts.rs:+3:30: +3:38 + StorageLive(_34); // scope 0 at $DIR/shifts.rs:+3:30: +3:33 + _34 = _2; // scope 0 at $DIR/shifts.rs:+3:30: +3:33 + StorageLive(_35); // scope 0 at $DIR/shifts.rs:+3:37: +3:38 + _35 = _5; // scope 0 at $DIR/shifts.rs:+3:37: +3:38 + _36 = _35 as u128 (IntToInt); // scope 0 at $DIR/shifts.rs:+3:30: +3:38 + _37 = Lt(move _36, const 128_u128); // scope 0 at $DIR/shifts.rs:+3:30: +3:38 + assert(move _37, "attempt to shift left by `{}`, which would overflow", _35) -> [success: bb6, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+3:30: +3:38 + } + + bb6: { + _33 = Shl(move _34, move _35); // scope 0 at $DIR/shifts.rs:+3:30: +3:38 + StorageDead(_35); // scope 0 at $DIR/shifts.rs:+3:37: +3:38 + StorageDead(_34); // scope 0 at $DIR/shifts.rs:+3:37: +3:38 + _22 = [move _23, move _28, move _33]; // scope 0 at $DIR/shifts.rs:+3:9: +3:39 + StorageDead(_33); // scope 0 at $DIR/shifts.rs:+3:38: +3:39 + StorageDead(_28); // scope 0 at $DIR/shifts.rs:+3:38: +3:39 + StorageDead(_23); // scope 0 at $DIR/shifts.rs:+3:38: +3:39 + _0 = (move _6, move _22); // scope 0 at $DIR/shifts.rs:+1:5: +4:6 + StorageDead(_22); // scope 0 at $DIR/shifts.rs:+4:5: +4:6 + StorageDead(_6); // scope 0 at $DIR/shifts.rs:+4:5: +4:6 + return; // scope 0 at $DIR/shifts.rs:+5:2: +5:2 + } + + bb7 (cleanup): { + resume; // scope 0 at $DIR/shifts.rs:+0:1: +5:2 + } +} diff --git a/tests/mir-opt/building/shifts.shift_unsigned.built.after.mir b/tests/mir-opt/building/shifts.shift_unsigned.built.after.mir new file mode 100644 index 000000000..04da2d20d --- /dev/null +++ b/tests/mir-opt/building/shifts.shift_unsigned.built.after.mir @@ -0,0 +1,135 @@ +// MIR for `shift_unsigned` after built + +fn shift_unsigned(_1: u8, _2: i128, _3: u8, _4: u32, _5: u128) -> ([u8; 3], [i128; 3]) { + debug small => _1; // in scope 0 at $DIR/shifts.rs:+0:19: +0:24 + debug big => _2; // in scope 0 at $DIR/shifts.rs:+0:30: +0:33 + debug a => _3; // in scope 0 at $DIR/shifts.rs:+0:41: +0:42 + debug b => _4; // in scope 0 at $DIR/shifts.rs:+0:48: +0:49 + debug c => _5; // in scope 0 at $DIR/shifts.rs:+0:56: +0:57 + let mut _0: ([u8; 3], [i128; 3]); // return place in scope 0 at $DIR/shifts.rs:+0:68: +0:88 + let mut _6: [u8; 3]; // in scope 0 at $DIR/shifts.rs:+2:9: +2:45 + let mut _7: u8; // in scope 0 at $DIR/shifts.rs:+2:10: +2:20 + let mut _8: u8; // in scope 0 at $DIR/shifts.rs:+2:10: +2:15 + let mut _9: u8; // in scope 0 at $DIR/shifts.rs:+2:19: +2:20 + let mut _10: bool; // in scope 0 at $DIR/shifts.rs:+2:10: +2:20 + let mut _11: u8; // in scope 0 at $DIR/shifts.rs:+2:22: +2:32 + let mut _12: u8; // in scope 0 at $DIR/shifts.rs:+2:22: +2:27 + let mut _13: u32; // in scope 0 at $DIR/shifts.rs:+2:31: +2:32 + let mut _14: bool; // in scope 0 at $DIR/shifts.rs:+2:22: +2:32 + let mut _15: u8; // in scope 0 at $DIR/shifts.rs:+2:34: +2:44 + let mut _16: u8; // in scope 0 at $DIR/shifts.rs:+2:34: +2:39 + let mut _17: u128; // in scope 0 at $DIR/shifts.rs:+2:43: +2:44 + let mut _18: bool; // in scope 0 at $DIR/shifts.rs:+2:34: +2:44 + let mut _19: [i128; 3]; // in scope 0 at $DIR/shifts.rs:+3:9: +3:39 + let mut _20: i128; // in scope 0 at $DIR/shifts.rs:+3:10: +3:18 + let mut _21: i128; // in scope 0 at $DIR/shifts.rs:+3:10: +3:13 + let mut _22: u8; // in scope 0 at $DIR/shifts.rs:+3:17: +3:18 + let mut _23: bool; // in scope 0 at $DIR/shifts.rs:+3:10: +3:18 + let mut _24: i128; // in scope 0 at $DIR/shifts.rs:+3:20: +3:28 + let mut _25: i128; // in scope 0 at $DIR/shifts.rs:+3:20: +3:23 + let mut _26: u32; // in scope 0 at $DIR/shifts.rs:+3:27: +3:28 + let mut _27: bool; // in scope 0 at $DIR/shifts.rs:+3:20: +3:28 + let mut _28: i128; // in scope 0 at $DIR/shifts.rs:+3:30: +3:38 + let mut _29: i128; // in scope 0 at $DIR/shifts.rs:+3:30: +3:33 + let mut _30: u128; // in scope 0 at $DIR/shifts.rs:+3:37: +3:38 + let mut _31: bool; // in scope 0 at $DIR/shifts.rs:+3:30: +3:38 + + bb0: { + StorageLive(_6); // scope 0 at $DIR/shifts.rs:+2:9: +2:45 + StorageLive(_7); // scope 0 at $DIR/shifts.rs:+2:10: +2:20 + StorageLive(_8); // scope 0 at $DIR/shifts.rs:+2:10: +2:15 + _8 = _1; // scope 0 at $DIR/shifts.rs:+2:10: +2:15 + StorageLive(_9); // scope 0 at $DIR/shifts.rs:+2:19: +2:20 + _9 = _3; // scope 0 at $DIR/shifts.rs:+2:19: +2:20 + _10 = Lt(_9, const 8_u8); // scope 0 at $DIR/shifts.rs:+2:10: +2:20 + assert(move _10, "attempt to shift right by `{}`, which would overflow", _9) -> [success: bb1, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+2:10: +2:20 + } + + bb1: { + _7 = Shr(move _8, move _9); // scope 0 at $DIR/shifts.rs:+2:10: +2:20 + StorageDead(_9); // scope 0 at $DIR/shifts.rs:+2:19: +2:20 + StorageDead(_8); // scope 0 at $DIR/shifts.rs:+2:19: +2:20 + StorageLive(_11); // scope 0 at $DIR/shifts.rs:+2:22: +2:32 + StorageLive(_12); // scope 0 at $DIR/shifts.rs:+2:22: +2:27 + _12 = _1; // scope 0 at $DIR/shifts.rs:+2:22: +2:27 + StorageLive(_13); // scope 0 at $DIR/shifts.rs:+2:31: +2:32 + _13 = _4; // scope 0 at $DIR/shifts.rs:+2:31: +2:32 + _14 = Lt(_13, const 8_u32); // scope 0 at $DIR/shifts.rs:+2:22: +2:32 + assert(move _14, "attempt to shift right by `{}`, which would overflow", _13) -> [success: bb2, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+2:22: +2:32 + } + + bb2: { + _11 = Shr(move _12, move _13); // scope 0 at $DIR/shifts.rs:+2:22: +2:32 + StorageDead(_13); // scope 0 at $DIR/shifts.rs:+2:31: +2:32 + StorageDead(_12); // scope 0 at $DIR/shifts.rs:+2:31: +2:32 + StorageLive(_15); // scope 0 at $DIR/shifts.rs:+2:34: +2:44 + StorageLive(_16); // scope 0 at $DIR/shifts.rs:+2:34: +2:39 + _16 = _1; // scope 0 at $DIR/shifts.rs:+2:34: +2:39 + StorageLive(_17); // scope 0 at $DIR/shifts.rs:+2:43: +2:44 + _17 = _5; // scope 0 at $DIR/shifts.rs:+2:43: +2:44 + _18 = Lt(_17, const 8_u128); // scope 0 at $DIR/shifts.rs:+2:34: +2:44 + assert(move _18, "attempt to shift right by `{}`, which would overflow", _17) -> [success: bb3, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+2:34: +2:44 + } + + bb3: { + _15 = Shr(move _16, move _17); // scope 0 at $DIR/shifts.rs:+2:34: +2:44 + StorageDead(_17); // scope 0 at $DIR/shifts.rs:+2:43: +2:44 + StorageDead(_16); // scope 0 at $DIR/shifts.rs:+2:43: +2:44 + _6 = [move _7, move _11, move _15]; // scope 0 at $DIR/shifts.rs:+2:9: +2:45 + StorageDead(_15); // scope 0 at $DIR/shifts.rs:+2:44: +2:45 + StorageDead(_11); // scope 0 at $DIR/shifts.rs:+2:44: +2:45 + StorageDead(_7); // scope 0 at $DIR/shifts.rs:+2:44: +2:45 + StorageLive(_19); // scope 0 at $DIR/shifts.rs:+3:9: +3:39 + StorageLive(_20); // scope 0 at $DIR/shifts.rs:+3:10: +3:18 + StorageLive(_21); // scope 0 at $DIR/shifts.rs:+3:10: +3:13 + _21 = _2; // scope 0 at $DIR/shifts.rs:+3:10: +3:13 + StorageLive(_22); // scope 0 at $DIR/shifts.rs:+3:17: +3:18 + _22 = _3; // scope 0 at $DIR/shifts.rs:+3:17: +3:18 + _23 = Lt(_22, const 128_u8); // scope 0 at $DIR/shifts.rs:+3:10: +3:18 + assert(move _23, "attempt to shift left by `{}`, which would overflow", _22) -> [success: bb4, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+3:10: +3:18 + } + + bb4: { + _20 = Shl(move _21, move _22); // scope 0 at $DIR/shifts.rs:+3:10: +3:18 + StorageDead(_22); // scope 0 at $DIR/shifts.rs:+3:17: +3:18 + StorageDead(_21); // scope 0 at $DIR/shifts.rs:+3:17: +3:18 + StorageLive(_24); // scope 0 at $DIR/shifts.rs:+3:20: +3:28 + StorageLive(_25); // scope 0 at $DIR/shifts.rs:+3:20: +3:23 + _25 = _2; // scope 0 at $DIR/shifts.rs:+3:20: +3:23 + StorageLive(_26); // scope 0 at $DIR/shifts.rs:+3:27: +3:28 + _26 = _4; // scope 0 at $DIR/shifts.rs:+3:27: +3:28 + _27 = Lt(_26, const 128_u32); // scope 0 at $DIR/shifts.rs:+3:20: +3:28 + assert(move _27, "attempt to shift left by `{}`, which would overflow", _26) -> [success: bb5, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+3:20: +3:28 + } + + bb5: { + _24 = Shl(move _25, move _26); // scope 0 at $DIR/shifts.rs:+3:20: +3:28 + StorageDead(_26); // scope 0 at $DIR/shifts.rs:+3:27: +3:28 + StorageDead(_25); // scope 0 at $DIR/shifts.rs:+3:27: +3:28 + StorageLive(_28); // scope 0 at $DIR/shifts.rs:+3:30: +3:38 + StorageLive(_29); // scope 0 at $DIR/shifts.rs:+3:30: +3:33 + _29 = _2; // scope 0 at $DIR/shifts.rs:+3:30: +3:33 + StorageLive(_30); // scope 0 at $DIR/shifts.rs:+3:37: +3:38 + _30 = _5; // scope 0 at $DIR/shifts.rs:+3:37: +3:38 + _31 = Lt(_30, const 128_u128); // scope 0 at $DIR/shifts.rs:+3:30: +3:38 + assert(move _31, "attempt to shift left by `{}`, which would overflow", _30) -> [success: bb6, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+3:30: +3:38 + } + + bb6: { + _28 = Shl(move _29, move _30); // scope 0 at $DIR/shifts.rs:+3:30: +3:38 + StorageDead(_30); // scope 0 at $DIR/shifts.rs:+3:37: +3:38 + StorageDead(_29); // scope 0 at $DIR/shifts.rs:+3:37: +3:38 + _19 = [move _20, move _24, move _28]; // scope 0 at $DIR/shifts.rs:+3:9: +3:39 + StorageDead(_28); // scope 0 at $DIR/shifts.rs:+3:38: +3:39 + StorageDead(_24); // scope 0 at $DIR/shifts.rs:+3:38: +3:39 + StorageDead(_20); // scope 0 at $DIR/shifts.rs:+3:38: +3:39 + _0 = (move _6, move _19); // scope 0 at $DIR/shifts.rs:+1:5: +4:6 + StorageDead(_19); // scope 0 at $DIR/shifts.rs:+4:5: +4:6 + StorageDead(_6); // scope 0 at $DIR/shifts.rs:+4:5: +4:6 + return; // scope 0 at $DIR/shifts.rs:+5:2: +5:2 + } + + bb7 (cleanup): { + resume; // scope 0 at $DIR/shifts.rs:+0:1: +5:2 + } +} diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir index 234cd0839..54f0ea2d8 100644 --- a/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir +++ b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir @@ -3,21 +3,21 @@ fn move_out_by_subslice() -> () { let mut _0: (); // return place in scope 0 at $DIR/uniform_array_move_out.rs:+0:27: +0:27 let _1: [std::boxed::Box<i32>; 2]; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 - let mut _2: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _3: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _4: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _5: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _6: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _7: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - let mut _8: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - let mut _9: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - let mut _10: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - let mut _11: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + let mut _2: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + let mut _3: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + let mut _4: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + let mut _5: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + let mut _6: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + let mut _7: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + let mut _8: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + let mut _9: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + let mut _10: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + let mut _11: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 scope 1 { debug a => _1; // in scope 1 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 - let _12: [std::boxed::Box<i32>; 2]; // in scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12 + let _12: [std::boxed::Box<i32>; 2]; // in scope 1 at $DIR/uniform_array_move_out.rs:+7:10: +7:12 scope 4 { - debug _y => _12; // in scope 4 at $DIR/uniform_array_move_out.rs:+2:10: +2:12 + debug _y => _12; // in scope 4 at $DIR/uniform_array_move_out.rs:+7:10: +7:12 } } scope 2 { @@ -27,85 +27,86 @@ fn move_out_by_subslice() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - _3 = SizeOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - _4 = AlignOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + StorageLive(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + _3 = SizeOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + _4 = AlignOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; // scope 2 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 // mir::Constant - // + span: $DIR/uniform_array_move_out.rs:11:14: 11:19 + // + span: $DIR/uniform_array_move_out.rs:18:9: 18:20 // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) } } bb1: { - StorageLive(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - _6 = ShallowInitBox(move _5, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - (*_6) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 - _2 = move _6; // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - drop(_6) -> [return: bb2, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 + StorageLive(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + _6 = ShallowInitBox(move _5, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + (*_6) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+3:18: +3:19 + _2 = move _6; // scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + drop(_6) -> [return: bb2, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+3:19: +3:20 } bb2: { - StorageDead(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 - StorageLive(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - _8 = SizeOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - _9 = AlignOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + StorageDead(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+3:19: +3:20 + StorageLive(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + _8 = SizeOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + _9 = AlignOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; // scope 3 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 // mir::Constant - // + span: $DIR/uniform_array_move_out.rs:11:21: 11:26 + // + span: $DIR/uniform_array_move_out.rs:20:9: 20:20 // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) } } bb3: { - StorageLive(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - _11 = ShallowInitBox(move _10, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - (*_11) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 - _7 = move _11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - drop(_11) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 + StorageLive(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + _11 = ShallowInitBox(move _10, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + (*_11) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+5:18: +5:19 + _7 = move _11; // scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + drop(_11) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:+5:19: +5:20 } bb4: { - StorageDead(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 - _1 = [move _2, move _7]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:13: +1:27 - drop(_7) -> [return: bb5, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + StorageDead(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+5:19: +5:20 + _1 = [move _2, move _7]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:13: +6:6 + drop(_7) -> [return: bb5, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6 } bb5: { - StorageDead(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 - drop(_2) -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + StorageDead(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6 + drop(_2) -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6 } bb6: { - StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6 FakeRead(ForLet(None), _1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 - StorageLive(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12 - _12 = move _1[0..2]; // scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12 - _0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:+0:27: +3:2 - drop(_12) -> [return: bb7, unwind: bb9]; // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 + PlaceMention(_1); // scope 1 at $DIR/uniform_array_move_out.rs:+7:21: +7:22 + StorageLive(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+7:10: +7:12 + _12 = move _1[0..2]; // scope 1 at $DIR/uniform_array_move_out.rs:+7:10: +7:12 + _0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:+0:27: +8:2 + drop(_12) -> [return: bb7, unwind: bb9]; // scope 1 at $DIR/uniform_array_move_out.rs:+8:1: +8:2 } bb7: { - StorageDead(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 - drop(_1) -> [return: bb8, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 + StorageDead(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+8:1: +8:2 + drop(_1) -> [return: bb8, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+8:1: +8:2 } bb8: { - StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 - return; // scope 0 at $DIR/uniform_array_move_out.rs:+3:2: +3:2 + StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+8:1: +8:2 + return; // scope 0 at $DIR/uniform_array_move_out.rs:+8:2: +8:2 } bb9 (cleanup): { - drop(_1) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 + drop(_1) -> [return: bb12, unwind terminate]; // scope 0 at $DIR/uniform_array_move_out.rs:+8:1: +8:2 } bb10 (cleanup): { - drop(_7) -> bb11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + drop(_7) -> [return: bb11, unwind terminate]; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6 } bb11 (cleanup): { - drop(_2) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + drop(_2) -> [return: bb12, unwind terminate]; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6 } bb12 (cleanup): { - resume; // scope 0 at $DIR/uniform_array_move_out.rs:+0:1: +3:2 + resume; // scope 0 at $DIR/uniform_array_move_out.rs:+0:1: +8:2 } } diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir index 24a189498..5090a4ba6 100644 --- a/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir +++ b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir @@ -3,21 +3,21 @@ fn move_out_from_end() -> () { let mut _0: (); // return place in scope 0 at $DIR/uniform_array_move_out.rs:+0:24: +0:24 let _1: [std::boxed::Box<i32>; 2]; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 - let mut _2: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _3: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _4: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _5: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _6: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _7: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - let mut _8: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - let mut _9: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - let mut _10: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - let mut _11: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + let mut _2: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + let mut _3: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + let mut _4: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + let mut _5: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + let mut _6: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + let mut _7: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + let mut _8: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + let mut _9: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + let mut _10: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + let mut _11: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 scope 1 { debug a => _1; // in scope 1 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 - let _12: std::boxed::Box<i32>; // in scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16 + let _12: std::boxed::Box<i32>; // in scope 1 at $DIR/uniform_array_move_out.rs:+7:14: +7:16 scope 4 { - debug _y => _12; // in scope 4 at $DIR/uniform_array_move_out.rs:+2:14: +2:16 + debug _y => _12; // in scope 4 at $DIR/uniform_array_move_out.rs:+7:14: +7:16 } } scope 2 { @@ -27,85 +27,86 @@ fn move_out_from_end() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - _3 = SizeOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - _4 = AlignOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + StorageLive(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + _3 = SizeOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + _4 = AlignOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; // scope 2 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 // mir::Constant - // + span: $DIR/uniform_array_move_out.rs:5:14: 5:19 + // + span: $DIR/uniform_array_move_out.rs:7:9: 7:20 // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) } } bb1: { - StorageLive(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - _6 = ShallowInitBox(move _5, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - (*_6) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 - _2 = move _6; // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - drop(_6) -> [return: bb2, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 + StorageLive(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + _6 = ShallowInitBox(move _5, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + (*_6) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+3:18: +3:19 + _2 = move _6; // scope 0 at $DIR/uniform_array_move_out.rs:+3:9: +3:20 + drop(_6) -> [return: bb2, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+3:19: +3:20 } bb2: { - StorageDead(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 - StorageLive(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - _8 = SizeOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - _9 = AlignOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + StorageDead(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+3:19: +3:20 + StorageLive(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + _8 = SizeOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + _9 = AlignOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; // scope 3 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 // mir::Constant - // + span: $DIR/uniform_array_move_out.rs:5:21: 5:26 + // + span: $DIR/uniform_array_move_out.rs:9:9: 9:20 // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) } } bb3: { - StorageLive(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - _11 = ShallowInitBox(move _10, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - (*_11) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 - _7 = move _11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - drop(_11) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 + StorageLive(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + _11 = ShallowInitBox(move _10, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + (*_11) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+5:18: +5:19 + _7 = move _11; // scope 0 at $DIR/uniform_array_move_out.rs:+5:9: +5:20 + drop(_11) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:+5:19: +5:20 } bb4: { - StorageDead(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 - _1 = [move _2, move _7]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:13: +1:27 - drop(_7) -> [return: bb5, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + StorageDead(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+5:19: +5:20 + _1 = [move _2, move _7]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:13: +6:6 + drop(_7) -> [return: bb5, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6 } bb5: { - StorageDead(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 - drop(_2) -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + StorageDead(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6 + drop(_2) -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6 } bb6: { - StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6 FakeRead(ForLet(None), _1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 - StorageLive(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16 - _12 = move _1[1 of 2]; // scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16 - _0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:+0:24: +3:2 - drop(_12) -> [return: bb7, unwind: bb9]; // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 + PlaceMention(_1); // scope 1 at $DIR/uniform_array_move_out.rs:+7:20: +7:21 + StorageLive(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+7:14: +7:16 + _12 = move _1[1 of 2]; // scope 1 at $DIR/uniform_array_move_out.rs:+7:14: +7:16 + _0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:+0:24: +8:2 + drop(_12) -> [return: bb7, unwind: bb9]; // scope 1 at $DIR/uniform_array_move_out.rs:+8:1: +8:2 } bb7: { - StorageDead(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 - drop(_1) -> [return: bb8, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 + StorageDead(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+8:1: +8:2 + drop(_1) -> [return: bb8, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+8:1: +8:2 } bb8: { - StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 - return; // scope 0 at $DIR/uniform_array_move_out.rs:+3:2: +3:2 + StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+8:1: +8:2 + return; // scope 0 at $DIR/uniform_array_move_out.rs:+8:2: +8:2 } bb9 (cleanup): { - drop(_1) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 + drop(_1) -> [return: bb12, unwind terminate]; // scope 0 at $DIR/uniform_array_move_out.rs:+8:1: +8:2 } bb10 (cleanup): { - drop(_7) -> bb11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + drop(_7) -> [return: bb11, unwind terminate]; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6 } bb11 (cleanup): { - drop(_2) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + drop(_2) -> [return: bb12, unwind terminate]; // scope 0 at $DIR/uniform_array_move_out.rs:+6:5: +6:6 } bb12 (cleanup): { - resume; // scope 0 at $DIR/uniform_array_move_out.rs:+0:1: +3:2 + resume; // scope 0 at $DIR/uniform_array_move_out.rs:+0:1: +8:2 } } diff --git a/tests/mir-opt/building/uniform_array_move_out.rs b/tests/mir-opt/building/uniform_array_move_out.rs index e925036ec..4ba107c87 100644 --- a/tests/mir-opt/building/uniform_array_move_out.rs +++ b/tests/mir-opt/building/uniform_array_move_out.rs @@ -1,14 +1,24 @@ -#![feature(box_syntax)] +#![feature(stmt_expr_attributes, rustc_attrs)] // EMIT_MIR uniform_array_move_out.move_out_from_end.built.after.mir fn move_out_from_end() { - let a = [box 1, box 2]; + let a = [ + #[rustc_box] + Box::new(1), + #[rustc_box] + Box::new(2), + ]; let [.., _y] = a; } // EMIT_MIR uniform_array_move_out.move_out_by_subslice.built.after.mir fn move_out_by_subslice() { - let a = [box 1, box 2]; + let a = [ + #[rustc_box] + Box::new(1), + #[rustc_box] + Box::new(2), + ]; let [_y @ ..] = a; } diff --git a/tests/mir-opt/combine_array_len.rs b/tests/mir-opt/combine_array_len.rs index 3ef3bd09a..08c5f1a1f 100644 --- a/tests/mir-opt/combine_array_len.rs +++ b/tests/mir-opt/combine_array_len.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: InstCombine // EMIT_MIR combine_array_len.norm2.InstCombine.diff diff --git a/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff b/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff index 20b0fb964..b715a544f 100644 --- a/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff +++ b/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff @@ -72,7 +72,7 @@ } bb4 (cleanup): { - drop(_2) -> bb5; // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:14: +0:15 + drop(_2) -> [return: bb5, unwind terminate]; // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:14: +0:15 } bb5 (cleanup): { diff --git a/tests/mir-opt/combine_transmutes.adt_transmutes.InstCombine.diff b/tests/mir-opt/combine_transmutes.adt_transmutes.InstCombine.diff new file mode 100644 index 000000000..168e8c610 --- /dev/null +++ b/tests/mir-opt/combine_transmutes.adt_transmutes.InstCombine.diff @@ -0,0 +1,158 @@ +- // MIR for `adt_transmutes` before InstCombine ++ // MIR for `adt_transmutes` after InstCombine + + fn adt_transmutes() -> () { + let mut _0: (); // return place in scope 0 at $DIR/combine_transmutes.rs:+0:32: +0:32 + let _1: u8; // in scope 0 at $DIR/combine_transmutes.rs:+1:9: +1:11 + let mut _2: EnumNoRepr; // in scope 0 at $DIR/combine_transmutes.rs:+1:28: +1:41 + let mut _4: EnumNoRepr; // in scope 0 at $DIR/combine_transmutes.rs:+2:28: +2:41 + let mut _6: EnumReprIsize; // in scope 0 at $DIR/combine_transmutes.rs:+3:31: +3:47 + let mut _8: EnumReprIsize; // in scope 0 at $DIR/combine_transmutes.rs:+4:31: +4:47 + let mut _10: std::cmp::Ordering; // in scope 0 at $DIR/combine_transmutes.rs:+5:28: +5:52 + let mut _12: std::cmp::Ordering; // in scope 0 at $DIR/combine_transmutes.rs:+6:28: +6:52 + let mut _14: std::option::Option<std::num::NonZeroU8>; // in scope 0 at $DIR/combine_transmutes.rs:+7:28: +7:58 + let mut _16: std::num::Wrapping<i16>; // in scope 0 at $DIR/combine_transmutes.rs:+8:29: +8:54 + let mut _18: std::num::Wrapping<i16>; // in scope 0 at $DIR/combine_transmutes.rs:+9:29: +9:54 + let mut _20: Union32; // in scope 0 at $DIR/combine_transmutes.rs:+10:29: +10:47 + let mut _22: Union32; // in scope 0 at $DIR/combine_transmutes.rs:+11:29: +11:47 + let mut _24: std::mem::MaybeUninit<std::string::String>; // in scope 0 at $DIR/combine_transmutes.rs:+12:46: +12:77 + scope 1 { + debug _a => _1; // in scope 1 at $DIR/combine_transmutes.rs:+1:9: +1:11 + let _3: i8; // in scope 1 at $DIR/combine_transmutes.rs:+2:9: +2:11 + scope 2 { + debug _a => _3; // in scope 2 at $DIR/combine_transmutes.rs:+2:9: +2:11 + let _5: usize; // in scope 2 at $DIR/combine_transmutes.rs:+3:9: +3:11 + scope 3 { + debug _a => _5; // in scope 3 at $DIR/combine_transmutes.rs:+3:9: +3:11 + let _7: isize; // in scope 3 at $DIR/combine_transmutes.rs:+4:9: +4:11 + scope 4 { + debug _a => _7; // in scope 4 at $DIR/combine_transmutes.rs:+4:9: +4:11 + let _9: u8; // in scope 4 at $DIR/combine_transmutes.rs:+5:9: +5:11 + scope 5 { + debug _a => _9; // in scope 5 at $DIR/combine_transmutes.rs:+5:9: +5:11 + let _11: i8; // in scope 5 at $DIR/combine_transmutes.rs:+6:9: +6:11 + scope 6 { + debug _a => _11; // in scope 6 at $DIR/combine_transmutes.rs:+6:9: +6:11 + let _13: u8; // in scope 6 at $DIR/combine_transmutes.rs:+7:9: +7:11 + scope 7 { + debug _a => _13; // in scope 7 at $DIR/combine_transmutes.rs:+7:9: +7:11 + let _15: i16; // in scope 7 at $DIR/combine_transmutes.rs:+8:9: +8:11 + scope 8 { + debug _a => _15; // in scope 8 at $DIR/combine_transmutes.rs:+8:9: +8:11 + let _17: u16; // in scope 8 at $DIR/combine_transmutes.rs:+9:9: +9:11 + scope 9 { + debug _a => _17; // in scope 9 at $DIR/combine_transmutes.rs:+9:9: +9:11 + let _19: u32; // in scope 9 at $DIR/combine_transmutes.rs:+10:9: +10:11 + scope 10 { + debug _a => _19; // in scope 10 at $DIR/combine_transmutes.rs:+10:9: +10:11 + let _21: i32; // in scope 10 at $DIR/combine_transmutes.rs:+11:9: +11:11 + scope 11 { + debug _a => _21; // in scope 11 at $DIR/combine_transmutes.rs:+11:9: +11:11 + let _23: std::mem::ManuallyDrop<std::string::String>; // in scope 11 at $DIR/combine_transmutes.rs:+12:9: +12:11 + scope 12 { + debug _a => _23; // in scope 12 at $DIR/combine_transmutes.rs:+12:9: +12:11 + } + } + } + } + } + } + } + } + } + } + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/combine_transmutes.rs:+1:9: +1:11 + StorageLive(_2); // scope 0 at $DIR/combine_transmutes.rs:+1:28: +1:41 + _2 = EnumNoRepr::A; // scope 0 at $DIR/combine_transmutes.rs:+1:28: +1:41 + _1 = move _2 as u8 (Transmute); // scope 0 at $DIR/combine_transmutes.rs:+1:18: +1:42 + StorageDead(_2); // scope 0 at $DIR/combine_transmutes.rs:+1:41: +1:42 + StorageLive(_3); // scope 1 at $DIR/combine_transmutes.rs:+2:9: +2:11 + StorageLive(_4); // scope 1 at $DIR/combine_transmutes.rs:+2:28: +2:41 + _4 = EnumNoRepr::B; // scope 1 at $DIR/combine_transmutes.rs:+2:28: +2:41 + _3 = move _4 as i8 (Transmute); // scope 1 at $DIR/combine_transmutes.rs:+2:18: +2:42 + StorageDead(_4); // scope 1 at $DIR/combine_transmutes.rs:+2:41: +2:42 + StorageLive(_5); // scope 2 at $DIR/combine_transmutes.rs:+3:9: +3:11 + StorageLive(_6); // scope 2 at $DIR/combine_transmutes.rs:+3:31: +3:47 + _6 = EnumReprIsize::A; // scope 2 at $DIR/combine_transmutes.rs:+3:31: +3:47 + _5 = move _6 as usize (Transmute); // scope 2 at $DIR/combine_transmutes.rs:+3:21: +3:48 + StorageDead(_6); // scope 2 at $DIR/combine_transmutes.rs:+3:47: +3:48 + StorageLive(_7); // scope 3 at $DIR/combine_transmutes.rs:+4:9: +4:11 + StorageLive(_8); // scope 3 at $DIR/combine_transmutes.rs:+4:31: +4:47 + _8 = EnumReprIsize::B; // scope 3 at $DIR/combine_transmutes.rs:+4:31: +4:47 +- _7 = move _8 as isize (Transmute); // scope 3 at $DIR/combine_transmutes.rs:+4:21: +4:48 ++ _7 = discriminant(_8); // scope 3 at $DIR/combine_transmutes.rs:+4:21: +4:48 + StorageDead(_8); // scope 3 at $DIR/combine_transmutes.rs:+4:47: +4:48 + StorageLive(_9); // scope 4 at $DIR/combine_transmutes.rs:+5:9: +5:11 + StorageLive(_10); // scope 4 at $DIR/combine_transmutes.rs:+5:28: +5:52 + _10 = Less; // scope 4 at $DIR/combine_transmutes.rs:+5:28: +5:52 + _9 = move _10 as u8 (Transmute); // scope 4 at $DIR/combine_transmutes.rs:+5:18: +5:53 + StorageDead(_10); // scope 4 at $DIR/combine_transmutes.rs:+5:52: +5:53 + StorageLive(_11); // scope 5 at $DIR/combine_transmutes.rs:+6:9: +6:11 + StorageLive(_12); // scope 5 at $DIR/combine_transmutes.rs:+6:28: +6:52 + _12 = Less; // scope 5 at $DIR/combine_transmutes.rs:+6:28: +6:52 +- _11 = move _12 as i8 (Transmute); // scope 5 at $DIR/combine_transmutes.rs:+6:18: +6:53 ++ _11 = discriminant(_12); // scope 5 at $DIR/combine_transmutes.rs:+6:18: +6:53 + StorageDead(_12); // scope 5 at $DIR/combine_transmutes.rs:+6:52: +6:53 + StorageLive(_13); // scope 6 at $DIR/combine_transmutes.rs:+7:9: +7:11 + StorageLive(_14); // scope 6 at $DIR/combine_transmutes.rs:+7:28: +7:58 + _14 = Option::<NonZeroU8>::Some(const _); // scope 6 at $DIR/combine_transmutes.rs:+7:28: +7:58 + // mir::Constant + // + span: $DIR/combine_transmutes.rs:41:33: 41:57 + // + literal: Const { ty: NonZeroU8, val: Unevaluated(NonZeroU8::MAX, [], None) } + _13 = move _14 as u8 (Transmute); // scope 6 at $DIR/combine_transmutes.rs:+7:18: +7:59 + StorageDead(_14); // scope 6 at $DIR/combine_transmutes.rs:+7:58: +7:59 + StorageLive(_15); // scope 7 at $DIR/combine_transmutes.rs:+8:9: +8:11 + StorageLive(_16); // scope 7 at $DIR/combine_transmutes.rs:+8:29: +8:54 + _16 = Wrapping::<i16>(const 0_i16); // scope 7 at $DIR/combine_transmutes.rs:+8:29: +8:54 +- _15 = move _16 as i16 (Transmute); // scope 7 at $DIR/combine_transmutes.rs:+8:19: +8:55 ++ _15 = move (_16.0: i16); // scope 7 at $DIR/combine_transmutes.rs:+8:19: +8:55 + StorageDead(_16); // scope 7 at $DIR/combine_transmutes.rs:+8:54: +8:55 + StorageLive(_17); // scope 8 at $DIR/combine_transmutes.rs:+9:9: +9:11 + StorageLive(_18); // scope 8 at $DIR/combine_transmutes.rs:+9:29: +9:54 + _18 = Wrapping::<i16>(const 0_i16); // scope 8 at $DIR/combine_transmutes.rs:+9:29: +9:54 + _17 = move _18 as u16 (Transmute); // scope 8 at $DIR/combine_transmutes.rs:+9:19: +9:55 + StorageDead(_18); // scope 8 at $DIR/combine_transmutes.rs:+9:54: +9:55 + StorageLive(_19); // scope 9 at $DIR/combine_transmutes.rs:+10:9: +10:11 + StorageLive(_20); // scope 9 at $DIR/combine_transmutes.rs:+10:29: +10:47 + _20 = Union32 { u32: const 0_i32 }; // scope 9 at $DIR/combine_transmutes.rs:+10:29: +10:47 + _19 = move _20 as u32 (Transmute); // scope 9 at $DIR/combine_transmutes.rs:+10:19: +10:48 + StorageDead(_20); // scope 9 at $DIR/combine_transmutes.rs:+10:47: +10:48 + StorageLive(_21); // scope 10 at $DIR/combine_transmutes.rs:+11:9: +11:11 + StorageLive(_22); // scope 10 at $DIR/combine_transmutes.rs:+11:29: +11:47 + _22 = Union32 { u32: const 0_u32 }; // scope 10 at $DIR/combine_transmutes.rs:+11:29: +11:47 + _21 = move _22 as i32 (Transmute); // scope 10 at $DIR/combine_transmutes.rs:+11:19: +11:48 + StorageDead(_22); // scope 10 at $DIR/combine_transmutes.rs:+11:47: +11:48 + StorageLive(_23); // scope 11 at $DIR/combine_transmutes.rs:+12:9: +12:11 + StorageLive(_24); // scope 11 at $DIR/combine_transmutes.rs:+12:46: +12:77 + _24 = MaybeUninit::<String>::uninit() -> [return: bb1, unwind unreachable]; // scope 11 at $DIR/combine_transmutes.rs:+12:46: +12:77 + // mir::Constant + // + span: $DIR/combine_transmutes.rs:46:46: 46:75 + // + user_ty: UserType(23) + // + literal: Const { ty: fn() -> MaybeUninit<String> {MaybeUninit::<String>::uninit}, val: Value(<ZST>) } + } + + bb1: { +- _23 = move _24 as std::mem::ManuallyDrop<std::string::String> (Transmute); // scope 11 at $DIR/combine_transmutes.rs:+12:36: +12:78 ++ _23 = move (_24.1: std::mem::ManuallyDrop<std::string::String>); // scope 11 at $DIR/combine_transmutes.rs:+12:36: +12:78 + StorageDead(_24); // scope 11 at $DIR/combine_transmutes.rs:+12:77: +12:78 + _0 = const (); // scope 0 at $DIR/combine_transmutes.rs:+0:32: +13:2 + StorageDead(_23); // scope 11 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_21); // scope 10 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_19); // scope 9 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_17); // scope 8 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_15); // scope 7 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_13); // scope 6 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_11); // scope 5 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_9); // scope 4 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_7); // scope 3 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_5); // scope 2 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_3); // scope 1 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_1); // scope 0 at $DIR/combine_transmutes.rs:+13:1: +13:2 + return; // scope 0 at $DIR/combine_transmutes.rs:+13:2: +13:2 + } + } + diff --git a/tests/mir-opt/combine_transmutes.identity_transmutes.InstCombine.diff b/tests/mir-opt/combine_transmutes.identity_transmutes.InstCombine.diff new file mode 100644 index 000000000..ae1185c7f --- /dev/null +++ b/tests/mir-opt/combine_transmutes.identity_transmutes.InstCombine.diff @@ -0,0 +1,43 @@ +- // MIR for `identity_transmutes` before InstCombine ++ // MIR for `identity_transmutes` after InstCombine + + fn identity_transmutes() -> () { + let mut _0: (); // return place in scope 0 at $DIR/combine_transmutes.rs:+0:37: +0:37 + let _1: i32; // in scope 0 at $DIR/combine_transmutes.rs:+2:9: +2:11 + let mut _3: std::vec::Vec<i32>; // in scope 0 at $DIR/combine_transmutes.rs:+3:46: +3:56 + scope 1 { + debug _a => _1; // in scope 1 at $DIR/combine_transmutes.rs:+2:9: +2:11 + let _2: std::vec::Vec<i32>; // in scope 1 at $DIR/combine_transmutes.rs:+3:9: +3:11 + scope 2 { + debug _a => _2; // in scope 2 at $DIR/combine_transmutes.rs:+3:9: +3:11 + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/combine_transmutes.rs:+2:9: +2:11 +- _1 = const 1_i32 as i32 (Transmute); // scope 0 at $DIR/combine_transmutes.rs:+2:14: +2:38 ++ _1 = const 1_i32; // scope 0 at $DIR/combine_transmutes.rs:+2:14: +2:38 + StorageLive(_2); // scope 1 at $DIR/combine_transmutes.rs:+3:9: +3:11 + StorageLive(_3); // scope 1 at $DIR/combine_transmutes.rs:+3:46: +3:56 + _3 = Vec::<i32>::new() -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/combine_transmutes.rs:+3:46: +3:56 + // mir::Constant + // + span: $DIR/combine_transmutes.rs:15:46: 15:54 + // + user_ty: UserType(0) + // + literal: Const { ty: fn() -> Vec<i32> {Vec::<i32>::new}, val: Value(<ZST>) } + } + + bb1: { +- _2 = move _3 as std::vec::Vec<i32> (Transmute); // scope 1 at $DIR/combine_transmutes.rs:+3:14: +3:57 ++ _2 = move _3; // scope 1 at $DIR/combine_transmutes.rs:+3:14: +3:57 + StorageDead(_3); // scope 1 at $DIR/combine_transmutes.rs:+3:56: +3:57 + _0 = const (); // scope 0 at $DIR/combine_transmutes.rs:+0:37: +4:2 + drop(_2) -> [return: bb2, unwind unreachable]; // scope 1 at $DIR/combine_transmutes.rs:+4:1: +4:2 + } + + bb2: { + StorageDead(_2); // scope 1 at $DIR/combine_transmutes.rs:+4:1: +4:2 + StorageDead(_1); // scope 0 at $DIR/combine_transmutes.rs:+4:1: +4:2 + return; // scope 0 at $DIR/combine_transmutes.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/combine_transmutes.integer_transmutes.InstCombine.diff b/tests/mir-opt/combine_transmutes.integer_transmutes.InstCombine.diff new file mode 100644 index 000000000..8de7c34e6 --- /dev/null +++ b/tests/mir-opt/combine_transmutes.integer_transmutes.InstCombine.diff @@ -0,0 +1,24 @@ +- // MIR for `integer_transmutes` before InstCombine ++ // MIR for `integer_transmutes` after InstCombine + + fn integer_transmutes() -> () { + let mut _0: (); // return place in scope 0 at $DIR/combine_transmutes.rs:+0:36: +0:36 + let mut _1: u32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _2: i64; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _3: i64; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _4: u32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _5: usize; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { +- _1 = const 1_i32 as u32 (Transmute); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL ++ _1 = const 1_i32 as u32 (IntToInt); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _2 = const 1_i32 as i64 (Transmute); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL +- _3 = const 1_u64 as i64 (Transmute); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL ++ _3 = const 1_u64 as i64 (IntToInt); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _4 = const 1_u64 as u32 (Transmute); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL +- _5 = const 1_isize as usize (Transmute); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL ++ _5 = const 1_isize as usize (IntToInt); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + return; // scope 0 at $DIR/combine_transmutes.rs:+8:13: +8:21 + } + } + diff --git a/tests/mir-opt/combine_transmutes.rs b/tests/mir-opt/combine_transmutes.rs new file mode 100644 index 000000000..de9b9c35c --- /dev/null +++ b/tests/mir-opt/combine_transmutes.rs @@ -0,0 +1,65 @@ +// unit-test: InstCombine +// compile-flags: -C panic=abort + +#![crate_type = "lib"] +#![feature(core_intrinsics)] +#![feature(custom_mir)] + +use std::intrinsics::mir::*; +use std::mem::{MaybeUninit, ManuallyDrop, transmute}; + +// EMIT_MIR combine_transmutes.identity_transmutes.InstCombine.diff +pub unsafe fn identity_transmutes() { + // These are nops and should be removed + let _a = transmute::<i32, i32>(1); + let _a = transmute::<Vec<i32>, Vec<i32>>(Vec::new()); +} + +#[custom_mir(dialect = "runtime", phase = "initial")] +// EMIT_MIR combine_transmutes.integer_transmutes.InstCombine.diff +pub unsafe fn integer_transmutes() { + mir! { + { + let A = CastTransmute::<i32, u32>(1); // Can be a cast + let B = CastTransmute::<i32, i64>(1); // UB + let C = CastTransmute::<u64, i64>(1); // Can be a cast + let D = CastTransmute::<u64, u32>(1); // UB + let E = CastTransmute::<isize, usize>(1); // Can be a cast + Return() + } + } +} + +// EMIT_MIR combine_transmutes.adt_transmutes.InstCombine.diff +pub unsafe fn adt_transmutes() { + let _a: u8 = transmute(EnumNoRepr::A); + let _a: i8 = transmute(EnumNoRepr::B); + let _a: usize = transmute(EnumReprIsize::A); + let _a: isize = transmute(EnumReprIsize::B); + let _a: u8 = transmute(std::cmp::Ordering::Less); + let _a: i8 = transmute(std::cmp::Ordering::Less); + let _a: u8 = transmute(Some(std::num::NonZeroU8::MAX)); + let _a: i16 = transmute(std::num::Wrapping(0_i16)); + let _a: u16 = transmute(std::num::Wrapping(0_i16)); + let _a: u32 = transmute(Union32 { i32: 0 }); + let _a: i32 = transmute(Union32 { u32: 0 }); + let _a: ManuallyDrop<String> = transmute(MaybeUninit::<String>::uninit()); +} + +#[inline(always)] +#[custom_mir(dialect = "runtime", phase = "initial")] +const unsafe fn mir_transmute<T, U>(x: T) -> U { + mir!{ + { + RET = CastTransmute(x); + Return() + } + } +} + +pub enum EnumNoRepr { A, B, C } + +#[repr(isize)] +pub enum EnumReprIsize { A, B, C } + +pub union Union32 { u32: u32, i32: i32 } diff --git a/tests/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir b/tests/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir index 41657b53f..19daae865 100644 --- a/tests/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir +++ b/tests/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir @@ -7,10 +7,10 @@ promoted[0] in FOO: &[&i32; 1] = { let mut _3: *const i32; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 bb0: { - _3 = const {alloc3: *const i32}; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 + _3 = const {alloc2: *const i32}; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 // mir::Constant // + span: $DIR/const_promotion_extern_static.rs:13:42: 13:43 - // + literal: Const { ty: *const i32, val: Value(Scalar(alloc3)) } + // + literal: Const { ty: *const i32, val: Value(Scalar(alloc2)) } _2 = &(*_3); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:41: +0:43 _1 = [move _2]; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46 _0 = &_1; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 @@ -18,4 +18,4 @@ promoted[0] in FOO: &[&i32; 1] = { } } -alloc3 (extern static: X) +alloc2 (extern static: X) diff --git a/tests/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff b/tests/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff index 25ba0face..5b13d6005 100644 --- a/tests/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff +++ b/tests/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff @@ -18,11 +18,11 @@ - StorageLive(_3); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46 - StorageLive(_4); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:45 - StorageLive(_5); // scope 1 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 -- _5 = const {alloc3: *const i32}; // scope 1 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 +- _5 = const {alloc2: *const i32}; // scope 1 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 + _6 = const _; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 // mir::Constant - // + span: $DIR/const_promotion_extern_static.rs:13:42: 13:43 -- // + literal: Const { ty: *const i32, val: Value(Scalar(alloc3)) } +- // + literal: Const { ty: *const i32, val: Value(Scalar(alloc2)) } - _4 = &(*_5); // scope 1 at $DIR/const_promotion_extern_static.rs:+0:41: +0:43 - _3 = [move _4]; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46 - _2 = &_3; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 @@ -50,5 +50,5 @@ } } - -- alloc3 (extern static: X) +- alloc2 (extern static: X) diff --git a/tests/mir-opt/const_prop/aggregate.main.ConstProp.diff b/tests/mir-opt/const_prop/aggregate.main.ConstProp.diff index f6e58955b..041197266 100644 --- a/tests/mir-opt/const_prop/aggregate.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/aggregate.main.ConstProp.diff @@ -29,7 +29,7 @@ + _5 = const 1_u8; // scope 1 at $DIR/aggregate.rs:+2:9: +2:10 _4 = foo(move _5) -> bb1; // scope 1 at $DIR/aggregate.rs:+2:5: +2:11 // mir::Constant - // + span: $DIR/aggregate.rs:8:5: 8:8 + // + span: $DIR/aggregate.rs:9:5: 9:8 // + literal: Const { ty: fn(u8) {foo}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir index 4706af92c..05d4bf8b5 100644 --- a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir +++ b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir @@ -25,7 +25,7 @@ fn main() -> () { _5 = const 1_u8; // scope 1 at $DIR/aggregate.rs:+2:9: +2:10 _4 = foo(move _5) -> bb1; // scope 1 at $DIR/aggregate.rs:+2:5: +2:11 // mir::Constant - // + span: $DIR/aggregate.rs:8:5: 8:8 + // + span: $DIR/aggregate.rs:9:5: 9:8 // + literal: Const { ty: fn(u8) {foo}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/const_prop/aggregate.rs b/tests/mir-opt/const_prop/aggregate.rs index aa123b7a8..ed5a4ab59 100644 --- a/tests/mir-opt/const_prop/aggregate.rs +++ b/tests/mir-opt/const_prop/aggregate.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: ConstProp // compile-flags: -O diff --git a/tests/mir-opt/const_prop/array_index.rs b/tests/mir-opt/const_prop/array_index.rs index d31c2827b..f36cf2213 100644 --- a/tests/mir-opt/const_prop/array_index.rs +++ b/tests/mir-opt/const_prop/array_index.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: ConstProp // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.rs b/tests/mir-opt/const_prop/bad_op_div_by_zero.rs index a6fd325ec..38f1a993d 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.rs +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: ConstProp // EMIT_MIR bad_op_div_by_zero.main.ConstProp.diff #[allow(unconditional_panic)] diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff index ae9ffd519..bedfa5992 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff @@ -27,17 +27,19 @@ } bb1: { - _5 = Eq(_1, const -1_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 +- _5 = Eq(_1, const -1_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - _6 = Eq(const 1_i32, const i32::MIN); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - _7 = BitAnd(move _5, move _6); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - assert(!move _7, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _1) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 ++ _5 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + _6 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + _7 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -+ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _1) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 ++ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, const 0_i32) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 } bb2: { - _2 = Rem(const 1_i32, _1); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 +- _2 = Rem(const 1_i32, _1); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 ++ _2 = Rem(const 1_i32, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 StorageDead(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+3:1: +3:2 return; // scope 0 at $DIR/bad_op_mod_by_zero.rs:+3:2: +3:2 } diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs index cc16a4a5a..a1078472c 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // EMIT_MIR bad_op_mod_by_zero.main.ConstProp.diff #[allow(unconditional_panic)] fn main() { diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff index 38d402b8f..e711babf0 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff @@ -25,7 +25,7 @@ StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _8 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 // mir::Constant - // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 + // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:6:25: 6:35 // + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) } _2 = &raw const (*_8); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff index 38d402b8f..e711babf0 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff @@ -25,7 +25,7 @@ StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _8 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 // mir::Constant - // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 + // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:6:25: 6:35 // + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) } _2 = &raw const (*_8); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs index cf22b06d5..3d252f2d2 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR bad_op_unsafe_oob_for_slices.main.ConstProp.diff #[allow(unconditional_panic)] diff --git a/tests/mir-opt/const_prop/boxes.main.ConstProp.diff b/tests/mir-opt/const_prop/boxes.main.ConstProp.diff index 5ec421eb2..b0e86e753 100644 --- a/tests/mir-opt/const_prop/boxes.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/boxes.main.ConstProp.diff @@ -4,14 +4,14 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/boxes.rs:+0:11: +0:11 let _1: i32; // in scope 0 at $DIR/boxes.rs:+1:9: +1:10 - let mut _2: i32; // in scope 0 at $DIR/boxes.rs:+1:13: +1:22 - let mut _3: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22 - let mut _4: usize; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22 - let mut _5: usize; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22 - let mut _6: *mut u8; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22 - let mut _7: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22 - let mut _8: *const i32; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22 - let mut _9: *const i32; // in scope 0 at $DIR/boxes.rs:+1:14: +1:22 + let mut _2: i32; // in scope 0 at $DIR/boxes.rs:+1:13: +2:18 + let mut _3: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18 + let mut _4: usize; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18 + let mut _5: usize; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18 + let mut _6: *mut u8; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18 + let mut _7: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18 + let mut _8: *const i32; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18 + let mut _9: *const i32; // in scope 0 at $DIR/boxes.rs:+1:14: +2:18 scope 1 { debug x => _1; // in scope 1 at $DIR/boxes.rs:+1:9: +1:10 } @@ -20,41 +20,41 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/boxes.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/boxes.rs:+1:13: +1:22 - StorageLive(_3); // scope 0 at $DIR/boxes.rs:+1:14: +1:22 -- _4 = SizeOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +1:22 -- _5 = AlignOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +1:22 -+ _4 = const 4_usize; // scope 2 at $DIR/boxes.rs:+1:14: +1:22 -+ _5 = const 4_usize; // scope 2 at $DIR/boxes.rs:+1:14: +1:22 - _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> bb1; // scope 2 at $DIR/boxes.rs:+1:14: +1:22 + StorageLive(_2); // scope 0 at $DIR/boxes.rs:+1:13: +2:18 + StorageLive(_3); // scope 0 at $DIR/boxes.rs:+1:14: +2:18 +- _4 = SizeOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +2:18 +- _5 = AlignOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +2:18 ++ _4 = const 4_usize; // scope 2 at $DIR/boxes.rs:+1:14: +2:18 ++ _5 = const 4_usize; // scope 2 at $DIR/boxes.rs:+1:14: +2:18 + _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> bb1; // scope 2 at $DIR/boxes.rs:+1:14: +2:18 // mir::Constant - // + span: $DIR/boxes.rs:13:14: 13:22 + // + span: $DIR/boxes.rs:13:14: 14:18 // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) } } bb1: { - StorageLive(_7); // scope 0 at $DIR/boxes.rs:+1:14: +1:22 - _7 = ShallowInitBox(move _6, i32); // scope 0 at $DIR/boxes.rs:+1:14: +1:22 - _8 = (((_7.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); // scope 0 at $DIR/boxes.rs:+1:19: +1:21 - (*_8) = const 42_i32; // scope 0 at $DIR/boxes.rs:+1:19: +1:21 - _3 = move _7; // scope 0 at $DIR/boxes.rs:+1:14: +1:22 - StorageDead(_7); // scope 0 at $DIR/boxes.rs:+1:21: +1:22 - _9 = (((_3.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); // scope 0 at $DIR/boxes.rs:+1:13: +1:22 - _2 = (*_9); // scope 0 at $DIR/boxes.rs:+1:13: +1:22 - _1 = Add(move _2, const 0_i32); // scope 0 at $DIR/boxes.rs:+1:13: +1:26 - StorageDead(_2); // scope 0 at $DIR/boxes.rs:+1:25: +1:26 - drop(_3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/boxes.rs:+1:26: +1:27 + StorageLive(_7); // scope 0 at $DIR/boxes.rs:+1:14: +2:18 + _7 = ShallowInitBox(move _6, i32); // scope 0 at $DIR/boxes.rs:+1:14: +2:18 + _8 = (((_7.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); // scope 0 at $DIR/boxes.rs:+2:14: +2:16 + (*_8) = const 42_i32; // scope 0 at $DIR/boxes.rs:+2:14: +2:16 + _3 = move _7; // scope 0 at $DIR/boxes.rs:+1:14: +2:18 + StorageDead(_7); // scope 0 at $DIR/boxes.rs:+2:17: +2:18 + _9 = (((_3.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); // scope 0 at $DIR/boxes.rs:+1:13: +2:18 + _2 = (*_9); // scope 0 at $DIR/boxes.rs:+1:13: +2:18 + _1 = Add(move _2, const 0_i32); // scope 0 at $DIR/boxes.rs:+1:13: +3:12 + StorageDead(_2); // scope 0 at $DIR/boxes.rs:+3:11: +3:12 + drop(_3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/boxes.rs:+3:12: +3:13 } bb2: { - StorageDead(_3); // scope 0 at $DIR/boxes.rs:+1:26: +1:27 - _0 = const (); // scope 0 at $DIR/boxes.rs:+0:11: +2:2 - StorageDead(_1); // scope 0 at $DIR/boxes.rs:+2:1: +2:2 - return; // scope 0 at $DIR/boxes.rs:+2:2: +2:2 + StorageDead(_3); // scope 0 at $DIR/boxes.rs:+3:12: +3:13 + _0 = const (); // scope 0 at $DIR/boxes.rs:+0:11: +4:2 + StorageDead(_1); // scope 0 at $DIR/boxes.rs:+4:1: +4:2 + return; // scope 0 at $DIR/boxes.rs:+4:2: +4:2 } bb3 (cleanup): { - resume; // scope 0 at $DIR/boxes.rs:+0:1: +2:2 + resume; // scope 0 at $DIR/boxes.rs:+0:1: +4:2 } } diff --git a/tests/mir-opt/const_prop/boxes.rs b/tests/mir-opt/const_prop/boxes.rs index d287830db..66e8c24d4 100644 --- a/tests/mir-opt/const_prop/boxes.rs +++ b/tests/mir-opt/const_prop/boxes.rs @@ -4,11 +4,13 @@ // ignore-wasm32 // ignore-wasm64 -#![feature(box_syntax)] +#![feature(rustc_attrs, stmt_expr_attributes)] -// Note: this test verifies that we, in fact, do not const prop `box` +// Note: this test verifies that we, in fact, do not const prop `#[rustc_box]` // EMIT_MIR boxes.main.ConstProp.diff fn main() { - let x = *(box 42) + 0; + let x = *(#[rustc_box] + Box::new(42)) + + 0; } diff --git a/tests/mir-opt/const_prop/checked_add.rs b/tests/mir-opt/const_prop/checked_add.rs index b9860da4c..007defd10 100644 --- a/tests/mir-opt/const_prop/checked_add.rs +++ b/tests/mir-opt/const_prop/checked_add.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: ConstProp // compile-flags: -C overflow-checks=on diff --git a/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff b/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff index bea7114c7..d75fae30b 100644 --- a/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff @@ -18,7 +18,7 @@ StorageLive(_3); // scope 0 at $DIR/const_prop_fails_gracefully.rs:+2:13: +2:16 _3 = const _; // scope 0 at $DIR/const_prop_fails_gracefully.rs:+2:13: +2:16 // mir::Constant - // + span: $DIR/const_prop_fails_gracefully.rs:8:13: 8:16 + // + span: $DIR/const_prop_fails_gracefully.rs:9:13: 9:16 // + literal: Const { ty: &i32, val: Unevaluated(FOO, [], None) } _2 = &raw const (*_3); // scope 0 at $DIR/const_prop_fails_gracefully.rs:+2:13: +2:16 _1 = move _2 as usize (PointerExposeAddress); // scope 0 at $DIR/const_prop_fails_gracefully.rs:+2:13: +2:39 @@ -29,7 +29,7 @@ _5 = _1; // scope 1 at $DIR/const_prop_fails_gracefully.rs:+3:10: +3:11 _4 = read(move _5) -> bb1; // scope 1 at $DIR/const_prop_fails_gracefully.rs:+3:5: +3:12 // mir::Constant - // + span: $DIR/const_prop_fails_gracefully.rs:9:5: 9:9 + // + span: $DIR/const_prop_fails_gracefully.rs:10:5: 10:9 // + literal: Const { ty: fn(usize) {read}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs b/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs index 0a3dcbd38..44d487842 100644 --- a/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs +++ b/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: ConstProp #[inline(never)] fn read(_: usize) { } diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff index f270ab8b6..7e77c18d5 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff @@ -14,7 +14,6 @@ } bb1: { - StorageLive(_2); // scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL _2 = begin_panic::<&str>(const "explicit panic"); // scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL // mir::Constant // + span: $SRC_DIR/std/src/panic.rs:LL:COL diff --git a/tests/mir-opt/const_prop/control_flow_simplification.rs b/tests/mir-opt/const_prop/control_flow_simplification.rs index 7dbe8e734..b2ca045e8 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.rs +++ b/tests/mir-opt/const_prop/control_flow_simplification.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: ConstProp // compile-flags: -Zmir-opt-level=1 diff --git a/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff index b9a10704b..6d8738aa6 100644 --- a/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff @@ -22,7 +22,7 @@ - switchInt(move _4) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 + _3 = const Option::<bool>::Some(true); // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 + // mir::Constant -+ // + span: $DIR/discriminant.rs:12:34: 12:44 ++ // + span: no-location + // + literal: Const { ty: Option<bool>, val: Value(Scalar(0x01)) } + _4 = const 1_isize; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 + switchInt(const 1_isize) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 diff --git a/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff index b9a10704b..6d8738aa6 100644 --- a/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff @@ -22,7 +22,7 @@ - switchInt(move _4) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 + _3 = const Option::<bool>::Some(true); // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 + // mir::Constant -+ // + span: $DIR/discriminant.rs:12:34: 12:44 ++ // + span: no-location + // + literal: Const { ty: Option<bool>, val: Value(Scalar(0x01)) } + _4 = const 1_isize; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 + switchInt(const 1_isize) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 diff --git a/tests/mir-opt/const_prop/indirect.rs b/tests/mir-opt/const_prop/indirect.rs index 44916cbfe..46fd8082d 100644 --- a/tests/mir-opt/const_prop/indirect.rs +++ b/tests/mir-opt/const_prop/indirect.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: ConstProp // compile-flags: -C overflow-checks=on diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.diff b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.diff index d03c23a3f..0ac7fa43d 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.diff @@ -8,7 +8,7 @@ let mut _3: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 scope 1 { } - scope 2 (inlined <u8 as Add>::add) { // at $DIR/inherit_overflow.rs:8:13: 8:47 + scope 2 (inlined <u8 as Add>::add) { // at $DIR/inherit_overflow.rs:9:13: 9:47 debug self => _2; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL debug other => _3; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL let mut _4: (u8, bool); // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL diff --git a/tests/mir-opt/const_prop/inherit_overflow.rs b/tests/mir-opt/const_prop/inherit_overflow.rs index 541a8c5c3..4e905d00d 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.rs +++ b/tests/mir-opt/const_prop/inherit_overflow.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: ConstProp // compile-flags: -Zmir-enable-passes=+Inline diff --git a/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff b/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff index 4f056dd85..85dedf68c 100644 --- a/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff @@ -12,12 +12,10 @@ let _3: [E; 1]; // in scope 1 at $DIR/invalid_constant.rs:+13:9: +13:21 scope 3 { debug _invalid_tag => _3; // in scope 3 at $DIR/invalid_constant.rs:+13:9: +13:21 - let _6: [Empty; 1]; // in scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 scope 5 { - debug _enum_without_variants => _6; // in scope 5 at $DIR/invalid_constant.rs:+20:9: +20:31 - let _7: main::Str<"���">; // in scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 + debug _enum_without_variants => const [ZeroSized: Empty]; // in scope 5 at $DIR/invalid_constant.rs:+20:9: +20:31 scope 7 { - debug _non_utf8_str => _7; // in scope 7 at $DIR/invalid_constant.rs:+24:9: +24:22 + debug _non_utf8_str => const Str::<"���">; // in scope 7 at $DIR/invalid_constant.rs:+24:9: +24:22 } } scope 6 { @@ -44,18 +42,14 @@ - _3 = [move _4]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60 + _4 = const Scalar(0x00000004): E; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:57 + // mir::Constant -+ // + span: $DIR/invalid_constant.rs:28:34: 28:57 ++ // + span: no-location + // + literal: Const { ty: E, val: Value(Scalar(0x00000004)) } + _3 = [const Scalar(0x00000004): E]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60 + // mir::Constant -+ // + span: $DIR/invalid_constant.rs:28:24: 28:60 ++ // + span: no-location + // + literal: Const { ty: E, val: Value(Scalar(0x00000004)) } StorageDead(_4); // scope 1 at $DIR/invalid_constant.rs:+13:59: +13:60 StorageDead(_5); // scope 1 at $DIR/invalid_constant.rs:+13:60: +13:61 - StorageLive(_6); // scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 - StorageLive(_7); // scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 - StorageDead(_7); // scope 5 at $DIR/invalid_constant.rs:+27:1: +27:2 - StorageDead(_6); // scope 3 at $DIR/invalid_constant.rs:+27:1: +27:2 StorageDead(_3); // scope 1 at $DIR/invalid_constant.rs:+27:1: +27:2 StorageDead(_1); // scope 0 at $DIR/invalid_constant.rs:+27:1: +27:2 return; // scope 0 at $DIR/invalid_constant.rs:+27:2: +27:2 diff --git a/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff b/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff new file mode 100644 index 000000000..e31c2bc39 --- /dev/null +++ b/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff @@ -0,0 +1,76 @@ +- // MIR for `main` before RemoveZsts ++ // MIR for `main` after RemoveZsts + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/invalid_constant.rs:+0:11: +0:11 + let _1: char; // in scope 0 at $DIR/invalid_constant.rs:+6:9: +6:22 + let mut _2: main::InvalidChar; // in scope 0 at $DIR/invalid_constant.rs:+6:34: +6:63 + let mut _4: E; // in scope 0 at $DIR/invalid_constant.rs:+13:25: +13:59 + let mut _5: main::InvalidTag; // in scope 0 at $DIR/invalid_constant.rs:+13:34: +13:55 + let mut _7: Empty; // in scope 0 at $DIR/invalid_constant.rs:+20:35: +20:73 + let mut _8: main::NoVariants; // in scope 0 at $DIR/invalid_constant.rs:+20:44: +20:65 + scope 1 { + debug _invalid_char => _1; // in scope 1 at $DIR/invalid_constant.rs:+6:9: +6:22 + let _3: [E; 1]; // in scope 1 at $DIR/invalid_constant.rs:+13:9: +13:21 + scope 3 { + debug _invalid_tag => _3; // in scope 3 at $DIR/invalid_constant.rs:+13:9: +13:21 + let _6: [Empty; 1]; // in scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 + scope 5 { +- debug _enum_without_variants => _6; // in scope 5 at $DIR/invalid_constant.rs:+20:9: +20:31 ++ debug _enum_without_variants => const [ZeroSized: Empty]; // in scope 5 at $DIR/invalid_constant.rs:+20:9: +20:31 + let _9: main::Str<"���">; // in scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 + scope 7 { +- debug _non_utf8_str => _9; // in scope 7 at $DIR/invalid_constant.rs:+24:9: +24:22 ++ debug _non_utf8_str => const Str::<"���">; // in scope 7 at $DIR/invalid_constant.rs:+24:9: +24:22 + } + } + scope 6 { + } + } + scope 4 { + } + } + scope 2 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/invalid_constant.rs:+6:9: +6:22 + StorageLive(_2); // scope 2 at $DIR/invalid_constant.rs:+6:34: +6:63 + _2 = InvalidChar { int: const 1114113_u32 }; // scope 2 at $DIR/invalid_constant.rs:+6:34: +6:63 + _1 = (_2.1: char); // scope 2 at $DIR/invalid_constant.rs:+6:34: +6:67 + StorageDead(_2); // scope 0 at $DIR/invalid_constant.rs:+6:69: +6:70 + StorageLive(_3); // scope 1 at $DIR/invalid_constant.rs:+13:9: +13:21 + StorageLive(_4); // scope 1 at $DIR/invalid_constant.rs:+13:25: +13:59 + StorageLive(_5); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55 + _5 = InvalidTag { int: const 4_u32 }; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55 + _4 = (_5.1: E); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:57 + _3 = [move _4]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60 + StorageDead(_4); // scope 1 at $DIR/invalid_constant.rs:+13:59: +13:60 + StorageDead(_5); // scope 1 at $DIR/invalid_constant.rs:+13:60: +13:61 +- StorageLive(_6); // scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 +- StorageLive(_7); // scope 3 at $DIR/invalid_constant.rs:+20:35: +20:73 ++ nop; // scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 ++ nop; // scope 3 at $DIR/invalid_constant.rs:+20:35: +20:73 + StorageLive(_8); // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65 + _8 = NoVariants { int: const 0_u32 }; // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65 +- _7 = (_8.1: Empty); // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:71 +- _6 = [move _7]; // scope 3 at $DIR/invalid_constant.rs:+20:34: +20:74 +- StorageDead(_7); // scope 3 at $DIR/invalid_constant.rs:+20:73: +20:74 ++ nop; // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:71 ++ nop; // scope 3 at $DIR/invalid_constant.rs:+20:34: +20:74 ++ nop; // scope 3 at $DIR/invalid_constant.rs:+20:73: +20:74 + StorageDead(_8); // scope 3 at $DIR/invalid_constant.rs:+20:74: +20:75 +- StorageLive(_9); // scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 +- _0 = const (); // scope 0 at $DIR/invalid_constant.rs:+0:11: +27:2 +- StorageDead(_9); // scope 5 at $DIR/invalid_constant.rs:+27:1: +27:2 +- StorageDead(_6); // scope 3 at $DIR/invalid_constant.rs:+27:1: +27:2 ++ nop; // scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 ++ nop; // scope 0 at $DIR/invalid_constant.rs:+0:11: +27:2 ++ nop; // scope 5 at $DIR/invalid_constant.rs:+27:1: +27:2 ++ nop; // scope 3 at $DIR/invalid_constant.rs:+27:1: +27:2 + StorageDead(_3); // scope 1 at $DIR/invalid_constant.rs:+27:1: +27:2 + StorageDead(_1); // scope 0 at $DIR/invalid_constant.rs:+27:1: +27:2 + return; // scope 0 at $DIR/invalid_constant.rs:+27:2: +27:2 + } + } + diff --git a/tests/mir-opt/const_prop/invalid_constant.rs b/tests/mir-opt/const_prop/invalid_constant.rs index 0337a7ca8..eb6172cdf 100644 --- a/tests/mir-opt/const_prop/invalid_constant.rs +++ b/tests/mir-opt/const_prop/invalid_constant.rs @@ -11,6 +11,7 @@ enum E { A, B, C } #[derive(Copy, Clone)] enum Empty {} +// EMIT_MIR invalid_constant.main.RemoveZsts.diff // EMIT_MIR invalid_constant.main.ConstProp.diff fn main() { // An invalid char. diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff index 964dd3080..265269409 100644 --- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff @@ -5,23 +5,18 @@ let mut _0: (); // return place in scope 0 at $DIR/issue_66971.rs:+0:11: +0:11 let _1: (); // in scope 0 at $DIR/issue_66971.rs:+1:5: +1:23 let mut _2: ((), u8, u8); // in scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 - let mut _3: (); // in scope 0 at $DIR/issue_66971.rs:+1:13: +1:15 bb0: { - StorageLive(_1); // scope 0 at $DIR/issue_66971.rs:+1:5: +1:23 StorageLive(_2); // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 - StorageLive(_3); // scope 0 at $DIR/issue_66971.rs:+1:13: +1:15 - _2 = (move _3, const 0_u8, const 0_u8); // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 - StorageDead(_3); // scope 0 at $DIR/issue_66971.rs:+1:21: +1:22 + _2 = (const (), const 0_u8, const 0_u8); // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 _1 = encode(move _2) -> bb1; // scope 0 at $DIR/issue_66971.rs:+1:5: +1:23 // mir::Constant - // + span: $DIR/issue_66971.rs:17:5: 17:11 + // + span: $DIR/issue_66971.rs:18:5: 18:11 // + literal: Const { ty: fn(((), u8, u8)) {encode}, val: Value(<ZST>) } } bb1: { StorageDead(_2); // scope 0 at $DIR/issue_66971.rs:+1:22: +1:23 - StorageDead(_1); // scope 0 at $DIR/issue_66971.rs:+1:23: +1:24 return; // scope 0 at $DIR/issue_66971.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/const_prop/issue_66971.rs b/tests/mir-opt/const_prop/issue_66971.rs index 6ca03438e..af95c9ca2 100644 --- a/tests/mir-opt/const_prop/issue_66971.rs +++ b/tests/mir-opt/const_prop/issue_66971.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: ConstProp // compile-flags: -Z mir-opt-level=3 diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff index a631cb310..54c9200d6 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff @@ -8,7 +8,6 @@ let mut _3: (u8, u8); // in scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 bb0: { - StorageLive(_1); // scope 0 at $DIR/issue_67019.rs:+1:5: +1:20 StorageLive(_2); // scope 0 at $DIR/issue_67019.rs:+1:10: +1:19 StorageLive(_3); // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 - _3 = (const 1_u8, const 2_u8); // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 @@ -17,13 +16,12 @@ StorageDead(_3); // scope 0 at $DIR/issue_67019.rs:+1:18: +1:19 _1 = test(move _2) -> bb1; // scope 0 at $DIR/issue_67019.rs:+1:5: +1:20 // mir::Constant - // + span: $DIR/issue_67019.rs:12:5: 12:9 + // + span: $DIR/issue_67019.rs:13:5: 13:9 // + literal: Const { ty: fn(((u8, u8),)) {test}, val: Value(<ZST>) } } bb1: { StorageDead(_2); // scope 0 at $DIR/issue_67019.rs:+1:19: +1:20 - StorageDead(_1); // scope 0 at $DIR/issue_67019.rs:+1:20: +1:21 return; // scope 0 at $DIR/issue_67019.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/const_prop/issue_67019.rs b/tests/mir-opt/const_prop/issue_67019.rs index ffc6fa1f2..08c7d4805 100644 --- a/tests/mir-opt/const_prop/issue_67019.rs +++ b/tests/mir-opt/const_prop/issue_67019.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: ConstProp // compile-flags: -Z mir-opt-level=3 diff --git a/tests/mir-opt/const_prop/large_array_index.rs b/tests/mir-opt/const_prop/large_array_index.rs index 48d134376..073f98495 100644 --- a/tests/mir-opt/const_prop/large_array_index.rs +++ b/tests/mir-opt/const_prop/large_array_index.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR large_array_index.main.ConstProp.diff diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff index 149aa6290..75f6ebc58 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff @@ -16,7 +16,7 @@ StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+1:9: +1:14 _1 = foo() -> bb1; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+1:29: +1:34 // mir::Constant - // + span: $DIR/mutable_variable_aggregate_partial_read.rs:6:29: 6:32 + // + span: $DIR/mutable_variable_aggregate_partial_read.rs:7:29: 7:32 // + literal: Const { ty: fn() -> (i32, i32) {foo}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs index cb59509ff..70a287cf3 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test // compile-flags: -O diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff index 4010dd6c6..9582504b2 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff @@ -26,7 +26,7 @@ StorageLive(_1); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10 _1 = foo() -> bb1; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:13: +1:18 // mir::Constant - // + span: $DIR/mutable_variable_unprop_assign.rs:6:13: 6:16 + // + span: $DIR/mutable_variable_unprop_assign.rs:7:13: 7:16 // + literal: Const { ty: fn() -> i32 {foo}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs index b077cfd3e..fabd04e9b 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test // compile-flags: -O diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.rs b/tests/mir-opt/const_prop/optimizes_into_variable.rs index abea07e20..5ffa15347 100644 --- a/tests/mir-opt/const_prop/optimizes_into_variable.rs +++ b/tests/mir-opt/const_prop/optimizes_into_variable.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test // compile-flags: -C overflow-checks=on diff --git a/tests/mir-opt/const_prop/repeat.rs b/tests/mir-opt/const_prop/repeat.rs index 36d9b9fc6..2f3b7d2c5 100644 --- a/tests/mir-opt/const_prop/repeat.rs +++ b/tests/mir-opt/const_prop/repeat.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // compile-flags: -O // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/const_prop/return_place.rs b/tests/mir-opt/const_prop/return_place.rs index 06a853696..ae119df85 100644 --- a/tests/mir-opt/const_prop/return_place.rs +++ b/tests/mir-opt/const_prop/return_place.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // compile-flags: -C overflow-checks=on // EMIT_MIR return_place.add.ConstProp.diff diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff index 22f710387..a091b4ace 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff @@ -12,16 +12,14 @@ bb0: { _1 = const 1_u32; // scope 0 at $DIR/scalar_literal_propagation.rs:+1:13: +1:14 - StorageLive(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 - _2 = consume(_1) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 + _2 = consume(const 1_u32) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 // mir::Constant - // + span: $DIR/scalar_literal_propagation.rs:4:5: 4:12 + // + span: $DIR/scalar_literal_propagation.rs:5:5: 5:12 // + literal: Const { ty: fn(u32) {consume}, val: Value(<ZST>) } } bb1: { - StorageDead(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:15: +2:16 return; // scope 0 at $DIR/scalar_literal_propagation.rs:+3:2: +3:2 } } diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.rs b/tests/mir-opt/const_prop/scalar_literal_propagation.rs index 8724e4d57..e13e352f8 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.rs +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // EMIT_MIR scalar_literal_propagation.main.ConstProp.diff fn main() { let x = 1; diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff index b99b83b0c..8bd2b48d6 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff @@ -20,7 +20,7 @@ StorageLive(_4); // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 _9 = const _; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 // mir::Constant - // + span: $DIR/slice_len.rs:7:6: 7:19 + // + span: $DIR/slice_len.rs:8:6: 8:19 // + literal: Const { ty: &[u32; 3], val: Unevaluated(main, [], Some(promoted[0])) } _4 = _9; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 _3 = _4; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff index b99b83b0c..8bd2b48d6 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff @@ -20,7 +20,7 @@ StorageLive(_4); // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 _9 = const _; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 // mir::Constant - // + span: $DIR/slice_len.rs:7:6: 7:19 + // + span: $DIR/slice_len.rs:8:6: 8:19 // + literal: Const { ty: &[u32; 3], val: Unevaluated(main, [], Some(promoted[0])) } _4 = _9; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 _3 = _4; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs index 8183def0c..4499c54f2 100644 --- a/tests/mir-opt/const_prop/slice_len.rs +++ b/tests/mir-opt/const_prop/slice_len.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: ConstProp // compile-flags: -Zmir-enable-passes=+InstCombine // EMIT_MIR_FOR_EACH_BIT_WIDTH diff --git a/tests/mir-opt/const_prop/switch_int.main.ConstProp.diff b/tests/mir-opt/const_prop/switch_int.main.ConstProp.diff index ddc1a4493..85704c48a 100644 --- a/tests/mir-opt/const_prop/switch_int.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/switch_int.main.ConstProp.diff @@ -15,14 +15,14 @@ bb1: { _0 = foo(const -1_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+3:14: +3:21 // mir::Constant - // + span: $DIR/switch_int.rs:9:14: 9:17 + // + span: $DIR/switch_int.rs:10:14: 10:17 // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } } bb2: { _0 = foo(const 0_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+2:14: +2:20 // mir::Constant - // + span: $DIR/switch_int.rs:8:14: 8:17 + // + span: $DIR/switch_int.rs:9:14: 9:17 // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.diff b/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.diff index 09c47ee6e..0864db225 100644 --- a/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.diff +++ b/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.diff @@ -15,14 +15,14 @@ bb1: { _0 = foo(const -1_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+3:14: +3:21 // mir::Constant - // + span: $DIR/switch_int.rs:9:14: 9:17 + // + span: $DIR/switch_int.rs:10:14: 10:17 // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } } bb2: { _0 = foo(const 0_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+2:14: +2:20 // mir::Constant - // + span: $DIR/switch_int.rs:8:14: 8:17 + // + span: $DIR/switch_int.rs:9:14: 9:17 // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/const_prop/switch_int.rs b/tests/mir-opt/const_prop/switch_int.rs index d7319eca1..2a2322e43 100644 --- a/tests/mir-opt/const_prop/switch_int.rs +++ b/tests/mir-opt/const_prop/switch_int.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default #[inline(never)] fn foo(_: i32) { } diff --git a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.diff b/tests/mir-opt/const_prop/transmute.from_char.ConstProp.diff new file mode 100644 index 000000000..933dfbb51 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.from_char.ConstProp.diff @@ -0,0 +1,15 @@ +- // MIR for `from_char` before ConstProp ++ // MIR for `from_char` after ConstProp + + fn from_char() -> i32 { + let mut _0: i32; // return place in scope 0 at $DIR/transmute.rs:+0:23: +0:26 + scope 1 { + } + + bb0: { +- _0 = const 'R' as i32 (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:28 ++ _0 = const 82_i32; // scope 1 at $DIR/transmute.rs:+1:14: +1:28 + return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.diff b/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.diff new file mode 100644 index 000000000..f3474855f --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.diff @@ -0,0 +1,14 @@ +- // MIR for `invalid_bool` before ConstProp ++ // MIR for `invalid_bool` after ConstProp + + fn invalid_bool() -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/transmute.rs:+0:33: +0:37 + scope 1 { + } + + bb0: { + _0 = const -1_i8 as bool (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:30 + return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.diff b/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.diff new file mode 100644 index 000000000..ba087e226 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.diff @@ -0,0 +1,14 @@ +- // MIR for `invalid_char` before ConstProp ++ // MIR for `invalid_char` after ConstProp + + fn invalid_char() -> char { + let mut _0: char; // return place in scope 0 at $DIR/transmute.rs:+0:33: +0:37 + scope 1 { + } + + bb0: { + _0 = const _ as char (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:33 + return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.diff b/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.diff new file mode 100644 index 000000000..76d464789 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.diff @@ -0,0 +1,23 @@ +- // MIR for `less_as_i8` before ConstProp ++ // MIR for `less_as_i8` after ConstProp + + fn less_as_i8() -> i8 { + let mut _0: i8; // return place in scope 0 at $DIR/transmute.rs:+0:24: +0:26 + let mut _1: std::cmp::Ordering; // in scope 0 at $DIR/transmute.rs:+1:24: +1:48 + scope 1 { + } + + bb0: { + StorageLive(_1); // scope 1 at $DIR/transmute.rs:+1:24: +1:48 +- _1 = Less; // scope 1 at $DIR/transmute.rs:+1:24: +1:48 +- _0 = move _1 as i8 (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:49 ++ _1 = const Less; // scope 1 at $DIR/transmute.rs:+1:24: +1:48 ++ // mir::Constant ++ // + span: no-location ++ // + literal: Const { ty: std::cmp::Ordering, val: Value(Scalar(0xff)) } ++ _0 = const -1_i8; // scope 1 at $DIR/transmute.rs:+1:14: +1:49 + StorageDead(_1); // scope 1 at $DIR/transmute.rs:+1:48: +1:49 + return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.rs b/tests/mir-opt/const_prop/transmute.rs new file mode 100644 index 000000000..b753cdccd --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.rs @@ -0,0 +1,61 @@ +// unit-test: ConstProp +// compile-flags: -O --crate-type=lib + +use std::mem::transmute; + +// EMIT_MIR transmute.less_as_i8.ConstProp.diff +pub fn less_as_i8() -> i8 { + unsafe { transmute(std::cmp::Ordering::Less) } +} + +// EMIT_MIR transmute.from_char.ConstProp.diff +pub fn from_char() -> i32 { + unsafe { transmute('R') } +} + +// EMIT_MIR transmute.valid_char.ConstProp.diff +pub fn valid_char() -> char { + unsafe { transmute(0x52_u32) } +} + +// EMIT_MIR transmute.invalid_char.ConstProp.diff +pub unsafe fn invalid_char() -> char { + unsafe { transmute(i32::MAX) } +} + +// EMIT_MIR transmute.invalid_bool.ConstProp.diff +pub unsafe fn invalid_bool() -> bool { + unsafe { transmute(-1_i8) } +} + +// EMIT_MIR transmute.undef_union_as_integer.ConstProp.diff +pub unsafe fn undef_union_as_integer() -> u32 { + union Union32 { value: u32, unit: () } + unsafe { transmute(Union32 { unit: () }) } +} + +// EMIT_MIR transmute.unreachable_direct.ConstProp.diff +pub unsafe fn unreachable_direct() -> ! { + let x: Never = unsafe { transmute(()) }; + match x {} +} + +// EMIT_MIR transmute.unreachable_ref.ConstProp.diff +pub unsafe fn unreachable_ref() -> ! { + let x: &Never = unsafe { transmute(1_usize) }; + match *x {} +} + +// EMIT_MIR transmute.unreachable_mut.ConstProp.diff +pub unsafe fn unreachable_mut() -> ! { + let x: &mut Never = unsafe { transmute(1_usize) }; + match *x {} +} + +// EMIT_MIR transmute.unreachable_box.ConstProp.diff +pub unsafe fn unreachable_box() -> ! { + let x: Box<Never> = unsafe { transmute(1_usize) }; + match *x {} +} + +enum Never {} diff --git a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.diff b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.diff new file mode 100644 index 000000000..538b1f26e --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.diff @@ -0,0 +1,22 @@ +- // MIR for `undef_union_as_integer` before ConstProp ++ // MIR for `undef_union_as_integer` after ConstProp + + fn undef_union_as_integer() -> u32 { + let mut _0: u32; // return place in scope 0 at $DIR/transmute.rs:+0:43: +0:46 + let mut _1: undef_union_as_integer::Union32; // in scope 0 at $DIR/transmute.rs:+2:24: +2:44 + let mut _2: (); // in scope 0 at $DIR/transmute.rs:+2:40: +2:42 + scope 1 { + } + + bb0: { + StorageLive(_1); // scope 1 at $DIR/transmute.rs:+2:24: +2:44 + StorageLive(_2); // scope 1 at $DIR/transmute.rs:+2:40: +2:42 + _2 = (); // scope 1 at $DIR/transmute.rs:+2:40: +2:42 + _1 = Union32 { value: move _2 }; // scope 1 at $DIR/transmute.rs:+2:24: +2:44 + StorageDead(_2); // scope 1 at $DIR/transmute.rs:+2:43: +2:44 + _0 = move _1 as u32 (Transmute); // scope 1 at $DIR/transmute.rs:+2:14: +2:45 + StorageDead(_1); // scope 1 at $DIR/transmute.rs:+2:44: +2:45 + return; // scope 0 at $DIR/transmute.rs:+3:2: +3:2 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.diff new file mode 100644 index 000000000..8bf97996a --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.diff @@ -0,0 +1,23 @@ +- // MIR for `unreachable_box` before ConstProp ++ // MIR for `unreachable_box` after ConstProp + + fn unreachable_box() -> ! { + let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 + let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2 + let _2: std::boxed::Box<Never>; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _3: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16 + scope 1 { + debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + } + scope 2 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2 + StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 + _2 = const 1_usize as std::boxed::Box<Never> (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 + StorageLive(_3); // scope 1 at $DIR/transmute.rs:+2:5: +2:16 + unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.diff b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.diff new file mode 100644 index 000000000..81b7b3689 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.diff @@ -0,0 +1,25 @@ +- // MIR for `unreachable_direct` before ConstProp ++ // MIR for `unreachable_direct` after ConstProp + + fn unreachable_direct() -> ! { + let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:39: +0:40 + let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:41: +3:2 + let _2: Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _3: (); // in scope 0 at $DIR/transmute.rs:+1:39: +1:41 + let mut _4: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:15 + scope 1 { + debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + } + scope 2 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:41: +3:2 + StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 + StorageLive(_3); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 + _3 = (); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 + _2 = move _3 as Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:29: +1:42 + unreachable; // scope 2 at $DIR/transmute.rs:+1:29: +1:42 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.diff new file mode 100644 index 000000000..34f7aea8e --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.diff @@ -0,0 +1,27 @@ +- // MIR for `unreachable_mut` before ConstProp ++ // MIR for `unreachable_mut` after ConstProp + + fn unreachable_mut() -> ! { + let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 + let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2 + let _2: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _3: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:34: +1:52 + let mut _4: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16 + scope 1 { + debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + } + scope 2 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2 + StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 + StorageLive(_3); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 + _3 = const 1_usize as &mut Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 + _2 = &mut (*_3); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 + StorageDead(_3); // scope 0 at $DIR/transmute.rs:+1:54: +1:55 + StorageLive(_4); // scope 1 at $DIR/transmute.rs:+2:5: +2:16 + unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.diff b/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.diff new file mode 100644 index 000000000..ff95f2a0b --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.diff @@ -0,0 +1,23 @@ +- // MIR for `unreachable_ref` before ConstProp ++ // MIR for `unreachable_ref` after ConstProp + + fn unreachable_ref() -> ! { + let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 + let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2 + let _2: &Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _3: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16 + scope 1 { + debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + } + scope 2 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2 + StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 + _2 = const 1_usize as &Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:30: +1:48 + StorageLive(_3); // scope 1 at $DIR/transmute.rs:+2:5: +2:16 + unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.diff b/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.diff new file mode 100644 index 000000000..eac33b730 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.diff @@ -0,0 +1,15 @@ +- // MIR for `valid_char` before ConstProp ++ // MIR for `valid_char` after ConstProp + + fn valid_char() -> char { + let mut _0: char; // return place in scope 0 at $DIR/transmute.rs:+0:24: +0:28 + scope 1 { + } + + bb0: { +- _0 = const 82_u32 as char (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:33 ++ _0 = const 'R'; // scope 1 at $DIR/transmute.rs:+1:14: +1:33 + return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff index 270a1ccf5..12313b6c5 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff @@ -13,15 +13,13 @@ bb0: { - _1 = (const 1_u32, const 2_u32); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19 + _1 = const (1_u32, 2_u32); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19 - StorageLive(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15 _2 = consume(_1) -> bb1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15 // mir::Constant - // + span: $DIR/tuple_literal_propagation.rs:5:5: 5:12 + // + span: $DIR/tuple_literal_propagation.rs:6:5: 6:12 // + literal: Const { ty: fn((u32, u32)) {consume}, val: Value(<ZST>) } } bb1: { - StorageDead(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:15: +3:16 return; // scope 0 at $DIR/tuple_literal_propagation.rs:+4:2: +4:2 } } diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.rs b/tests/mir-opt/const_prop/tuple_literal_propagation.rs index e644baec4..edd748d00 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.rs +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // EMIT_MIR tuple_literal_propagation.main.ConstProp.diff fn main() { let x = (1, 2); diff --git a/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff b/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff index b183865a9..2a0bff57d 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff +++ b/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff @@ -15,7 +15,7 @@ _4 = &_3; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL _0 = cmp_ref(_2, _4) -> bb1; // scope 0 at $DIR/borrowed_local.rs:+8:13: +8:45 // mir::Constant - // + span: $DIR/borrowed_local.rs:23:29: 23:36 + // + span: $DIR/borrowed_local.rs:24:29: 24:36 // + literal: Const { ty: for<'a, 'b> fn(&'a u8, &'b u8) -> bool {cmp_ref}, val: Value(<ZST>) } } @@ -23,7 +23,7 @@ - _0 = opaque::<u8>(_3) -> bb2; // scope 0 at $DIR/borrowed_local.rs:+12:13: +12:38 + _0 = opaque::<u8>(_1) -> bb2; // scope 0 at $DIR/borrowed_local.rs:+12:13: +12:38 // mir::Constant - // + span: $DIR/borrowed_local.rs:27:28: 27:34 + // + span: $DIR/borrowed_local.rs:28:28: 28:34 // + literal: Const { ty: fn(u8) -> bool {opaque::<u8>}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/copy-prop/borrowed_local.rs b/tests/mir-opt/copy-prop/borrowed_local.rs index c4b980e2b..9186da5af 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.rs +++ b/tests/mir-opt/copy-prop/borrowed_local.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: CopyProp #![feature(custom_mir, core_intrinsics)] diff --git a/tests/mir-opt/copy-prop/branch.foo.CopyProp.diff b/tests/mir-opt/copy-prop/branch.foo.CopyProp.diff index 8b116532d..b78c19d78 100644 --- a/tests/mir-opt/copy-prop/branch.foo.CopyProp.diff +++ b/tests/mir-opt/copy-prop/branch.foo.CopyProp.diff @@ -18,7 +18,7 @@ StorageLive(_1); // scope 0 at $DIR/branch.rs:+1:9: +1:10 _1 = val() -> bb1; // scope 0 at $DIR/branch.rs:+1:13: +1:18 // mir::Constant - // + span: $DIR/branch.rs:13:13: 13:16 + // + span: $DIR/branch.rs:14:13: 14:16 // + literal: Const { ty: fn() -> i32 {val}, val: Value(<ZST>) } } @@ -27,7 +27,7 @@ StorageLive(_3); // scope 1 at $DIR/branch.rs:+3:16: +3:22 _3 = cond() -> bb2; // scope 1 at $DIR/branch.rs:+3:16: +3:22 // mir::Constant - // + span: $DIR/branch.rs:15:16: 15:20 + // + span: $DIR/branch.rs:16:16: 16:20 // + literal: Const { ty: fn() -> bool {cond}, val: Value(<ZST>) } } @@ -44,7 +44,7 @@ StorageLive(_4); // scope 1 at $DIR/branch.rs:+6:9: +6:14 _4 = val() -> bb5; // scope 1 at $DIR/branch.rs:+6:9: +6:14 // mir::Constant - // + span: $DIR/branch.rs:18:9: 18:12 + // + span: $DIR/branch.rs:19:9: 19:12 // + literal: Const { ty: fn() -> i32 {val}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/copy-prop/branch.rs b/tests/mir-opt/copy-prop/branch.rs index 50b1e00fa..0a2e16946 100644 --- a/tests/mir-opt/copy-prop/branch.rs +++ b/tests/mir-opt/copy-prop/branch.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default //! Tests that we bail out when there are multiple assignments to the same local. // unit-test: CopyProp fn val() -> i32 { diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.diff index ac4e9a2bf..24bca3220 100644 --- a/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.diff +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.diff @@ -13,7 +13,7 @@ _3 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:11: +1:12 _2 = dummy(move _3) -> bb1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:5: +1:13 // mir::Constant - // + span: $DIR/copy_propagation_arg.rs:16:5: 16:10 + // + span: $DIR/copy_propagation_arg.rs:17:5: 17:10 // + literal: Const { ty: fn(u8) -> u8 {dummy}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.diff index 0a3e985e7..87708f340 100644 --- a/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.diff +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.diff @@ -13,7 +13,7 @@ _3 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+2:15: +2:16 _2 = dummy(move _3) -> bb1; // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:17 // mir::Constant - // + span: $DIR/copy_propagation_arg.rs:11:9: 11:14 + // + span: $DIR/copy_propagation_arg.rs:12:9: 12:14 // + literal: Const { ty: fn(u8) -> u8 {dummy}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.rs b/tests/mir-opt/copy-prop/copy_propagation_arg.rs index cc98985f1..1b65dcb01 100644 --- a/tests/mir-opt/copy-prop/copy_propagation_arg.rs +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // Check that CopyProp does not propagate an assignment to a function argument // (doing so can break usages of the original argument value) // unit-test: CopyProp diff --git a/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.diff b/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.diff index 6ca73ffdd..160f47bdd 100644 --- a/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.diff +++ b/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.diff @@ -11,7 +11,7 @@ - _0 = opaque::<NotCopy>(move _1) -> bb1; // scope 0 at $DIR/custom_move_arg.rs:+3:9: +3:41 + _0 = opaque::<NotCopy>(_1) -> bb1; // scope 0 at $DIR/custom_move_arg.rs:+3:9: +3:41 // mir::Constant - // + span: $DIR/custom_move_arg.rs:15:24: 15:30 + // + span: $DIR/custom_move_arg.rs:16:24: 16:30 // + literal: Const { ty: fn(NotCopy) {opaque::<NotCopy>}, val: Value(<ZST>) } } @@ -20,7 +20,7 @@ - _0 = opaque::<NotCopy>(_3) -> bb2; // scope 0 at $DIR/custom_move_arg.rs:+7:9: +7:35 + _0 = opaque::<NotCopy>(_1) -> bb2; // scope 0 at $DIR/custom_move_arg.rs:+7:9: +7:35 // mir::Constant - // + span: $DIR/custom_move_arg.rs:19:24: 19:30 + // + span: $DIR/custom_move_arg.rs:20:24: 20:30 // + literal: Const { ty: fn(NotCopy) {opaque::<NotCopy>}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/copy-prop/custom_move_arg.rs b/tests/mir-opt/copy-prop/custom_move_arg.rs index 4a591146e..29c368df8 100644 --- a/tests/mir-opt/copy-prop/custom_move_arg.rs +++ b/tests/mir-opt/copy-prop/custom_move_arg.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: CopyProp #![feature(custom_mir, core_intrinsics)] diff --git a/tests/mir-opt/copy-prop/cycle.main.CopyProp.diff b/tests/mir-opt/copy-prop/cycle.main.CopyProp.diff index 3e61869e8..23d92ed1a 100644 --- a/tests/mir-opt/copy-prop/cycle.main.CopyProp.diff +++ b/tests/mir-opt/copy-prop/cycle.main.CopyProp.diff @@ -24,7 +24,7 @@ StorageLive(_1); // scope 0 at $DIR/cycle.rs:+1:9: +1:14 _1 = val() -> bb1; // scope 0 at $DIR/cycle.rs:+1:17: +1:22 // mir::Constant - // + span: $DIR/cycle.rs:9:17: 9:20 + // + span: $DIR/cycle.rs:10:17: 10:20 // + literal: Const { ty: fn() -> i32 {val}, val: Value(<ZST>) } } @@ -43,7 +43,7 @@ _6 = _1; // scope 3 at $DIR/cycle.rs:+6:10: +6:11 _5 = std::mem::drop::<i32>(move _6) -> bb2; // scope 3 at $DIR/cycle.rs:+6:5: +6:12 // mir::Constant - // + span: $DIR/cycle.rs:14:5: 14:9 + // + span: $DIR/cycle.rs:15:5: 15:9 // + literal: Const { ty: fn(i32) {std::mem::drop::<i32>}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/copy-prop/cycle.rs b/tests/mir-opt/copy-prop/cycle.rs index b74c39726..da70f6bec 100644 --- a/tests/mir-opt/copy-prop/cycle.rs +++ b/tests/mir-opt/copy-prop/cycle.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default //! Tests that cyclic assignments don't hang CopyProp, and result in reasonable code. // unit-test: CopyProp fn val() -> i32 { diff --git a/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir index d48b04e2d..c56418d88 100644 --- a/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir +++ b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir @@ -18,7 +18,7 @@ fn f(_1: usize) -> usize { _4 = _1; // scope 1 at $DIR/dead_stores_79191.rs:+4:8: +4:9 _0 = id::<usize>(move _4) -> bb1; // scope 1 at $DIR/dead_stores_79191.rs:+4:5: +4:10 // mir::Constant - // + span: $DIR/dead_stores_79191.rs:12:5: 12:7 + // + span: $DIR/dead_stores_79191.rs:13:5: 13:7 // + literal: Const { ty: fn(usize) -> usize {id::<usize>}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/copy-prop/dead_stores_79191.rs b/tests/mir-opt/copy-prop/dead_stores_79191.rs index e3493b8b7..84453c55e 100644 --- a/tests/mir-opt/copy-prop/dead_stores_79191.rs +++ b/tests/mir-opt/copy-prop/dead_stores_79191.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: CopyProp fn id<T>(x: T) -> T { diff --git a/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir index 727791f50..f35542173 100644 --- a/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir +++ b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir @@ -18,7 +18,7 @@ fn f(_1: usize) -> usize { _4 = _1; // scope 1 at $DIR/dead_stores_better.rs:+4:8: +4:9 _0 = id::<usize>(move _4) -> bb1; // scope 1 at $DIR/dead_stores_better.rs:+4:5: +4:10 // mir::Constant - // + span: $DIR/dead_stores_better.rs:16:5: 16:7 + // + span: $DIR/dead_stores_better.rs:17:5: 17:7 // + literal: Const { ty: fn(usize) -> usize {id::<usize>}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/copy-prop/dead_stores_better.rs b/tests/mir-opt/copy-prop/dead_stores_better.rs index 8465b3c98..87b916fd3 100644 --- a/tests/mir-opt/copy-prop/dead_stores_better.rs +++ b/tests/mir-opt/copy-prop/dead_stores_better.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // This is a copy of the `dead_stores_79191` test, except that we turn on DSE. This demonstrates // that that pass enables this one to do more optimizations. diff --git a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.diff b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.diff index 97d0a01e0..e09ccb831 100644 --- a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.diff +++ b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.diff @@ -51,7 +51,7 @@ StorageDead(_7); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:18 _5 = core::slice::<impl [i32]>::len(move _6) -> bb1; // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24 // mir::Constant - // + span: $DIR/issue_107511.rs:10:19: 10:22 + // + span: $DIR/issue_107511.rs:11:19: 11:22 // + literal: Const { ty: for<'a> fn(&'a [i32]) -> usize {core::slice::<impl [i32]>::len}, val: Value(<ZST>) } } @@ -61,7 +61,7 @@ StorageDead(_5); // scope 2 at $DIR/issue_107511.rs:+6:23: +6:24 _3 = <std::ops::Range<usize> as IntoIterator>::into_iter(move _4) -> bb2; // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24 // mir::Constant - // + span: $DIR/issue_107511.rs:10:14: 10:24 + // + span: $DIR/issue_107511.rs:11:14: 11:24 // + literal: Const { ty: fn(std::ops::Range<usize>) -> <std::ops::Range<usize> as IntoIterator>::IntoIter {<std::ops::Range<usize> as IntoIterator>::into_iter}, val: Value(<ZST>) } } @@ -81,7 +81,7 @@ _12 = &mut (*_13); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 _11 = <std::ops::Range<usize> as Iterator>::next(move _12) -> bb4; // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 // mir::Constant - // + span: $DIR/issue_107511.rs:10:14: 10:24 + // + span: $DIR/issue_107511.rs:11:14: 11:24 // + literal: Const { ty: for<'a> fn(&'a mut std::ops::Range<usize>) -> Option<<std::ops::Range<usize> as Iterator>::Item> {<std::ops::Range<usize> as Iterator>::next}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/copy-prop/issue_107511.rs b/tests/mir-opt/copy-prop/issue_107511.rs index d593f2872..2b00ff155 100644 --- a/tests/mir-opt/copy-prop/issue_107511.rs +++ b/tests/mir-opt/copy-prop/issue_107511.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: CopyProp // EMIT_MIR issue_107511.main.CopyProp.diff diff --git a/tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff b/tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff index d76bf1cfe..650bd66a7 100644 --- a/tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff +++ b/tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff @@ -24,7 +24,7 @@ - _3 = g::<T>(move _4, move _5) -> bb1; // scope 1 at $DIR/move_arg.rs:+2:5: +2:12 + _3 = g::<T>(_1, _1) -> bb1; // scope 1 at $DIR/move_arg.rs:+2:5: +2:12 // mir::Constant - // + span: $DIR/move_arg.rs:7:5: 7:6 + // + span: $DIR/move_arg.rs:8:5: 8:6 // + literal: Const { ty: fn(T, T) {g::<T>}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/copy-prop/move_arg.rs b/tests/mir-opt/copy-prop/move_arg.rs index 40ae1d8f4..f88d9a9e7 100644 --- a/tests/mir-opt/copy-prop/move_arg.rs +++ b/tests/mir-opt/copy-prop/move_arg.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // Test that we do not move multiple times from the same local. // unit-test: CopyProp diff --git a/tests/mir-opt/copy-prop/move_projection.f.CopyProp.diff b/tests/mir-opt/copy-prop/move_projection.f.CopyProp.diff index 02308beb8..beb85d68a 100644 --- a/tests/mir-opt/copy-prop/move_projection.f.CopyProp.diff +++ b/tests/mir-opt/copy-prop/move_projection.f.CopyProp.diff @@ -13,14 +13,14 @@ + _3 = (_1.0: u8); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _0 = opaque::<Foo>(_1) -> bb1; // scope 0 at $DIR/move_projection.rs:+6:13: +6:44 // mir::Constant - // + span: $DIR/move_projection.rs:19:28: 19:34 + // + span: $DIR/move_projection.rs:20:28: 20:34 // + literal: Const { ty: fn(Foo) -> bool {opaque::<Foo>}, val: Value(<ZST>) } } bb1: { _0 = opaque::<u8>(move _3) -> bb2; // scope 0 at $DIR/move_projection.rs:+9:13: +9:44 // mir::Constant - // + span: $DIR/move_projection.rs:22:28: 22:34 + // + span: $DIR/move_projection.rs:23:28: 23:34 // + literal: Const { ty: fn(u8) -> bool {opaque::<u8>}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/copy-prop/move_projection.rs b/tests/mir-opt/copy-prop/move_projection.rs index 2a1bbae99..c158c69e0 100644 --- a/tests/mir-opt/copy-prop/move_projection.rs +++ b/tests/mir-opt/copy-prop/move_projection.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: CopyProp #![feature(custom_mir, core_intrinsics)] diff --git a/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.diff b/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.diff new file mode 100644 index 000000000..b4a248245 --- /dev/null +++ b/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.diff @@ -0,0 +1,56 @@ +- // MIR for `demiraw` before CopyProp ++ // MIR for `demiraw` after CopyProp + + fn demiraw(_1: u8) -> () { + debug x => _1; // in scope 0 at $DIR/reborrow.rs:+0:12: +0:17 + let mut _0: (); // return place in scope 0 at $DIR/reborrow.rs:+0:23: +0:23 + let _2: *mut u8; // in scope 0 at $DIR/reborrow.rs:+1:9: +1:10 + let mut _4: &mut u8; // in scope 0 at $DIR/reborrow.rs:+2:22: +2:29 + let _6: (); // in scope 0 at $DIR/reborrow.rs:+4:5: +4:14 + let mut _7: *mut u8; // in scope 0 at $DIR/reborrow.rs:+4:12: +4:13 + scope 1 { + debug a => _2; // in scope 1 at $DIR/reborrow.rs:+1:9: +1:10 + let _3: &mut u8; // in scope 1 at $DIR/reborrow.rs:+2:9: +2:10 + scope 2 { + debug b => _3; // in scope 2 at $DIR/reborrow.rs:+2:9: +2:10 + let _5: *mut u8; // in scope 2 at $DIR/reborrow.rs:+3:9: +3:10 + scope 4 { +- debug c => _5; // in scope 4 at $DIR/reborrow.rs:+3:9: +3:10 ++ debug c => _2; // in scope 4 at $DIR/reborrow.rs:+3:9: +3:10 + } + } + scope 3 { + } + } + + bb0: { +- StorageLive(_2); // scope 0 at $DIR/reborrow.rs:+1:9: +1:10 + _2 = &raw mut _1; // scope 0 at $DIR/reborrow.rs:+1:13: +1:23 + StorageLive(_3); // scope 1 at $DIR/reborrow.rs:+2:9: +2:10 + StorageLive(_4); // scope 1 at $DIR/reborrow.rs:+2:22: +2:29 + _4 = &mut (*_2); // scope 3 at $DIR/reborrow.rs:+2:22: +2:29 + _3 = &mut (*_4); // scope 1 at $DIR/reborrow.rs:+2:22: +2:29 + StorageDead(_4); // scope 1 at $DIR/reborrow.rs:+2:31: +2:32 +- StorageLive(_5); // scope 2 at $DIR/reborrow.rs:+3:9: +3:10 +- _5 = _2; // scope 2 at $DIR/reborrow.rs:+3:13: +3:14 + StorageLive(_6); // scope 4 at $DIR/reborrow.rs:+4:5: +4:14 +- StorageLive(_7); // scope 4 at $DIR/reborrow.rs:+4:12: +4:13 +- _7 = _5; // scope 4 at $DIR/reborrow.rs:+4:12: +4:13 +- _6 = opaque::<*mut u8>(move _7) -> bb1; // scope 4 at $DIR/reborrow.rs:+4:5: +4:14 ++ _6 = opaque::<*mut u8>(_2) -> bb1; // scope 4 at $DIR/reborrow.rs:+4:5: +4:14 + // mir::Constant + // + span: $DIR/reborrow.rs:39:5: 39:11 + // + literal: Const { ty: fn(*mut u8) {opaque::<*mut u8>}, val: Value(<ZST>) } + } + + bb1: { +- StorageDead(_7); // scope 4 at $DIR/reborrow.rs:+4:13: +4:14 + StorageDead(_6); // scope 4 at $DIR/reborrow.rs:+4:14: +4:15 + _0 = const (); // scope 0 at $DIR/reborrow.rs:+0:23: +5:2 +- StorageDead(_5); // scope 2 at $DIR/reborrow.rs:+5:1: +5:2 + StorageDead(_3); // scope 1 at $DIR/reborrow.rs:+5:1: +5:2 +- StorageDead(_2); // scope 0 at $DIR/reborrow.rs:+5:1: +5:2 + return; // scope 0 at $DIR/reborrow.rs:+5:2: +5:2 + } + } + diff --git a/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.diff b/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.diff new file mode 100644 index 000000000..a6a6c05b2 --- /dev/null +++ b/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.diff @@ -0,0 +1,52 @@ +- // MIR for `miraw` before CopyProp ++ // MIR for `miraw` after CopyProp + + fn miraw(_1: u8) -> () { + debug x => _1; // in scope 0 at $DIR/reborrow.rs:+0:10: +0:15 + let mut _0: (); // return place in scope 0 at $DIR/reborrow.rs:+0:21: +0:21 + let _2: *mut u8; // in scope 0 at $DIR/reborrow.rs:+1:9: +1:10 + let _5: (); // in scope 0 at $DIR/reborrow.rs:+4:5: +4:14 + let mut _6: *mut u8; // in scope 0 at $DIR/reborrow.rs:+4:12: +4:13 + scope 1 { + debug a => _2; // in scope 1 at $DIR/reborrow.rs:+1:9: +1:10 + let _3: *mut u8; // in scope 1 at $DIR/reborrow.rs:+2:9: +2:10 + scope 2 { + debug b => _3; // in scope 2 at $DIR/reborrow.rs:+2:9: +2:10 + let _4: *mut u8; // in scope 2 at $DIR/reborrow.rs:+3:9: +3:10 + scope 4 { +- debug c => _4; // in scope 4 at $DIR/reborrow.rs:+3:9: +3:10 ++ debug c => _2; // in scope 4 at $DIR/reborrow.rs:+3:9: +3:10 + } + } + scope 3 { + } + } + + bb0: { +- StorageLive(_2); // scope 0 at $DIR/reborrow.rs:+1:9: +1:10 + _2 = &raw mut _1; // scope 0 at $DIR/reborrow.rs:+1:13: +1:23 + StorageLive(_3); // scope 1 at $DIR/reborrow.rs:+2:9: +2:10 + _3 = &raw mut (*_2); // scope 3 at $DIR/reborrow.rs:+2:22: +2:33 +- StorageLive(_4); // scope 2 at $DIR/reborrow.rs:+3:9: +3:10 +- _4 = _2; // scope 2 at $DIR/reborrow.rs:+3:13: +3:14 + StorageLive(_5); // scope 4 at $DIR/reborrow.rs:+4:5: +4:14 +- StorageLive(_6); // scope 4 at $DIR/reborrow.rs:+4:12: +4:13 +- _6 = _4; // scope 4 at $DIR/reborrow.rs:+4:12: +4:13 +- _5 = opaque::<*mut u8>(move _6) -> bb1; // scope 4 at $DIR/reborrow.rs:+4:5: +4:14 ++ _5 = opaque::<*mut u8>(_2) -> bb1; // scope 4 at $DIR/reborrow.rs:+4:5: +4:14 + // mir::Constant + // + span: $DIR/reborrow.rs:31:5: 31:11 + // + literal: Const { ty: fn(*mut u8) {opaque::<*mut u8>}, val: Value(<ZST>) } + } + + bb1: { +- StorageDead(_6); // scope 4 at $DIR/reborrow.rs:+4:13: +4:14 + StorageDead(_5); // scope 4 at $DIR/reborrow.rs:+4:14: +4:15 + _0 = const (); // scope 0 at $DIR/reborrow.rs:+0:21: +5:2 +- StorageDead(_4); // scope 2 at $DIR/reborrow.rs:+5:1: +5:2 + StorageDead(_3); // scope 1 at $DIR/reborrow.rs:+5:1: +5:2 +- StorageDead(_2); // scope 0 at $DIR/reborrow.rs:+5:1: +5:2 + return; // scope 0 at $DIR/reborrow.rs:+5:2: +5:2 + } + } + diff --git a/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.diff b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.diff new file mode 100644 index 000000000..f3d26cc6e --- /dev/null +++ b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.diff @@ -0,0 +1,50 @@ +- // MIR for `remut` before CopyProp ++ // MIR for `remut` after CopyProp + + fn remut(_1: u8) -> () { + debug x => _1; // in scope 0 at $DIR/reborrow.rs:+0:10: +0:15 + let mut _0: (); // return place in scope 0 at $DIR/reborrow.rs:+0:21: +0:21 + let _2: &mut u8; // in scope 0 at $DIR/reborrow.rs:+1:9: +1:10 + let _5: (); // in scope 0 at $DIR/reborrow.rs:+4:5: +4:14 + let mut _6: &mut u8; // in scope 0 at $DIR/reborrow.rs:+4:12: +4:13 + scope 1 { + debug a => _2; // in scope 1 at $DIR/reborrow.rs:+1:9: +1:10 + let _3: &mut u8; // in scope 1 at $DIR/reborrow.rs:+2:9: +2:10 + scope 2 { + debug b => _3; // in scope 2 at $DIR/reborrow.rs:+2:9: +2:10 + let _4: &mut u8; // in scope 2 at $DIR/reborrow.rs:+3:9: +3:10 + scope 3 { +- debug c => _4; // in scope 3 at $DIR/reborrow.rs:+3:9: +3:10 ++ debug c => _2; // in scope 3 at $DIR/reborrow.rs:+3:9: +3:10 + } + } + } + + bb0: { +- StorageLive(_2); // scope 0 at $DIR/reborrow.rs:+1:9: +1:10 + _2 = &mut _1; // scope 0 at $DIR/reborrow.rs:+1:13: +1:19 + StorageLive(_3); // scope 1 at $DIR/reborrow.rs:+2:9: +2:10 + _3 = &mut (*_2); // scope 1 at $DIR/reborrow.rs:+2:13: +2:20 +- StorageLive(_4); // scope 2 at $DIR/reborrow.rs:+3:9: +3:10 +- _4 = move _2; // scope 2 at $DIR/reborrow.rs:+3:13: +3:14 + StorageLive(_5); // scope 3 at $DIR/reborrow.rs:+4:5: +4:14 +- StorageLive(_6); // scope 3 at $DIR/reborrow.rs:+4:12: +4:13 +- _6 = move _4; // scope 3 at $DIR/reborrow.rs:+4:12: +4:13 +- _5 = opaque::<&mut u8>(move _6) -> bb1; // scope 3 at $DIR/reborrow.rs:+4:5: +4:14 ++ _5 = opaque::<&mut u8>(move _2) -> bb1; // scope 3 at $DIR/reborrow.rs:+4:5: +4:14 + // mir::Constant + // + span: $DIR/reborrow.rs:15:5: 15:11 + // + literal: Const { ty: fn(&mut u8) {opaque::<&mut u8>}, val: Value(<ZST>) } + } + + bb1: { +- StorageDead(_6); // scope 3 at $DIR/reborrow.rs:+4:13: +4:14 + StorageDead(_5); // scope 3 at $DIR/reborrow.rs:+4:14: +4:15 + _0 = const (); // scope 0 at $DIR/reborrow.rs:+0:21: +5:2 +- StorageDead(_4); // scope 2 at $DIR/reborrow.rs:+5:1: +5:2 + StorageDead(_3); // scope 1 at $DIR/reborrow.rs:+5:1: +5:2 +- StorageDead(_2); // scope 0 at $DIR/reborrow.rs:+5:1: +5:2 + return; // scope 0 at $DIR/reborrow.rs:+5:2: +5:2 + } + } + diff --git a/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.diff b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.diff new file mode 100644 index 000000000..63e42b4dc --- /dev/null +++ b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.diff @@ -0,0 +1,50 @@ +- // MIR for `reraw` before CopyProp ++ // MIR for `reraw` after CopyProp + + fn reraw(_1: u8) -> () { + debug x => _1; // in scope 0 at $DIR/reborrow.rs:+0:10: +0:15 + let mut _0: (); // return place in scope 0 at $DIR/reborrow.rs:+0:21: +0:21 + let _2: &mut u8; // in scope 0 at $DIR/reborrow.rs:+1:9: +1:10 + let _5: (); // in scope 0 at $DIR/reborrow.rs:+4:5: +4:14 + let mut _6: &mut u8; // in scope 0 at $DIR/reborrow.rs:+4:12: +4:13 + scope 1 { + debug a => _2; // in scope 1 at $DIR/reborrow.rs:+1:9: +1:10 + let _3: *mut u8; // in scope 1 at $DIR/reborrow.rs:+2:9: +2:10 + scope 2 { + debug b => _3; // in scope 2 at $DIR/reborrow.rs:+2:9: +2:10 + let _4: &mut u8; // in scope 2 at $DIR/reborrow.rs:+3:9: +3:10 + scope 3 { +- debug c => _4; // in scope 3 at $DIR/reborrow.rs:+3:9: +3:10 ++ debug c => _2; // in scope 3 at $DIR/reborrow.rs:+3:9: +3:10 + } + } + } + + bb0: { +- StorageLive(_2); // scope 0 at $DIR/reborrow.rs:+1:9: +1:10 + _2 = &mut _1; // scope 0 at $DIR/reborrow.rs:+1:13: +1:19 + StorageLive(_3); // scope 1 at $DIR/reborrow.rs:+2:9: +2:10 + _3 = &raw mut (*_2); // scope 1 at $DIR/reborrow.rs:+2:13: +2:24 +- StorageLive(_4); // scope 2 at $DIR/reborrow.rs:+3:9: +3:10 +- _4 = move _2; // scope 2 at $DIR/reborrow.rs:+3:13: +3:14 + StorageLive(_5); // scope 3 at $DIR/reborrow.rs:+4:5: +4:14 +- StorageLive(_6); // scope 3 at $DIR/reborrow.rs:+4:12: +4:13 +- _6 = move _4; // scope 3 at $DIR/reborrow.rs:+4:12: +4:13 +- _5 = opaque::<&mut u8>(move _6) -> bb1; // scope 3 at $DIR/reborrow.rs:+4:5: +4:14 ++ _5 = opaque::<&mut u8>(move _2) -> bb1; // scope 3 at $DIR/reborrow.rs:+4:5: +4:14 + // mir::Constant + // + span: $DIR/reborrow.rs:23:5: 23:11 + // + literal: Const { ty: fn(&mut u8) {opaque::<&mut u8>}, val: Value(<ZST>) } + } + + bb1: { +- StorageDead(_6); // scope 3 at $DIR/reborrow.rs:+4:13: +4:14 + StorageDead(_5); // scope 3 at $DIR/reborrow.rs:+4:14: +4:15 + _0 = const (); // scope 0 at $DIR/reborrow.rs:+0:21: +5:2 +- StorageDead(_4); // scope 2 at $DIR/reborrow.rs:+5:1: +5:2 + StorageDead(_3); // scope 1 at $DIR/reborrow.rs:+5:1: +5:2 +- StorageDead(_2); // scope 0 at $DIR/reborrow.rs:+5:1: +5:2 + return; // scope 0 at $DIR/reborrow.rs:+5:2: +5:2 + } + } + diff --git a/tests/mir-opt/copy-prop/reborrow.rs b/tests/mir-opt/copy-prop/reborrow.rs new file mode 100644 index 000000000..91b77966b --- /dev/null +++ b/tests/mir-opt/copy-prop/reborrow.rs @@ -0,0 +1,47 @@ +// ignore-wasm32 compiled with panic=abort by default +// Check that CopyProp considers reborrows as not mutating the pointer. +// unit-test: CopyProp + +#![feature(raw_ref_op)] + +#[inline(never)] +fn opaque(_: impl Sized) {} + +// EMIT_MIR reborrow.remut.CopyProp.diff +fn remut(mut x: u8) { + let a = &mut x; + let b = &mut *a; //< this cannot mutate a. + let c = a; //< so `c` and `a` can be merged. + opaque(c); +} + +// EMIT_MIR reborrow.reraw.CopyProp.diff +fn reraw(mut x: u8) { + let a = &mut x; + let b = &raw mut *a; //< this cannot mutate a. + let c = a; //< so `c` and `a` can be merged. + opaque(c); +} + +// EMIT_MIR reborrow.miraw.CopyProp.diff +fn miraw(mut x: u8) { + let a = &raw mut x; + let b = unsafe { &raw mut *a }; //< this cannot mutate a. + let c = a; //< so `c` and `a` can be merged. + opaque(c); +} + +// EMIT_MIR reborrow.demiraw.CopyProp.diff +fn demiraw(mut x: u8) { + let a = &raw mut x; + let b = unsafe { &mut *a }; //< this cannot mutate a. + let c = a; //< so `c` and `a` can be merged. + opaque(c); +} + +fn main() { + remut(0); + reraw(0); + miraw(0); + demiraw(0); +} diff --git a/tests/mir-opt/dataflow-const-prop/checked.rs b/tests/mir-opt/dataflow-const-prop/checked.rs index 0738a4ee5..0f9f5a97f 100644 --- a/tests/mir-opt/dataflow-const-prop/checked.rs +++ b/tests/mir-opt/dataflow-const-prop/checked.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: DataflowConstProp // compile-flags: -Coverflow-checks=on diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff index 29781e9ce..1edcc28e6 100644 --- a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff +++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff @@ -8,7 +8,7 @@ let mut _3: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 scope 1 { } - scope 2 (inlined <u8 as Add>::add) { // at $DIR/inherit_overflow.rs:8:13: 8:47 + scope 2 (inlined <u8 as Add>::add) { // at $DIR/inherit_overflow.rs:9:13: 9:47 debug self => _2; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL debug other => _3; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL let mut _4: (u8, bool); // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.rs b/tests/mir-opt/dataflow-const-prop/inherit_overflow.rs index f4aba60f0..90349d527 100644 --- a/tests/mir-opt/dataflow-const-prop/inherit_overflow.rs +++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: DataflowConstProp // compile-flags: -Zmir-enable-passes=+Inline diff --git a/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff index 158f187f1..70ef17afd 100644 --- a/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff +++ b/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff @@ -26,7 +26,7 @@ _3 = &(*_4); // scope 1 at $DIR/ref_without_sb.rs:+2:12: +2:14 _2 = escape::<i32>(move _3) -> bb1; // scope 1 at $DIR/ref_without_sb.rs:+2:5: +2:15 // mir::Constant - // + span: $DIR/ref_without_sb.rs:12:5: 12:11 + // + span: $DIR/ref_without_sb.rs:13:5: 13:11 // + literal: Const { ty: for<'a> fn(&'a i32) {escape::<i32>}, val: Value(<ZST>) } } @@ -38,7 +38,7 @@ StorageLive(_5); // scope 1 at $DIR/ref_without_sb.rs:+4:5: +4:20 _5 = some_function() -> bb2; // scope 1 at $DIR/ref_without_sb.rs:+4:5: +4:20 // mir::Constant - // + span: $DIR/ref_without_sb.rs:14:5: 14:18 + // + span: $DIR/ref_without_sb.rs:15:5: 15:18 // + literal: Const { ty: fn() {some_function}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs b/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs index 2fd480b09..f53de3cf2 100644 --- a/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs +++ b/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: DataflowConstProp #[inline(never)] diff --git a/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.diff index 004643e36..6ca569f3d 100644 --- a/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.diff +++ b/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.diff @@ -32,7 +32,7 @@ _5 = _3; // scope 3 at $DIR/sibling_ptr.rs:+4:10: +4:11 _4 = ptr::mut_ptr::<impl *mut u8>::add(move _5, const 1_usize) -> bb1; // scope 3 at $DIR/sibling_ptr.rs:+4:10: +4:18 // mir::Constant - // + span: $DIR/sibling_ptr.rs:15:12: 15:15 + // + span: $DIR/sibling_ptr.rs:16:12: 16:15 // + literal: Const { ty: unsafe fn(*mut u8, usize) -> *mut u8 {ptr::mut_ptr::<impl *mut u8>::add}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs b/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs index 6dfb3a4ed..81fc3c2f4 100644 --- a/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs +++ b/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // This attempts to modify `x.1` via a pointer derived from `addr_of_mut!(x.0)`. // According to Miri, that is UB. However, T-opsem has not finalized that // decision and as such we cannot rely on it in optimizations. Consequently, diff --git a/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.diff index 8018400e7..9854beaeb 100644 --- a/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.diff +++ b/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.diff @@ -25,7 +25,7 @@ - _2 = foo(move _3) -> bb1; // scope 1 at $DIR/terminator.rs:+3:5: +3:15 + _2 = foo(const 2_i32) -> bb1; // scope 1 at $DIR/terminator.rs:+3:5: +3:15 // mir::Constant - // + span: $DIR/terminator.rs:9:5: 9:8 + // + span: $DIR/terminator.rs:10:5: 10:8 // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/dataflow-const-prop/terminator.rs b/tests/mir-opt/dataflow-const-prop/terminator.rs index d151f666a..4f001df35 100644 --- a/tests/mir-opt/dataflow-const-prop/terminator.rs +++ b/tests/mir-opt/dataflow-const-prop/terminator.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: DataflowConstProp fn foo(n: i32) {} diff --git a/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff b/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff index cd3b792fb..2776ff51d 100644 --- a/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff +++ b/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff @@ -32,7 +32,7 @@ + StorageLive(_4); // scope 0 at $DIR/cycle.rs:+3:11: +3:17 + _4 = cond() -> bb2; // scope 0 at $DIR/cycle.rs:+3:11: +3:17 // mir::Constant - // + span: $DIR/cycle.rs:12:11: 12:15 + // + span: $DIR/cycle.rs:13:11: 13:15 // + literal: Const { ty: fn() -> bool {cond}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/dead-store-elimination/cycle.rs b/tests/mir-opt/dead-store-elimination/cycle.rs index b35ce0bcb..570bfe84d 100644 --- a/tests/mir-opt/dead-store-elimination/cycle.rs +++ b/tests/mir-opt/dead-store-elimination/cycle.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: DeadStoreElimination #[inline(never)] diff --git a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff index 3b1f81175..c4ebf1ca8 100644 --- a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff +++ b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff @@ -19,7 +19,7 @@ _3 = &(*_1); // scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23 _2 = core::str::<impl str>::as_bytes(move _3) -> bb1; // scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23 // mir::Constant - // + span: $DIR/deduplicate_blocks.rs:5:13: 5:21 + // + span: $DIR/deduplicate_blocks.rs:6:13: 6:21 // + literal: Const { ty: for<'a> fn(&'a str) -> &'a [u8] {core::str::<impl str>::as_bytes}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/deduplicate_blocks.rs b/tests/mir-opt/deduplicate_blocks.rs index 2b9eed99e..46012e19a 100644 --- a/tests/mir-opt/deduplicate_blocks.rs +++ b/tests/mir-opt/deduplicate_blocks.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: DeduplicateBlocks // EMIT_MIR deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff diff --git a/tests/mir-opt/deref-patterns/string.foo.PreCodegen.after.mir b/tests/mir-opt/deref-patterns/string.foo.PreCodegen.after.mir index 9597a0c83..97826ed19 100644 --- a/tests/mir-opt/deref-patterns/string.foo.PreCodegen.after.mir +++ b/tests/mir-opt/deref-patterns/string.foo.PreCodegen.after.mir @@ -25,19 +25,19 @@ fn foo(_1: Option<String>) -> i32 { _7 = const false; // scope 0 at $DIR/string.rs:+3:9: +3:10 _6 = move _1; // scope 0 at $DIR/string.rs:+3:9: +3:10 _0 = const 4321_i32; // scope 1 at $DIR/string.rs:+3:14: +3:18 - drop(_6) -> bb6; // scope 0 at $DIR/string.rs:+3:17: +3:18 + drop(_6) -> [return: bb6, unwind unreachable]; // scope 0 at $DIR/string.rs:+3:17: +3:18 } bb2: { _2 = &((_1 as Some).0: std::string::String); // scope 0 at $DIR/string.rs:+2:14: +2:17 - _3 = <String as Deref>::deref(move _2) -> bb3; // scope 0 at $DIR/string.rs:+2:14: +2:17 + _3 = <String as Deref>::deref(move _2) -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/string.rs:+2:14: +2:17 // mir::Constant // + span: $DIR/string.rs:9:14: 9:17 // + literal: Const { ty: for<'a> fn(&'a String) -> &'a <String as Deref>::Target {<String as Deref>::deref}, val: Value(<ZST>) } } bb3: { - _4 = <str as PartialEq>::eq(_3, const "a") -> bb4; // scope 0 at $DIR/string.rs:+2:14: +2:17 + _4 = <str as PartialEq>::eq(_3, const "a") -> [return: bb4, unwind unreachable]; // scope 0 at $DIR/string.rs:+2:14: +2:17 // mir::Constant // + span: $DIR/string.rs:9:14: 9:17 // + literal: Const { ty: for<'a, 'b> fn(&'a str, &'b str) -> bool {<str as PartialEq>::eq}, val: Value(<ZST>) } @@ -65,7 +65,7 @@ fn foo(_1: Option<String>) -> i32 { } bb8: { - drop(_1) -> bb7; // scope 0 at $DIR/string.rs:+5:1: +5:2 + drop(_1) -> [return: bb7, unwind unreachable]; // scope 0 at $DIR/string.rs:+5:1: +5:2 } bb9: { diff --git a/tests/mir-opt/derefer_inline_test.main.Derefer.diff b/tests/mir-opt/derefer_inline_test.main.Derefer.diff index 3540df308..426d4fb21 100644 --- a/tests/mir-opt/derefer_inline_test.main.Derefer.diff +++ b/tests/mir-opt/derefer_inline_test.main.Derefer.diff @@ -3,58 +3,42 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/derefer_inline_test.rs:+0:11: +0:11 - let _1: std::boxed::Box<std::boxed::Box<u32>>; // in scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12 - let mut _2: usize; // in scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12 - let mut _3: usize; // in scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12 - let mut _4: *mut u8; // in scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12 - let mut _5: std::boxed::Box<std::boxed::Box<u32>>; // in scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12 - scope 1 { - } + let _1: std::boxed::Box<std::boxed::Box<u32>>; // in scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:18 + let mut _2: std::boxed::Box<u32>; // in scope 0 at $DIR/derefer_inline_test.rs:+1:14: +1:17 bb0: { - StorageLive(_1); // scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12 - _2 = SizeOf(std::boxed::Box<u32>); // scope 1 at $DIR/derefer_inline_test.rs:+1:5: +1:12 - _3 = AlignOf(std::boxed::Box<u32>); // scope 1 at $DIR/derefer_inline_test.rs:+1:5: +1:12 - _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 1 at $DIR/derefer_inline_test.rs:+1:5: +1:12 + StorageLive(_1); // scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:18 + StorageLive(_2); // scope 0 at $DIR/derefer_inline_test.rs:+1:14: +1:17 + _2 = f() -> bb1; // scope 0 at $DIR/derefer_inline_test.rs:+1:14: +1:17 // mir::Constant - // + span: $DIR/derefer_inline_test.rs:11:5: 11:12 - // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) } + // + span: $DIR/derefer_inline_test.rs:10:14: 10:15 + // + literal: Const { ty: fn() -> Box<u32> {f}, val: Value(<ZST>) } } bb1: { - StorageLive(_5); // scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12 - _5 = ShallowInitBox(move _4, std::boxed::Box<u32>); // scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12 - (*_5) = f() -> [return: bb2, unwind: bb6]; // scope 0 at $DIR/derefer_inline_test.rs:+1:9: +1:12 + _1 = Box::<Box<u32>>::new(move _2) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:18 // mir::Constant - // + span: $DIR/derefer_inline_test.rs:11:9: 11:10 - // + literal: Const { ty: fn() -> Box<u32> {f}, val: Value(<ZST>) } + // + span: $DIR/derefer_inline_test.rs:10:5: 10:13 + // + user_ty: UserType(0) + // + literal: Const { ty: fn(Box<u32>) -> Box<Box<u32>> {Box::<Box<u32>>::new}, val: Value(<ZST>) } } bb2: { - _1 = move _5; // scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12 - drop(_5) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/derefer_inline_test.rs:+1:11: +1:12 + StorageDead(_2); // scope 0 at $DIR/derefer_inline_test.rs:+1:17: +1:18 + drop(_1) -> bb3; // scope 0 at $DIR/derefer_inline_test.rs:+1:18: +1:19 } bb3: { - StorageDead(_5); // scope 0 at $DIR/derefer_inline_test.rs:+1:11: +1:12 - drop(_1) -> bb4; // scope 0 at $DIR/derefer_inline_test.rs:+1:12: +1:13 - } - - bb4: { - StorageDead(_1); // scope 0 at $DIR/derefer_inline_test.rs:+1:12: +1:13 + StorageDead(_1); // scope 0 at $DIR/derefer_inline_test.rs:+1:18: +1:19 _0 = const (); // scope 0 at $DIR/derefer_inline_test.rs:+0:11: +2:2 return; // scope 0 at $DIR/derefer_inline_test.rs:+2:2: +2:2 } - bb5 (cleanup): { - drop(_1) -> bb7; // scope 0 at $DIR/derefer_inline_test.rs:+1:12: +1:13 - } - - bb6 (cleanup): { - drop(_5) -> bb7; // scope 0 at $DIR/derefer_inline_test.rs:+1:11: +1:12 + bb4 (cleanup): { + drop(_2) -> [return: bb5, unwind terminate]; // scope 0 at $DIR/derefer_inline_test.rs:+1:17: +1:18 } - bb7 (cleanup): { + bb5 (cleanup): { resume; // scope 0 at $DIR/derefer_inline_test.rs:+0:1: +2:2 } } diff --git a/tests/mir-opt/derefer_inline_test.rs b/tests/mir-opt/derefer_inline_test.rs index cc06a7dd8..38311d4d0 100644 --- a/tests/mir-opt/derefer_inline_test.rs +++ b/tests/mir-opt/derefer_inline_test.rs @@ -2,11 +2,10 @@ // EMIT_MIR derefer_inline_test.main.Derefer.diff // ignore-wasm32 compiled with panic=abort by default -#![feature(box_syntax)] #[inline] fn f() -> Box<u32> { - box 0 + Box::new(0) } fn main() { - box f(); + Box::new(f()); } diff --git a/tests/mir-opt/dest-prop/branch.foo.DestinationPropagation.diff b/tests/mir-opt/dest-prop/branch.foo.DestinationPropagation.diff index 9c7296632..b7416d389 100644 --- a/tests/mir-opt/dest-prop/branch.foo.DestinationPropagation.diff +++ b/tests/mir-opt/dest-prop/branch.foo.DestinationPropagation.diff @@ -22,7 +22,7 @@ + nop; // scope 0 at $DIR/branch.rs:+1:9: +1:10 + _0 = val() -> bb1; // scope 0 at $DIR/branch.rs:+1:13: +1:18 // mir::Constant - // + span: $DIR/branch.rs:13:13: 13:16 + // + span: $DIR/branch.rs:14:13: 14:16 // + literal: Const { ty: fn() -> i32 {val}, val: Value(<ZST>) } } @@ -32,7 +32,7 @@ StorageLive(_3); // scope 1 at $DIR/branch.rs:+3:16: +3:22 _3 = cond() -> bb2; // scope 1 at $DIR/branch.rs:+3:16: +3:22 // mir::Constant - // + span: $DIR/branch.rs:15:16: 15:20 + // + span: $DIR/branch.rs:16:16: 16:20 // + literal: Const { ty: fn() -> bool {cond}, val: Value(<ZST>) } } @@ -50,7 +50,7 @@ StorageLive(_4); // scope 1 at $DIR/branch.rs:+6:9: +6:14 _4 = val() -> bb5; // scope 1 at $DIR/branch.rs:+6:9: +6:14 // mir::Constant - // + span: $DIR/branch.rs:18:9: 18:12 + // + span: $DIR/branch.rs:19:9: 19:12 // + literal: Const { ty: fn() -> i32 {val}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/dest-prop/branch.rs b/tests/mir-opt/dest-prop/branch.rs index 898c908b1..7e4276e66 100644 --- a/tests/mir-opt/dest-prop/branch.rs +++ b/tests/mir-opt/dest-prop/branch.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default //! Tests that assignment in both branches of an `if` are eliminated. // unit-test: DestinationPropagation fn val() -> i32 { diff --git a/tests/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff b/tests/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff index 298991b5a..a61e741f7 100644 --- a/tests/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff +++ b/tests/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff @@ -16,7 +16,7 @@ + nop; // scope 0 at $DIR/copy_propagation_arg.rs:+1:11: +1:12 + _2 = dummy(move _1) -> bb1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:5: +1:13 // mir::Constant - // + span: $DIR/copy_propagation_arg.rs:16:5: 16:10 + // + span: $DIR/copy_propagation_arg.rs:17:5: 17:10 // + literal: Const { ty: fn(u8) -> u8 {dummy}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff b/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff index d37a9f71d..c7fbecac5 100644 --- a/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff +++ b/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff @@ -15,7 +15,7 @@ - _2 = dummy(move _3) -> bb1; // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:17 + _1 = dummy(move _3) -> bb1; // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:17 // mir::Constant - // + span: $DIR/copy_propagation_arg.rs:11:9: 11:14 + // + span: $DIR/copy_propagation_arg.rs:12:9: 12:14 // + literal: Const { ty: fn(u8) -> u8 {dummy}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/dest-prop/copy_propagation_arg.rs b/tests/mir-opt/dest-prop/copy_propagation_arg.rs index 31be6c931..57cb328c2 100644 --- a/tests/mir-opt/dest-prop/copy_propagation_arg.rs +++ b/tests/mir-opt/dest-prop/copy_propagation_arg.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // Check that DestinationPropagation does not propagate an assignment to a function argument // (doing so can break usages of the original argument value) // unit-test: DestinationPropagation diff --git a/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff b/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff index cfc203c5f..b06f069a2 100644 --- a/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff +++ b/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff @@ -28,7 +28,7 @@ + nop; // scope 0 at $DIR/cycle.rs:+1:9: +1:14 + _6 = val() -> bb1; // scope 0 at $DIR/cycle.rs:+1:17: +1:22 // mir::Constant - // + span: $DIR/cycle.rs:9:17: 9:20 + // + span: $DIR/cycle.rs:10:17: 10:20 // + literal: Const { ty: fn() -> i32 {val}, val: Value(<ZST>) } } @@ -56,7 +56,7 @@ + nop; // scope 3 at $DIR/cycle.rs:+6:10: +6:11 _5 = std::mem::drop::<i32>(move _6) -> bb2; // scope 3 at $DIR/cycle.rs:+6:5: +6:12 // mir::Constant - // + span: $DIR/cycle.rs:14:5: 14:9 + // + span: $DIR/cycle.rs:15:5: 15:9 // + literal: Const { ty: fn(i32) {std::mem::drop::<i32>}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/dest-prop/cycle.rs b/tests/mir-opt/dest-prop/cycle.rs index 6182878f3..3aea19d80 100644 --- a/tests/mir-opt/dest-prop/cycle.rs +++ b/tests/mir-opt/dest-prop/cycle.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default //! Tests that cyclic assignments don't hang DestinationPropagation, and result in reasonable code. // unit-test: DestinationPropagation fn val() -> i32 { diff --git a/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.mir b/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.mir index 63cac133b..b9d4b59d2 100644 --- a/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.mir +++ b/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.mir @@ -22,7 +22,7 @@ fn f(_1: usize) -> usize { nop; // scope 1 at $DIR/dead_stores_79191.rs:+4:8: +4:9 _0 = id::<usize>(move _1) -> bb1; // scope 1 at $DIR/dead_stores_79191.rs:+4:5: +4:10 // mir::Constant - // + span: $DIR/dead_stores_79191.rs:12:5: 12:7 + // + span: $DIR/dead_stores_79191.rs:13:5: 13:7 // + literal: Const { ty: fn(usize) -> usize {id::<usize>}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/dest-prop/dead_stores_79191.rs b/tests/mir-opt/dest-prop/dead_stores_79191.rs index 43e0bf664..9d4814838 100644 --- a/tests/mir-opt/dest-prop/dead_stores_79191.rs +++ b/tests/mir-opt/dest-prop/dead_stores_79191.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: DestinationPropagation fn id<T>(x: T) -> T { diff --git a/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir b/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir index 26068931a..9eb0e09bf 100644 --- a/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir +++ b/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir @@ -21,7 +21,7 @@ fn f(_1: usize) -> usize { nop; // scope 1 at $DIR/dead_stores_better.rs:+4:8: +4:9 _0 = id::<usize>(move _1) -> bb1; // scope 1 at $DIR/dead_stores_better.rs:+4:5: +4:10 // mir::Constant - // + span: $DIR/dead_stores_better.rs:16:5: 16:7 + // + span: $DIR/dead_stores_better.rs:17:5: 17:7 // + literal: Const { ty: fn(usize) -> usize {id::<usize>}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/dest-prop/dead_stores_better.rs b/tests/mir-opt/dest-prop/dead_stores_better.rs index 003ad57d8..72d406bfd 100644 --- a/tests/mir-opt/dest-prop/dead_stores_better.rs +++ b/tests/mir-opt/dest-prop/dead_stores_better.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // This is a copy of the `dead_stores_79191` test, except that we turn on DSE. This demonstrates // that that pass enables this one to do more optimizations. diff --git a/tests/mir-opt/dest-prop/simple.rs b/tests/mir-opt/dest-prop/simple.rs index d4c27228f..3a4aec34e 100644 --- a/tests/mir-opt/dest-prop/simple.rs +++ b/tests/mir-opt/dest-prop/simple.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default //! Copy of `nrvo-simple.rs`, to ensure that full dest-prop handles it too. // unit-test: DestinationPropagation // EMIT_MIR simple.nrvo.DestinationPropagation.diff diff --git a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.diff b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.diff index fbed31788..457fc8308 100644 --- a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.diff +++ b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.diff @@ -10,7 +10,7 @@ debug un => _1; // in scope 1 at $DIR/union.rs:+5:9: +5:11 scope 2 { } - scope 3 (inlined std::mem::drop::<u32>) { // at $DIR/union.rs:15:5: 15:27 + scope 3 (inlined std::mem::drop::<u32>) { // at $DIR/union.rs:16:5: 16:27 debug _x => _3; // in scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL } } @@ -20,7 +20,7 @@ StorageLive(_2); // scope 0 at $DIR/union.rs:+5:23: +5:28 _2 = val() -> bb1; // scope 0 at $DIR/union.rs:+5:23: +5:28 // mir::Constant - // + span: $DIR/union.rs:13:23: 13:26 + // + span: $DIR/union.rs:14:23: 14:26 // + literal: Const { ty: fn() -> u32 {val}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/dest-prop/union.rs b/tests/mir-opt/dest-prop/union.rs index eb6cb09fc..062d02d06 100644 --- a/tests/mir-opt/dest-prop/union.rs +++ b/tests/mir-opt/dest-prop/union.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default //! Tests that we can propagate into places that are projections into unions // compile-flags: -Zunsound-mir-opts fn val() -> u32 { diff --git a/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.diff b/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.diff index 9ea756c27..ae63d724d 100644 --- a/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.diff +++ b/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.diff @@ -36,7 +36,7 @@ - _6 = _2; // scope 1 at $DIR/unreachable.rs:+3:14: +3:15 - _4 = g::<T>(move _5, move _6) -> bb2; // scope 1 at $DIR/unreachable.rs:+3:9: +3:16 - // mir::Constant -- // + span: $DIR/unreachable.rs:11:9: 11:10 +- // + span: $DIR/unreachable.rs:12:9: 12:10 - // + literal: Const { ty: fn(T, T) {g::<T>}, val: Value(<ZST>) } - } - @@ -60,7 +60,7 @@ + _9 = _1; // scope 1 at $DIR/unreachable.rs:+5:14: +5:15 + _7 = g::<T>(move _1, move _9) -> bb2; // scope 1 at $DIR/unreachable.rs:+5:9: +5:16 // mir::Constant - // + span: $DIR/unreachable.rs:13:9: 13:10 + // + span: $DIR/unreachable.rs:14:9: 14:10 // + literal: Const { ty: fn(T, T) {g::<T>}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/dest-prop/unreachable.rs b/tests/mir-opt/dest-prop/unreachable.rs index 32b5def98..c73d11ae3 100644 --- a/tests/mir-opt/dest-prop/unreachable.rs +++ b/tests/mir-opt/dest-prop/unreachable.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // Check that unreachable code is removed after the destination propagation. // Regression test for issue #105428. // diff --git a/tests/mir-opt/div_overflow.const_dividend.PreCodegen.after.mir b/tests/mir-opt/div_overflow.const_dividend.PreCodegen.after.mir deleted file mode 100644 index 1a7fb916e..000000000 --- a/tests/mir-opt/div_overflow.const_dividend.PreCodegen.after.mir +++ /dev/null @@ -1,17 +0,0 @@ -// MIR for `const_dividend` after PreCodegen - -fn const_dividend(_1: i32) -> i32 { - debug a => _1; // in scope 0 at $DIR/div_overflow.rs:+0:23: +0:24 - let mut _0: i32; // return place in scope 0 at $DIR/div_overflow.rs:+0:34: +0:37 - let mut _2: bool; // in scope 0 at $DIR/div_overflow.rs:+1:5: +1:12 - - bb0: { - _2 = Eq(_1, const 0_i32); // scope 0 at $DIR/div_overflow.rs:+1:5: +1:12 - assert(!move _2, "attempt to divide `{}` by zero", const 256_i32) -> bb1; // scope 0 at $DIR/div_overflow.rs:+1:5: +1:12 - } - - bb1: { - _0 = Div(const 256_i32, _1); // scope 0 at $DIR/div_overflow.rs:+1:5: +1:12 - return; // scope 0 at $DIR/div_overflow.rs:+2:2: +2:2 - } -} diff --git a/tests/mir-opt/div_overflow.const_divisor.PreCodegen.after.mir b/tests/mir-opt/div_overflow.const_divisor.PreCodegen.after.mir deleted file mode 100644 index 5526a194b..000000000 --- a/tests/mir-opt/div_overflow.const_divisor.PreCodegen.after.mir +++ /dev/null @@ -1,11 +0,0 @@ -// MIR for `const_divisor` after PreCodegen - -fn const_divisor(_1: i32) -> i32 { - debug a => _1; // in scope 0 at $DIR/div_overflow.rs:+0:22: +0:23 - let mut _0: i32; // return place in scope 0 at $DIR/div_overflow.rs:+0:33: +0:36 - - bb0: { - _0 = Div(_1, const 256_i32); // scope 0 at $DIR/div_overflow.rs:+1:5: +1:12 - return; // scope 0 at $DIR/div_overflow.rs:+2:2: +2:2 - } -} diff --git a/tests/mir-opt/div_overflow.rs b/tests/mir-opt/div_overflow.rs deleted file mode 100644 index 10ce5bc0f..000000000 --- a/tests/mir-opt/div_overflow.rs +++ /dev/null @@ -1,18 +0,0 @@ -// compile-flags: -Copt-level=0 -Coverflow-checks=yes - -// Tests that division with a const does not emit a panicking branch for overflow - -// EMIT_MIR div_overflow.const_divisor.PreCodegen.after.mir -pub fn const_divisor(a: i32) -> i32 { - a / 256 -} - -// EMIT_MIR div_overflow.const_dividend.PreCodegen.after.mir -pub fn const_dividend(a: i32) -> i32 { - 256 / a -} - -fn main() { - const_divisor(123); - const_dividend(123); -} diff --git a/tests/mir-opt/dont_yeet_assert.generic.InstCombine.diff b/tests/mir-opt/dont_yeet_assert.generic.InstCombine.diff index c1a42a47e..c0fc1fb1d 100644 --- a/tests/mir-opt/dont_yeet_assert.generic.InstCombine.diff +++ b/tests/mir-opt/dont_yeet_assert.generic.InstCombine.diff @@ -7,7 +7,7 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/dont_yeet_assert.rs:+1:5: +1:61 - _1 = assert_mem_uninitialized_valid::<&T>() -> bb1; // scope 0 at $DIR/dont_yeet_assert.rs:+1:5: +1:61 + _1 = assert_mem_uninitialized_valid::<&T>() -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/dont_yeet_assert.rs:+1:5: +1:61 // mir::Constant // + span: $DIR/dont_yeet_assert.rs:10:5: 10:59 // + user_ty: UserType(0) diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff index 1f5c53381..8a4a16825 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff @@ -40,7 +40,7 @@ _5 = &(*_1); // scope 0 at $DIR/funky_arms.rs:+4:22: +4:37 _4 = Formatter::<'_>::sign_plus(move _5) -> bb1; // scope 0 at $DIR/funky_arms.rs:+4:22: +4:37 // mir::Constant - // + span: $DIR/funky_arms.rs:15:26: 15:35 + // + span: $DIR/funky_arms.rs:16:26: 16:35 // + literal: Const { ty: for<'a> fn(&'a Formatter<'_>) -> bool {Formatter::<'_>::sign_plus}, val: Value(<ZST>) } } @@ -54,7 +54,7 @@ - _6 = MinusPlus; // scope 1 at $DIR/funky_arms.rs:+10:17: +10:41 + _6 = const MinusPlus; // scope 1 at $DIR/funky_arms.rs:+10:17: +10:41 + // mir::Constant -+ // + span: $DIR/funky_arms.rs:21:17: 21:41 ++ // + span: no-location + // + literal: Const { ty: Sign, val: Value(Scalar(0x01)) } goto -> bb4; // scope 1 at $DIR/funky_arms.rs:+10:17: +10:41 } @@ -63,7 +63,7 @@ - _6 = Minus; // scope 1 at $DIR/funky_arms.rs:+9:18: +9:38 + _6 = const Minus; // scope 1 at $DIR/funky_arms.rs:+9:18: +9:38 + // mir::Constant -+ // + span: $DIR/funky_arms.rs:20:18: 20:38 ++ // + span: no-location + // + literal: Const { ty: Sign, val: Value(Scalar(0x00)) } goto -> bb4; // scope 1 at $DIR/funky_arms.rs:+9:18: +9:38 } @@ -74,7 +74,7 @@ _8 = &(*_1); // scope 3 at $DIR/funky_arms.rs:+13:30: +13:45 _7 = Formatter::<'_>::precision(move _8) -> bb5; // scope 3 at $DIR/funky_arms.rs:+13:30: +13:45 // mir::Constant - // + span: $DIR/funky_arms.rs:24:34: 24:43 + // + span: $DIR/funky_arms.rs:25:34: 25:43 // + literal: Const { ty: for<'a> fn(&'a Formatter<'_>) -> Option<usize> {Formatter::<'_>::precision}, val: Value(<ZST>) } } @@ -95,7 +95,7 @@ StorageDead(_15); // scope 3 at $DIR/funky_arms.rs:+15:78: +15:79 _0 = float_to_exponential_common_exact::<T>(_1, _2, move _13, move _14, _3) -> bb7; // scope 3 at $DIR/funky_arms.rs:+15:9: +15:87 // mir::Constant - // + span: $DIR/funky_arms.rs:26:9: 26:42 + // + span: $DIR/funky_arms.rs:27:9: 27:42 // + literal: Const { ty: for<'a, 'b, 'c> fn(&'a mut Formatter<'b>, &'c T, Sign, u32, bool) -> Result<(), std::fmt::Error> {float_to_exponential_common_exact::<T>}, val: Value(<ZST>) } } @@ -110,7 +110,7 @@ _20 = _6; // scope 2 at $DIR/funky_arms.rs:+17:56: +17:60 _0 = float_to_exponential_common_shortest::<T>(_1, _2, move _20, _3) -> bb9; // scope 2 at $DIR/funky_arms.rs:+17:9: +17:68 // mir::Constant - // + span: $DIR/funky_arms.rs:28:9: 28:45 + // + span: $DIR/funky_arms.rs:29:9: 29:45 // + literal: Const { ty: for<'a, 'b, 'c> fn(&'a mut Formatter<'b>, &'c T, Sign, bool) -> Result<(), std::fmt::Error> {float_to_exponential_common_shortest::<T>}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/funky_arms.rs b/tests/mir-opt/funky_arms.rs index 3e70d85e0..c4f75b5df 100644 --- a/tests/mir-opt/funky_arms.rs +++ b/tests/mir-opt/funky_arms.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // compile-flags: --crate-type lib -Cdebug-assertions=no #![feature(flt2dec)] diff --git a/tests/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir b/tests/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir index cfbe0aaf2..32b472ebe 100644 --- a/tests/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir +++ b/tests/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir @@ -110,7 +110,7 @@ yields () bb13 (cleanup): { StorageDead(_3); // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 - drop(_1) -> bb14; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 + drop(_1) -> [return: bb14, unwind terminate]; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 } bb14 (cleanup): { @@ -119,6 +119,6 @@ yields () bb15 (cleanup): { StorageDead(_3); // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 - drop(_1) -> bb14; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 + drop(_1) -> [return: bb14, unwind terminate]; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 } } diff --git a/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir b/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir index 7efda05d2..dc9bb533f 100644 --- a/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir @@ -63,7 +63,7 @@ fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator_tiny.rs:19:16: 19:24 StorageDead(_7); // scope 1 at $DIR/generator_tiny.rs:+3:17: +3:18 StorageDead(_6); // scope 1 at $DIR/generator_tiny.rs:+3:18: +3:19 StorageLive(_8); // scope 1 at $DIR/generator_tiny.rs:+4:13: +4:21 - _8 = callee() -> bb4; // scope 1 at $DIR/generator_tiny.rs:+4:13: +4:21 + _8 = callee() -> [return: bb4, unwind unreachable]; // scope 1 at $DIR/generator_tiny.rs:+4:13: +4:21 // mir::Constant // + span: $DIR/generator_tiny.rs:23:13: 23:19 // + literal: Const { ty: fn() {callee}, val: Value(<ZST>) } diff --git a/tests/mir-opt/inline/asm_unwind.main.Inline.diff b/tests/mir-opt/inline/asm_unwind.main.Inline.diff index f1b62ac38..ba1bfec05 100644 --- a/tests/mir-opt/inline/asm_unwind.main.Inline.diff +++ b/tests/mir-opt/inline/asm_unwind.main.Inline.diff @@ -7,7 +7,7 @@ + scope 1 (inlined foo) { // at $DIR/asm_unwind.rs:21:5: 21:10 + let _2: D; // in scope 1 at $DIR/asm_unwind.rs:15:9: 15:11 + scope 2 { -+ debug _d => _2; // in scope 2 at $DIR/asm_unwind.rs:15:9: 15:11 ++ debug _d => const D; // in scope 2 at $DIR/asm_unwind.rs:15:9: 15:11 + scope 3 { + } + } @@ -19,23 +19,23 @@ - // mir::Constant - // + span: $DIR/asm_unwind.rs:21:5: 21:8 - // + literal: Const { ty: fn() {foo}, val: Value(<ZST>) } -+ StorageLive(_2); // scope 1 at $DIR/asm_unwind.rs:15:9: 15:11 -+ asm!("", options(MAY_UNWIND)) -> [return: bb1, unwind: bb3]; // scope 3 at $DIR/asm_unwind.rs:16:14: 16:54 ++ StorageLive(_2); // scope 0 at $DIR/asm_unwind.rs:+1:5: +1:10 ++ asm!("", options(MAY_UNWIND)) -> [return: bb2, unwind: bb3]; // scope 3 at $DIR/asm_unwind.rs:16:14: 16:54 } bb1: { -+ drop(_2) -> bb2; // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 -+ } -+ -+ bb2: { -+ StorageDead(_2); // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 ++ StorageDead(_2); // scope 0 at $DIR/asm_unwind.rs:+1:5: +1:10 StorageDead(_1); // scope 0 at $DIR/asm_unwind.rs:+1:10: +1:11 _0 = const (); // scope 0 at $DIR/asm_unwind.rs:+0:15: +2:2 return; // scope 0 at $DIR/asm_unwind.rs:+2:2: +2:2 + } + ++ bb2: { ++ drop(_2) -> bb1; // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 ++ } ++ + bb3 (cleanup): { -+ drop(_2) -> bb4; // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 ++ drop(_2) -> [return: bb4, unwind terminate]; // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 + } + + bb4 (cleanup): { diff --git a/tests/mir-opt/inline/cycle.f.Inline.diff b/tests/mir-opt/inline/cycle.f.Inline.diff index 501390c3b..8da597577 100644 --- a/tests/mir-opt/inline/cycle.f.Inline.diff +++ b/tests/mir-opt/inline/cycle.f.Inline.diff @@ -33,7 +33,7 @@ } bb3 (cleanup): { - drop(_1) -> bb4; // scope 0 at $DIR/cycle.rs:+2:1: +2:2 + drop(_1) -> [return: bb4, unwind terminate]; // scope 0 at $DIR/cycle.rs:+2:1: +2:2 } bb4 (cleanup): { diff --git a/tests/mir-opt/inline/cycle.g.Inline.diff b/tests/mir-opt/inline/cycle.g.Inline.diff index 5f3ee467c..1e6e30f9e 100644 --- a/tests/mir-opt/inline/cycle.g.Inline.diff +++ b/tests/mir-opt/inline/cycle.g.Inline.diff @@ -5,11 +5,11 @@ let mut _0: (); // return place in scope 0 at $DIR/cycle.rs:+0:8: +0:8 let _1: (); // in scope 0 at $DIR/cycle.rs:+1:5: +1:12 + let mut _2: fn() {main}; // in scope 0 at $DIR/cycle.rs:+1:5: +1:12 ++ let mut _5: (); // in scope 0 at $DIR/cycle.rs:6:5: 6:8 + scope 1 (inlined f::<fn() {main}>) { // at $DIR/cycle.rs:12:5: 12:12 + debug g => _2; // in scope 1 at $DIR/cycle.rs:5:6: 5:7 + let _3: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8 + let mut _4: &fn() {main}; // in scope 1 at $DIR/cycle.rs:6:5: 6:6 -+ let mut _5: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8 + scope 2 (inlined <fn() {main} as Fn<()>>::call - shim(fn() {main})) { // at $DIR/cycle.rs:6:5: 6:8 + } + } @@ -25,14 +25,16 @@ - // mir::Constant // + span: $DIR/cycle.rs:12:7: 12:11 // + literal: Const { ty: fn() {main}, val: Value(<ZST>) } -+ StorageLive(_3); // scope 1 at $DIR/cycle.rs:6:5: 6:8 ++ StorageLive(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:12 + StorageLive(_4); // scope 1 at $DIR/cycle.rs:6:5: 6:6 + _4 = &_2; // scope 1 at $DIR/cycle.rs:6:5: 6:6 + StorageLive(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 ++ _5 = const (); // scope 1 at $DIR/cycle.rs:6:5: 6:8 + _3 = move (*_4)() -> [return: bb4, unwind: bb2]; // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL } bb1: { ++ StorageDead(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:12 + StorageDead(_2); // scope 0 at $DIR/cycle.rs:+1:5: +1:12 StorageDead(_1); // scope 0 at $DIR/cycle.rs:+1:12: +1:13 _0 = const (); // scope 0 at $DIR/cycle.rs:+0:8: +2:2 @@ -40,7 +42,7 @@ + } + + bb2 (cleanup): { -+ drop(_2) -> bb3; // scope 1 at $DIR/cycle.rs:7:1: 7:2 ++ drop(_2) -> [return: bb3, unwind terminate]; // scope 1 at $DIR/cycle.rs:7:1: 7:2 + } + + bb3 (cleanup): { @@ -48,9 +50,8 @@ + } + + bb4: { -+ StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:7: 6:8 ++ StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 + StorageDead(_4); // scope 1 at $DIR/cycle.rs:6:7: 6:8 -+ StorageDead(_3); // scope 1 at $DIR/cycle.rs:6:8: 6:9 + drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:7:1: 7:2 } } diff --git a/tests/mir-opt/inline/cycle.main.Inline.diff b/tests/mir-opt/inline/cycle.main.Inline.diff index 6b4c63bbd..315634945 100644 --- a/tests/mir-opt/inline/cycle.main.Inline.diff +++ b/tests/mir-opt/inline/cycle.main.Inline.diff @@ -5,11 +5,11 @@ let mut _0: (); // return place in scope 0 at $DIR/cycle.rs:+0:11: +0:11 let _1: (); // in scope 0 at $DIR/cycle.rs:+1:5: +1:9 + let mut _2: fn() {g}; // in scope 0 at $DIR/cycle.rs:+1:5: +1:9 ++ let mut _5: (); // in scope 0 at $DIR/cycle.rs:6:5: 6:8 + scope 1 (inlined f::<fn() {g}>) { // at $DIR/cycle.rs:17:5: 17:9 + debug g => _2; // in scope 1 at $DIR/cycle.rs:5:6: 5:7 + let _3: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8 + let mut _4: &fn() {g}; // in scope 1 at $DIR/cycle.rs:6:5: 6:6 -+ let mut _5: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8 + scope 2 (inlined <fn() {g} as Fn<()>>::call - shim(fn() {g})) { // at $DIR/cycle.rs:6:5: 6:8 + } + } @@ -25,14 +25,16 @@ - // mir::Constant // + span: $DIR/cycle.rs:17:7: 17:8 // + literal: Const { ty: fn() {g}, val: Value(<ZST>) } -+ StorageLive(_3); // scope 1 at $DIR/cycle.rs:6:5: 6:8 ++ StorageLive(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:9 + StorageLive(_4); // scope 1 at $DIR/cycle.rs:6:5: 6:6 + _4 = &_2; // scope 1 at $DIR/cycle.rs:6:5: 6:6 + StorageLive(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 ++ _5 = const (); // scope 1 at $DIR/cycle.rs:6:5: 6:8 + _3 = move (*_4)() -> [return: bb4, unwind: bb2]; // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL } bb1: { ++ StorageDead(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:9 + StorageDead(_2); // scope 0 at $DIR/cycle.rs:+1:5: +1:9 StorageDead(_1); // scope 0 at $DIR/cycle.rs:+1:9: +1:10 _0 = const (); // scope 0 at $DIR/cycle.rs:+0:11: +2:2 @@ -40,7 +42,7 @@ + } + + bb2 (cleanup): { -+ drop(_2) -> bb3; // scope 1 at $DIR/cycle.rs:7:1: 7:2 ++ drop(_2) -> [return: bb3, unwind terminate]; // scope 1 at $DIR/cycle.rs:7:1: 7:2 + } + + bb3 (cleanup): { @@ -48,9 +50,8 @@ + } + + bb4: { -+ StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:7: 6:8 ++ StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 + StorageDead(_4); // scope 1 at $DIR/cycle.rs:6:7: 6:8 -+ StorageDead(_3); // scope 1 at $DIR/cycle.rs:6:8: 6:9 + drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:7:1: 7:2 } } diff --git a/tests/mir-opt/inline/dyn_trait.get_query.Inline.diff b/tests/mir-opt/inline/dyn_trait.get_query.Inline.diff index 64c3e47ff..75d9bd54d 100644 --- a/tests/mir-opt/inline/dyn_trait.get_query.Inline.diff +++ b/tests/mir-opt/inline/dyn_trait.get_query.Inline.diff @@ -9,11 +9,11 @@ let mut _4: &<Q as Query>::C; // in scope 0 at $DIR/dyn_trait.rs:+2:23: +2:24 scope 1 { debug c => _2; // in scope 1 at $DIR/dyn_trait.rs:+1:9: +1:10 -+ scope 2 (inlined try_execute_query::<<Q as Query>::C>) { // at $DIR/dyn_trait.rs:34:5: 34:25 -+ debug c => _4; // in scope 2 at $DIR/dyn_trait.rs:26:36: 26:37 -+ let mut _5: &dyn Cache<V = <Q as Query>::V>; // in scope 2 at $DIR/dyn_trait.rs:27:14: 27:15 -+ scope 3 (inlined mk_cycle::<<Q as Query>::V>) { // at $DIR/dyn_trait.rs:27:5: 27:16 -+ debug c => _5; // in scope 3 at $DIR/dyn_trait.rs:20:27: 20:28 ++ scope 2 (inlined try_execute_query::<<Q as Query>::C>) { // at $DIR/dyn_trait.rs:35:5: 35:25 ++ debug c => _4; // in scope 2 at $DIR/dyn_trait.rs:27:36: 27:37 ++ let mut _5: &dyn Cache<V = <Q as Query>::V>; // in scope 2 at $DIR/dyn_trait.rs:28:14: 28:15 ++ scope 3 (inlined mk_cycle::<<Q as Query>::V>) { // at $DIR/dyn_trait.rs:28:5: 28:16 ++ debug c => _5; // in scope 3 at $DIR/dyn_trait.rs:21:27: 21:28 + } + } } @@ -24,7 +24,7 @@ _3 = &(*_1); // scope 0 at $DIR/dyn_trait.rs:+1:22: +1:23 _2 = <Q as Query>::cache::<T>(move _3) -> bb1; // scope 0 at $DIR/dyn_trait.rs:+1:13: +1:24 // mir::Constant - // + span: $DIR/dyn_trait.rs:33:13: 33:21 + // + span: $DIR/dyn_trait.rs:34:13: 34:21 // + user_ty: UserType(0) // + literal: Const { ty: for<'a> fn(&'a T) -> &'a <Q as Query>::C {<Q as Query>::cache::<T>}, val: Value(<ZST>) } } @@ -34,18 +34,18 @@ StorageLive(_4); // scope 1 at $DIR/dyn_trait.rs:+2:23: +2:24 _4 = &(*_2); // scope 1 at $DIR/dyn_trait.rs:+2:23: +2:24 - _0 = try_execute_query::<<Q as Query>::C>(move _4) -> bb2; // scope 1 at $DIR/dyn_trait.rs:+2:5: +2:25 -+ StorageLive(_5); // scope 2 at $DIR/dyn_trait.rs:27:14: 27:15 -+ _5 = _4 as &dyn Cache<V = <Q as Query>::V> (Pointer(Unsize)); // scope 2 at $DIR/dyn_trait.rs:27:14: 27:15 -+ _0 = <dyn Cache<V = <Q as Query>::V> as Cache>::store_nocache(_5) -> bb2; // scope 3 at $DIR/dyn_trait.rs:21:5: 21:22 ++ StorageLive(_5); // scope 2 at $DIR/dyn_trait.rs:28:14: 28:15 ++ _5 = _4 as &dyn Cache<V = <Q as Query>::V> (Pointer(Unsize)); // scope 2 at $DIR/dyn_trait.rs:28:14: 28:15 ++ _0 = <dyn Cache<V = <Q as Query>::V> as Cache>::store_nocache(_5) -> bb2; // scope 3 at $DIR/dyn_trait.rs:22:5: 22:22 // mir::Constant -- // + span: $DIR/dyn_trait.rs:34:5: 34:22 +- // + span: $DIR/dyn_trait.rs:35:5: 35:22 - // + literal: Const { ty: for<'a> fn(&'a <Q as Query>::C) {try_execute_query::<<Q as Query>::C>}, val: Value(<ZST>) } -+ // + span: $DIR/dyn_trait.rs:21:7: 21:20 ++ // + span: $DIR/dyn_trait.rs:22:7: 22:20 + // + literal: Const { ty: for<'a> fn(&'a dyn Cache<V = <Q as Query>::V>) {<dyn Cache<V = <Q as Query>::V> as Cache>::store_nocache}, val: Value(<ZST>) } } bb2: { -+ StorageDead(_5); // scope 2 at $DIR/dyn_trait.rs:27:15: 27:16 ++ StorageDead(_5); // scope 2 at $DIR/dyn_trait.rs:28:15: 28:16 StorageDead(_4); // scope 1 at $DIR/dyn_trait.rs:+2:24: +2:25 StorageDead(_2); // scope 0 at $DIR/dyn_trait.rs:+3:1: +3:2 return; // scope 0 at $DIR/dyn_trait.rs:+3:2: +3:2 diff --git a/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff b/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff index 7653a5ded..925c95988 100644 --- a/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff +++ b/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff @@ -11,7 +11,7 @@ _2 = &(*_1); // scope 0 at $DIR/dyn_trait.rs:+1:5: +1:22 _0 = <dyn Cache<V = V> as Cache>::store_nocache(move _2) -> bb1; // scope 0 at $DIR/dyn_trait.rs:+1:5: +1:22 // mir::Constant - // + span: $DIR/dyn_trait.rs:21:7: 21:20 + // + span: $DIR/dyn_trait.rs:22:7: 22:20 // + literal: Const { ty: for<'a> fn(&'a dyn Cache<V = V>) {<dyn Cache<V = V> as Cache>::store_nocache}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/inline/dyn_trait.rs b/tests/mir-opt/inline/dyn_trait.rs index 6a46e1e07..2af81f825 100644 --- a/tests/mir-opt/inline/dyn_trait.rs +++ b/tests/mir-opt/inline/dyn_trait.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default #![crate_type = "lib"] use std::fmt::Debug; diff --git a/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff b/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff index 3fa9c3e88..f4e5272ab 100644 --- a/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff +++ b/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff @@ -6,8 +6,8 @@ let mut _0: (); // return place in scope 0 at $DIR/dyn_trait.rs:+0:43: +0:43 let mut _2: &dyn Cache<V = <C as Cache>::V>; // in scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15 let mut _3: &C; // in scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15 -+ scope 1 (inlined mk_cycle::<<C as Cache>::V>) { // at $DIR/dyn_trait.rs:27:5: 27:16 -+ debug c => _2; // in scope 1 at $DIR/dyn_trait.rs:20:27: 20:28 ++ scope 1 (inlined mk_cycle::<<C as Cache>::V>) { // at $DIR/dyn_trait.rs:28:5: 28:16 ++ debug c => _2; // in scope 1 at $DIR/dyn_trait.rs:21:27: 21:28 + } bb0: { @@ -17,11 +17,11 @@ _2 = move _3 as &dyn Cache<V = <C as Cache>::V> (Pointer(Unsize)); // scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15 StorageDead(_3); // scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15 - _0 = mk_cycle::<<C as Cache>::V>(move _2) -> bb1; // scope 0 at $DIR/dyn_trait.rs:+1:5: +1:16 -+ _0 = <dyn Cache<V = <C as Cache>::V> as Cache>::store_nocache(_2) -> bb1; // scope 1 at $DIR/dyn_trait.rs:21:5: 21:22 ++ _0 = <dyn Cache<V = <C as Cache>::V> as Cache>::store_nocache(_2) -> bb1; // scope 1 at $DIR/dyn_trait.rs:22:5: 22:22 // mir::Constant -- // + span: $DIR/dyn_trait.rs:27:5: 27:13 +- // + span: $DIR/dyn_trait.rs:28:5: 28:13 - // + literal: Const { ty: for<'a> fn(&'a (dyn Cache<V = <C as Cache>::V> + 'a)) {mk_cycle::<<C as Cache>::V>}, val: Value(<ZST>) } -+ // + span: $DIR/dyn_trait.rs:21:7: 21:20 ++ // + span: $DIR/dyn_trait.rs:22:7: 22:20 + // + literal: Const { ty: for<'a> fn(&'a dyn Cache<V = <C as Cache>::V>) {<dyn Cache<V = <C as Cache>::V> as Cache>::store_nocache}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/inline/exponential_runtime.main.Inline.diff b/tests/mir-opt/inline/exponential_runtime.main.Inline.diff index 7fd62be7a..30af8661d 100644 --- a/tests/mir-opt/inline/exponential_runtime.main.Inline.diff +++ b/tests/mir-opt/inline/exponential_runtime.main.Inline.diff @@ -4,72 +4,72 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/exponential_runtime.rs:+0:11: +0:11 let _1: (); // in scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 -+ scope 1 (inlined <() as G>::call) { // at $DIR/exponential_runtime.rs:86:5: 86:22 -+ let _2: (); // in scope 1 at $DIR/exponential_runtime.rs:73:9: 73:25 -+ let _3: (); // in scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 -+ let _4: (); // in scope 1 at $DIR/exponential_runtime.rs:75:9: 75:25 -+ scope 2 (inlined <() as F>::call) { // at $DIR/exponential_runtime.rs:73:9: 73:25 -+ let _5: (); // in scope 2 at $DIR/exponential_runtime.rs:61:9: 61:25 -+ let _6: (); // in scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 -+ let _7: (); // in scope 2 at $DIR/exponential_runtime.rs:63:9: 63:25 ++ scope 1 (inlined <() as G>::call) { // at $DIR/exponential_runtime.rs:87:5: 87:22 ++ let _2: (); // in scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 ++ let _3: (); // in scope 1 at $DIR/exponential_runtime.rs:75:9: 75:25 ++ let _4: (); // in scope 1 at $DIR/exponential_runtime.rs:76:9: 76:25 ++ scope 2 (inlined <() as F>::call) { // at $DIR/exponential_runtime.rs:74:9: 74:25 ++ let _5: (); // in scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 ++ let _6: (); // in scope 2 at $DIR/exponential_runtime.rs:63:9: 63:25 ++ let _7: (); // in scope 2 at $DIR/exponential_runtime.rs:64:9: 64:25 + } + } bb0: { StorageLive(_1); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 - _1 = <() as G>::call() -> bb1; // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 -+ StorageLive(_2); // scope 1 at $DIR/exponential_runtime.rs:73:9: 73:25 -+ StorageLive(_5); // scope 2 at $DIR/exponential_runtime.rs:61:9: 61:25 -+ _5 = <() as E>::call() -> bb3; // scope 2 at $DIR/exponential_runtime.rs:61:9: 61:25 ++ StorageLive(_2); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 ++ StorageLive(_3); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 ++ StorageLive(_4); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 ++ StorageLive(_5); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 ++ StorageLive(_6); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 ++ StorageLive(_7); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 ++ _5 = <() as E>::call() -> bb4; // scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 // mir::Constant -- // + span: $DIR/exponential_runtime.rs:86:5: 86:20 +- // + span: $DIR/exponential_runtime.rs:87:5: 87:20 - // + literal: Const { ty: fn() {<() as G>::call}, val: Value(<ZST>) } -+ // + span: $DIR/exponential_runtime.rs:61:9: 61:23 ++ // + span: $DIR/exponential_runtime.rs:62:9: 62:23 + // + literal: Const { ty: fn() {<() as E>::call}, val: Value(<ZST>) } } bb1: { -+ StorageDead(_3); // scope 1 at $DIR/exponential_runtime.rs:74:25: 74:26 -+ StorageLive(_4); // scope 1 at $DIR/exponential_runtime.rs:75:9: 75:25 -+ _4 = <() as F>::call() -> bb2; // scope 1 at $DIR/exponential_runtime.rs:75:9: 75:25 -+ // mir::Constant -+ // + span: $DIR/exponential_runtime.rs:75:9: 75:23 -+ // + literal: Const { ty: fn() {<() as F>::call}, val: Value(<ZST>) } -+ } -+ -+ bb2: { -+ StorageDead(_4); // scope 1 at $DIR/exponential_runtime.rs:75:25: 75:26 ++ StorageDead(_4); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 ++ StorageDead(_3); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 ++ StorageDead(_2); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 StorageDead(_1); // scope 0 at $DIR/exponential_runtime.rs:+1:22: +1:23 _0 = const (); // scope 0 at $DIR/exponential_runtime.rs:+0:11: +2:2 return; // scope 0 at $DIR/exponential_runtime.rs:+2:2: +2:2 + } + ++ bb2: { ++ StorageDead(_7); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 ++ StorageDead(_6); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 ++ StorageDead(_5); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 ++ _3 = <() as F>::call() -> bb3; // scope 1 at $DIR/exponential_runtime.rs:75:9: 75:25 ++ // mir::Constant ++ // + span: $DIR/exponential_runtime.rs:75:9: 75:23 ++ // + literal: Const { ty: fn() {<() as F>::call}, val: Value(<ZST>) } ++ } ++ + bb3: { -+ StorageDead(_5); // scope 2 at $DIR/exponential_runtime.rs:61:25: 61:26 -+ StorageLive(_6); // scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 -+ _6 = <() as E>::call() -> bb4; // scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 ++ _4 = <() as F>::call() -> bb1; // scope 1 at $DIR/exponential_runtime.rs:76:9: 76:25 + // mir::Constant -+ // + span: $DIR/exponential_runtime.rs:62:9: 62:23 -+ // + literal: Const { ty: fn() {<() as E>::call}, val: Value(<ZST>) } ++ // + span: $DIR/exponential_runtime.rs:76:9: 76:23 ++ // + literal: Const { ty: fn() {<() as F>::call}, val: Value(<ZST>) } + } + + bb4: { -+ StorageDead(_6); // scope 2 at $DIR/exponential_runtime.rs:62:25: 62:26 -+ StorageLive(_7); // scope 2 at $DIR/exponential_runtime.rs:63:9: 63:25 -+ _7 = <() as E>::call() -> bb5; // scope 2 at $DIR/exponential_runtime.rs:63:9: 63:25 ++ _6 = <() as E>::call() -> bb5; // scope 2 at $DIR/exponential_runtime.rs:63:9: 63:25 + // mir::Constant + // + span: $DIR/exponential_runtime.rs:63:9: 63:23 + // + literal: Const { ty: fn() {<() as E>::call}, val: Value(<ZST>) } + } + + bb5: { -+ StorageDead(_7); // scope 2 at $DIR/exponential_runtime.rs:63:25: 63:26 -+ StorageDead(_2); // scope 1 at $DIR/exponential_runtime.rs:73:25: 73:26 -+ StorageLive(_3); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 -+ _3 = <() as F>::call() -> bb1; // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 ++ _7 = <() as E>::call() -> bb2; // scope 2 at $DIR/exponential_runtime.rs:64:9: 64:25 + // mir::Constant -+ // + span: $DIR/exponential_runtime.rs:74:9: 74:23 -+ // + literal: Const { ty: fn() {<() as F>::call}, val: Value(<ZST>) } ++ // + span: $DIR/exponential_runtime.rs:64:9: 64:23 ++ // + literal: Const { ty: fn() {<() as E>::call}, val: Value(<ZST>) } } } diff --git a/tests/mir-opt/inline/exponential_runtime.rs b/tests/mir-opt/inline/exponential_runtime.rs index d9219d76a..39985528f 100644 --- a/tests/mir-opt/inline/exponential_runtime.rs +++ b/tests/mir-opt/inline/exponential_runtime.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // Checks that code with exponential runtime does not have exponential behavior in inlining. trait A { diff --git a/tests/mir-opt/inline/inline_closure.foo.Inline.after.mir b/tests/mir-opt/inline/inline_closure.foo.Inline.after.mir index fff8d0171..1d2f99cbe 100644 --- a/tests/mir-opt/inline/inline_closure.foo.Inline.after.mir +++ b/tests/mir-opt/inline/inline_closure.foo.Inline.after.mir @@ -23,7 +23,7 @@ fn foo(_1: T, _2: i32) -> i32 { StorageLive(_3); // scope 0 at $DIR/inline_closure.rs:+1:9: +1:10 _3 = [closure@foo::<T>::{closure#0}]; // scope 0 at $DIR/inline_closure.rs:+1:13: +1:24 // closure - // + def_id: DefId(0:6 ~ inline_closure[92ba]::foo::{closure#0}) + // + def_id: DefId(0:6 ~ inline_closure[8f32]::foo::{closure#0}) // + substs: [ // T, // i8, diff --git a/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir b/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir index dab204306..80274bb7e 100644 --- a/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir +++ b/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir @@ -26,7 +26,7 @@ fn foo(_1: T, _2: &i32) -> i32 { StorageLive(_3); // scope 0 at $DIR/inline_closure_borrows_arg.rs:+1:9: +1:10 _3 = [closure@foo::<T>::{closure#0}]; // scope 0 at $DIR/inline_closure_borrows_arg.rs:+1:13: +4:6 // closure - // + def_id: DefId(0:6 ~ inline_closure_borrows_arg[96e9]::foo::{closure#0}) + // + def_id: DefId(0:6 ~ inline_closure_borrows_arg[f89f]::foo::{closure#0}) // + substs: [ // T, // i8, diff --git a/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir b/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir index 84fd051e0..b36711f82 100644 --- a/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir +++ b/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir @@ -32,7 +32,7 @@ fn foo(_1: T, _2: i32) -> (i32, T) { _5 = &_1; // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24 _3 = [closure@foo::<T>::{closure#0}] { q: move _4, t: move _5 }; // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24 // closure - // + def_id: DefId(0:6 ~ inline_closure_captures[8bc0]::foo::{closure#0}) + // + def_id: DefId(0:6 ~ inline_closure_captures[63a5]::foo::{closure#0}) // + substs: [ // T, // i8, diff --git a/tests/mir-opt/inline/inline_cycle.one.Inline.diff b/tests/mir-opt/inline/inline_cycle.one.Inline.diff index 5510cd7bc..f6ba69a1d 100644 --- a/tests/mir-opt/inline/inline_cycle.one.Inline.diff +++ b/tests/mir-opt/inline/inline_cycle.one.Inline.diff @@ -4,9 +4,9 @@ fn one() -> () { let mut _0: (); // return place in scope 0 at $DIR/inline_cycle.rs:+0:10: +0:10 let _1: (); // in scope 0 at $DIR/inline_cycle.rs:+1:5: +1:24 -+ scope 1 (inlined <C as Call>::call) { // at $DIR/inline_cycle.rs:14:5: 14:24 -+ scope 2 (inlined <A<C> as Call>::call) { // at $DIR/inline_cycle.rs:43:9: 43:23 -+ scope 3 (inlined <B<C> as Call>::call) { // at $DIR/inline_cycle.rs:28:9: 28:31 ++ scope 1 (inlined <C as Call>::call) { // at $DIR/inline_cycle.rs:15:5: 15:24 ++ scope 2 (inlined <A<C> as Call>::call) { // at $DIR/inline_cycle.rs:44:9: 44:23 ++ scope 3 (inlined <B<C> as Call>::call) { // at $DIR/inline_cycle.rs:29:9: 29:31 + } + } + } @@ -14,10 +14,10 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:24 - _1 = <C as Call>::call() -> bb1; // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:24 -+ _1 = <C as Call>::call() -> bb1; // scope 3 at $DIR/inline_cycle.rs:36:9: 36:28 ++ _1 = <C as Call>::call() -> bb1; // scope 3 at $DIR/inline_cycle.rs:37:9: 37:28 // mir::Constant -- // + span: $DIR/inline_cycle.rs:14:5: 14:22 -+ // + span: $DIR/inline_cycle.rs:36:9: 36:26 +- // + span: $DIR/inline_cycle.rs:15:5: 15:22 ++ // + span: $DIR/inline_cycle.rs:37:9: 37:26 // + literal: Const { ty: fn() {<C as Call>::call}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/inline/inline_cycle.rs b/tests/mir-opt/inline/inline_cycle.rs index 63ad57de1..2f81696cf 100644 --- a/tests/mir-opt/inline/inline_cycle.rs +++ b/tests/mir-opt/inline/inline_cycle.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // Check that inliner handles various forms of recursion and doesn't fall into // an infinite inlining cycle. The particular outcome of inlining is not // crucial otherwise. diff --git a/tests/mir-opt/inline/inline_cycle.two.Inline.diff b/tests/mir-opt/inline/inline_cycle.two.Inline.diff index 64c0065b5..c8f58111d 100644 --- a/tests/mir-opt/inline/inline_cycle.two.Inline.diff +++ b/tests/mir-opt/inline/inline_cycle.two.Inline.diff @@ -5,11 +5,11 @@ let mut _0: (); // return place in scope 0 at $DIR/inline_cycle.rs:+0:10: +0:10 let _1: (); // in scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 + let mut _2: fn() {f}; // in scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 -+ scope 1 (inlined call::<fn() {f}>) { // at $DIR/inline_cycle.rs:49:5: 49:12 -+ debug f => _2; // in scope 1 at $DIR/inline_cycle.rs:53:22: 53:23 -+ let _3: (); // in scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 -+ let mut _4: (); // in scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 -+ scope 2 (inlined <fn() {f} as FnOnce<()>>::call_once - shim(fn() {f})) { // at $DIR/inline_cycle.rs:54:5: 54:8 ++ let mut _4: (); // in scope 0 at $DIR/inline_cycle.rs:55:5: 55:8 ++ scope 1 (inlined call::<fn() {f}>) { // at $DIR/inline_cycle.rs:50:5: 50:12 ++ debug f => _2; // in scope 1 at $DIR/inline_cycle.rs:54:22: 54:23 ++ let _3: (); // in scope 1 at $DIR/inline_cycle.rs:55:5: 55:8 ++ scope 2 (inlined <fn() {f} as FnOnce<()>>::call_once - shim(fn() {f})) { // at $DIR/inline_cycle.rs:55:5: 55:8 + } + } @@ -19,19 +19,20 @@ + StorageLive(_2); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 + _2 = f; // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 // mir::Constant -- // + span: $DIR/inline_cycle.rs:49:5: 49:9 +- // + span: $DIR/inline_cycle.rs:50:5: 50:9 - // + literal: Const { ty: fn(fn() {f}) {call::<fn() {f}>}, val: Value(<ZST>) } - // mir::Constant - // + span: $DIR/inline_cycle.rs:49:10: 49:11 + // + span: $DIR/inline_cycle.rs:50:10: 50:11 // + literal: Const { ty: fn() {f}, val: Value(<ZST>) } -+ StorageLive(_3); // scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 -+ StorageLive(_4); // scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 ++ StorageLive(_3); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 ++ StorageLive(_4); // scope 1 at $DIR/inline_cycle.rs:55:5: 55:8 ++ _4 = const (); // scope 1 at $DIR/inline_cycle.rs:55:5: 55:8 + _3 = move _2() -> bb1; // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL } bb1: { -+ StorageDead(_4); // scope 1 at $DIR/inline_cycle.rs:54:7: 54:8 -+ StorageDead(_3); // scope 1 at $DIR/inline_cycle.rs:54:8: 54:9 ++ StorageDead(_4); // scope 1 at $DIR/inline_cycle.rs:55:5: 55:8 ++ StorageDead(_3); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 + StorageDead(_2); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 StorageDead(_1); // scope 0 at $DIR/inline_cycle.rs:+1:12: +1:13 _0 = const (); // scope 0 at $DIR/inline_cycle.rs:+0:10: +2:2 diff --git a/tests/mir-opt/inline/inline_cycle_generic.main.Inline.diff b/tests/mir-opt/inline/inline_cycle_generic.main.Inline.diff index 52debab4d..9429ca593 100644 --- a/tests/mir-opt/inline/inline_cycle_generic.main.Inline.diff +++ b/tests/mir-opt/inline/inline_cycle_generic.main.Inline.diff @@ -4,23 +4,20 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/inline_cycle_generic.rs:+0:11: +0:11 let _1: (); // in scope 0 at $DIR/inline_cycle_generic.rs:+1:5: +1:24 -+ scope 1 (inlined <C as Call>::call) { // at $DIR/inline_cycle_generic.rs:9:5: 9:24 -+ scope 2 (inlined <B<A> as Call>::call) { // at $DIR/inline_cycle_generic.rs:38:9: 38:31 -+ scope 3 (inlined <A as Call>::call) { // at $DIR/inline_cycle_generic.rs:31:9: 31:28 -+ scope 4 (inlined <B<C> as Call>::call) { // at $DIR/inline_cycle_generic.rs:23:9: 23:31 -+ } -+ } ++ scope 1 (inlined <C as Call>::call) { // at $DIR/inline_cycle_generic.rs:10:5: 10:24 ++ scope 2 (inlined <B<A> as Call>::call) { // at $DIR/inline_cycle_generic.rs:39:9: 39:31 + } + } bb0: { StorageLive(_1); // scope 0 at $DIR/inline_cycle_generic.rs:+1:5: +1:24 - _1 = <C as Call>::call() -> bb1; // scope 0 at $DIR/inline_cycle_generic.rs:+1:5: +1:24 -+ _1 = <C as Call>::call() -> bb1; // scope 4 at $DIR/inline_cycle_generic.rs:31:9: 31:28 ++ _1 = <A as Call>::call() -> bb1; // scope 2 at $DIR/inline_cycle_generic.rs:32:9: 32:28 // mir::Constant -- // + span: $DIR/inline_cycle_generic.rs:9:5: 9:22 -+ // + span: $DIR/inline_cycle_generic.rs:31:9: 31:26 - // + literal: Const { ty: fn() {<C as Call>::call}, val: Value(<ZST>) } +- // + span: $DIR/inline_cycle_generic.rs:10:5: 10:22 +- // + literal: Const { ty: fn() {<C as Call>::call}, val: Value(<ZST>) } ++ // + span: $DIR/inline_cycle_generic.rs:32:9: 32:26 ++ // + literal: Const { ty: fn() {<A as Call>::call}, val: Value(<ZST>) } } bb1: { diff --git a/tests/mir-opt/inline/inline_cycle_generic.rs b/tests/mir-opt/inline/inline_cycle_generic.rs index 24b4f3793..84e6e4005 100644 --- a/tests/mir-opt/inline/inline_cycle_generic.rs +++ b/tests/mir-opt/inline/inline_cycle_generic.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // Check that inliner handles various forms of recursion and doesn't fall into // an infinite inlining cycle. The particular outcome of inlining is not // crucial otherwise. diff --git a/tests/mir-opt/inline/inline_diverging.g.Inline.diff b/tests/mir-opt/inline/inline_diverging.g.Inline.diff index b787a19f4..4f22ad437 100644 --- a/tests/mir-opt/inline/inline_diverging.g.Inline.diff +++ b/tests/mir-opt/inline/inline_diverging.g.Inline.diff @@ -34,7 +34,7 @@ bb2: { StorageLive(_6); // scope 0 at $DIR/inline_diverging.rs:+4:9: +4:16 - _6 = panic(); // scope 0 at $DIR/inline_diverging.rs:+4:9: +4:16 -+ StorageLive(_7); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL ++ StorageLive(_7); // scope 0 at $DIR/inline_diverging.rs:+4:9: +4:16 + _7 = begin_panic::<&str>(const "explicit panic"); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL // mir::Constant - // + span: $DIR/inline_diverging.rs:16:9: 16:14 diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.diff index e1b2f7dbf..d501b6ca8 100644 --- a/tests/mir-opt/inline/inline_diverging.h.Inline.diff +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.diff @@ -5,19 +5,18 @@ let mut _0: (); // return place in scope 0 at $DIR/inline_diverging.rs:+0:12: +0:12 let _1: (!, !); // in scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22 + let mut _2: fn() -> ! {sleep}; // in scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22 ++ let mut _8: (); // in scope 0 at $DIR/inline_diverging.rs:27:13: 27:16 + scope 1 (inlined call_twice::<!, fn() -> ! {sleep}>) { // at $DIR/inline_diverging.rs:22:5: 22:22 + debug f => _2; // in scope 1 at $DIR/inline_diverging.rs:26:36: 26:37 + let _3: !; // in scope 1 at $DIR/inline_diverging.rs:27:9: 27:10 + let mut _4: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline_diverging.rs:27:13: 27:14 -+ let mut _5: (); // in scope 1 at $DIR/inline_diverging.rs:27:13: 27:16 -+ let mut _6: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline_diverging.rs:28:13: 28:14 -+ let mut _7: (); // in scope 1 at $DIR/inline_diverging.rs:28:13: 28:16 -+ let mut _8: !; // in scope 1 at $DIR/inline_diverging.rs:29:6: 29:7 -+ let mut _9: !; // in scope 1 at $DIR/inline_diverging.rs:29:9: 29:10 ++ let mut _5: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline_diverging.rs:28:13: 28:14 ++ let mut _6: !; // in scope 1 at $DIR/inline_diverging.rs:29:6: 29:7 ++ let mut _7: !; // in scope 1 at $DIR/inline_diverging.rs:29:9: 29:10 + scope 2 { + debug a => _3; // in scope 2 at $DIR/inline_diverging.rs:27:9: 27:10 + scope 3 { -+ debug b => _9; // in scope 3 at $DIR/inline_diverging.rs:28:9: 28:10 ++ debug b => _7; // in scope 3 at $DIR/inline_diverging.rs:28:9: 28:10 + } + } + scope 4 (inlined <fn() -> ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { // at $DIR/inline_diverging.rs:27:13: 27:16 @@ -35,21 +34,21 @@ - // mir::Constant // + span: $DIR/inline_diverging.rs:22:16: 22:21 // + literal: Const { ty: fn() -> ! {sleep}, val: Value(<ZST>) } -+ StorageLive(_9); // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22 ++ StorageLive(_7); // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22 + StorageLive(_3); // scope 1 at $DIR/inline_diverging.rs:27:9: 27:10 + StorageLive(_4); // scope 1 at $DIR/inline_diverging.rs:27:13: 27:14 + _4 = &_2; // scope 1 at $DIR/inline_diverging.rs:27:13: 27:14 -+ StorageLive(_5); // scope 1 at $DIR/inline_diverging.rs:27:13: 27:16 ++ StorageLive(_8); // scope 1 at $DIR/inline_diverging.rs:27:13: 27:16 ++ _8 = const (); // scope 1 at $DIR/inline_diverging.rs:27:13: 27:16 + _3 = move (*_4)() -> [return: bb6, unwind: bb4]; // scope 4 at $SRC_DIR/core/src/ops/function.rs:LL:COL + } + + bb1: { -+ StorageDead(_7); // scope 2 at $DIR/inline_diverging.rs:28:15: 28:16 -+ StorageDead(_6); // scope 2 at $DIR/inline_diverging.rs:28:15: 28:16 -+ StorageLive(_8); // scope 3 at $DIR/inline_diverging.rs:29:6: 29:7 -+ _8 = move _3; // scope 3 at $DIR/inline_diverging.rs:29:6: 29:7 -+ _1 = (move _8, move _9); // scope 3 at $DIR/inline_diverging.rs:29:5: 29:11 -+ StorageDead(_8); // scope 3 at $DIR/inline_diverging.rs:29:10: 29:11 ++ StorageDead(_5); // scope 2 at $DIR/inline_diverging.rs:28:15: 28:16 ++ StorageLive(_6); // scope 3 at $DIR/inline_diverging.rs:29:6: 29:7 ++ _6 = move _3; // scope 3 at $DIR/inline_diverging.rs:29:6: 29:7 ++ _1 = (move _6, move _7); // scope 3 at $DIR/inline_diverging.rs:29:5: 29:11 ++ StorageDead(_6); // scope 3 at $DIR/inline_diverging.rs:29:10: 29:11 + StorageDead(_3); // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 + drop(_2) -> bb2; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 + } @@ -59,11 +58,11 @@ + } + + bb3 (cleanup): { -+ drop(_3) -> bb4; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 ++ drop(_3) -> [return: bb4, unwind terminate]; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 + } + + bb4 (cleanup): { -+ drop(_2) -> bb5; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 ++ drop(_2) -> [return: bb5, unwind terminate]; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 + } + + bb5 (cleanup): { @@ -71,12 +70,11 @@ + } + + bb6: { -+ StorageDead(_5); // scope 1 at $DIR/inline_diverging.rs:27:15: 27:16 ++ StorageDead(_8); // scope 1 at $DIR/inline_diverging.rs:27:13: 27:16 + StorageDead(_4); // scope 1 at $DIR/inline_diverging.rs:27:15: 27:16 -+ StorageLive(_6); // scope 2 at $DIR/inline_diverging.rs:28:13: 28:14 -+ _6 = &_2; // scope 2 at $DIR/inline_diverging.rs:28:13: 28:14 -+ StorageLive(_7); // scope 2 at $DIR/inline_diverging.rs:28:13: 28:16 -+ _9 = <fn() -> ! {sleep} as Fn<()>>::call(move _6, move _7) -> [return: bb1, unwind: bb3]; // scope 2 at $DIR/inline_diverging.rs:28:13: 28:16 ++ StorageLive(_5); // scope 2 at $DIR/inline_diverging.rs:28:13: 28:14 ++ _5 = &_2; // scope 2 at $DIR/inline_diverging.rs:28:13: 28:14 ++ _7 = <fn() -> ! {sleep} as Fn<()>>::call(move _5, const ()) -> [return: bb1, unwind: bb3]; // scope 2 at $DIR/inline_diverging.rs:28:13: 28:16 + // mir::Constant + // + span: $DIR/inline_diverging.rs:28:13: 28:14 + // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a fn() -> ! {sleep}, ()) -> <fn() -> ! {sleep} as FnOnce<()>>::Output {<fn() -> ! {sleep} as Fn<()>>::call}, val: Value(<ZST>) } diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.diff b/tests/mir-opt/inline/inline_generator.main.Inline.diff index 01f5052b6..c3ca2d7d4 100644 --- a/tests/mir-opt/inline/inline_generator.main.Inline.diff +++ b/tests/mir-opt/inline/inline_generator.main.Inline.diff @@ -44,7 +44,7 @@ - bb1: { + _4 = [generator@$DIR/inline_generator.rs:15:5: 15:8 (#0)]; // scope 2 at $DIR/inline_generator.rs:15:5: 15:41 + // generator -+ // + def_id: DefId(0:7 ~ inline_generator[ea31]::g::{closure#0}) ++ // + def_id: DefId(0:7 ~ inline_generator[e37e]::g::{closure#0}) + // + substs: [ + // bool, + // i32, diff --git a/tests/mir-opt/inline/inline_instruction_set.default.Inline.diff b/tests/mir-opt/inline/inline_instruction_set.default.Inline.diff index f1988ea4b..a1d2423ae 100644 --- a/tests/mir-opt/inline/inline_instruction_set.default.Inline.diff +++ b/tests/mir-opt/inline/inline_instruction_set.default.Inline.diff @@ -16,7 +16,7 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 - _1 = instruction_set_a32() -> bb1; // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 + _1 = instruction_set_a32() -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 // mir::Constant // + span: $DIR/inline_instruction_set.rs:57:5: 57:24 // + literal: Const { ty: fn() {instruction_set_a32}, val: Value(<ZST>) } @@ -25,7 +25,7 @@ bb1: { StorageDead(_1); // scope 0 at $DIR/inline_instruction_set.rs:+1:26: +1:27 StorageLive(_2); // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 - _2 = instruction_set_t32() -> bb2; // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 + _2 = instruction_set_t32() -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 // mir::Constant // + span: $DIR/inline_instruction_set.rs:58:5: 58:24 // + literal: Const { ty: fn() {instruction_set_t32}, val: Value(<ZST>) } @@ -34,7 +34,7 @@ bb2: { StorageDead(_2); // scope 0 at $DIR/inline_instruction_set.rs:+2:26: +2:27 StorageLive(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 -- _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 +- _3 = instruction_set_default() -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 - // mir::Constant - // + span: $DIR/inline_instruction_set.rs:59:5: 59:28 - // + literal: Const { ty: fn() {instruction_set_default}, val: Value(<ZST>) } @@ -43,11 +43,11 @@ - bb3: { StorageDead(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:30: +3:31 StorageLive(_4); // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 -- _4 = inline_always_and_using_inline_asm() -> bb4; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 +- _4 = inline_always_and_using_inline_asm() -> [return: bb4, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 - // mir::Constant - // + span: $DIR/inline_instruction_set.rs:60:5: 60:39 - // + literal: Const { ty: fn() {inline_always_and_using_inline_asm}, val: Value(<ZST>) } -+ asm!("/* do nothing */", options((empty))) -> bb3; // scope 3 at $DIR/inline_instruction_set.rs:43:14: 43:38 ++ asm!("/* do nothing */", options((empty))) -> [return: bb3, unwind unreachable]; // scope 3 at $DIR/inline_instruction_set.rs:43:14: 43:38 } - bb4: { diff --git a/tests/mir-opt/inline/inline_instruction_set.t32.Inline.diff b/tests/mir-opt/inline/inline_instruction_set.t32.Inline.diff index e777b2cc2..36aec4f47 100644 --- a/tests/mir-opt/inline/inline_instruction_set.t32.Inline.diff +++ b/tests/mir-opt/inline/inline_instruction_set.t32.Inline.diff @@ -14,7 +14,7 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 - _1 = instruction_set_a32() -> bb1; // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 + _1 = instruction_set_a32() -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 // mir::Constant // + span: $DIR/inline_instruction_set.rs:49:5: 49:24 // + literal: Const { ty: fn() {instruction_set_a32}, val: Value(<ZST>) } @@ -23,7 +23,7 @@ bb1: { StorageDead(_1); // scope 0 at $DIR/inline_instruction_set.rs:+1:26: +1:27 StorageLive(_2); // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 -- _2 = instruction_set_t32() -> bb2; // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 +- _2 = instruction_set_t32() -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 - // mir::Constant - // + span: $DIR/inline_instruction_set.rs:50:5: 50:24 - // + literal: Const { ty: fn() {instruction_set_t32}, val: Value(<ZST>) } @@ -32,7 +32,7 @@ - bb2: { StorageDead(_2); // scope 0 at $DIR/inline_instruction_set.rs:+2:26: +2:27 StorageLive(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 -- _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 +- _3 = instruction_set_default() -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 - // mir::Constant - // + span: $DIR/inline_instruction_set.rs:51:5: 51:28 - // + literal: Const { ty: fn() {instruction_set_default}, val: Value(<ZST>) } @@ -41,8 +41,8 @@ - bb3: { StorageDead(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:30: +3:31 StorageLive(_4); // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 -- _4 = inline_always_and_using_inline_asm() -> bb4; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 -+ _4 = inline_always_and_using_inline_asm() -> bb2; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 +- _4 = inline_always_and_using_inline_asm() -> [return: bb4, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 ++ _4 = inline_always_and_using_inline_asm() -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 // mir::Constant // + span: $DIR/inline_instruction_set.rs:52:5: 52:39 // + literal: Const { ty: fn() {inline_always_and_using_inline_asm}, val: Value(<ZST>) } diff --git a/tests/mir-opt/inline/inline_into_box_place.main.Inline.diff b/tests/mir-opt/inline/inline_into_box_place.main.Inline.diff index a1cbf0d3e..a5129e0e8 100644 --- a/tests/mir-opt/inline/inline_into_box_place.main.Inline.diff +++ b/tests/mir-opt/inline/inline_into_box_place.main.Inline.diff @@ -4,81 +4,78 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/inline_into_box_place.rs:+0:11: +0:11 let _1: std::boxed::Box<std::vec::Vec<u32>>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:9: +1:11 - let mut _2: usize; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - let mut _3: usize; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - let mut _4: *mut u8; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - let mut _5: std::boxed::Box<std::vec::Vec<u32>>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - let mut _6: (); // in scope 0 at $DIR/inline_into_box_place.rs:+1:42: +1:43 - let mut _7: *const std::vec::Vec<u32>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 -+ let mut _8: &mut std::vec::Vec<u32>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 -+ let mut _9: std::vec::Vec<u32>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 + let mut _2: std::vec::Vec<u32>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:38: +1:48 scope 1 { debug _x => _1; // in scope 1 at $DIR/inline_into_box_place.rs:+1:9: +1:11 } - scope 2 { - } -+ scope 3 (inlined Vec::<u32>::new) { // at $DIR/inline_into_box_place.rs:8:33: 8:43 -+ let mut _10: alloc::raw_vec::RawVec<u32>; // in scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ scope 2 (inlined Vec::<u32>::new) { // at $DIR/inline_into_box_place.rs:8:38: 8:48 ++ let mut _3: alloc::raw_vec::RawVec<u32>; // in scope 2 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ } ++ scope 3 (inlined Box::<Vec<u32>>::new) { // at $DIR/inline_into_box_place.rs:8:29: 8:49 ++ debug x => _2; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL ++ let mut _4: usize; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL ++ let mut _5: usize; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL ++ let mut _6: *mut u8; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL ++ let mut _7: *const std::vec::Vec<u32>; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL ++ scope 4 { ++ } + } bb0: { StorageLive(_1); // scope 0 at $DIR/inline_into_box_place.rs:+1:9: +1:11 - _2 = SizeOf(std::vec::Vec<u32>); // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - _3 = AlignOf(std::vec::Vec<u32>); // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43 + StorageLive(_2); // scope 0 at $DIR/inline_into_box_place.rs:+1:38: +1:48 +- _2 = Vec::<u32>::new() -> bb1; // scope 0 at $DIR/inline_into_box_place.rs:+1:38: +1:48 ++ StorageLive(_3); // scope 2 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ _3 = const _; // scope 2 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL // mir::Constant - // + span: $DIR/inline_into_box_place.rs:8:29: 8:43 - // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) } +- // + span: $DIR/inline_into_box_place.rs:8:38: 8:46 +- // + user_ty: UserType(2) +- // + literal: Const { ty: fn() -> Vec<u32> {Vec::<u32>::new}, val: Value(<ZST>) } ++ // + span: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ // + user_ty: UserType(0) ++ // + literal: Const { ty: alloc::raw_vec::RawVec<u32>, val: Unevaluated(alloc::raw_vec::RawVec::<T>::NEW, [u32], None) } ++ _2 = Vec::<u32> { buf: move _3, len: const 0_usize }; // scope 2 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ StorageDead(_3); // scope 2 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ _4 = SizeOf(std::vec::Vec<u32>); // scope 4 at $SRC_DIR/alloc/src/boxed.rs:LL:COL ++ _5 = AlignOf(std::vec::Vec<u32>); // scope 4 at $SRC_DIR/alloc/src/boxed.rs:LL:COL ++ _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> [return: bb3, unwind: bb4]; // scope 4 at $SRC_DIR/alloc/src/boxed.rs:LL:COL ++ // mir::Constant ++ // + span: $SRC_DIR/alloc/src/boxed.rs:LL:COL ++ // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) } } bb1: { - StorageLive(_5); // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - _5 = ShallowInitBox(move _4, std::vec::Vec<u32>); // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - _7 = (((_5.0: std::ptr::Unique<std::vec::Vec<u32>>).0: std::ptr::NonNull<std::vec::Vec<u32>>).0: *const std::vec::Vec<u32>); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 -- (*_7) = Vec::<u32>::new() -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 -+ StorageLive(_8); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 -+ _8 = &mut (*_7); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 -+ StorageLive(_9); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 -+ StorageLive(_10); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -+ _10 = const _; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL - // mir::Constant -- // + span: $DIR/inline_into_box_place.rs:8:33: 8:41 +- _1 = Box::<Vec<u32>>::new(move _2) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:49 +- // mir::Constant +- // + span: $DIR/inline_into_box_place.rs:8:29: 8:37 - // + user_ty: UserType(1) -- // + literal: Const { ty: fn() -> Vec<u32> {Vec::<u32>::new}, val: Value(<ZST>) } -- } -- +- // + literal: Const { ty: fn(Vec<u32>) -> Box<Vec<u32>> {Box::<Vec<u32>>::new}, val: Value(<ZST>) } ++ StorageDead(_1); // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2 ++ return; // scope 0 at $DIR/inline_into_box_place.rs:+2:2: +2:2 + } + - bb2: { -+ // + span: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -+ // + user_ty: UserType(0) -+ // + literal: Const { ty: alloc::raw_vec::RawVec<u32>, val: Unevaluated(alloc::raw_vec::RawVec::<T>::NEW, [u32], None) } -+ _9 = Vec::<u32> { buf: move _10, len: const 0_usize }; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -+ StorageDead(_10); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -+ (*_8) = move _9; // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 -+ StorageDead(_9); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 -+ StorageDead(_8); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 - _1 = move _5; // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - StorageDead(_5); // scope 0 at $DIR/inline_into_box_place.rs:+1:42: +1:43 - _0 = const (); // scope 0 at $DIR/inline_into_box_place.rs:+0:11: +2:2 +- StorageDead(_2); // scope 0 at $DIR/inline_into_box_place.rs:+1:48: +1:49 +- _0 = const (); // scope 0 at $DIR/inline_into_box_place.rs:+0:11: +2:2 - drop(_1) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2 -+ drop(_1) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2 ++ bb2 (cleanup): { ++ resume; // scope 0 at $DIR/inline_into_box_place.rs:+0:1: +2:2 } -- bb3: { -+ bb2: { - StorageDead(_1); // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2 - return; // scope 0 at $DIR/inline_into_box_place.rs:+2:2: +2:2 + bb3: { +- StorageDead(_1); // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2 +- return; // scope 0 at $DIR/inline_into_box_place.rs:+2:2: +2:2 ++ _1 = ShallowInitBox(move _6, std::vec::Vec<u32>); // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL ++ _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 ++ (*_7) = move _2; // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL ++ StorageDead(_2); // scope 0 at $DIR/inline_into_box_place.rs:+1:48: +1:49 ++ _0 = const (); // scope 0 at $DIR/inline_into_box_place.rs:+0:11: +2:2 ++ drop(_1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2 } -- bb4 (cleanup): { -+ bb3 (cleanup): { - resume; // scope 0 at $DIR/inline_into_box_place.rs:+0:1: +2:2 -- } -- -- bb5 (cleanup): { -- _6 = alloc::alloc::box_free::<Vec<u32>, std::alloc::Global>(move (_5.0: std::ptr::Unique<std::vec::Vec<u32>>), move (_5.1: std::alloc::Global)) -> bb4; // scope 0 at $DIR/inline_into_box_place.rs:+1:42: +1:43 -- // mir::Constant -- // + span: $DIR/inline_into_box_place.rs:8:42: 8:43 -- // + literal: Const { ty: unsafe fn(Unique<Vec<u32>>, std::alloc::Global) {alloc::alloc::box_free::<Vec<u32>, std::alloc::Global>}, val: Value(<ZST>) } + bb4 (cleanup): { +- resume; // scope 0 at $DIR/inline_into_box_place.rs:+0:1: +2:2 ++ drop(_2) -> [return: bb2, unwind terminate]; // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL } } diff --git a/tests/mir-opt/inline/inline_into_box_place.rs b/tests/mir-opt/inline/inline_into_box_place.rs index 232bcc7b2..02823e4e1 100644 --- a/tests/mir-opt/inline/inline_into_box_place.rs +++ b/tests/mir-opt/inline/inline_into_box_place.rs @@ -1,9 +1,9 @@ // ignore-endian-big // ignore-wasm32-bare compiled with panic=abort by default +// ignore-debug MIR alignment checks in std alter the diff, breaking the test // compile-flags: -Z mir-opt-level=4 -#![feature(box_syntax)] // EMIT_MIR inline_into_box_place.main.Inline.diff fn main() { - let _x: Box<Vec<u32>> = box Vec::new(); + let _x: Box<Vec<u32>> = Box::new(Vec::new()); } diff --git a/tests/mir-opt/inline/inline_options.main.Inline.after.mir b/tests/mir-opt/inline/inline_options.main.Inline.after.mir index 1c590be94..a2938ead0 100644 --- a/tests/mir-opt/inline/inline_options.main.Inline.after.mir +++ b/tests/mir-opt/inline/inline_options.main.Inline.after.mir @@ -4,52 +4,52 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/inline_options.rs:+0:11: +0:11 let _1: (); // in scope 0 at $DIR/inline_options.rs:+1:5: +1:18 let _2: (); // in scope 0 at $DIR/inline_options.rs:+2:5: +2:21 - scope 1 (inlined inlined::<u32>) { // at $DIR/inline_options.rs:10:5: 10:21 - let _3: (); // in scope 1 at $DIR/inline_options.rs:16:23: 16:26 - let _4: (); // in scope 1 at $DIR/inline_options.rs:16:28: 16:31 - let _5: (); // in scope 1 at $DIR/inline_options.rs:16:33: 16:36 + scope 1 (inlined inlined::<u32>) { // at $DIR/inline_options.rs:11:5: 11:21 + let _3: (); // in scope 1 at $DIR/inline_options.rs:17:23: 17:26 + let _4: (); // in scope 1 at $DIR/inline_options.rs:17:28: 17:31 + let _5: (); // in scope 1 at $DIR/inline_options.rs:17:33: 17:36 } bb0: { StorageLive(_1); // scope 0 at $DIR/inline_options.rs:+1:5: +1:18 _1 = not_inlined() -> bb1; // scope 0 at $DIR/inline_options.rs:+1:5: +1:18 // mir::Constant - // + span: $DIR/inline_options.rs:9:5: 9:16 + // + span: $DIR/inline_options.rs:10:5: 10:16 // + literal: Const { ty: fn() {not_inlined}, val: Value(<ZST>) } } bb1: { StorageDead(_1); // scope 0 at $DIR/inline_options.rs:+1:18: +1:19 StorageLive(_2); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 - StorageLive(_3); // scope 1 at $DIR/inline_options.rs:16:23: 16:26 - _3 = g() -> bb2; // scope 1 at $DIR/inline_options.rs:16:23: 16:26 + StorageLive(_3); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 + StorageLive(_4); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 + StorageLive(_5); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 + _3 = g() -> bb3; // scope 1 at $DIR/inline_options.rs:17:23: 17:26 // mir::Constant - // + span: $DIR/inline_options.rs:16:23: 16:24 + // + span: $DIR/inline_options.rs:17:23: 17:24 // + literal: Const { ty: fn() {g}, val: Value(<ZST>) } } bb2: { - StorageDead(_3); // scope 1 at $DIR/inline_options.rs:16:26: 16:27 - StorageLive(_4); // scope 1 at $DIR/inline_options.rs:16:28: 16:31 - _4 = g() -> bb3; // scope 1 at $DIR/inline_options.rs:16:28: 16:31 - // mir::Constant - // + span: $DIR/inline_options.rs:16:28: 16:29 - // + literal: Const { ty: fn() {g}, val: Value(<ZST>) } + StorageDead(_5); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 + StorageDead(_4); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 + StorageDead(_3); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 + StorageDead(_2); // scope 0 at $DIR/inline_options.rs:+2:21: +2:22 + _0 = const (); // scope 0 at $DIR/inline_options.rs:+0:11: +3:2 + return; // scope 0 at $DIR/inline_options.rs:+3:2: +3:2 } bb3: { - StorageDead(_4); // scope 1 at $DIR/inline_options.rs:16:31: 16:32 - StorageLive(_5); // scope 1 at $DIR/inline_options.rs:16:33: 16:36 - _5 = g() -> bb4; // scope 1 at $DIR/inline_options.rs:16:33: 16:36 + _4 = g() -> bb4; // scope 1 at $DIR/inline_options.rs:17:28: 17:31 // mir::Constant - // + span: $DIR/inline_options.rs:16:33: 16:34 + // + span: $DIR/inline_options.rs:17:28: 17:29 // + literal: Const { ty: fn() {g}, val: Value(<ZST>) } } bb4: { - StorageDead(_5); // scope 1 at $DIR/inline_options.rs:16:36: 16:37 - StorageDead(_2); // scope 0 at $DIR/inline_options.rs:+2:21: +2:22 - _0 = const (); // scope 0 at $DIR/inline_options.rs:+0:11: +3:2 - return; // scope 0 at $DIR/inline_options.rs:+3:2: +3:2 + _5 = g() -> bb2; // scope 1 at $DIR/inline_options.rs:17:33: 17:36 + // mir::Constant + // + span: $DIR/inline_options.rs:17:33: 17:34 + // + literal: Const { ty: fn() {g}, val: Value(<ZST>) } } } diff --git a/tests/mir-opt/inline/inline_options.rs b/tests/mir-opt/inline/inline_options.rs index 477f050b6..f0a898832 100644 --- a/tests/mir-opt/inline/inline_options.rs +++ b/tests/mir-opt/inline/inline_options.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // Checks that inlining threshold can be controlled with // inline-mir-threshold and inline-hint-threshold options. // diff --git a/tests/mir-opt/inline/inline_specialization.main.Inline.diff b/tests/mir-opt/inline/inline_specialization.main.Inline.diff index af08296ed..9dde9994d 100644 --- a/tests/mir-opt/inline/inline_specialization.main.Inline.diff +++ b/tests/mir-opt/inline/inline_specialization.main.Inline.diff @@ -7,19 +7,19 @@ scope 1 { debug x => _1; // in scope 1 at $DIR/inline_specialization.rs:+1:9: +1:10 } -+ scope 2 (inlined <Vec<()> as Foo>::bar) { // at $DIR/inline_specialization.rs:5:13: 5:38 ++ scope 2 (inlined <Vec<()> as Foo>::bar) { // at $DIR/inline_specialization.rs:6:13: 6:38 + } bb0: { StorageLive(_1); // scope 0 at $DIR/inline_specialization.rs:+1:9: +1:10 - _1 = <Vec<()> as Foo>::bar() -> bb1; // scope 0 at $DIR/inline_specialization.rs:+1:13: +1:38 - // mir::Constant -- // + span: $DIR/inline_specialization.rs:5:13: 5:36 +- // + span: $DIR/inline_specialization.rs:6:13: 6:36 - // + literal: Const { ty: fn() -> u32 {<Vec<()> as Foo>::bar}, val: Value(<ZST>) } - } - - bb1: { -+ _1 = const 123_u32; // scope 2 at $DIR/inline_specialization.rs:14:31: 14:34 ++ _1 = const 123_u32; // scope 2 at $DIR/inline_specialization.rs:15:31: 15:34 _0 = const (); // scope 0 at $DIR/inline_specialization.rs:+0:11: +2:2 StorageDead(_1); // scope 0 at $DIR/inline_specialization.rs:+2:1: +2:2 return; // scope 0 at $DIR/inline_specialization.rs:+2:2: +2:2 diff --git a/tests/mir-opt/inline/inline_specialization.rs b/tests/mir-opt/inline/inline_specialization.rs index 87275b4e5..c24795e05 100644 --- a/tests/mir-opt/inline/inline_specialization.rs +++ b/tests/mir-opt/inline/inline_specialization.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default #![feature(specialization)] // EMIT_MIR inline_specialization.main.Inline.diff diff --git a/tests/mir-opt/inline/inline_trait_method.rs b/tests/mir-opt/inline/inline_trait_method.rs index 74be53f55..6aa957eb5 100644 --- a/tests/mir-opt/inline/inline_trait_method.rs +++ b/tests/mir-opt/inline/inline_trait_method.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // compile-flags: -Z span_free_formats fn main() { diff --git a/tests/mir-opt/inline/inline_trait_method.test.Inline.after.mir b/tests/mir-opt/inline/inline_trait_method.test.Inline.after.mir index 637bf282a..a9020a5bb 100644 --- a/tests/mir-opt/inline/inline_trait_method.test.Inline.after.mir +++ b/tests/mir-opt/inline/inline_trait_method.test.Inline.after.mir @@ -10,7 +10,7 @@ fn test(_1: &dyn X) -> u32 { _2 = &(*_1); // scope 0 at $DIR/inline_trait_method.rs:+1:5: +1:10 _0 = <dyn X as X>::y(move _2) -> bb1; // scope 0 at $DIR/inline_trait_method.rs:+1:5: +1:10 // mir::Constant - // + span: $DIR/inline_trait_method.rs:9:7: 9:8 + // + span: $DIR/inline_trait_method.rs:10:7: 10:8 // + literal: Const { ty: for<'a> fn(&'a dyn X) -> u32 {<dyn X as X>::y}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/inline/inline_trait_method_2.rs b/tests/mir-opt/inline/inline_trait_method_2.rs index 378e71a25..07a601908 100644 --- a/tests/mir-opt/inline/inline_trait_method_2.rs +++ b/tests/mir-opt/inline/inline_trait_method_2.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // compile-flags: -Z span_free_formats -Z mir-opt-level=4 // EMIT_MIR inline_trait_method_2.test2.Inline.after.mir diff --git a/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir b/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir index b7c5bbecb..a4bbecf3b 100644 --- a/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir +++ b/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir @@ -5,8 +5,8 @@ fn test2(_1: &dyn X) -> bool { let mut _0: bool; // return place in scope 0 at $DIR/inline_trait_method_2.rs:+0:24: +0:28 let mut _2: &dyn X; // in scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 let mut _3: &dyn X; // in scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 - scope 1 (inlined test) { // at $DIR/inline_trait_method_2.rs:5:5: 5:12 - debug x => _2; // in scope 1 at $DIR/inline_trait_method_2.rs:9:9: 9:10 + scope 1 (inlined test) { // at $DIR/inline_trait_method_2.rs:6:5: 6:12 + debug x => _2; // in scope 1 at $DIR/inline_trait_method_2.rs:10:9: 10:10 } bb0: { @@ -15,9 +15,9 @@ fn test2(_1: &dyn X) -> bool { _3 = &(*_1); // scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 _2 = move _3 as &dyn X (Pointer(Unsize)); // scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 StorageDead(_3); // scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 - _0 = <dyn X as X>::y(_2) -> bb1; // scope 1 at $DIR/inline_trait_method_2.rs:10:5: 10:10 + _0 = <dyn X as X>::y(_2) -> bb1; // scope 1 at $DIR/inline_trait_method_2.rs:11:5: 11:10 // mir::Constant - // + span: $DIR/inline_trait_method_2.rs:10:7: 10:8 + // + span: $DIR/inline_trait_method_2.rs:11:7: 11:8 // + literal: Const { ty: for<'a> fn(&'a dyn X) -> bool {<dyn X as X>::y}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/inline/issue_106141.outer.Inline.diff b/tests/mir-opt/inline/issue_106141.outer.Inline.diff index 97361fa5f..18df6f9af 100644 --- a/tests/mir-opt/inline/issue_106141.outer.Inline.diff +++ b/tests/mir-opt/inline/issue_106141.outer.Inline.diff @@ -3,14 +3,14 @@ fn outer() -> usize { let mut _0: usize; // return place in scope 0 at $DIR/issue_106141.rs:+0:19: +0:24 -+ scope 1 (inlined inner) { // at $DIR/issue_106141.rs:2:5: 2:12 -+ let mut _1: bool; // in scope 1 at $DIR/issue_106141.rs:13:8: 13:21 -+ let mut _2: bool; // in scope 1 at $DIR/issue_106141.rs:13:8: 13:21 -+ let mut _3: &[bool; 1]; // in scope 1 at $DIR/issue_106141.rs:11:18: 11:25 ++ scope 1 (inlined inner) { // at $DIR/issue_106141.rs:3:5: 3:12 ++ let mut _1: bool; // in scope 1 at $DIR/issue_106141.rs:14:8: 14:21 ++ let mut _2: bool; // in scope 1 at $DIR/issue_106141.rs:14:8: 14:21 ++ let mut _3: &[bool; 1]; // in scope 1 at $DIR/issue_106141.rs:12:18: 12:25 + scope 2 { -+ debug buffer => _3; // in scope 2 at $DIR/issue_106141.rs:11:9: 11:15 ++ debug buffer => _3; // in scope 2 at $DIR/issue_106141.rs:12:9: 12:15 + scope 3 { -+ debug index => _0; // in scope 3 at $DIR/issue_106141.rs:12:9: 12:14 ++ debug index => _0; // in scope 3 at $DIR/issue_106141.rs:13:9: 13:14 + } + } + } @@ -18,36 +18,36 @@ bb0: { - _0 = inner() -> bb1; // scope 0 at $DIR/issue_106141.rs:+1:5: +1:12 + StorageLive(_3); // scope 0 at $DIR/issue_106141.rs:+1:5: +1:12 -+ _3 = const _; // scope 1 at $DIR/issue_106141.rs:11:18: 11:25 ++ _3 = const _; // scope 1 at $DIR/issue_106141.rs:12:18: 12:25 // mir::Constant -- // + span: $DIR/issue_106141.rs:2:5: 2:10 +- // + span: $DIR/issue_106141.rs:3:5: 3:10 - // + literal: Const { ty: fn() -> usize {inner}, val: Value(<ZST>) } -+ // + span: $DIR/issue_106141.rs:11:18: 11:25 ++ // + span: $DIR/issue_106141.rs:12:18: 12:25 + // + literal: Const { ty: &[bool; 1], val: Unevaluated(inner, [], Some(promoted[0])) } -+ _0 = index() -> bb1; // scope 2 at $DIR/issue_106141.rs:12:17: 12:24 ++ _0 = index() -> bb1; // scope 2 at $DIR/issue_106141.rs:13:17: 13:24 + // mir::Constant -+ // + span: $DIR/issue_106141.rs:12:17: 12:22 ++ // + span: $DIR/issue_106141.rs:13:17: 13:22 + // + literal: Const { ty: fn() -> usize {index}, val: Value(<ZST>) } } bb1: { -+ StorageLive(_1); // scope 3 at $DIR/issue_106141.rs:13:8: 13:21 -+ _2 = Lt(_0, const 1_usize); // scope 3 at $DIR/issue_106141.rs:13:8: 13:21 -+ assert(move _2, "index out of bounds: the length is {} but the index is {}", const 1_usize, _0) -> bb2; // scope 3 at $DIR/issue_106141.rs:13:8: 13:21 ++ StorageLive(_1); // scope 3 at $DIR/issue_106141.rs:14:8: 14:21 ++ _2 = Lt(_0, const 1_usize); // scope 3 at $DIR/issue_106141.rs:14:8: 14:21 ++ assert(move _2, "index out of bounds: the length is {} but the index is {}", const 1_usize, _0) -> bb2; // scope 3 at $DIR/issue_106141.rs:14:8: 14:21 + } + + bb2: { -+ _1 = (*_3)[_0]; // scope 3 at $DIR/issue_106141.rs:13:8: 13:21 -+ switchInt(move _1) -> [0: bb3, otherwise: bb4]; // scope 3 at $DIR/issue_106141.rs:13:8: 13:21 ++ _1 = (*_3)[_0]; // scope 3 at $DIR/issue_106141.rs:14:8: 14:21 ++ switchInt(move _1) -> [0: bb3, otherwise: bb4]; // scope 3 at $DIR/issue_106141.rs:14:8: 14:21 + } + + bb3: { -+ _0 = const 0_usize; // scope 3 at $DIR/issue_106141.rs:16:9: 16:10 -+ goto -> bb4; // scope 3 at $DIR/issue_106141.rs:13:5: 17:6 ++ _0 = const 0_usize; // scope 3 at $DIR/issue_106141.rs:17:9: 17:10 ++ goto -> bb4; // scope 3 at $DIR/issue_106141.rs:14:5: 18:6 + } + + bb4: { -+ StorageDead(_1); // scope 3 at $DIR/issue_106141.rs:17:5: 17:6 ++ StorageDead(_1); // scope 3 at $DIR/issue_106141.rs:18:5: 18:6 + StorageDead(_3); // scope 0 at $DIR/issue_106141.rs:+1:5: +1:12 return; // scope 0 at $DIR/issue_106141.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/inline/issue_106141.rs b/tests/mir-opt/inline/issue_106141.rs index c8288b7f3..b6bd806e6 100644 --- a/tests/mir-opt/inline/issue_106141.rs +++ b/tests/mir-opt/inline/issue_106141.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default pub fn outer() -> usize { inner() } diff --git a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir index 4dd1aad48..1da3c8bb7 100644 --- a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir +++ b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir @@ -10,10 +10,9 @@ fn main() -> () { scope 1 { debug f => _1; // in scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:9: +1:10 scope 2 (inlined main::{closure#0}) { // at $DIR/issue_76997_inline_scopes_parenting.rs:6:5: 6:10 - debug x => _5; // in scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:14: +1:15 - let _6: (); // in scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:23: +1:24 + debug x => const (); // in scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:14: +1:15 scope 3 { - debug y => _6; // in scope 3 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:23: +1:24 + debug y => const (); // in scope 3 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:23: +1:24 } } } @@ -22,7 +21,7 @@ fn main() -> () { StorageLive(_1); // scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:9: +1:10 _1 = [closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16]; // scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:13: +1:33 // closure - // + def_id: DefId(0:4 ~ issue_76997_inline_scopes_parenting[bc59]::main::{closure#0}) + // + def_id: DefId(0:4 ~ issue_76997_inline_scopes_parenting[5cd2]::main::{closure#0}) // + substs: [ // i8, // extern "rust-call" fn(((),)), @@ -36,8 +35,6 @@ fn main() -> () { _3 = (move _4,); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 StorageLive(_5); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 _5 = move (_3.0: ()); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 - StorageLive(_6); // scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:23: +1:24 - StorageDead(_6); // scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:32: +1:33 StorageDead(_5); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 StorageDead(_4); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:9: +2:10 StorageDead(_3); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:9: +2:10 diff --git a/tests/mir-opt/inline/issue_78442.bar.Inline.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.diff index aa62e4a16..dc3fe7555 100644 --- a/tests/mir-opt/inline/issue_78442.bar.Inline.diff +++ b/tests/mir-opt/inline/issue_78442.bar.Inline.diff @@ -46,11 +46,11 @@ - bb3: { - return; // scope 0 at $DIR/issue_78442.rs:+5:2: +5:2 + bb3 (cleanup): { -+ drop(_1) -> bb4; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 ++ drop(_1) -> [return: bb4, unwind terminate]; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 } bb4 (cleanup): { -- drop(_1) -> bb5; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 +- drop(_1) -> [return: bb5, unwind terminate]; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 + resume; // scope 0 at $DIR/issue_78442.rs:+0:1: +5:2 } diff --git a/tests/mir-opt/inline/issue_78442.bar.RevealAll.diff b/tests/mir-opt/inline/issue_78442.bar.RevealAll.diff index 21055c6bf..8f56ef258 100644 --- a/tests/mir-opt/inline/issue_78442.bar.RevealAll.diff +++ b/tests/mir-opt/inline/issue_78442.bar.RevealAll.diff @@ -47,7 +47,7 @@ } bb4 (cleanup): { - drop(_1) -> bb5; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 + drop(_1) -> [return: bb5, unwind terminate]; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 } bb5 (cleanup): { diff --git a/tests/mir-opt/inline/unchecked_shifts.rs b/tests/mir-opt/inline/unchecked_shifts.rs new file mode 100644 index 000000000..17724530d --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.rs @@ -0,0 +1,18 @@ +// ignore-wasm32 compiled with panic=abort by default +#![crate_type = "lib"] +#![feature(unchecked_math)] + +// ignore-debug: the debug assertions prevent the inlining we are testing for +// compile-flags: -Zmir-opt-level=2 -Zinline-mir + +// EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff +// EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir +pub unsafe fn unchecked_shl_unsigned_smaller(a: u16, b: u32) -> u16 { + a.unchecked_shl(b) +} + +// EMIT_MIR unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff +// EMIT_MIR unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir +pub unsafe fn unchecked_shr_signed_smaller(a: i16, b: u32) -> i16 { + a.unchecked_shr(b) +} diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff new file mode 100644 index 000000000..6184a0acd --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff @@ -0,0 +1,144 @@ +- // MIR for `unchecked_shl_unsigned_smaller` before Inline ++ // MIR for `unchecked_shl_unsigned_smaller` after Inline + + fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { + debug a => _1; // in scope 0 at $DIR/unchecked_shifts.rs:+0:46: +0:47 + debug b => _2; // in scope 0 at $DIR/unchecked_shifts.rs:+0:54: +0:55 + let mut _0: u16; // return place in scope 0 at $DIR/unchecked_shifts.rs:+0:65: +0:68 + let mut _3: u16; // in scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:6 + let mut _4: u32; // in scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22 ++ scope 1 (inlined core::num::<impl u16>::unchecked_shl) { // at $DIR/unchecked_shifts.rs:11:7: 11:23 ++ debug self => _3; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ debug rhs => _4; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ let mut _5: u16; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ let mut _6: std::option::Option<u16>; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ let mut _7: std::result::Result<u16, std::num::TryFromIntError>; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ scope 2 { ++ scope 3 (inlined <u32 as TryInto<u16>>::try_into) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ debug self => _4; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ scope 4 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ debug u => _4; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _8: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _9: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _10: u16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } ++ } ++ scope 5 (inlined Result::<u16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ debug self => _7; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ let mut _11: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ let _12: u16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ scope 6 { ++ debug x => _12; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ scope 7 { ++ scope 8 { ++ debug x => const TryFromIntError(()); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ } ++ } ++ scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _13: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 10 { ++ debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL ++ } ++ scope 11 { ++ scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 14 { ++ scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL ++ } ++ } ++ } ++ } ++ scope 12 (inlined Option::<u16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL ++ debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL ++ } ++ } ++ } ++ } + + bb0: { + StorageLive(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:6 + _3 = _1; // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:6 + StorageLive(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22 + _4 = _2; // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22 +- _0 = core::num::<impl u16>::unchecked_shl(move _3, move _4) -> bb1; // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:23 +- // mir::Constant +- // + span: $DIR/unchecked_shifts.rs:11:7: 11:20 +- // + literal: Const { ty: unsafe fn(u16, u32) -> u16 {core::num::<impl u16>::unchecked_shl}, val: Value(<ZST>) } ++ StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _9 = const 65535_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _8 = Gt(_4, move _9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ switchInt(move _8) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb1: { ++ StorageDead(_12); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ StorageLive(_13); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ switchInt(move _14) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ } ++ ++ bb2: { ++ StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23 + StorageDead(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23 + return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 ++ } ++ ++ bb3: { ++ _7 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ // mir::Constant ++ // + span: no-location ++ // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } ++ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } ++ ++ bb4: { ++ StorageLive(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _10 = _4 as u16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _7 = Result::<u16, TryFromIntError>::Ok(move _10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } ++ ++ bb5: { ++ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_12); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ _11 = discriminant(_7); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ switchInt(move _11) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb6: { ++ _6 = Option::<u16>::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb7: { ++ unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb8: { ++ _12 = move ((_7 as Ok).0: u16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ _6 = Option::<u16>::Some(move _12); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL ++ goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb9: { ++ _5 = move ((_6 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_13); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ _0 = unchecked_shl::<u16>(_3, move _5) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ // mir::Constant ++ // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u16, u16) -> u16 {unchecked_shl::<u16>}, val: Value(<ZST>) } + } + } + diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir new file mode 100644 index 000000000..726b6bbf9 --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir @@ -0,0 +1,130 @@ +// MIR for `unchecked_shl_unsigned_smaller` after PreCodegen + +fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { + debug a => _1; // in scope 0 at $DIR/unchecked_shifts.rs:+0:46: +0:47 + debug b => _2; // in scope 0 at $DIR/unchecked_shifts.rs:+0:54: +0:55 + let mut _0: u16; // return place in scope 0 at $DIR/unchecked_shifts.rs:+0:65: +0:68 + scope 1 (inlined core::num::<impl u16>::unchecked_shl) { // at $DIR/unchecked_shifts.rs:11:7: 11:23 + debug self => _1; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug rhs => _2; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _3: u16; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _4: std::option::Option<u16>; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _5: std::result::Result<u16, std::num::TryFromIntError>; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + scope 2 { + scope 3 (inlined <u32 as TryInto<u16>>::try_into) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug self => _2; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + scope 4 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug u => _2; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _6: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _7: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _8: u16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + } + scope 5 (inlined Result::<u16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug self => _5; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _9: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let _10: u16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + scope 6 { + debug x => _10; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + } + scope 7 { + scope 8 { + debug x => const TryFromIntError(()); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + } + } + } + scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug self => _4; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _11: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _12: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + scope 10 { + debug val => _3; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL + } + scope 11 { + scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL + scope 14 { + scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + } + } + } + scope 12 (inlined Option::<u16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _11; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL + } + } + } + } + + bb0: { + StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageLive(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _7 = const 65535_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _6 = Gt(_2, move _7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + switchInt(move _6) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb1: { + StorageDead(_10); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageLive(_11); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _12 = discriminant(_4); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _12) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + } + + bb2: { + StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 + } + + bb3: { + _5 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + // mir::Constant + // + span: no-location + // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } + goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb4: { + StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _8 = _2 as u16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _5 = Result::<u16, TryFromIntError>::Ok(move _8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb5: { + StorageDead(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_10); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _9 = discriminant(_5); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + switchInt(move _9) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb6: { + _4 = Option::<u16>::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb7: { + unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb8: { + _10 = move ((_5 as Ok).0: u16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + _4 = Option::<u16>::Some(move _10); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb9: { + _3 = move ((_4 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_11); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _0 = unchecked_shl::<u16>(_1, move _3) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u16, u16) -> u16 {unchecked_shl::<u16>}, val: Value(<ZST>) } + } +} diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff new file mode 100644 index 000000000..35d5b6e72 --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff @@ -0,0 +1,144 @@ +- // MIR for `unchecked_shr_signed_smaller` before Inline ++ // MIR for `unchecked_shr_signed_smaller` after Inline + + fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { + debug a => _1; // in scope 0 at $DIR/unchecked_shifts.rs:+0:44: +0:45 + debug b => _2; // in scope 0 at $DIR/unchecked_shifts.rs:+0:52: +0:53 + let mut _0: i16; // return place in scope 0 at $DIR/unchecked_shifts.rs:+0:63: +0:66 + let mut _3: i16; // in scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:6 + let mut _4: u32; // in scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22 ++ scope 1 (inlined core::num::<impl i16>::unchecked_shr) { // at $DIR/unchecked_shifts.rs:17:7: 17:23 ++ debug self => _3; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ debug rhs => _4; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ let mut _5: i16; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ let mut _6: std::option::Option<i16>; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ let mut _7: std::result::Result<i16, std::num::TryFromIntError>; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ scope 2 { ++ scope 3 (inlined <u32 as TryInto<i16>>::try_into) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ debug self => _4; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ scope 4 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ debug u => _4; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _8: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _9: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _10: i16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } ++ } ++ scope 5 (inlined Result::<i16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ debug self => _7; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ let mut _11: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ let _12: i16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ scope 6 { ++ debug x => _12; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ scope 7 { ++ scope 8 { ++ debug x => const TryFromIntError(()); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ } ++ } ++ scope 9 (inlined #[track_caller] Option::<i16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _13: &std::option::Option<i16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 10 { ++ debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL ++ } ++ scope 11 { ++ scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 14 { ++ scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL ++ } ++ } ++ } ++ } ++ scope 12 (inlined Option::<i16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL ++ debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL ++ } ++ } ++ } ++ } + + bb0: { + StorageLive(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:6 + _3 = _1; // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:6 + StorageLive(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22 + _4 = _2; // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22 +- _0 = core::num::<impl i16>::unchecked_shr(move _3, move _4) -> bb1; // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:23 +- // mir::Constant +- // + span: $DIR/unchecked_shifts.rs:17:7: 17:20 +- // + literal: Const { ty: unsafe fn(i16, u32) -> i16 {core::num::<impl i16>::unchecked_shr}, val: Value(<ZST>) } ++ StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _9 = const 32767_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _8 = Gt(_4, move _9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ switchInt(move _8) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb1: { ++ StorageDead(_12); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ StorageLive(_13); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ switchInt(move _14) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ } ++ ++ bb2: { ++ StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageDead(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23 + StorageDead(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23 + return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 ++ } ++ ++ bb3: { ++ _7 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ // mir::Constant ++ // + span: no-location ++ // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } ++ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } ++ ++ bb4: { ++ StorageLive(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _10 = _4 as i16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _7 = Result::<i16, TryFromIntError>::Ok(move _10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } ++ ++ bb5: { ++ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_12); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ _11 = discriminant(_7); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ switchInt(move _11) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb6: { ++ _6 = Option::<i16>::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb7: { ++ unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb8: { ++ _12 = move ((_7 as Ok).0: i16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ _6 = Option::<i16>::Some(move _12); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL ++ goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb9: { ++ _5 = move ((_6 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_13); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ _0 = unchecked_shr::<i16>(_3, move _5) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ // mir::Constant ++ // + span: $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(i16, i16) -> i16 {unchecked_shr::<i16>}, val: Value(<ZST>) } + } + } + diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir new file mode 100644 index 000000000..b006085b5 --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir @@ -0,0 +1,130 @@ +// MIR for `unchecked_shr_signed_smaller` after PreCodegen + +fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { + debug a => _1; // in scope 0 at $DIR/unchecked_shifts.rs:+0:44: +0:45 + debug b => _2; // in scope 0 at $DIR/unchecked_shifts.rs:+0:52: +0:53 + let mut _0: i16; // return place in scope 0 at $DIR/unchecked_shifts.rs:+0:63: +0:66 + scope 1 (inlined core::num::<impl i16>::unchecked_shr) { // at $DIR/unchecked_shifts.rs:17:7: 17:23 + debug self => _1; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + debug rhs => _2; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + let mut _3: i16; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + let mut _4: std::option::Option<i16>; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + let mut _5: std::result::Result<i16, std::num::TryFromIntError>; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + scope 2 { + scope 3 (inlined <u32 as TryInto<i16>>::try_into) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + debug self => _2; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + scope 4 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug u => _2; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _6: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _7: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _8: i16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + } + scope 5 (inlined Result::<i16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + debug self => _5; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _9: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let _10: i16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + scope 6 { + debug x => _10; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + } + scope 7 { + scope 8 { + debug x => const TryFromIntError(()); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + } + } + } + scope 9 (inlined #[track_caller] Option::<i16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + debug self => _4; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _11: &std::option::Option<i16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _12: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + scope 10 { + debug val => _3; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL + } + scope 11 { + scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL + scope 14 { + scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + } + } + } + scope 12 (inlined Option::<i16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _11; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL + } + } + } + } + + bb0: { + StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageLive(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _7 = const 32767_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _6 = Gt(_2, move _7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + switchInt(move _6) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb1: { + StorageDead(_10); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageLive(_11); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + _12 = discriminant(_4); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _12) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + } + + bb2: { + StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 + } + + bb3: { + _5 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + // mir::Constant + // + span: no-location + // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } + goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb4: { + StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _8 = _2 as i16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _5 = Result::<i16, TryFromIntError>::Ok(move _8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb5: { + StorageDead(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_10); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + _9 = discriminant(_5); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + switchInt(move _9) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb6: { + _4 = Option::<i16>::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb7: { + unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb8: { + _10 = move ((_5 as Ok).0: i16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + _4 = Option::<i16>::Some(move _10); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb9: { + _3 = move ((_4 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_11); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + _0 = unchecked_shr::<i16>(_1, move _3) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/num/int_macros.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(i16, i16) -> i16 {unchecked_shr::<i16>}, val: Value(<ZST>) } + } +} diff --git a/tests/mir-opt/inline/unwrap_unchecked.rs b/tests/mir-opt/inline/unwrap_unchecked.rs new file mode 100644 index 000000000..5856f1479 --- /dev/null +++ b/tests/mir-opt/inline/unwrap_unchecked.rs @@ -0,0 +1,11 @@ +#![crate_type = "lib"] + +// ignore-wasm32-bare compiled with panic=abort by default +// ignore-debug: the debug assertions prevent the inlining we are testing for +// compile-flags: -Zmir-opt-level=2 -Zinline-mir + +// EMIT_MIR unwrap_unchecked.unwrap_unchecked.Inline.diff +// EMIT_MIR unwrap_unchecked.unwrap_unchecked.PreCodegen.after.mir +pub unsafe fn unwrap_unchecked<T>(slf: Option<T>) -> T { + slf.unwrap_unchecked() +} diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff new file mode 100644 index 000000000..543ddcfc4 --- /dev/null +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff @@ -0,0 +1,55 @@ +- // MIR for `unwrap_unchecked` before Inline ++ // MIR for `unwrap_unchecked` after Inline + + fn unwrap_unchecked(_1: Option<T>) -> T { + debug slf => _1; // in scope 0 at $DIR/unwrap_unchecked.rs:+0:35: +0:38 + let mut _0: T; // return place in scope 0 at $DIR/unwrap_unchecked.rs:+0:54: +0:55 + let mut _2: std::option::Option<T>; // in scope 0 at $DIR/unwrap_unchecked.rs:+1:5: +1:8 ++ scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) { // at $DIR/unwrap_unchecked.rs:10:9: 10:27 ++ debug self => _2; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _3: &std::option::Option<T>; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _4: isize; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 2 { ++ debug val => _0; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL ++ } ++ scope 3 { ++ scope 5 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 6 { ++ scope 7 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL ++ } ++ } ++ } ++ } ++ scope 4 (inlined Option::<T>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL ++ debug self => _3; // in scope 4 at $SRC_DIR/core/src/option.rs:LL:COL ++ } ++ } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/unwrap_unchecked.rs:+1:5: +1:8 + _2 = move _1; // scope 0 at $DIR/unwrap_unchecked.rs:+1:5: +1:8 +- _0 = Option::<T>::unwrap_unchecked(move _2) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/unwrap_unchecked.rs:+1:5: +1:27 +- // mir::Constant +- // + span: $DIR/unwrap_unchecked.rs:10:9: 10:25 +- // + literal: Const { ty: unsafe fn(Option<T>) -> T {Option::<T>::unwrap_unchecked}, val: Value(<ZST>) } ++ StorageLive(_3); // scope 0 at $DIR/unwrap_unchecked.rs:+1:9: +1:27 ++ _4 = discriminant(_2); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL ++ switchInt(move _4) -> [0: bb1, 1: bb2, otherwise: bb1]; // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL + } + + bb1: { +- StorageDead(_2); // scope 0 at $DIR/unwrap_unchecked.rs:+1:26: +1:27 +- return; // scope 0 at $DIR/unwrap_unchecked.rs:+2:2: +2:2 ++ unreachable; // scope 6 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + +- bb2 (cleanup): { +- resume; // scope 0 at $DIR/unwrap_unchecked.rs:+0:1: +2:2 ++ bb2: { ++ _0 = move ((_2 as Some).0: T); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_3); // scope 0 at $DIR/unwrap_unchecked.rs:+1:9: +1:27 ++ StorageDead(_2); // scope 0 at $DIR/unwrap_unchecked.rs:+1:26: +1:27 ++ return; // scope 0 at $DIR/unwrap_unchecked.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.mir new file mode 100644 index 000000000..c5e2469fc --- /dev/null +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.mir @@ -0,0 +1,41 @@ +// MIR for `unwrap_unchecked` after PreCodegen + +fn unwrap_unchecked(_1: Option<T>) -> T { + debug slf => _1; // in scope 0 at $DIR/unwrap_unchecked.rs:+0:35: +0:38 + let mut _0: T; // return place in scope 0 at $DIR/unwrap_unchecked.rs:+0:54: +0:55 + scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) { // at $DIR/unwrap_unchecked.rs:10:9: 10:27 + debug self => _1; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _2: &std::option::Option<T>; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _3: isize; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL + scope 2 { + debug val => _0; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + } + scope 3 { + scope 5 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL + scope 6 { + scope 7 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + } + } + } + scope 4 (inlined Option::<T>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _2; // in scope 4 at $SRC_DIR/core/src/option.rs:LL:COL + } + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/unwrap_unchecked.rs:+1:9: +1:27 + _3 = discriminant(_1); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _3) -> [1: bb2, otherwise: bb1]; // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL + } + + bb1: { + unreachable; // scope 6 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + + bb2: { + _0 = move ((_1 as Some).0: T); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_2); // scope 0 at $DIR/unwrap_unchecked.rs:+1:9: +1:27 + return; // scope 0 at $DIR/unwrap_unchecked.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/instcombine_duplicate_switch_targets.assert_zero.InstCombine.diff b/tests/mir-opt/instcombine_duplicate_switch_targets.assert_zero.InstCombine.diff new file mode 100644 index 000000000..e04079453 --- /dev/null +++ b/tests/mir-opt/instcombine_duplicate_switch_targets.assert_zero.InstCombine.diff @@ -0,0 +1,21 @@ +- // MIR for `assert_zero` before InstCombine ++ // MIR for `assert_zero` after InstCombine + + fn assert_zero(_1: u8) -> u8 { + let mut _0: u8; // return place in scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+0:37: +0:39 + + bb0: { +- switchInt(_1) -> [0: bb2, 1: bb1, otherwise: bb1]; // scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+3:13: +7:14 ++ switchInt(_1) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+3:13: +7:14 + } + + bb1: { + unreachable; // scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+10:13: +10:26 + } + + bb2: { + _0 = _1; // scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+13:13: +13:20 + return; // scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+14:13: +14:21 + } + } + diff --git a/tests/mir-opt/instcombine_duplicate_switch_targets.rs b/tests/mir-opt/instcombine_duplicate_switch_targets.rs new file mode 100644 index 000000000..ef3b487af --- /dev/null +++ b/tests/mir-opt/instcombine_duplicate_switch_targets.rs @@ -0,0 +1,27 @@ +#![feature(custom_mir, core_intrinsics)] +#![crate_type = "lib"] + +use std::intrinsics::mir::*; + +// unit-test: InstCombine + +// EMIT_MIR instcombine_duplicate_switch_targets.assert_zero.InstCombine.diff +#[custom_mir(dialect = "runtime", phase = "post-cleanup")] +pub unsafe fn assert_zero(x: u8) -> u8 { + mir!( + { + match x { + 0 => retblock, + 1 => unreachable, + _ => unreachable, + } + } + unreachable = { + Unreachable() + } + retblock = { + RET = x; + Return() + } + ) +} diff --git a/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff b/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff index 2f6f5f87e..49006e012 100644 --- a/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff +++ b/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff @@ -14,7 +14,7 @@ bb1: { + Coverage::Expression(4294967295) = 1 + 2 for /the/src/instrument_coverage.rs:12:5 - 13:17; // scope 0 at /the/src/instrument_coverage.rs:+1:5: +5:6 - falseUnwind -> [real: bb2, cleanup: bb6]; // scope 0 at /the/src/instrument_coverage.rs:+1:5: +5:6 + falseUnwind -> [real: bb2, unwind: bb6]; // scope 0 at /the/src/instrument_coverage.rs:+1:5: +5:6 } bb2: { diff --git a/tests/mir-opt/intrinsic_asserts.generic.InstCombine.diff b/tests/mir-opt/intrinsic_asserts.generic.InstCombine.diff index 8ff64c1ea..09fc145e7 100644 --- a/tests/mir-opt/intrinsic_asserts.generic.InstCombine.diff +++ b/tests/mir-opt/intrinsic_asserts.generic.InstCombine.diff @@ -8,33 +8,33 @@ let _3: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:60 bb0: { - StorageLive(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:46 - _1 = assert_inhabited::<T>() -> bb1; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:46 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:46 + _1 = assert_inhabited::<T>() -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:46 // mir::Constant // + span: $DIR/intrinsic_asserts.rs:25:5: 25:44 // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_inhabited::<T>}, val: Value(<ZST>) } } bb1: { - StorageDead(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:46: +1:47 - StorageLive(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:47 - _2 = assert_zero_valid::<T>() -> bb2; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:47 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+1:46: +1:47 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:47 + _2 = assert_zero_valid::<T>() -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:47 // mir::Constant // + span: $DIR/intrinsic_asserts.rs:26:5: 26:45 // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_zero_valid::<T>}, val: Value(<ZST>) } } bb2: { - StorageDead(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:47: +2:48 - StorageLive(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:60 - _3 = assert_mem_uninitialized_valid::<T>() -> bb3; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:60 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+2:47: +2:48 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:60 + _3 = assert_mem_uninitialized_valid::<T>() -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:60 // mir::Constant // + span: $DIR/intrinsic_asserts.rs:27:5: 27:58 // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_mem_uninitialized_valid::<T>}, val: Value(<ZST>) } } bb3: { - StorageDead(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:60: +3:61 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+3:60: +3:61 nop; // scope 0 at $DIR/intrinsic_asserts.rs:+0:21: +4:2 return; // scope 0 at $DIR/intrinsic_asserts.rs:+4:2: +4:2 } diff --git a/tests/mir-opt/intrinsic_asserts.panics.InstCombine.diff b/tests/mir-opt/intrinsic_asserts.panics.InstCombine.diff index ddc015903..c52174ef5 100644 --- a/tests/mir-opt/intrinsic_asserts.panics.InstCombine.diff +++ b/tests/mir-opt/intrinsic_asserts.panics.InstCombine.diff @@ -8,19 +8,19 @@ let _3: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:62 bb0: { - StorageLive(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:50 -- _1 = assert_inhabited::<Never>() -> bb1; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:50 -+ _1 = assert_inhabited::<Never>(); // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:50 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:50 +- _1 = assert_inhabited::<Never>() -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:50 ++ _1 = assert_inhabited::<Never>() -> unwind unreachable; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:50 // mir::Constant // + span: $DIR/intrinsic_asserts.rs:17:5: 17:48 // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_inhabited::<Never>}, val: Value(<ZST>) } } bb1: { - StorageDead(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:50: +1:51 - StorageLive(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:49 -- _2 = assert_zero_valid::<&u8>() -> bb2; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:49 -+ _2 = assert_zero_valid::<&u8>(); // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:49 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+1:50: +1:51 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:49 +- _2 = assert_zero_valid::<&u8>() -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:49 ++ _2 = assert_zero_valid::<&u8>() -> unwind unreachable; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:49 // mir::Constant // + span: $DIR/intrinsic_asserts.rs:18:5: 18:47 // + user_ty: UserType(0) @@ -28,10 +28,10 @@ } bb2: { - StorageDead(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:49: +2:50 - StorageLive(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:62 -- _3 = assert_mem_uninitialized_valid::<&u8>() -> bb3; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:62 -+ _3 = assert_mem_uninitialized_valid::<&u8>(); // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:62 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+2:49: +2:50 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:62 +- _3 = assert_mem_uninitialized_valid::<&u8>() -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:62 ++ _3 = assert_mem_uninitialized_valid::<&u8>() -> unwind unreachable; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:62 // mir::Constant // + span: $DIR/intrinsic_asserts.rs:19:5: 19:60 // + user_ty: UserType(1) @@ -39,7 +39,7 @@ } bb3: { - StorageDead(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:62: +3:63 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+3:62: +3:63 nop; // scope 0 at $DIR/intrinsic_asserts.rs:+0:17: +4:2 return; // scope 0 at $DIR/intrinsic_asserts.rs:+4:2: +4:2 } diff --git a/tests/mir-opt/intrinsic_asserts.removable.InstCombine.diff b/tests/mir-opt/intrinsic_asserts.removable.InstCombine.diff index 568fbf1a0..d059d47ee 100644 --- a/tests/mir-opt/intrinsic_asserts.removable.InstCombine.diff +++ b/tests/mir-opt/intrinsic_asserts.removable.InstCombine.diff @@ -8,8 +8,8 @@ let _3: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:61 bb0: { - StorageLive(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:47 -- _1 = assert_inhabited::<()>() -> bb1; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:47 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:47 +- _1 = assert_inhabited::<()>() -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:47 - // mir::Constant - // + span: $DIR/intrinsic_asserts.rs:7:5: 7:45 - // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_inhabited::<()>}, val: Value(<ZST>) } @@ -17,9 +17,9 @@ } bb1: { - StorageDead(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:47: +1:48 - StorageLive(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:48 -- _2 = assert_zero_valid::<u8>() -> bb2; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:48 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+1:47: +1:48 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:48 +- _2 = assert_zero_valid::<u8>() -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:48 - // mir::Constant - // + span: $DIR/intrinsic_asserts.rs:8:5: 8:46 - // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_zero_valid::<u8>}, val: Value(<ZST>) } @@ -27,9 +27,9 @@ } bb2: { - StorageDead(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:48: +2:49 - StorageLive(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:61 -- _3 = assert_mem_uninitialized_valid::<u8>() -> bb3; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:61 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+2:48: +2:49 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:61 +- _3 = assert_mem_uninitialized_valid::<u8>() -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:61 - // mir::Constant - // + span: $DIR/intrinsic_asserts.rs:9:5: 9:59 - // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_mem_uninitialized_valid::<u8>}, val: Value(<ZST>) } @@ -37,7 +37,7 @@ } bb3: { - StorageDead(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:61: +3:62 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+3:61: +3:62 nop; // scope 0 at $DIR/intrinsic_asserts.rs:+0:20: +4:2 return; // scope 0 at $DIR/intrinsic_asserts.rs:+4:2: +4:2 } diff --git a/tests/mir-opt/issue_101973.inner.ConstProp.diff b/tests/mir-opt/issue_101973.inner.ConstProp.diff index 6db8e4d26..d048b9e65 100644 --- a/tests/mir-opt/issue_101973.inner.ConstProp.diff +++ b/tests/mir-opt/issue_101973.inner.ConstProp.diff @@ -12,18 +12,19 @@ let mut _7: u32; // in scope 0 at $DIR/issue_101973.rs:+1:31: +1:52 let mut _8: u32; // in scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 let mut _9: u32; // in scope 0 at $DIR/issue_101973.rs:+1:33: +1:39 - let mut _10: (u32, bool); // in scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 - let mut _11: (u32, bool); // in scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 - scope 1 (inlined imm8) { // at $DIR/issue_101973.rs:14:5: 14:17 - debug x => _1; // in scope 1 at $DIR/issue_101973.rs:5:13: 5:14 - let mut _12: u32; // in scope 1 at $DIR/issue_101973.rs:7:12: 7:27 - let mut _13: u32; // in scope 1 at $DIR/issue_101973.rs:7:12: 7:20 - let mut _14: (u32, bool); // in scope 1 at $DIR/issue_101973.rs:7:12: 7:20 + let mut _10: u32; // in scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 + let mut _11: bool; // in scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 + let mut _12: u32; // in scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 + let mut _13: bool; // in scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 + scope 1 (inlined imm8) { // at $DIR/issue_101973.rs:15:5: 15:17 + debug x => _1; // in scope 1 at $DIR/issue_101973.rs:6:13: 6:14 + let mut _14: u32; // in scope 1 at $DIR/issue_101973.rs:8:12: 8:27 + let mut _15: u32; // in scope 1 at $DIR/issue_101973.rs:8:12: 8:20 scope 2 { - debug out => _4; // in scope 2 at $DIR/issue_101973.rs:6:9: 6:16 + debug out => _4; // in scope 2 at $DIR/issue_101973.rs:7:9: 7:16 } } - scope 3 (inlined core::num::<impl u32>::rotate_right) { // at $DIR/issue_101973.rs:14:18: 14:58 + scope 3 (inlined core::num::<impl u32>::rotate_right) { // at $DIR/issue_101973.rs:15:18: 15:58 debug self => _4; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL debug n => _6; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL } @@ -32,43 +33,46 @@ StorageLive(_2); // scope 0 at $DIR/issue_101973.rs:+1:5: +1:65 StorageLive(_3); // scope 0 at $DIR/issue_101973.rs:+1:5: +1:58 StorageLive(_4); // scope 0 at $DIR/issue_101973.rs:+1:5: +1:17 - StorageLive(_12); // scope 2 at $DIR/issue_101973.rs:7:12: 7:27 - StorageLive(_13); // scope 2 at $DIR/issue_101973.rs:7:12: 7:20 - _14 = CheckedShr(_1, const 0_i32); // scope 2 at $DIR/issue_101973.rs:7:12: 7:20 - assert(!move (_14.1: bool), "attempt to shift right by `{}`, which would overflow", const 0_i32) -> bb3; // scope 2 at $DIR/issue_101973.rs:7:12: 7:20 + StorageLive(_14); // scope 2 at $DIR/issue_101973.rs:8:12: 8:27 + StorageLive(_15); // scope 2 at $DIR/issue_101973.rs:8:12: 8:20 + _15 = Shr(_1, const 0_i32); // scope 2 at $DIR/issue_101973.rs:8:12: 8:20 + _14 = BitAnd(move _15, const 255_u32); // scope 2 at $DIR/issue_101973.rs:8:12: 8:27 + StorageDead(_15); // scope 2 at $DIR/issue_101973.rs:8:26: 8:27 + _4 = BitOr(const 0_u32, move _14); // scope 2 at $DIR/issue_101973.rs:8:5: 8:27 + StorageDead(_14); // scope 2 at $DIR/issue_101973.rs:8:26: 8:27 + StorageLive(_6); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 + StorageLive(_7); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:52 + StorageLive(_8); // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 +- _10 = const 8_i32 as u32 (IntToInt); // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 +- _11 = Lt(move _10, const 32_u32); // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 +- assert(move _11, "attempt to shift right by `{}`, which would overflow", const 8_i32) -> bb1; // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 ++ _10 = const 8_u32; // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 ++ _11 = const true; // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 ++ assert(const true, "attempt to shift right by `{}`, which would overflow", const 8_i32) -> bb1; // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 } bb1: { - _8 = move (_10.0: u32); // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 + _8 = Shr(_1, const 8_i32); // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 _7 = BitAnd(move _8, const 15_u32); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:52 StorageDead(_8); // scope 0 at $DIR/issue_101973.rs:+1:51: +1:52 - _11 = CheckedShl(_7, const 1_i32); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 - assert(!move (_11.1: bool), "attempt to shift left by `{}`, which would overflow", const 1_i32) -> bb2; // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 +- _12 = const 1_i32 as u32 (IntToInt); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 +- _13 = Lt(move _12, const 32_u32); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 +- assert(move _13, "attempt to shift left by `{}`, which would overflow", const 1_i32) -> bb2; // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 ++ _12 = const 1_u32; // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 ++ _13 = const true; // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 ++ assert(const true, "attempt to shift left by `{}`, which would overflow", const 1_i32) -> bb2; // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 } bb2: { - _6 = move (_11.0: u32); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 + _6 = Shl(move _7, const 1_i32); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 StorageDead(_7); // scope 0 at $DIR/issue_101973.rs:+1:56: +1:57 - _3 = rotate_right::<u32>(_4, _6) -> bb4; // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _3 = rotate_right::<u32>(_4, _6) -> [return: bb3, unwind unreachable]; // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL // + literal: Const { ty: extern "rust-intrinsic" fn(u32, u32) -> u32 {rotate_right::<u32>}, val: Value(<ZST>) } } bb3: { - _13 = move (_14.0: u32); // scope 2 at $DIR/issue_101973.rs:7:12: 7:20 - _12 = BitAnd(move _13, const 255_u32); // scope 2 at $DIR/issue_101973.rs:7:12: 7:27 - StorageDead(_13); // scope 2 at $DIR/issue_101973.rs:7:26: 7:27 - _4 = BitOr(const 0_u32, move _12); // scope 2 at $DIR/issue_101973.rs:7:5: 7:27 - StorageDead(_12); // scope 2 at $DIR/issue_101973.rs:7:26: 7:27 - StorageLive(_6); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 - StorageLive(_7); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:52 - StorageLive(_8); // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 - _10 = CheckedShr(_1, const 8_i32); // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 - assert(!move (_10.1: bool), "attempt to shift right by `{}`, which would overflow", const 8_i32) -> bb1; // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 - } - - bb4: { StorageDead(_6); // scope 0 at $DIR/issue_101973.rs:+1:57: +1:58 StorageDead(_4); // scope 0 at $DIR/issue_101973.rs:+1:57: +1:58 _2 = move _3 as i32 (IntToInt); // scope 0 at $DIR/issue_101973.rs:+1:5: +1:65 diff --git a/tests/mir-opt/issue_101973.rs b/tests/mir-opt/issue_101973.rs index 216659a23..da388f149 100644 --- a/tests/mir-opt/issue_101973.rs +++ b/tests/mir-opt/issue_101973.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // compile-flags: -O -C debug-assertions=on // This needs inlining followed by ConstProp to reproduce, so we cannot use "unit-test". diff --git a/tests/mir-opt/issue_104451_unwindable_intrinsics.main.AbortUnwindingCalls.after.mir b/tests/mir-opt/issue_104451_unwindable_intrinsics.main.AbortUnwindingCalls.after.mir new file mode 100644 index 000000000..f50c0eb47 --- /dev/null +++ b/tests/mir-opt/issue_104451_unwindable_intrinsics.main.AbortUnwindingCalls.after.mir @@ -0,0 +1,25 @@ +// MIR for `main` after AbortUnwindingCalls + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue_104451_unwindable_intrinsics.rs:+0:11: +0:11 + let mut _1: !; // in scope 0 at $DIR/issue_104451_unwindable_intrinsics.rs:+2:9: +2:62 + let mut _2: (); // in scope 0 at $DIR/issue_104451_unwindable_intrinsics.rs:+2:45: +2:47 + scope 1 { + } + + bb0: { + StorageLive(_1); // scope 1 at $DIR/issue_104451_unwindable_intrinsics.rs:+2:9: +2:62 + StorageLive(_2); // scope 1 at $DIR/issue_104451_unwindable_intrinsics.rs:+2:45: +2:47 + _2 = (); // scope 1 at $DIR/issue_104451_unwindable_intrinsics.rs:+2:45: +2:47 + _1 = const_eval_select::<(), fn() -> ! {ow_ct}, fn() -> ! {ow_ct}, !>(move _2, ow_ct, ow_ct); // scope 1 at $DIR/issue_104451_unwindable_intrinsics.rs:+2:9: +2:62 + // mir::Constant + // + span: $DIR/issue_104451_unwindable_intrinsics.rs:8:9: 8:44 + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn((), fn() -> ! {ow_ct}, fn() -> ! {ow_ct}) -> ! {const_eval_select::<(), fn() -> ! {ow_ct}, fn() -> ! {ow_ct}, !>}, val: Value(<ZST>) } + // mir::Constant + // + span: $DIR/issue_104451_unwindable_intrinsics.rs:8:49: 8:54 + // + literal: Const { ty: fn() -> ! {ow_ct}, val: Value(<ZST>) } + // mir::Constant + // + span: $DIR/issue_104451_unwindable_intrinsics.rs:8:56: 8:61 + // + literal: Const { ty: fn() -> ! {ow_ct}, val: Value(<ZST>) } + } +} diff --git a/tests/mir-opt/issue_104451_unwindable_intrinsics.rs b/tests/mir-opt/issue_104451_unwindable_intrinsics.rs new file mode 100644 index 000000000..9babd4aae --- /dev/null +++ b/tests/mir-opt/issue_104451_unwindable_intrinsics.rs @@ -0,0 +1,14 @@ +// Check that `UnwindAction::Unreachable` is not generated for unwindable intrinsics. +// ignore-wasm32 compiled with panic=abort by default +#![feature(core_intrinsics)] + +// EMIT_MIR issue_104451_unwindable_intrinsics.main.AbortUnwindingCalls.after.mir +fn main() { + unsafe { + core::intrinsics::const_eval_select((), ow_ct, ow_ct) + } +} + +const fn ow_ct() -> ! { + panic!(); +} diff --git a/tests/mir-opt/issue_38669.main.SimplifyCfg-initial.after.mir b/tests/mir-opt/issue_38669.main.SimplifyCfg-initial.after.mir index b0d5b291b..ccaa508c1 100644 --- a/tests/mir-opt/issue_38669.main.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/issue_38669.main.SimplifyCfg-initial.after.mir @@ -19,7 +19,7 @@ fn main() -> () { } bb1: { - falseUnwind -> [real: bb2, cleanup: bb5]; // scope 1 at $DIR/issue_38669.rs:+2:5: +7:6 + falseUnwind -> [real: bb2, unwind: bb5]; // scope 1 at $DIR/issue_38669.rs:+2:5: +7:6 } bb2: { diff --git a/tests/mir-opt/issue_41110.main.ElaborateDrops.diff b/tests/mir-opt/issue_41110.main.ElaborateDrops.diff index 7ac75b51a..ac2520249 100644 --- a/tests/mir-opt/issue_41110.main.ElaborateDrops.diff +++ b/tests/mir-opt/issue_41110.main.ElaborateDrops.diff @@ -46,17 +46,17 @@ } bb3 (cleanup): { -- drop(_3) -> bb5; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 +- drop(_3) -> [return: bb5, unwind terminate]; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 + goto -> bb5; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 } bb4 (cleanup): { -- drop(_4) -> bb5; // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27 +- drop(_4) -> [return: bb5, unwind terminate]; // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27 + goto -> bb5; // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27 } bb5 (cleanup): { -- drop(_2) -> bb6; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 +- drop(_2) -> [return: bb6, unwind terminate]; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 + goto -> bb8; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 } @@ -65,7 +65,7 @@ + } + + bb7 (cleanup): { -+ drop(_2) -> bb6; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 ++ drop(_2) -> [return: bb6, unwind terminate]; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 + } + + bb8 (cleanup): { diff --git a/tests/mir-opt/issue_41110.test.ElaborateDrops.diff b/tests/mir-opt/issue_41110.test.ElaborateDrops.diff index 79e3d073b..a4a07ad12 100644 --- a/tests/mir-opt/issue_41110.test.ElaborateDrops.diff +++ b/tests/mir-opt/issue_41110.test.ElaborateDrops.diff @@ -38,50 +38,52 @@ StorageLive(_5); // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 + _6 = const false; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 _5 = move _1; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 -- replace(_2 <- move _5) -> [return: bb2, unwind: bb6]; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 -+ goto -> bb12; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 +- drop(_2) -> [return: bb2, unwind: bb3]; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 ++ goto -> bb2; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 } bb2: { -- drop(_5) -> [return: bb3, unwind: bb8]; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 -+ goto -> bb3; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 + _2 = move _5; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 +- drop(_5) -> [return: bb4, unwind: bb8]; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 ++ goto -> bb4; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 + } + + bb3 (cleanup): { + _2 = move _5; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 + drop(_5) -> [return: bb8, unwind terminate]; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 } - bb3: { + bb4: { StorageDead(_5); // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 _0 = const (); // scope 0 at $DIR/issue_41110.rs:+0:15: +5:2 - drop(_2) -> [return: bb4, unwind: bb9]; // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2 + drop(_2) -> [return: bb5, unwind: bb9]; // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2 } - bb4: { + bb5: { StorageDead(_2); // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2 -- drop(_1) -> bb5; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 -+ goto -> bb5; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 +- drop(_1) -> bb6; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 ++ goto -> bb6; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 } - bb5: { + bb6: { + _6 = const false; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 StorageDead(_1); // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 return; // scope 0 at $DIR/issue_41110.rs:+5:2: +5:2 } - bb6 (cleanup): { - drop(_5) -> bb8; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 - } - bb7 (cleanup): { -- drop(_4) -> bb8; // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12 +- drop(_4) -> [return: bb8, unwind terminate]; // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12 + goto -> bb8; // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12 } bb8 (cleanup): { -- drop(_2) -> bb9; // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2 +- drop(_2) -> [return: bb9, unwind terminate]; // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2 + goto -> bb9; // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2 } bb9 (cleanup): { -- drop(_1) -> bb10; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 -+ goto -> bb14; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 +- drop(_1) -> [return: bb10, unwind terminate]; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 ++ goto -> bb13; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 } bb10 (cleanup): { @@ -89,21 +91,15 @@ + } + + bb11 (cleanup): { -+ _2 = move _5; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 -+ goto -> bb10; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 ++ unreachable; // scope 0 at $DIR/issue_41110.rs:+0:1: +5:2 + } + -+ bb12: { -+ _2 = move _5; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 -+ goto -> bb2; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 ++ bb12 (cleanup): { ++ drop(_1) -> [return: bb10, unwind terminate]; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 + } + + bb13 (cleanup): { -+ drop(_1) -> bb10; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 -+ } -+ -+ bb14 (cleanup): { -+ switchInt(_6) -> [0: bb10, otherwise: bb13]; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 ++ switchInt(_6) -> [0: bb10, otherwise: bb12]; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 } } diff --git a/tests/mir-opt/issue_41888.main.ElaborateDrops.diff b/tests/mir-opt/issue_41888.main.ElaborateDrops.diff index 257f0b1e6..d98f75e75 100644 --- a/tests/mir-opt/issue_41888.main.ElaborateDrops.diff +++ b/tests/mir-opt/issue_41888.main.ElaborateDrops.diff @@ -34,7 +34,7 @@ } bb1: { - switchInt(move _2) -> [0: bb7, otherwise: bb2]; // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14 + switchInt(move _2) -> [0: bb8, otherwise: bb2]; // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14 } bb2: { @@ -43,47 +43,56 @@ _4 = K; // scope 1 at $DIR/issue_41888.rs:+3:18: +3:19 _3 = E::F(move _4); // scope 1 at $DIR/issue_41888.rs:+3:13: +3:20 StorageDead(_4); // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 -- replace(_1 <- move _3) -> [return: bb3, unwind: bb10]; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 -+ goto -> bb14; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 +- drop(_1) -> [return: bb3, unwind: bb4]; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 ++ goto -> bb3; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 } bb3: { -- drop(_3) -> [return: bb4, unwind: bb11]; // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 -+ goto -> bb4; // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 ++ _7 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 ++ _8 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 ++ _9 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 + _1 = move _3; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 +- drop(_3) -> [return: bb5, unwind: bb11]; // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 ++ goto -> bb5; // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 } - bb4: { + bb4 (cleanup): { + _1 = move _3; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 + drop(_3) -> [return: bb11, unwind terminate]; // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 + } + + bb5: { StorageDead(_3); // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 _5 = discriminant(_1); // scope 2 at $DIR/issue_41888.rs:+4:16: +4:24 - switchInt(move _5) -> [0: bb5, otherwise: bb6]; // scope 2 at $DIR/issue_41888.rs:+4:16: +4:24 + switchInt(move _5) -> [0: bb6, otherwise: bb7]; // scope 2 at $DIR/issue_41888.rs:+4:16: +4:24 } - bb5: { + bb6: { StorageLive(_6); // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23 + _9 = const false; // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23 _6 = move ((_1 as F).0: K); // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23 _0 = const (); // scope 2 at $DIR/issue_41888.rs:+4:29: +7:10 StorageDead(_6); // scope 1 at $DIR/issue_41888.rs:+7:9: +7:10 - goto -> bb8; // scope 1 at $DIR/issue_41888.rs:+4:9: +7:10 + goto -> bb9; // scope 1 at $DIR/issue_41888.rs:+4:9: +7:10 } - bb6: { + bb7: { _0 = const (); // scope 1 at $DIR/issue_41888.rs:+7:10: +7:10 - goto -> bb8; // scope 1 at $DIR/issue_41888.rs:+4:9: +7:10 + goto -> bb9; // scope 1 at $DIR/issue_41888.rs:+4:9: +7:10 } - bb7: { + bb8: { _0 = const (); // scope 1 at $DIR/issue_41888.rs:+8:6: +8:6 - goto -> bb8; // scope 1 at $DIR/issue_41888.rs:+2:5: +8:6 + goto -> bb9; // scope 1 at $DIR/issue_41888.rs:+2:5: +8:6 } - bb8: { + bb9: { StorageDead(_2); // scope 1 at $DIR/issue_41888.rs:+8:5: +8:6 -- drop(_1) -> bb9; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 -+ goto -> bb20; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 +- drop(_1) -> bb10; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ goto -> bb19; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 } - bb9: { + bb10: { + _7 = const false; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + _8 = const false; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + _9 = const false; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 @@ -91,12 +100,8 @@ return; // scope 0 at $DIR/issue_41888.rs:+9:2: +9:2 } - bb10 (cleanup): { - drop(_3) -> bb11; // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 - } - bb11 (cleanup): { -- drop(_1) -> bb12; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 +- drop(_1) -> [return: bb12, unwind terminate]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + goto -> bb12; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 } @@ -105,54 +110,42 @@ + } + + bb13 (cleanup): { -+ _7 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 -+ _8 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 -+ _9 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 -+ _1 = move _3; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 -+ goto -> bb12; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 ++ unreachable; // scope 0 at $DIR/issue_41888.rs:+0:1: +9:2 + } + + bb14: { -+ _7 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 -+ _8 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 -+ _9 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 -+ _1 = move _3; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 -+ goto -> bb3; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 -+ } -+ -+ bb15: { + _7 = const false; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 -+ goto -> bb9; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ goto -> bb10; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + } + -+ bb16 (cleanup): { ++ bb15 (cleanup): { + goto -> bb12; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + } + -+ bb17: { -+ drop(_1) -> [return: bb15, unwind: bb12]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ bb16: { ++ drop(_1) -> [return: bb14, unwind: bb12]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + } + -+ bb18 (cleanup): { -+ drop(_1) -> bb12; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ bb17 (cleanup): { ++ drop(_1) -> [return: bb12, unwind terminate]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + } + -+ bb19: { ++ bb18: { + _10 = discriminant(_1); // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 -+ switchInt(move _10) -> [0: bb15, otherwise: bb17]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ switchInt(move _10) -> [0: bb14, otherwise: bb16]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + } + -+ bb20: { -+ switchInt(_7) -> [0: bb15, otherwise: bb19]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ bb19: { ++ switchInt(_7) -> [0: bb14, otherwise: bb18]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + } + -+ bb21 (cleanup): { ++ bb20 (cleanup): { + _11 = discriminant(_1); // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 -+ switchInt(move _11) -> [0: bb16, otherwise: bb18]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ switchInt(move _11) -> [0: bb15, otherwise: bb17]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + } + -+ bb22 (cleanup): { -+ switchInt(_7) -> [0: bb12, otherwise: bb21]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ bb21 (cleanup): { ++ switchInt(_7) -> [0: bb12, otherwise: bb20]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 } } diff --git a/tests/mir-opt/issue_62289.rs b/tests/mir-opt/issue_62289.rs index 37e3390d5..af1bfea3f 100644 --- a/tests/mir-opt/issue_62289.rs +++ b/tests/mir-opt/issue_62289.rs @@ -2,11 +2,14 @@ // initializing it // ignore-wasm32-bare compiled with panic=abort by default -#![feature(box_syntax)] +#![feature(rustc_attrs)] // EMIT_MIR issue_62289.test.ElaborateDrops.before.mir fn test() -> Option<Box<u32>> { - Some(box (None?)) + Some( + #[rustc_box] + Box::new(None?), + ) } fn main() { diff --git a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.mir b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.mir index adfa3a773..8ed910150 100644 --- a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.mir +++ b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.mir @@ -2,121 +2,121 @@ fn test() -> Option<Box<u32>> { let mut _0: std::option::Option<std::boxed::Box<u32>>; // return place in scope 0 at $DIR/issue_62289.rs:+0:14: +0:30 - let mut _1: std::boxed::Box<u32>; // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 - let mut _2: usize; // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 - let mut _3: usize; // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 - let mut _4: *mut u8; // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 - let mut _5: std::boxed::Box<u32>; // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 - let mut _6: std::ops::ControlFlow<std::option::Option<std::convert::Infallible>, u32>; // in scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 - let mut _7: std::option::Option<u32>; // in scope 0 at $DIR/issue_62289.rs:+1:15: +1:19 - let mut _8: isize; // in scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 - let _9: std::option::Option<std::convert::Infallible>; // in scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 - let mut _10: !; // in scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 - let mut _11: std::option::Option<std::convert::Infallible>; // in scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 - let _12: u32; // in scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 + let mut _1: std::boxed::Box<u32>; // in scope 0 at $DIR/issue_62289.rs:+3:9: +3:24 + let mut _2: usize; // in scope 0 at $DIR/issue_62289.rs:+3:9: +3:24 + let mut _3: usize; // in scope 0 at $DIR/issue_62289.rs:+3:9: +3:24 + let mut _4: *mut u8; // in scope 0 at $DIR/issue_62289.rs:+3:9: +3:24 + let mut _5: std::boxed::Box<u32>; // in scope 0 at $DIR/issue_62289.rs:+3:9: +3:24 + let mut _6: std::ops::ControlFlow<std::option::Option<std::convert::Infallible>, u32>; // in scope 0 at $DIR/issue_62289.rs:+3:18: +3:23 + let mut _7: std::option::Option<u32>; // in scope 0 at $DIR/issue_62289.rs:+3:18: +3:22 + let mut _8: isize; // in scope 0 at $DIR/issue_62289.rs:+3:22: +3:23 + let _9: std::option::Option<std::convert::Infallible>; // in scope 0 at $DIR/issue_62289.rs:+3:22: +3:23 + let mut _10: !; // in scope 0 at $DIR/issue_62289.rs:+3:22: +3:23 + let mut _11: std::option::Option<std::convert::Infallible>; // in scope 0 at $DIR/issue_62289.rs:+3:22: +3:23 + let _12: u32; // in scope 0 at $DIR/issue_62289.rs:+3:18: +3:23 scope 1 { } scope 2 { - debug residual => _9; // in scope 2 at $DIR/issue_62289.rs:+1:19: +1:20 + debug residual => _9; // in scope 2 at $DIR/issue_62289.rs:+3:22: +3:23 scope 3 { } } scope 4 { - debug val => _12; // in scope 4 at $DIR/issue_62289.rs:+1:15: +1:20 + debug val => _12; // in scope 4 at $DIR/issue_62289.rs:+3:18: +3:23 scope 5 { } } bb0: { - StorageLive(_1); // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 - _2 = SizeOf(u32); // scope 1 at $DIR/issue_62289.rs:+1:10: +1:21 - _3 = AlignOf(u32); // scope 1 at $DIR/issue_62289.rs:+1:10: +1:21 - _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 1 at $DIR/issue_62289.rs:+1:10: +1:21 + StorageLive(_1); // scope 0 at $DIR/issue_62289.rs:+3:9: +3:24 + _2 = SizeOf(u32); // scope 1 at $DIR/issue_62289.rs:+3:9: +3:24 + _3 = AlignOf(u32); // scope 1 at $DIR/issue_62289.rs:+3:9: +3:24 + _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 1 at $DIR/issue_62289.rs:+3:9: +3:24 // mir::Constant - // + span: $DIR/issue_62289.rs:9:10: 9:21 + // + span: $DIR/issue_62289.rs:11:9: 11:24 // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) } } bb1: { - StorageLive(_5); // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 - _5 = ShallowInitBox(move _4, u32); // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 - StorageLive(_6); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 - StorageLive(_7); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:19 - _7 = Option::<u32>::None; // scope 0 at $DIR/issue_62289.rs:+1:15: +1:19 - _6 = <Option<u32> as Try>::branch(move _7) -> [return: bb2, unwind: bb12]; // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 + StorageLive(_5); // scope 0 at $DIR/issue_62289.rs:+3:9: +3:24 + _5 = ShallowInitBox(move _4, u32); // scope 0 at $DIR/issue_62289.rs:+3:9: +3:24 + StorageLive(_6); // scope 0 at $DIR/issue_62289.rs:+3:18: +3:23 + StorageLive(_7); // scope 0 at $DIR/issue_62289.rs:+3:18: +3:22 + _7 = Option::<u32>::None; // scope 0 at $DIR/issue_62289.rs:+3:18: +3:22 + _6 = <Option<u32> as Try>::branch(move _7) -> [return: bb2, unwind: bb12]; // scope 0 at $DIR/issue_62289.rs:+3:18: +3:23 // mir::Constant - // + span: $DIR/issue_62289.rs:9:15: 9:20 + // + span: $DIR/issue_62289.rs:11:18: 11:23 // + literal: Const { ty: fn(Option<u32>) -> ControlFlow<<Option<u32> as Try>::Residual, <Option<u32> as Try>::Output> {<Option<u32> as Try>::branch}, val: Value(<ZST>) } } bb2: { - StorageDead(_7); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 - _8 = discriminant(_6); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 - switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb4]; // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 + StorageDead(_7); // scope 0 at $DIR/issue_62289.rs:+3:22: +3:23 + _8 = discriminant(_6); // scope 0 at $DIR/issue_62289.rs:+3:18: +3:23 + switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb4]; // scope 0 at $DIR/issue_62289.rs:+3:18: +3:23 } bb3: { - StorageLive(_12); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 - _12 = ((_6 as Continue).0: u32); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 - (*_5) = _12; // scope 5 at $DIR/issue_62289.rs:+1:15: +1:20 - StorageDead(_12); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 - _1 = move _5; // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 - drop(_5) -> [return: bb7, unwind: bb11]; // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21 + StorageLive(_12); // scope 0 at $DIR/issue_62289.rs:+3:18: +3:23 + _12 = ((_6 as Continue).0: u32); // scope 0 at $DIR/issue_62289.rs:+3:18: +3:23 + (*_5) = _12; // scope 5 at $DIR/issue_62289.rs:+3:18: +3:23 + StorageDead(_12); // scope 0 at $DIR/issue_62289.rs:+3:22: +3:23 + _1 = move _5; // scope 0 at $DIR/issue_62289.rs:+3:9: +3:24 + drop(_5) -> [return: bb7, unwind: bb11]; // scope 0 at $DIR/issue_62289.rs:+3:23: +3:24 } bb4: { - unreachable; // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 + unreachable; // scope 0 at $DIR/issue_62289.rs:+3:18: +3:23 } bb5: { - StorageLive(_9); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 - _9 = ((_6 as Break).0: std::option::Option<std::convert::Infallible>); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 - StorageLive(_11); // scope 3 at $DIR/issue_62289.rs:+1:19: +1:20 - _11 = _9; // scope 3 at $DIR/issue_62289.rs:+1:19: +1:20 - _0 = <Option<Box<u32>> as FromResidual<Option<Infallible>>>::from_residual(move _11) -> [return: bb6, unwind: bb12]; // scope 3 at $DIR/issue_62289.rs:+1:15: +1:20 + StorageLive(_9); // scope 0 at $DIR/issue_62289.rs:+3:22: +3:23 + _9 = ((_6 as Break).0: std::option::Option<std::convert::Infallible>); // scope 0 at $DIR/issue_62289.rs:+3:22: +3:23 + StorageLive(_11); // scope 3 at $DIR/issue_62289.rs:+3:22: +3:23 + _11 = _9; // scope 3 at $DIR/issue_62289.rs:+3:22: +3:23 + _0 = <Option<Box<u32>> as FromResidual<Option<Infallible>>>::from_residual(move _11) -> [return: bb6, unwind: bb12]; // scope 3 at $DIR/issue_62289.rs:+3:18: +3:23 // mir::Constant - // + span: $DIR/issue_62289.rs:9:19: 9:20 + // + span: $DIR/issue_62289.rs:11:22: 11:23 // + literal: Const { ty: fn(Option<Infallible>) -> Option<Box<u32>> {<Option<Box<u32>> as FromResidual<Option<Infallible>>>::from_residual}, val: Value(<ZST>) } } bb6: { - StorageDead(_11); // scope 3 at $DIR/issue_62289.rs:+1:19: +1:20 - StorageDead(_9); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 - drop(_5) -> bb9; // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21 + StorageDead(_11); // scope 3 at $DIR/issue_62289.rs:+3:22: +3:23 + StorageDead(_9); // scope 0 at $DIR/issue_62289.rs:+3:22: +3:23 + drop(_5) -> bb9; // scope 0 at $DIR/issue_62289.rs:+3:23: +3:24 } bb7: { - StorageDead(_5); // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21 - _0 = Option::<Box<u32>>::Some(move _1); // scope 0 at $DIR/issue_62289.rs:+1:5: +1:22 - drop(_1) -> bb8; // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22 + StorageDead(_5); // scope 0 at $DIR/issue_62289.rs:+3:23: +3:24 + _0 = Option::<Box<u32>>::Some(move _1); // scope 0 at $DIR/issue_62289.rs:+1:5: +4:6 + drop(_1) -> bb8; // scope 0 at $DIR/issue_62289.rs:+4:5: +4:6 } bb8: { - StorageDead(_1); // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22 - StorageDead(_6); // scope 0 at $DIR/issue_62289.rs:+2:1: +2:2 - goto -> bb10; // scope 0 at $DIR/issue_62289.rs:+2:2: +2:2 + StorageDead(_1); // scope 0 at $DIR/issue_62289.rs:+4:5: +4:6 + StorageDead(_6); // scope 0 at $DIR/issue_62289.rs:+5:1: +5:2 + goto -> bb10; // scope 0 at $DIR/issue_62289.rs:+5:2: +5:2 } bb9: { - StorageDead(_5); // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21 - StorageDead(_1); // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22 - StorageDead(_6); // scope 0 at $DIR/issue_62289.rs:+2:1: +2:2 - goto -> bb10; // scope 0 at $DIR/issue_62289.rs:+2:2: +2:2 + StorageDead(_5); // scope 0 at $DIR/issue_62289.rs:+3:23: +3:24 + StorageDead(_1); // scope 0 at $DIR/issue_62289.rs:+4:5: +4:6 + StorageDead(_6); // scope 0 at $DIR/issue_62289.rs:+5:1: +5:2 + goto -> bb10; // scope 0 at $DIR/issue_62289.rs:+5:2: +5:2 } bb10: { - return; // scope 0 at $DIR/issue_62289.rs:+2:2: +2:2 + return; // scope 0 at $DIR/issue_62289.rs:+5:2: +5:2 } bb11 (cleanup): { - drop(_1) -> bb13; // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22 + drop(_1) -> [return: bb13, unwind terminate]; // scope 0 at $DIR/issue_62289.rs:+4:5: +4:6 } bb12 (cleanup): { - drop(_5) -> bb13; // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21 + drop(_5) -> [return: bb13, unwind terminate]; // scope 0 at $DIR/issue_62289.rs:+3:23: +3:24 } bb13 (cleanup): { - resume; // scope 0 at $DIR/issue_62289.rs:+0:1: +2:2 + resume; // scope 0 at $DIR/issue_62289.rs:+0:1: +5:2 } } diff --git a/tests/mir-opt/issue_72181.main.built.after.mir b/tests/mir-opt/issue_72181.main.built.after.mir index e86836927..724e55e17 100644 --- a/tests/mir-opt/issue_72181.main.built.after.mir +++ b/tests/mir-opt/issue_72181.main.built.after.mir @@ -29,6 +29,7 @@ fn main() -> () { } bb1: { + PlaceMention(_1); // scope 0 at $DIR/issue_72181.rs:+1:13: +1:34 StorageDead(_1); // scope 0 at $DIR/issue_72181.rs:+1:34: +1:35 StorageLive(_2); // scope 1 at $DIR/issue_72181.rs:+3:9: +3:10 StorageLive(_3); // scope 1 at $DIR/issue_72181.rs:+3:14: +3:27 @@ -49,6 +50,7 @@ fn main() -> () { bb2: { _5 = (_2[_6].0: u64); // scope 4 at $DIR/issue_72181.rs:+4:22: +4:28 + PlaceMention(_5); // scope 2 at $DIR/issue_72181.rs:+4:13: +4:30 StorageDead(_6); // scope 2 at $DIR/issue_72181.rs:+4:30: +4:31 StorageDead(_5); // scope 2 at $DIR/issue_72181.rs:+4:30: +4:31 _0 = const (); // scope 0 at $DIR/issue_72181.rs:+0:11: +5:2 diff --git a/tests/mir-opt/issue_72181_1.main.built.after.mir b/tests/mir-opt/issue_72181_1.main.built.after.mir index 2172f3aa9..e1d896cbc 100644 --- a/tests/mir-opt/issue_72181_1.main.built.after.mir +++ b/tests/mir-opt/issue_72181_1.main.built.after.mir @@ -1,8 +1,8 @@ // MIR for `main` after built | User Type Annotations -| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(Void) }, span: $DIR/issue_72181_1.rs:16:12: 16:16, inferred_ty: Void -| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(Void) }, span: $DIR/issue_72181_1.rs:16:12: 16:16, inferred_ty: Void +| 0: user_ty: Canonical { value: Ty(Void), max_universe: U0, variables: [] }, span: $DIR/issue_72181_1.rs:16:12: 16:16, inferred_ty: Void +| 1: user_ty: Canonical { value: Ty(Void), max_universe: U0, variables: [] }, span: $DIR/issue_72181_1.rs:16:12: 16:16, inferred_ty: Void | fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/issue_72181_1.rs:+0:11: +0:11 diff --git a/tests/mir-opt/issue_76432.rs b/tests/mir-opt/issue_76432.rs index fbbfd4ceb..76bb11aae 100644 --- a/tests/mir-opt/issue_76432.rs +++ b/tests/mir-opt/issue_76432.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // compile-flags: -Zmir-enable-passes=-NormalizeArrayLen // Check that we do not insert StorageDead at each target if StorageDead was never seen diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff index cc4f7cc06..abb89b91d 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff @@ -42,7 +42,6 @@ } bb1: { - StorageLive(_15); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL _15 = core::panicking::panic(const "internal error: entered unreachable code"); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/panic.rs:LL:COL diff --git a/tests/mir-opt/issue_91633.bar.built.after.mir b/tests/mir-opt/issue_91633.bar.built.after.mir index c3fb90e84..88a383015 100644 --- a/tests/mir-opt/issue_91633.bar.built.after.mir +++ b/tests/mir-opt/issue_91633.bar.built.after.mir @@ -20,6 +20,7 @@ fn bar(_1: Box<[T]>) -> () { bb1: { StorageDead(_3); // scope 0 at $DIR/issue_91633.rs:+4:18: +4:19 + PlaceMention((*_2)); // scope 0 at $DIR/issue_91633.rs:+4:14: +4:19 StorageDead(_2); // scope 0 at $DIR/issue_91633.rs:+4:19: +4:20 _0 = const (); // scope 0 at $DIR/issue_91633.rs:+3:2: +5:3 drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue_91633.rs:+5:2: +5:3 @@ -30,7 +31,7 @@ fn bar(_1: Box<[T]>) -> () { } bb3 (cleanup): { - drop(_1) -> bb4; // scope 0 at $DIR/issue_91633.rs:+5:2: +5:3 + drop(_1) -> [return: bb4, unwind terminate]; // scope 0 at $DIR/issue_91633.rs:+5:2: +5:3 } bb4 (cleanup): { diff --git a/tests/mir-opt/issue_91633.foo.built.after.mir b/tests/mir-opt/issue_91633.foo.built.after.mir index 4e3dd365e..569135803 100644 --- a/tests/mir-opt/issue_91633.foo.built.after.mir +++ b/tests/mir-opt/issue_91633.foo.built.after.mir @@ -48,7 +48,7 @@ fn foo(_1: Box<[T]>) -> T { } bb5 (cleanup): { - drop(_1) -> bb6; // scope 0 at $DIR/issue_91633.rs:+4:2: +4:3 + drop(_1) -> [return: bb6, unwind terminate]; // scope 0 at $DIR/issue_91633.rs:+4:2: +4:3 } bb6 (cleanup): { diff --git a/tests/mir-opt/issue_91633.hey.built.after.mir b/tests/mir-opt/issue_91633.hey.built.after.mir index ccb06dd59..19f0c133e 100644 --- a/tests/mir-opt/issue_91633.hey.built.after.mir +++ b/tests/mir-opt/issue_91633.hey.built.after.mir @@ -23,6 +23,7 @@ fn hey(_1: &[T]) -> () { bb1: { StorageDead(_4); // scope 0 at $DIR/issue_91633.rs:+4:19: +4:20 _2 = &(*_3); // scope 0 at $DIR/issue_91633.rs:+4:14: +4:20 + PlaceMention(_2); // scope 0 at $DIR/issue_91633.rs:+4:14: +4:20 StorageDead(_2); // scope 0 at $DIR/issue_91633.rs:+4:20: +4:21 _0 = const (); // scope 0 at $DIR/issue_91633.rs:+3:2: +5:3 StorageDead(_3); // scope 0 at $DIR/issue_91633.rs:+5:2: +5:3 diff --git a/tests/mir-opt/issue_99325.main.built.after.mir b/tests/mir-opt/issue_99325.main.built.after.mir index 3e035c18d..2324f5356 100644 --- a/tests/mir-opt/issue_99325.main.built.after.mir +++ b/tests/mir-opt/issue_99325.main.built.after.mir @@ -1,8 +1,8 @@ // MIR for `main` after built | User Type Annotations -| 0: user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:3 ~ issue_99325[8f58]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Value(Branch([Leaf(0x41), Leaf(0x41), Leaf(0x41), Leaf(0x41)])) }], user_self_ty: None }) }, span: $DIR/issue_99325.rs:10:16: 10:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} -| 1: user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:3 ~ issue_99325[8f58]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Unevaluated(UnevaluatedConst { def: WithOptConstParam { did: DefId(0:8 ~ issue_99325[8f58]::main::{constant#1}), const_param_did: Some(DefId(0:4 ~ issue_99325[8f58]::function_with_bytes::BYTES)) }, substs: [] }) }], user_self_ty: None }) }, span: $DIR/issue_99325.rs:11:16: 11:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} +| 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Value(Branch([Leaf(0x41), Leaf(0x41), Leaf(0x41), Leaf(0x41)])) }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:10:16: 10:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} +| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Unevaluated(UnevaluatedConst { def: WithOptConstParam { did: DefId(0:8 ~ issue_99325[22bb]::main::{constant#1}), const_param_did: Some(DefId(0:4 ~ issue_99325[22bb]::function_with_bytes::BYTES)) }, substs: [] }) }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:11:16: 11:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} | fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/issue_99325.rs:+0:15: +0:15 diff --git a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir index 291fc5063..42b605326 100644 --- a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir +++ b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir @@ -5,7 +5,7 @@ fn num_to_digit(_1: char) -> u32 { let mut _0: u32; // return place in scope 0 at $DIR/issue_59352.rs:+0:35: +0:38 let mut _2: std::option::Option<u32>; // in scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 let mut _3: u32; // in scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 - scope 1 (inlined char::methods::<impl char>::is_digit) { // at $DIR/issue_59352.rs:14:12: 14:23 + scope 1 (inlined char::methods::<impl char>::is_digit) { // at $DIR/issue_59352.rs:15:12: 15:23 debug self => _1; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL debug radix => _3; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL let mut _4: &std::option::Option<u32>; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL @@ -15,7 +15,7 @@ fn num_to_digit(_1: char) -> u32 { let mut _6: isize; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL } } - scope 3 (inlined #[track_caller] Option::<u32>::unwrap) { // at $DIR/issue_59352.rs:14:42: 14:50 + scope 3 (inlined #[track_caller] Option::<u32>::unwrap) { // at $DIR/issue_59352.rs:15:42: 15:50 debug self => _2; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL let mut _7: isize; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL let mut _8: !; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL @@ -38,7 +38,7 @@ fn num_to_digit(_1: char) -> u32 { StorageLive(_2); // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 _2 = char::methods::<impl char>::to_digit(_1, const 8_u32) -> bb2; // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 // mir::Constant - // + span: $DIR/issue_59352.rs:14:30: 14:38 + // + span: $DIR/issue_59352.rs:15:30: 15:38 // + literal: Const { ty: fn(char, u32) -> Option<u32> {char::methods::<impl char>::to_digit}, val: Value(<ZST>) } } @@ -66,7 +66,6 @@ fn num_to_digit(_1: char) -> u32 { } bb6: { - StorageLive(_8); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL _8 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value"); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/option.rs:LL:COL diff --git a/tests/mir-opt/issues/issue_59352.rs b/tests/mir-opt/issues/issue_59352.rs index 1e0045555..92011bd65 100644 --- a/tests/mir-opt/issues/issue_59352.rs +++ b/tests/mir-opt/issues/issue_59352.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // This test is a mirror of codegen/issue-59352.rs. // The LLVM inliner doesn't inline `char::method::is_digit()` and so it doesn't recognize this case // as effectively `if x.is_some() { x.unwrap() } else { 0 }`. diff --git a/tests/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff b/tests/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff index bcda12880..8e6e6fc0e 100644 --- a/tests/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff +++ b/tests/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff @@ -24,61 +24,49 @@ StorageLive(_2); // scope 0 at $DIR/issue_75439.rs:+2:9: +2:15 StorageLive(_3); // scope 2 at $DIR/issue_75439.rs:+2:47: +2:52 _3 = _1; // scope 2 at $DIR/issue_75439.rs:+2:47: +2:52 - _2 = transmute::<[u8; 16], [u32; 4]>(move _3) -> bb1; // scope 2 at $DIR/issue_75439.rs:+2:37: +2:53 - // mir::Constant - // + span: $DIR/issue_75439.rs:8:37: 8:46 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn([u8; 16]) -> [u32; 4] {transmute::<[u8; 16], [u32; 4]>}, val: Value(<ZST>) } + _2 = move _3 as [u32; 4] (Transmute); // scope 2 at $DIR/issue_75439.rs:+2:37: +2:53 + StorageDead(_3); // scope 2 at $DIR/issue_75439.rs:+2:52: +2:53 + switchInt(_2[0 of 4]) -> [0: bb1, otherwise: bb6]; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 } bb1: { - StorageDead(_3); // scope 2 at $DIR/issue_75439.rs:+2:52: +2:53 - switchInt(_2[0 of 4]) -> [0: bb2, otherwise: bb8]; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 + switchInt(_2[1 of 4]) -> [0: bb2, otherwise: bb6]; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 } bb2: { - switchInt(_2[1 of 4]) -> [0: bb3, otherwise: bb8]; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 + switchInt(_2[2 of 4]) -> [0: bb4, 4294901760: bb5, otherwise: bb6]; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 } bb3: { - switchInt(_2[2 of 4]) -> [0: bb5, 4294901760: bb6, otherwise: bb8]; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 - } - - bb4: { StorageLive(_5); // scope 3 at $DIR/issue_75439.rs:+5:14: +5:38 StorageLive(_6); // scope 4 at $DIR/issue_75439.rs:+5:33: +5:35 _6 = _4; // scope 4 at $DIR/issue_75439.rs:+5:33: +5:35 - _5 = transmute::<u32, [u8; 4]>(move _6) -> bb7; // scope 4 at $DIR/issue_75439.rs:+5:23: +5:36 - // mir::Constant - // + span: $DIR/issue_75439.rs:11:23: 11:32 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32) -> [u8; 4] {transmute::<u32, [u8; 4]>}, val: Value(<ZST>) } + _5 = move _6 as [u8; 4] (Transmute); // scope 4 at $DIR/issue_75439.rs:+5:23: +5:36 + StorageDead(_6); // scope 4 at $DIR/issue_75439.rs:+5:35: +5:36 + _0 = Option::<[u8; 4]>::Some(move _5); // scope 3 at $DIR/issue_75439.rs:+5:9: +5:39 + StorageDead(_5); // scope 3 at $DIR/issue_75439.rs:+5:38: +5:39 + StorageDead(_4); // scope 1 at $DIR/issue_75439.rs:+6:5: +6:6 + goto -> bb7; // scope 1 at $DIR/issue_75439.rs:+4:5: +8:6 } - bb5: { + bb4: { StorageLive(_4); // scope 3 at $DIR/issue_75439.rs:+4:27: +4:29 _4 = _2[3 of 4]; // scope 3 at $DIR/issue_75439.rs:+4:27: +4:29 - goto -> bb4; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 + goto -> bb3; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 } - bb6: { + bb5: { StorageLive(_4); // scope 3 at $DIR/issue_75439.rs:+4:27: +4:29 _4 = _2[3 of 4]; // scope 3 at $DIR/issue_75439.rs:+4:27: +4:29 - goto -> bb4; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 + goto -> bb3; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 } - bb7: { - StorageDead(_6); // scope 4 at $DIR/issue_75439.rs:+5:35: +5:36 - _0 = Option::<[u8; 4]>::Some(move _5); // scope 3 at $DIR/issue_75439.rs:+5:9: +5:39 - StorageDead(_5); // scope 3 at $DIR/issue_75439.rs:+5:38: +5:39 - StorageDead(_4); // scope 1 at $DIR/issue_75439.rs:+6:5: +6:6 - goto -> bb9; // scope 1 at $DIR/issue_75439.rs:+4:5: +8:6 - } - - bb8: { + bb6: { _0 = Option::<[u8; 4]>::None; // scope 1 at $DIR/issue_75439.rs:+7:9: +7:13 - goto -> bb9; // scope 1 at $DIR/issue_75439.rs:+4:5: +8:6 + goto -> bb7; // scope 1 at $DIR/issue_75439.rs:+4:5: +8:6 } - bb9: { + bb7: { StorageDead(_2); // scope 0 at $DIR/issue_75439.rs:+9:1: +9:2 return; // scope 0 at $DIR/issue_75439.rs:+9:2: +9:2 } diff --git a/tests/mir-opt/loop_test.main.SimplifyCfg-promote-consts.after.mir b/tests/mir-opt/loop_test.main.SimplifyCfg-promote-consts.after.mir index 4ee2dae49..43d00b29e 100644 --- a/tests/mir-opt/loop_test.main.SimplifyCfg-promote-consts.after.mir +++ b/tests/mir-opt/loop_test.main.SimplifyCfg-promote-consts.after.mir @@ -35,7 +35,7 @@ fn main() -> () { } bb3: { - falseUnwind -> [real: bb4, cleanup: bb5]; // scope 0 at $DIR/loop_test.rs:+7:5: +10:6 + falseUnwind -> [real: bb4, unwind: bb5]; // scope 0 at $DIR/loop_test.rs:+7:5: +10:6 } bb4: { diff --git a/tests/mir-opt/lower_array_len.rs b/tests/mir-opt/lower_array_len.rs index 972d46cb8..e1bb51f2d 100644 --- a/tests/mir-opt/lower_array_len.rs +++ b/tests/mir-opt/lower_array_len.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: NormalizeArrayLen // compile-flags: -Zmir-enable-passes=+LowerSliceLenCalls diff --git a/tests/mir-opt/lower_intrinsics.align_of.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.align_of.LowerIntrinsics.diff index 3389db733..dd742d87a 100644 --- a/tests/mir-opt/lower_intrinsics.align_of.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.align_of.LowerIntrinsics.diff @@ -5,7 +5,7 @@ let mut _0: usize; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:25: +0:30 bb0: { -- _0 = std::intrinsics::min_align_of::<T>() -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:42 +- _0 = std::intrinsics::min_align_of::<T>() -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:42 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:21:5: 21:40 - // + literal: Const { ty: extern "rust-intrinsic" fn() -> usize {std::intrinsics::min_align_of::<T>}, val: Value(<ZST>) } diff --git a/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.diff index d9898d8e0..e95c3f9bc 100644 --- a/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.diff @@ -9,9 +9,9 @@ bb0: { StorageLive(_1); // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38 -- _1 = std::intrinsics::assume(const true) -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38 +- _1 = std::intrinsics::assume(const true) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:72:9: 72:32 +- // + span: $DIR/lower_intrinsics.rs:106:9: 106:32 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(bool) {std::intrinsics::assume}, val: Value(<ZST>) } + assume(const true); // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38 + goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38 diff --git a/tests/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff index d962ef8cb..1f03b7b0b 100644 --- a/tests/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff @@ -29,9 +29,9 @@ StorageLive(_4); // scope 0 at $DIR/lower_intrinsics.rs:+1:42: +1:44 _4 = &_1; // scope 0 at $DIR/lower_intrinsics.rs:+1:42: +1:44 _3 = &(*_4); // scope 0 at $DIR/lower_intrinsics.rs:+1:42: +1:44 -- _2 = discriminant_value::<T>(move _3) -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:45 +- _2 = discriminant_value::<T>(move _3) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:45 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:49:5: 49:41 +- // + span: $DIR/lower_intrinsics.rs:82:5: 82:41 - // + literal: Const { ty: for<'a> extern "rust-intrinsic" fn(&'a T) -> <T as DiscriminantKind>::Discriminant {discriminant_value::<T>}, val: Value(<ZST>) } + _2 = discriminant((*_3)); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:45 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:45 @@ -46,13 +46,13 @@ StorageLive(_7); // scope 0 at $DIR/lower_intrinsics.rs:+2:42: +2:44 _19 = const _; // scope 0 at $DIR/lower_intrinsics.rs:+2:42: +2:44 // mir::Constant - // + span: $DIR/lower_intrinsics.rs:50:42: 50:44 + // + span: $DIR/lower_intrinsics.rs:83:42: 83:44 // + literal: Const { ty: &i32, val: Unevaluated(discriminant, [T], Some(promoted[2])) } _7 = &(*_19); // scope 0 at $DIR/lower_intrinsics.rs:+2:42: +2:44 _6 = &(*_7); // scope 0 at $DIR/lower_intrinsics.rs:+2:42: +2:44 -- _5 = discriminant_value::<i32>(move _6) -> bb2; // scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:45 +- _5 = discriminant_value::<i32>(move _6) -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:45 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:50:5: 50:41 +- // + span: $DIR/lower_intrinsics.rs:83:5: 83:41 - // + literal: Const { ty: for<'a> extern "rust-intrinsic" fn(&'a i32) -> <i32 as DiscriminantKind>::Discriminant {discriminant_value::<i32>}, val: Value(<ZST>) } + _5 = discriminant((*_6)); // scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:45 + goto -> bb2; // scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:45 @@ -67,13 +67,13 @@ StorageLive(_11); // scope 0 at $DIR/lower_intrinsics.rs:+3:42: +3:45 _18 = const _; // scope 0 at $DIR/lower_intrinsics.rs:+3:42: +3:45 // mir::Constant - // + span: $DIR/lower_intrinsics.rs:51:42: 51:45 + // + span: $DIR/lower_intrinsics.rs:84:42: 84:45 // + literal: Const { ty: &(), val: Unevaluated(discriminant, [T], Some(promoted[1])) } _11 = &(*_18); // scope 0 at $DIR/lower_intrinsics.rs:+3:42: +3:45 _10 = &(*_11); // scope 0 at $DIR/lower_intrinsics.rs:+3:42: +3:45 -- _9 = discriminant_value::<()>(move _10) -> bb3; // scope 0 at $DIR/lower_intrinsics.rs:+3:5: +3:46 +- _9 = discriminant_value::<()>(move _10) -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+3:5: +3:46 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:51:5: 51:41 +- // + span: $DIR/lower_intrinsics.rs:84:5: 84:41 - // + literal: Const { ty: for<'a> extern "rust-intrinsic" fn(&'a ()) -> <() as DiscriminantKind>::Discriminant {discriminant_value::<()>}, val: Value(<ZST>) } + _9 = discriminant((*_10)); // scope 0 at $DIR/lower_intrinsics.rs:+3:5: +3:46 + goto -> bb3; // scope 0 at $DIR/lower_intrinsics.rs:+3:5: +3:46 @@ -88,13 +88,13 @@ StorageLive(_15); // scope 0 at $DIR/lower_intrinsics.rs:+4:42: +4:47 _17 = const _; // scope 0 at $DIR/lower_intrinsics.rs:+4:42: +4:47 // mir::Constant - // + span: $DIR/lower_intrinsics.rs:52:42: 52:47 + // + span: $DIR/lower_intrinsics.rs:85:42: 85:47 // + literal: Const { ty: &E, val: Unevaluated(discriminant, [T], Some(promoted[0])) } _15 = &(*_17); // scope 0 at $DIR/lower_intrinsics.rs:+4:42: +4:47 _14 = &(*_15); // scope 0 at $DIR/lower_intrinsics.rs:+4:42: +4:47 -- _13 = discriminant_value::<E>(move _14) -> bb4; // scope 0 at $DIR/lower_intrinsics.rs:+4:5: +4:48 +- _13 = discriminant_value::<E>(move _14) -> [return: bb4, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+4:5: +4:48 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:52:5: 52:41 +- // + span: $DIR/lower_intrinsics.rs:85:5: 85:41 - // + literal: Const { ty: for<'a> extern "rust-intrinsic" fn(&'a E) -> <E as DiscriminantKind>::Discriminant {discriminant_value::<E>}, val: Value(<ZST>) } + _13 = discriminant((*_14)); // scope 0 at $DIR/lower_intrinsics.rs:+4:5: +4:48 + goto -> bb4; // scope 0 at $DIR/lower_intrinsics.rs:+4:5: +4:48 diff --git a/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff index 5c972a00e..a54e9a932 100644 --- a/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff @@ -47,9 +47,9 @@ _9 = _10; // scope 3 at $DIR/lower_intrinsics.rs:+4:61: +4:79 _8 = move _9 as *mut i32 (PtrToPtr); // scope 3 at $DIR/lower_intrinsics.rs:+4:61: +4:91 StorageDead(_9); // scope 3 at $DIR/lower_intrinsics.rs:+4:90: +4:91 -- _3 = copy_nonoverlapping::<i32>(move _4, move _8, const 0_usize) -> bb1; // scope 3 at $DIR/lower_intrinsics.rs:+4:9: +4:95 +- _3 = copy_nonoverlapping::<i32>(move _4, move _8, const 0_usize) -> [return: bb1, unwind unreachable]; // scope 3 at $DIR/lower_intrinsics.rs:+4:9: +4:95 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:65:9: 65:28 +- // + span: $DIR/lower_intrinsics.rs:99:9: 99:28 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const i32, *mut i32, usize) {copy_nonoverlapping::<i32>}, val: Value(<ZST>) } + copy_nonoverlapping(dst = move _8, src = move _4, count = const 0_usize); // scope 3 at $DIR/lower_intrinsics.rs:+4:9: +4:95 + goto -> bb1; // scope 3 at $DIR/lower_intrinsics.rs:+4:9: +4:95 diff --git a/tests/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff index 4cbbc02c9..bfb000ccd 100644 --- a/tests/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff @@ -9,7 +9,7 @@ bb0: { StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:+1:30: +1:31 _2 = move _1; // scope 0 at $DIR/lower_intrinsics.rs:+1:30: +1:31 -- _0 = std::intrinsics::forget::<T>(move _2) -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:32 +- _0 = std::intrinsics::forget::<T>(move _2) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:32 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:26:5: 26:29 - // + literal: Const { ty: extern "rust-intrinsic" fn(T) {std::intrinsics::forget::<T>}, val: Value(<ZST>) } diff --git a/tests/mir-opt/lower_intrinsics.non_const.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.non_const.LowerIntrinsics.diff index d8cd5f59a..64d82907c 100644 --- a/tests/mir-opt/lower_intrinsics.non_const.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.non_const.LowerIntrinsics.diff @@ -17,7 +17,7 @@ // + literal: Const { ty: extern "rust-intrinsic" fn() -> usize {std::intrinsics::size_of::<T>}, val: Value(<ZST>) } StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:+3:5: +3:14 _2 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+3:5: +3:14 -- _0 = move _2() -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+3:5: +3:16 +- _0 = move _2() -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+3:5: +3:16 + _0 = SizeOf(T); // scope 1 at $DIR/lower_intrinsics.rs:+3:5: +3:16 + goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+3:5: +3:16 } diff --git a/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff new file mode 100644 index 000000000..cc5079af7 --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff @@ -0,0 +1,54 @@ +- // MIR for `option_payload` before LowerIntrinsics ++ // MIR for `option_payload` after LowerIntrinsics + + fn option_payload(_1: &Option<usize>, _2: &Option<String>) -> () { + debug o => _1; // in scope 0 at $DIR/lower_intrinsics.rs:+0:23: +0:24 + debug p => _2; // in scope 0 at $DIR/lower_intrinsics.rs:+0:42: +0:43 + let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:62: +0:62 + let mut _4: *const std::option::Option<usize>; // in scope 0 at $DIR/lower_intrinsics.rs:+2:55: +2:56 + let mut _6: *const std::option::Option<std::string::String>; // in scope 0 at $DIR/lower_intrinsics.rs:+3:55: +3:56 + scope 1 { + let _3: *const usize; // in scope 1 at $DIR/lower_intrinsics.rs:+2:13: +2:15 + scope 2 { + debug _x => _3; // in scope 2 at $DIR/lower_intrinsics.rs:+2:13: +2:15 + let _5: *const std::string::String; // in scope 2 at $DIR/lower_intrinsics.rs:+3:13: +3:15 + scope 3 { + debug _y => _5; // in scope 3 at $DIR/lower_intrinsics.rs:+3:13: +3:15 + } + } + } + + bb0: { + StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:+2:13: +2:15 + StorageLive(_4); // scope 1 at $DIR/lower_intrinsics.rs:+2:55: +2:56 + _4 = &raw const (*_1); // scope 1 at $DIR/lower_intrinsics.rs:+2:55: +2:56 +- _3 = option_payload_ptr::<usize>(move _4) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:133:18: 133:54 +- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const Option<usize>) -> *const usize {option_payload_ptr::<usize>}, val: Value(<ZST>) } ++ _3 = &raw const (((*_4) as Some).0: usize); // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57 ++ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57 + } + + bb1: { + StorageDead(_4); // scope 1 at $DIR/lower_intrinsics.rs:+2:56: +2:57 + StorageLive(_5); // scope 2 at $DIR/lower_intrinsics.rs:+3:13: +3:15 + StorageLive(_6); // scope 2 at $DIR/lower_intrinsics.rs:+3:55: +3:56 + _6 = &raw const (*_2); // scope 2 at $DIR/lower_intrinsics.rs:+3:55: +3:56 +- _5 = option_payload_ptr::<String>(move _6) -> [return: bb2, unwind unreachable]; // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:134:18: 134:54 +- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const Option<String>) -> *const String {option_payload_ptr::<String>}, val: Value(<ZST>) } ++ _5 = &raw const (((*_6) as Some).0: std::string::String); // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57 ++ goto -> bb2; // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57 + } + + bb2: { + StorageDead(_6); // scope 2 at $DIR/lower_intrinsics.rs:+3:56: +3:57 + _0 = const (); // scope 1 at $DIR/lower_intrinsics.rs:+1:5: +4:6 + StorageDead(_5); // scope 2 at $DIR/lower_intrinsics.rs:+4:5: +4:6 + StorageDead(_3); // scope 1 at $DIR/lower_intrinsics.rs:+4:5: +4:6 + return; // scope 0 at $DIR/lower_intrinsics.rs:+5:2: +5:2 + } + } + diff --git a/tests/mir-opt/lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.diff new file mode 100644 index 000000000..5805df48f --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.diff @@ -0,0 +1,27 @@ +- // MIR for `read_via_copy_primitive` before LowerIntrinsics ++ // MIR for `read_via_copy_primitive` after LowerIntrinsics + + fn read_via_copy_primitive(_1: &i32) -> i32 { + debug r => _1; // in scope 0 at $DIR/lower_intrinsics.rs:+0:32: +0:33 + let mut _0: i32; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:44: +0:47 + let mut _2: *const i32; // in scope 0 at $DIR/lower_intrinsics.rs:+1:46: +1:47 + scope 1 { + } + + bb0: { + StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:+1:46: +1:47 + _2 = &raw const (*_1); // scope 1 at $DIR/lower_intrinsics.rs:+1:46: +1:47 +- _0 = read_via_copy::<i32>(move _2) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:119:14: 119:45 +- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const i32) -> i32 {read_via_copy::<i32>}, val: Value(<ZST>) } ++ _0 = (*_2); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48 ++ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48 + } + + bb1: { + StorageDead(_2); // scope 1 at $DIR/lower_intrinsics.rs:+1:47: +1:48 + return; // scope 0 at $DIR/lower_intrinsics.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.diff new file mode 100644 index 000000000..95b2ec49d --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.diff @@ -0,0 +1,21 @@ +- // MIR for `read_via_copy_uninhabited` before LowerIntrinsics ++ // MIR for `read_via_copy_uninhabited` after LowerIntrinsics + + fn read_via_copy_uninhabited(_1: &Never) -> Never { + debug r => _1; // in scope 0 at $DIR/lower_intrinsics.rs:+0:34: +0:35 + let mut _0: Never; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:48: +0:53 + let mut _2: *const Never; // in scope 0 at $DIR/lower_intrinsics.rs:+1:46: +1:47 + scope 1 { + } + + bb0: { + StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:+1:46: +1:47 + _2 = &raw const (*_1); // scope 1 at $DIR/lower_intrinsics.rs:+1:46: +1:47 +- _0 = read_via_copy::<Never>(move _2) -> unwind unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:124:14: 124:45 +- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const Never) -> Never {read_via_copy::<Never>}, val: Value(<ZST>) } ++ unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48 + } + } + diff --git a/tests/mir-opt/lower_intrinsics.rs b/tests/mir-opt/lower_intrinsics.rs index 7147be43c..33fef930a 100644 --- a/tests/mir-opt/lower_intrinsics.rs +++ b/tests/mir-opt/lower_intrinsics.rs @@ -1,7 +1,7 @@ // unit-test: LowerIntrinsics // ignore-wasm32 compiled with panic=abort by default -#![feature(core_intrinsics, intrinsics)] +#![feature(core_intrinsics, intrinsics, rustc_attrs)] #![crate_type = "lib"] // EMIT_MIR lower_intrinsics.wrapping.LowerIntrinsics.diff @@ -38,6 +38,39 @@ pub fn non_const<T>() -> usize { size_of_t() } +// EMIT_MIR lower_intrinsics.transmute_inhabited.LowerIntrinsics.diff +pub fn transmute_inhabited(c: std::cmp::Ordering) -> i8 { + unsafe { std::mem::transmute(c) } +} + +// EMIT_MIR lower_intrinsics.transmute_uninhabited.LowerIntrinsics.diff +pub unsafe fn transmute_uninhabited(u: ()) -> Never { + unsafe { std::mem::transmute::<(), Never>(u) } +} + +// EMIT_MIR lower_intrinsics.transmute_ref_dst.LowerIntrinsics.diff +pub unsafe fn transmute_ref_dst<T: ?Sized>(u: &T) -> *const T { + unsafe { std::mem::transmute(u) } +} + +// EMIT_MIR lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff +pub unsafe fn transmute_to_ref_uninhabited() -> ! { + let x: &Never = std::mem::transmute(1usize); + match *x {} +} + +// EMIT_MIR lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff +pub unsafe fn transmute_to_mut_uninhabited() -> ! { + let x: &mut Never = std::mem::transmute(1usize); + match *x {} +} + +// EMIT_MIR lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff +pub unsafe fn transmute_to_box_uninhabited() -> ! { + let x: Box<Never> = std::mem::transmute(1usize); + match *x {} +} + pub enum E { A, B, @@ -54,6 +87,7 @@ pub fn discriminant<T>(t: T) { extern "rust-intrinsic" { // Cannot use `std::intrinsics::copy_nonoverlapping` as that is a wrapper function + #[rustc_nounwind] fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize); } @@ -79,3 +113,24 @@ pub fn with_overflow(a: i32, b: i32) { let _y = core::intrinsics::sub_with_overflow(a, b); let _z = core::intrinsics::mul_with_overflow(a, b); } + +// EMIT_MIR lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.diff +pub fn read_via_copy_primitive(r: &i32) -> i32 { + unsafe { core::intrinsics::read_via_copy(r) } +} + +// EMIT_MIR lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.diff +pub fn read_via_copy_uninhabited(r: &Never) -> Never { + unsafe { core::intrinsics::read_via_copy(r) } +} + +pub enum Never {} + +// EMIT_MIR lower_intrinsics.option_payload.LowerIntrinsics.diff +#[cfg(not(bootstrap))] +pub fn option_payload(o: &Option<usize>, p: &Option<String>) { + unsafe { + let _x = core::intrinsics::option_payload_ptr(o); + let _y = core::intrinsics::option_payload_ptr(p); + } +} diff --git a/tests/mir-opt/lower_intrinsics.size_of.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.size_of.LowerIntrinsics.diff index cf0ab73a5..27e8accea 100644 --- a/tests/mir-opt/lower_intrinsics.size_of.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.size_of.LowerIntrinsics.diff @@ -5,7 +5,7 @@ let mut _0: usize; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:24: +0:29 bb0: { -- _0 = std::intrinsics::size_of::<T>() -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:37 +- _0 = std::intrinsics::size_of::<T>() -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:37 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:16:5: 16:35 - // + literal: Const { ty: extern "rust-intrinsic" fn() -> usize {std::intrinsics::size_of::<T>}, val: Value(<ZST>) } diff --git a/tests/mir-opt/lower_intrinsics.transmute_inhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_inhabited.LowerIntrinsics.diff new file mode 100644 index 000000000..1b3b76851 --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.transmute_inhabited.LowerIntrinsics.diff @@ -0,0 +1,27 @@ +- // MIR for `transmute_inhabited` before LowerIntrinsics ++ // MIR for `transmute_inhabited` after LowerIntrinsics + + fn transmute_inhabited(_1: std::cmp::Ordering) -> i8 { + debug c => _1; // in scope 0 at $DIR/lower_intrinsics.rs:+0:28: +0:29 + let mut _0: i8; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:54: +0:56 + let mut _2: std::cmp::Ordering; // in scope 0 at $DIR/lower_intrinsics.rs:+1:34: +1:35 + scope 1 { + } + + bb0: { + StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:+1:34: +1:35 + _2 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+1:34: +1:35 +- _0 = transmute::<std::cmp::Ordering, i8>(move _2) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:43:14: 43:33 +- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(std::cmp::Ordering) -> i8 {transmute::<std::cmp::Ordering, i8>}, val: Value(<ZST>) } ++ _0 = move _2 as i8 (Transmute); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36 ++ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36 + } + + bb1: { + StorageDead(_2); // scope 1 at $DIR/lower_intrinsics.rs:+1:35: +1:36 + return; // scope 0 at $DIR/lower_intrinsics.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/lower_intrinsics.transmute_ref_dst.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_ref_dst.LowerIntrinsics.diff new file mode 100644 index 000000000..c6a7d2287 --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.transmute_ref_dst.LowerIntrinsics.diff @@ -0,0 +1,27 @@ +- // MIR for `transmute_ref_dst` before LowerIntrinsics ++ // MIR for `transmute_ref_dst` after LowerIntrinsics + + fn transmute_ref_dst(_1: &T) -> *const T { + debug u => _1; // in scope 0 at $DIR/lower_intrinsics.rs:+0:44: +0:45 + let mut _0: *const T; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:54: +0:62 + let mut _2: &T; // in scope 0 at $DIR/lower_intrinsics.rs:+1:34: +1:35 + scope 1 { + } + + bb0: { + StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:+1:34: +1:35 + _2 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+1:34: +1:35 +- _0 = transmute::<&T, *const T>(move _2) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:53:14: 53:33 +- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&T) -> *const T {transmute::<&T, *const T>}, val: Value(<ZST>) } ++ _0 = move _2 as *const T (Transmute); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36 ++ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36 + } + + bb1: { + StorageDead(_2); // scope 1 at $DIR/lower_intrinsics.rs:+1:35: +1:36 + return; // scope 0 at $DIR/lower_intrinsics.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff new file mode 100644 index 000000000..8735a7500 --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff @@ -0,0 +1,29 @@ +- // MIR for `transmute_to_box_uninhabited` before LowerIntrinsics ++ // MIR for `transmute_to_box_uninhabited` after LowerIntrinsics + + fn transmute_to_box_uninhabited() -> ! { + let mut _0: !; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:49: +0:50 + let mut _1: !; // in scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 + let _2: std::boxed::Box<Never>; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 + let mut _3: !; // in scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:16 + scope 1 { + debug x => _2; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:10 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 + StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 +- _2 = transmute::<usize, Box<Never>>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:70:25: 70:44 +- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize) -> Box<Never> {transmute::<usize, Box<Never>>}, val: Value(<ZST>) } ++ _2 = const 1_usize as std::boxed::Box<Never> (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 ++ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 + } + + bb1: { + StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:+2:5: +2:16 + unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+2:11: +2:13 + } + } + diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff new file mode 100644 index 000000000..a77213277 --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff @@ -0,0 +1,29 @@ +- // MIR for `transmute_to_mut_uninhabited` before LowerIntrinsics ++ // MIR for `transmute_to_mut_uninhabited` after LowerIntrinsics + + fn transmute_to_mut_uninhabited() -> ! { + let mut _0: !; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:49: +0:50 + let mut _1: !; // in scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 + let _2: &mut Never; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 + let mut _3: !; // in scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:16 + scope 1 { + debug x => _2; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:10 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 + StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 +- _2 = transmute::<usize, &mut Never>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:64:25: 64:44 +- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize) -> &mut Never {transmute::<usize, &mut Never>}, val: Value(<ZST>) } ++ _2 = const 1_usize as &mut Never (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 ++ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 + } + + bb1: { + StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:+2:5: +2:16 + unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+2:11: +2:13 + } + } + diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff new file mode 100644 index 000000000..c4d53d4e8 --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff @@ -0,0 +1,29 @@ +- // MIR for `transmute_to_ref_uninhabited` before LowerIntrinsics ++ // MIR for `transmute_to_ref_uninhabited` after LowerIntrinsics + + fn transmute_to_ref_uninhabited() -> ! { + let mut _0: !; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:49: +0:50 + let mut _1: !; // in scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 + let _2: &Never; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 + let mut _3: !; // in scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:16 + scope 1 { + debug x => _2; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:10 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 + StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 +- _2 = transmute::<usize, &Never>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:58:21: 58:40 +- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize) -> &Never {transmute::<usize, &Never>}, val: Value(<ZST>) } ++ _2 = const 1_usize as &Never (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48 ++ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48 + } + + bb1: { + StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:+2:5: +2:16 + unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+2:11: +2:13 + } + } + diff --git a/tests/mir-opt/lower_intrinsics.transmute_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_uninhabited.LowerIntrinsics.diff new file mode 100644 index 000000000..f0b76127d --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.transmute_uninhabited.LowerIntrinsics.diff @@ -0,0 +1,22 @@ +- // MIR for `transmute_uninhabited` before LowerIntrinsics ++ // MIR for `transmute_uninhabited` after LowerIntrinsics + + fn transmute_uninhabited(_1: ()) -> Never { + debug u => _1; // in scope 0 at $DIR/lower_intrinsics.rs:+0:37: +0:38 + let mut _0: Never; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:47: +0:52 + let mut _2: (); // in scope 0 at $DIR/lower_intrinsics.rs:+1:47: +1:48 + scope 1 { + } + + bb0: { + StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:+1:47: +1:48 + _2 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+1:47: +1:48 +- _0 = transmute::<(), Never>(move _2) -> unwind unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:49 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:48:14: 48:46 +- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(()) -> Never {transmute::<(), Never>}, val: Value(<ZST>) } ++ _0 = move _2 as Never (Transmute); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:49 ++ unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:49 + } + } + diff --git a/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff index 6f17d4451..c0cc698c4 100644 --- a/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff @@ -12,7 +12,7 @@ bb0: { StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:47 StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45 -- _3 = std::intrinsics::unreachable(); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45 +- _3 = std::intrinsics::unreachable() -> unwind unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:31:14: 31:43 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn() -> ! {std::intrinsics::unreachable}, val: Value(<ZST>) } diff --git a/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.diff index 9870a70de..9cf4fbb88 100644 --- a/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.diff @@ -30,9 +30,9 @@ _4 = _1; // scope 0 at $DIR/lower_intrinsics.rs:+1:50: +1:51 StorageLive(_5); // scope 0 at $DIR/lower_intrinsics.rs:+1:53: +1:54 _5 = _2; // scope 0 at $DIR/lower_intrinsics.rs:+1:53: +1:54 -- _3 = add_with_overflow::<i32>(move _4, move _5) -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:55 +- _3 = add_with_overflow::<i32>(move _4, move _5) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:55 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:78:14: 78:49 +- // + span: $DIR/lower_intrinsics.rs:112:14: 112:49 - // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> (i32, bool) {add_with_overflow::<i32>}, val: Value(<ZST>) } + _3 = CheckedAdd(move _4, move _5); // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:55 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:55 @@ -46,9 +46,9 @@ _7 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+2:50: +2:51 StorageLive(_8); // scope 1 at $DIR/lower_intrinsics.rs:+2:53: +2:54 _8 = _2; // scope 1 at $DIR/lower_intrinsics.rs:+2:53: +2:54 -- _6 = sub_with_overflow::<i32>(move _7, move _8) -> bb2; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:55 +- _6 = sub_with_overflow::<i32>(move _7, move _8) -> [return: bb2, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:55 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:79:14: 79:49 +- // + span: $DIR/lower_intrinsics.rs:113:14: 113:49 - // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> (i32, bool) {sub_with_overflow::<i32>}, val: Value(<ZST>) } + _6 = CheckedSub(move _7, move _8); // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:55 + goto -> bb2; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:55 @@ -62,9 +62,9 @@ _10 = _1; // scope 2 at $DIR/lower_intrinsics.rs:+3:50: +3:51 StorageLive(_11); // scope 2 at $DIR/lower_intrinsics.rs:+3:53: +3:54 _11 = _2; // scope 2 at $DIR/lower_intrinsics.rs:+3:53: +3:54 -- _9 = mul_with_overflow::<i32>(move _10, move _11) -> bb3; // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:55 +- _9 = mul_with_overflow::<i32>(move _10, move _11) -> [return: bb3, unwind unreachable]; // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:55 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:80:14: 80:49 +- // + span: $DIR/lower_intrinsics.rs:114:14: 114:49 - // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> (i32, bool) {mul_with_overflow::<i32>}, val: Value(<ZST>) } + _9 = CheckedMul(move _10, move _11); // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:55 + goto -> bb3; // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:55 diff --git a/tests/mir-opt/lower_intrinsics.wrapping.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.wrapping.LowerIntrinsics.diff index 22ef75fd8..0bfb34aca 100644 --- a/tests/mir-opt/lower_intrinsics.wrapping.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.wrapping.LowerIntrinsics.diff @@ -30,7 +30,7 @@ _4 = _1; // scope 0 at $DIR/lower_intrinsics.rs:+1:45: +1:46 StorageLive(_5); // scope 0 at $DIR/lower_intrinsics.rs:+1:48: +1:49 _5 = _2; // scope 0 at $DIR/lower_intrinsics.rs:+1:48: +1:49 -- _3 = wrapping_add::<i32>(move _4, move _5) -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:50 +- _3 = wrapping_add::<i32>(move _4, move _5) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:50 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:9:14: 9:44 - // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> i32 {wrapping_add::<i32>}, val: Value(<ZST>) } @@ -46,7 +46,7 @@ _7 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+2:45: +2:46 StorageLive(_8); // scope 1 at $DIR/lower_intrinsics.rs:+2:48: +2:49 _8 = _2; // scope 1 at $DIR/lower_intrinsics.rs:+2:48: +2:49 -- _6 = wrapping_sub::<i32>(move _7, move _8) -> bb2; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:50 +- _6 = wrapping_sub::<i32>(move _7, move _8) -> [return: bb2, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:50 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:10:14: 10:44 - // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> i32 {wrapping_sub::<i32>}, val: Value(<ZST>) } @@ -62,7 +62,7 @@ _10 = _1; // scope 2 at $DIR/lower_intrinsics.rs:+3:45: +3:46 StorageLive(_11); // scope 2 at $DIR/lower_intrinsics.rs:+3:48: +3:49 _11 = _2; // scope 2 at $DIR/lower_intrinsics.rs:+3:48: +3:49 -- _9 = wrapping_mul::<i32>(move _10, move _11) -> bb3; // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:50 +- _9 = wrapping_mul::<i32>(move _10, move _11) -> [return: bb3, unwind unreachable]; // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:50 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:11:14: 11:44 - // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> i32 {wrapping_mul::<i32>}, val: Value(<ZST>) } diff --git a/tests/mir-opt/lower_intrinsics_e2e.f_u64.PreCodegen.after.mir b/tests/mir-opt/lower_intrinsics_e2e.f_u64.PreCodegen.after.mir index f6d8bdd74..4f5df1331 100644 --- a/tests/mir-opt/lower_intrinsics_e2e.f_u64.PreCodegen.after.mir +++ b/tests/mir-opt/lower_intrinsics_e2e.f_u64.PreCodegen.after.mir @@ -12,15 +12,13 @@ fn f_u64() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/lower_intrinsics_e2e.rs:+1:5: +1:21 - StorageLive(_2); // scope 1 at $DIR/lower_intrinsics_e2e.rs:23:9: 23:21 - _2 = f_non_zst::<u64>(const 0_u64) -> bb1; // scope 1 at $DIR/lower_intrinsics_e2e.rs:23:9: 23:21 + _2 = f_non_zst::<u64>(const 0_u64) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics_e2e.rs:23:9: 23:21 // mir::Constant // + span: $DIR/lower_intrinsics_e2e.rs:23:9: 23:18 // + literal: Const { ty: fn(u64) {f_non_zst::<u64>}, val: Value(<ZST>) } } bb1: { - StorageDead(_2); // scope 1 at $DIR/lower_intrinsics_e2e.rs:23:21: 23:22 StorageDead(_1); // scope 0 at $DIR/lower_intrinsics_e2e.rs:+1:5: +1:21 return; // scope 0 at $DIR/lower_intrinsics_e2e.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/lower_intrinsics_e2e.f_unit.PreCodegen.after.mir b/tests/mir-opt/lower_intrinsics_e2e.f_unit.PreCodegen.after.mir index b672e1a6e..8654e80cd 100644 --- a/tests/mir-opt/lower_intrinsics_e2e.f_unit.PreCodegen.after.mir +++ b/tests/mir-opt/lower_intrinsics_e2e.f_unit.PreCodegen.after.mir @@ -2,26 +2,21 @@ fn f_unit() -> () { let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics_e2e.rs:+0:17: +0:17 - let mut _1: (); // in scope 0 at $DIR/lower_intrinsics_e2e.rs:+1:16: +1:18 scope 1 (inlined f_dispatch::<()>) { // at $DIR/lower_intrinsics_e2e.rs:9:5: 9:19 - debug t => _1; // in scope 1 at $DIR/lower_intrinsics_e2e.rs:19:22: 19:23 - let _2: (); // in scope 1 at $DIR/lower_intrinsics_e2e.rs:21:9: 21:17 + debug t => const (); // in scope 1 at $DIR/lower_intrinsics_e2e.rs:19:22: 19:23 + let _1: (); // in scope 1 at $DIR/lower_intrinsics_e2e.rs:21:9: 21:17 scope 2 (inlined std::mem::size_of::<()>) { // at $DIR/lower_intrinsics_e2e.rs:20:8: 20:32 } } bb0: { - StorageLive(_1); // scope 0 at $DIR/lower_intrinsics_e2e.rs:+1:16: +1:18 - StorageLive(_2); // scope 1 at $DIR/lower_intrinsics_e2e.rs:21:9: 21:17 - _2 = f_zst::<()>(move _1) -> bb1; // scope 1 at $DIR/lower_intrinsics_e2e.rs:21:9: 21:17 + _1 = f_zst::<()>(const ()) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics_e2e.rs:21:9: 21:17 // mir::Constant // + span: $DIR/lower_intrinsics_e2e.rs:21:9: 21:14 // + literal: Const { ty: fn(()) {f_zst::<()>}, val: Value(<ZST>) } } bb1: { - StorageDead(_2); // scope 1 at $DIR/lower_intrinsics_e2e.rs:21:17: 21:18 - StorageDead(_1); // scope 0 at $DIR/lower_intrinsics_e2e.rs:+1:18: +1:19 return; // scope 0 at $DIR/lower_intrinsics_e2e.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.diff b/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.diff index 2b0370cf3..67918e62b 100644 --- a/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.diff +++ b/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.diff @@ -22,7 +22,7 @@ _6 = &(*_2); // scope 0 at $DIR/lower_slice_len.rs:+1:16: +1:27 - _5 = core::slice::<impl [u8]>::len(move _6) -> bb1; // scope 0 at $DIR/lower_slice_len.rs:+1:16: +1:27 - // mir::Constant -- // + span: $DIR/lower_slice_len.rs:5:22: 5:25 +- // + span: $DIR/lower_slice_len.rs:6:22: 6:25 - // + literal: Const { ty: for<'a> fn(&'a [u8]) -> usize {core::slice::<impl [u8]>::len}, val: Value(<ZST>) } + _5 = Len((*_6)); // scope 0 at $DIR/lower_slice_len.rs:+1:16: +1:27 + goto -> bb1; // scope 0 at $DIR/lower_slice_len.rs:+1:16: +1:27 diff --git a/tests/mir-opt/lower_slice_len.rs b/tests/mir-opt/lower_slice_len.rs index 12955aed1..9c39c29fc 100644 --- a/tests/mir-opt/lower_slice_len.rs +++ b/tests/mir-opt/lower_slice_len.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: LowerSliceLenCalls // EMIT_MIR lower_slice_len.bound.LowerSliceLenCalls.diff diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff index 84e4d35f9..3081e78f2 100644 --- a/tests/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/tests/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -243,7 +243,7 @@ } - bb25 (cleanup): { -- drop(_2) -> bb26; // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2 +- drop(_2) -> [return: bb26, unwind terminate]; // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2 + bb22 (cleanup): { + goto -> bb27; // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2 } diff --git a/tests/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir b/tests/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir index 0cb34a2f2..950f8758e 100644 --- a/tests/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir +++ b/tests/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir @@ -40,7 +40,7 @@ fn main() -> () { } bb3 (cleanup): { - drop(_2) -> bb4; // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:34: +1:35 + drop(_2) -> [return: bb4, unwind terminate]; // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:34: +1:35 } bb4 (cleanup): { diff --git a/tests/mir-opt/nrvo_simple.rs b/tests/mir-opt/nrvo_simple.rs index 5786ae621..525dfe426 100644 --- a/tests/mir-opt/nrvo_simple.rs +++ b/tests/mir-opt/nrvo_simple.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: RenameReturnPlace // EMIT_MIR nrvo_simple.nrvo.RenameReturnPlace.diff diff --git a/tests/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir b/tests/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir index 210f178a0..81b96e3b6 100644 --- a/tests/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir +++ b/tests/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir @@ -28,21 +28,21 @@ fn main() -> () { StorageDead(_5); // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:28: +2:29 StorageLive(_6); // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8 _6 = move (_1.0: Aligned); // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8 - drop(_6) -> [return: bb4, unwind: bb3]; // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8 + drop(_6) -> [return: bb4, unwind: bb1]; // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8 } - bb1: { - StorageDead(_1); // scope 0 at $DIR/packed_struct_drop_aligned.rs:+3:1: +3:2 - return; // scope 0 at $DIR/packed_struct_drop_aligned.rs:+3:2: +3:2 + bb1 (cleanup): { + (_1.0: Aligned) = move _4; // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8 + drop(_1) -> [return: bb3, unwind terminate]; // scope 0 at $DIR/packed_struct_drop_aligned.rs:+3:1: +3:2 } - bb2 (cleanup): { - resume; // scope 0 at $DIR/packed_struct_drop_aligned.rs:+0:1: +3:2 + bb2: { + StorageDead(_1); // scope 0 at $DIR/packed_struct_drop_aligned.rs:+3:1: +3:2 + return; // scope 0 at $DIR/packed_struct_drop_aligned.rs:+3:2: +3:2 } bb3 (cleanup): { - (_1.0: Aligned) = move _4; // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8 - drop(_1) -> bb2; // scope 0 at $DIR/packed_struct_drop_aligned.rs:+3:1: +3:2 + resume; // scope 0 at $DIR/packed_struct_drop_aligned.rs:+0:1: +3:2 } bb4: { @@ -50,6 +50,6 @@ fn main() -> () { (_1.0: Aligned) = move _4; // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8 StorageDead(_4); // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:28: +2:29 _0 = const (); // scope 0 at $DIR/packed_struct_drop_aligned.rs:+0:11: +3:2 - drop(_1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/packed_struct_drop_aligned.rs:+3:1: +3:2 + drop(_1) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/packed_struct_drop_aligned.rs:+3:1: +3:2 } } diff --git a/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff b/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff index a8dd91efc..0e8309532 100644 --- a/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff +++ b/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff @@ -34,7 +34,7 @@ _3 = std::ops::Range::<i32> { start: const 0_i32, end: const 10_i32 }; // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19 _2 = <std::ops::Range<i32> as IntoIterator>::into_iter(move _3) -> bb1; // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19 // mir::Constant - // + span: $DIR/remove_storage_markers.rs:10:14: 10:19 + // + span: $DIR/remove_storage_markers.rs:11:14: 11:19 // + literal: Const { ty: fn(std::ops::Range<i32>) -> <std::ops::Range<i32> as IntoIterator>::IntoIter {<std::ops::Range<i32> as IntoIterator>::into_iter}, val: Value(<ZST>) } } @@ -54,7 +54,7 @@ _8 = &mut (*_9); // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19 _7 = <std::ops::Range<i32> as Iterator>::next(move _8) -> bb3; // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19 // mir::Constant - // + span: $DIR/remove_storage_markers.rs:10:14: 10:19 + // + span: $DIR/remove_storage_markers.rs:11:14: 11:19 // + literal: Const { ty: for<'a> fn(&'a mut std::ops::Range<i32>) -> Option<<std::ops::Range<i32> as Iterator>::Item> {<std::ops::Range<i32> as Iterator>::next}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/remove_storage_markers.rs b/tests/mir-opt/remove_storage_markers.rs index f00b82691..480db8ac1 100644 --- a/tests/mir-opt/remove_storage_markers.rs +++ b/tests/mir-opt/remove_storage_markers.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: RemoveStorageMarkers // Checks that storage markers are removed at opt-level=0. diff --git a/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff b/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff index 07e4dd418..7713649c5 100644 --- a/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff +++ b/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff @@ -11,7 +11,7 @@ } bb0: { - StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:5: +1:12 + nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:5: +1:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:10: +1:11 _3 = move _1; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:10: +1:11 drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL @@ -23,7 +23,7 @@ bb2: { StorageDead(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:11: +1:12 - StorageDead(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13 + nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13 nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+0:32: +2:2 return; // scope 0 at $DIR/remove_unneeded_drops.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff b/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff index e809ca4e9..533db4051 100644 --- a/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff +++ b/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff @@ -11,7 +11,7 @@ } bb0: { - StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:5: +1:12 + nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:5: +1:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:10: +1:11 _3 = move _1; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:10: +1:11 drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL @@ -23,7 +23,7 @@ bb2: { StorageDead(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:11: +1:12 - StorageDead(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13 + nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13 nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+0:27: +2:2 return; // scope 0 at $DIR/remove_unneeded_drops.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff index 087f76dbd..04a2d54e9 100644 --- a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff +++ b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff @@ -11,7 +11,7 @@ } bb0: { - StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:5: +1:12 +- nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:5: +1:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:10: +1:11 _3 = _1; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:10: +1:11 - drop(_3) -> bb1; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL @@ -19,7 +19,7 @@ - - bb1: { StorageDead(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:11: +1:12 - StorageDead(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13 +- nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13 - nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+0:17: +2:2 return; // scope 0 at $DIR/remove_unneeded_drops.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff index 933d6895f..782d0c6c5 100644 --- a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff +++ b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff @@ -11,7 +11,7 @@ } bb0: { - StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:5: +1:12 +- nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:5: +1:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:10: +1:11 _3 = _1; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:10: +1:11 - drop(_3) -> bb1; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL @@ -19,7 +19,7 @@ - - bb1: { StorageDead(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:11: +1:12 - StorageDead(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13 +- nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13 - nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+0:36: +2:2 return; // scope 0 at $DIR/remove_unneeded_drops.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/remove_zsts.get_union.PreCodegen.after.mir b/tests/mir-opt/remove_zsts.get_union.PreCodegen.after.mir index af34bc5ed..7ac9ef3d4 100644 --- a/tests/mir-opt/remove_zsts.get_union.PreCodegen.after.mir +++ b/tests/mir-opt/remove_zsts.get_union.PreCodegen.after.mir @@ -2,12 +2,9 @@ fn get_union() -> Foo { let mut _0: Foo; // return place in scope 0 at $DIR/remove_zsts.rs:+0:19: +0:22 - let mut _1: (); // in scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 bb0: { - StorageLive(_1); // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 - _0 = Foo { x: move _1 }; // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 - StorageDead(_1); // scope 0 at $DIR/remove_zsts.rs:+1:17: +1:18 + _0 = Foo { x: const () }; // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 return; // scope 0 at $DIR/remove_zsts.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/remove_zsts.get_union.RemoveZsts.diff b/tests/mir-opt/remove_zsts.get_union.RemoveZsts.diff index 0af29b2ba..edd86ef0a 100644 --- a/tests/mir-opt/remove_zsts.get_union.RemoveZsts.diff +++ b/tests/mir-opt/remove_zsts.get_union.RemoveZsts.diff @@ -6,11 +6,14 @@ let mut _1: (); // in scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 bb0: { - StorageLive(_1); // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 +- StorageLive(_1); // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 - _1 = (); // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 +- _0 = Foo { x: move _1 }; // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 +- StorageDead(_1); // scope 0 at $DIR/remove_zsts.rs:+1:17: +1:18 + nop; // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 - _0 = Foo { x: move _1 }; // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 - StorageDead(_1); // scope 0 at $DIR/remove_zsts.rs:+1:17: +1:18 ++ nop; // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 ++ _0 = Foo { x: const () }; // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 ++ nop; // scope 0 at $DIR/remove_zsts.rs:+1:17: +1:18 return; // scope 0 at $DIR/remove_zsts.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir b/tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir index d7b6d64b6..4eef028e1 100644 --- a/tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir +++ b/tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir @@ -108,7 +108,7 @@ fn main() -> () { StorageLive(_14); // scope 1 at $DIR/retag.rs:+11:31: +14:6 _14 = [closure@main::{closure#0}]; // scope 1 at $DIR/retag.rs:+11:31: +14:6 // closure - // + def_id: DefId(0:14 ~ retag[4622]::main::{closure#0}) + // + def_id: DefId(0:14 ~ retag[7654]::main::{closure#0}) // + substs: [ // i8, // for<'a> extern "rust-call" fn((&'a i32,)) -> &'a i32, @@ -186,11 +186,11 @@ fn main() -> () { } bb7 (cleanup): { - drop(_21) -> bb9; // scope 7 at $DIR/retag.rs:+18:24: +18:25 + drop(_21) -> [return: bb9, unwind terminate]; // scope 7 at $DIR/retag.rs:+18:24: +18:25 } bb8 (cleanup): { - drop(_5) -> bb9; // scope 1 at $DIR/retag.rs:+3:36: +3:37 + drop(_5) -> [return: bb9, unwind terminate]; // scope 1 at $DIR/retag.rs:+3:36: +3:37 } bb9 (cleanup): { diff --git a/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff b/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff index cfcd43093..bdf1de468 100644 --- a/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff +++ b/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff @@ -12,7 +12,6 @@ let mut _7: !; // in scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 let mut _8: std::result::Result<std::convert::Infallible, i32>; // in scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 let _9: i32; // in scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 - let mut _16: i32; // in scope 0 at $SRC_DIR/core/src/result.rs:LL:COL scope 1 { debug residual => _6; // in scope 1 at $DIR/separate_const_switch.rs:+1:9: +1:10 scope 2 { @@ -23,7 +22,7 @@ scope 9 { debug e => _14; // in scope 9 at $SRC_DIR/core/src/result.rs:LL:COL scope 10 (inlined <i32 as From<i32>>::from) { // at $SRC_DIR/core/src/result.rs:LL:COL - debug t => _16; // in scope 10 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug t => _14; // in scope 10 at $SRC_DIR/core/src/convert/mod.rs:LL:COL } } } @@ -90,10 +89,7 @@ StorageLive(_14); // scope 2 at $DIR/separate_const_switch.rs:+1:8: +1:10 _14 = move ((_8 as Err).0: i32); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL StorageLive(_15); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL - StorageLive(_16); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL - _16 = move _14; // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL - _15 = move _16; // scope 10 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - StorageDead(_16); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL + _15 = move _14; // scope 10 at $SRC_DIR/core/src/convert/mod.rs:LL:COL _0 = Result::<i32, i32>::Err(move _15); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL StorageDead(_15); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL StorageDead(_14); // scope 2 at $DIR/separate_const_switch.rs:+1:8: +1:10 diff --git a/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff b/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff index 3c7e9dc61..b5e0a66d8 100644 --- a/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff +++ b/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff @@ -61,7 +61,7 @@ bb4: { _8 = discriminant(_2); // scope 0 at $DIR/separate_const_switch.rs:+5:11: +10:6 - switchInt(move _8) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6 + switchInt(move _8) -> [0: bb6, 1: bb5, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6 } bb5: { @@ -69,14 +69,10 @@ _11 = ((_2 as Break).0: usize); // scope 0 at $DIR/separate_const_switch.rs:+12:28: +12:29 _0 = Option::<i32>::None; // scope 4 at $DIR/separate_const_switch.rs:+12:34: +12:38 StorageDead(_11); // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38 - goto -> bb8; // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38 + goto -> bb7; // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38 } bb6: { - unreachable; // scope 0 at $DIR/separate_const_switch.rs:+5:11: +10:6 - } - - bb7: { StorageLive(_9); // scope 0 at $DIR/separate_const_switch.rs:+11:31: +11:32 _9 = ((_2 as Continue).0: i32); // scope 0 at $DIR/separate_const_switch.rs:+11:31: +11:32 StorageLive(_10); // scope 3 at $DIR/separate_const_switch.rs:+11:42: +11:43 @@ -84,10 +80,10 @@ _0 = Option::<i32>::Some(move _10); // scope 3 at $DIR/separate_const_switch.rs:+11:37: +11:44 StorageDead(_10); // scope 3 at $DIR/separate_const_switch.rs:+11:43: +11:44 StorageDead(_9); // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44 - goto -> bb8; // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44 + goto -> bb7; // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44 } - bb8: { + bb7: { StorageDead(_2); // scope 0 at $DIR/separate_const_switch.rs:+14:1: +14:2 return; // scope 0 at $DIR/separate_const_switch.rs:+14:2: +14:2 } diff --git a/tests/mir-opt/simple_option_map_e2e.ezmap.PreCodegen.after.mir b/tests/mir-opt/simple_option_map_e2e.ezmap.PreCodegen.after.mir index 66ba4df76..cae89fb17 100644 --- a/tests/mir-opt/simple_option_map_e2e.ezmap.PreCodegen.after.mir +++ b/tests/mir-opt/simple_option_map_e2e.ezmap.PreCodegen.after.mir @@ -3,30 +3,28 @@ fn ezmap(_1: Option<i32>) -> Option<i32> { debug x => _1; // in scope 0 at $DIR/simple_option_map_e2e.rs:+0:14: +0:15 let mut _0: std::option::Option<i32>; // return place in scope 0 at $DIR/simple_option_map_e2e.rs:+0:33: +0:44 - let mut _2: [closure@$DIR/simple_option_map_e2e.rs:14:12: 14:15]; // in scope 0 at $DIR/simple_option_map_e2e.rs:+1:12: +1:21 scope 1 (inlined map::<i32, i32, [closure@$DIR/simple_option_map_e2e.rs:14:12: 14:15]>) { // at $DIR/simple_option_map_e2e.rs:14:5: 14:22 debug slf => _1; // in scope 1 at $DIR/simple_option_map_e2e.rs:2:17: 2:20 - debug f => _2; // in scope 1 at $DIR/simple_option_map_e2e.rs:2:33: 2:34 - let mut _3: isize; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:9: 7:16 - let _4: i32; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15 - let mut _5: i32; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:25: 7:29 + debug f => const ZeroSized: [closure@$DIR/simple_option_map_e2e.rs:14:12: 14:15]; // in scope 1 at $DIR/simple_option_map_e2e.rs:2:33: 2:34 + let mut _2: isize; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:9: 7:16 + let _3: i32; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15 + let mut _4: i32; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:25: 7:29 scope 2 { - debug x => _4; // in scope 2 at $DIR/simple_option_map_e2e.rs:7:14: 7:15 + debug x => _3; // in scope 2 at $DIR/simple_option_map_e2e.rs:7:14: 7:15 scope 3 (inlined ezmap::{closure#0}) { // at $DIR/simple_option_map_e2e.rs:7:25: 7:29 - debug n => _4; // in scope 3 at $DIR/simple_option_map_e2e.rs:+1:13: +1:14 + debug n => _3; // in scope 3 at $DIR/simple_option_map_e2e.rs:+1:13: +1:14 } } } bb0: { - StorageLive(_2); // scope 0 at $DIR/simple_option_map_e2e.rs:+1:12: +1:21 - _3 = discriminant(_1); // scope 1 at $DIR/simple_option_map_e2e.rs:6:11: 6:14 - switchInt(move _3) -> [0: bb1, 1: bb3, otherwise: bb2]; // scope 1 at $DIR/simple_option_map_e2e.rs:6:5: 6:14 + _2 = discriminant(_1); // scope 1 at $DIR/simple_option_map_e2e.rs:6:11: 6:14 + switchInt(move _2) -> [0: bb1, 1: bb3, otherwise: bb2]; // scope 1 at $DIR/simple_option_map_e2e.rs:6:5: 6:14 } bb1: { _0 = Option::<i32>::None; // scope 1 at $DIR/simple_option_map_e2e.rs:8:17: 8:21 - goto -> bb4; // scope 1 at $DIR/simple_option_map_e2e.rs:8:17: 8:21 + return; // scope 1 at $DIR/simple_option_map_e2e.rs:8:17: 8:21 } bb2: { @@ -34,16 +32,11 @@ fn ezmap(_1: Option<i32>) -> Option<i32> { } bb3: { - _4 = ((_1 as Some).0: i32); // scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15 - StorageLive(_5); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29 - _5 = Add(_4, const 1_i32); // scope 3 at $DIR/simple_option_map_e2e.rs:+1:16: +1:21 - _0 = Option::<i32>::Some(move _5); // scope 2 at $DIR/simple_option_map_e2e.rs:7:20: 7:30 - StorageDead(_5); // scope 2 at $DIR/simple_option_map_e2e.rs:7:29: 7:30 - goto -> bb4; // scope 1 at $DIR/simple_option_map_e2e.rs:10:1: 10:2 - } - - bb4: { - StorageDead(_2); // scope 0 at $DIR/simple_option_map_e2e.rs:+1:21: +1:22 - return; // scope 0 at $DIR/simple_option_map_e2e.rs:+2:2: +2:2 + _3 = ((_1 as Some).0: i32); // scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15 + StorageLive(_4); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29 + _4 = Add(_3, const 1_i32); // scope 3 at $DIR/simple_option_map_e2e.rs:+1:16: +1:21 + _0 = Option::<i32>::Some(move _4); // scope 2 at $DIR/simple_option_map_e2e.rs:7:20: 7:30 + StorageDead(_4); // scope 2 at $DIR/simple_option_map_e2e.rs:7:29: 7:30 + return; // scope 1 at $DIR/simple_option_map_e2e.rs:10:1: 10:2 } } diff --git a/tests/mir-opt/simplify_cfg.main.SimplifyCfg-initial.diff b/tests/mir-opt/simplify_cfg.main.SimplifyCfg-initial.diff index 1e66b1f70..c61107d25 100644 --- a/tests/mir-opt/simplify_cfg.main.SimplifyCfg-initial.diff +++ b/tests/mir-opt/simplify_cfg.main.SimplifyCfg-initial.diff @@ -12,8 +12,8 @@ } bb1: { -- falseUnwind -> [real: bb2, cleanup: bb11]; // scope 0 at $DIR/simplify_cfg.rs:+1:5: +5:6 -+ falseUnwind -> [real: bb2, cleanup: bb6]; // scope 0 at $DIR/simplify_cfg.rs:+1:5: +5:6 +- falseUnwind -> [real: bb2, unwind: bb11]; // scope 0 at $DIR/simplify_cfg.rs:+1:5: +5:6 ++ falseUnwind -> [real: bb2, unwind: bb6]; // scope 0 at $DIR/simplify_cfg.rs:+1:5: +5:6 } bb2: { diff --git a/tests/mir-opt/simplify_duplicate_unreachable_blocks.assert_nonzero_nonmax.SimplifyCfg-after-uninhabited-enum-branching.diff b/tests/mir-opt/simplify_duplicate_unreachable_blocks.assert_nonzero_nonmax.SimplifyCfg-after-uninhabited-enum-branching.diff new file mode 100644 index 000000000..f7f50206a --- /dev/null +++ b/tests/mir-opt/simplify_duplicate_unreachable_blocks.assert_nonzero_nonmax.SimplifyCfg-after-uninhabited-enum-branching.diff @@ -0,0 +1,25 @@ +- // MIR for `assert_nonzero_nonmax` before SimplifyCfg-after-uninhabited-enum-branching ++ // MIR for `assert_nonzero_nonmax` after SimplifyCfg-after-uninhabited-enum-branching + + fn assert_nonzero_nonmax(_1: u8) -> u8 { + let mut _0: u8; // return place in scope 0 at $DIR/simplify_duplicate_unreachable_blocks.rs:+0:47: +0:49 + + bb0: { +- switchInt(_1) -> [0: bb1, 255: bb2, otherwise: bb3]; // scope 0 at $DIR/simplify_duplicate_unreachable_blocks.rs:+3:13: +7:14 ++ switchInt(_1) -> [0: bb1, 255: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_duplicate_unreachable_blocks.rs:+3:13: +7:14 + } + + bb1: { + unreachable; // scope 0 at $DIR/simplify_duplicate_unreachable_blocks.rs:+10:13: +10:26 + } + + bb2: { +- unreachable; // scope 0 at $DIR/simplify_duplicate_unreachable_blocks.rs:+13:13: +13:26 +- } +- +- bb3: { + _0 = _1; // scope 0 at $DIR/simplify_duplicate_unreachable_blocks.rs:+16:13: +16:20 + return; // scope 0 at $DIR/simplify_duplicate_unreachable_blocks.rs:+17:13: +17:21 + } + } + diff --git a/tests/mir-opt/simplify_duplicate_unreachable_blocks.rs b/tests/mir-opt/simplify_duplicate_unreachable_blocks.rs new file mode 100644 index 000000000..e2578407f --- /dev/null +++ b/tests/mir-opt/simplify_duplicate_unreachable_blocks.rs @@ -0,0 +1,30 @@ +#![feature(custom_mir, core_intrinsics)] +#![crate_type = "lib"] + +use std::intrinsics::mir::*; + +// unit-test: SimplifyCfg-after-uninhabited-enum-branching + +// EMIT_MIR simplify_duplicate_unreachable_blocks.assert_nonzero_nonmax.SimplifyCfg-after-uninhabited-enum-branching.diff +#[custom_mir(dialect = "runtime", phase = "post-cleanup")] +pub unsafe fn assert_nonzero_nonmax(x: u8) -> u8 { + mir!( + { + match x { + 0 => unreachable1, + u8::MAX => unreachable2, + _ => retblock, + } + } + unreachable1 = { + Unreachable() + } + unreachable2 = { + Unreachable() + } + retblock = { + RET = x; + Return() + } + ) +} diff --git a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.diff b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.diff index f9e22866b..b473d0fde 100644 --- a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.diff +++ b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.diff @@ -14,15 +14,13 @@ } bb1: { - StorageLive(_2); // scope 0 at $DIR/simplify_if.rs:+2:9: +2:15 _2 = noop() -> bb2; // scope 0 at $DIR/simplify_if.rs:+2:9: +2:15 // mir::Constant - // + span: $DIR/simplify_if.rs:7:9: 7:13 + // + span: $DIR/simplify_if.rs:8:9: 8:13 // + literal: Const { ty: fn() {noop}, val: Value(<ZST>) } } bb2: { - StorageDead(_2); // scope 0 at $DIR/simplify_if.rs:+2:15: +2:16 goto -> bb4; // scope 0 at $DIR/simplify_if.rs:+1:5: +3:6 } diff --git a/tests/mir-opt/simplify_if.rs b/tests/mir-opt/simplify_if.rs index 2d093d926..b86f80a80 100644 --- a/tests/mir-opt/simplify_if.rs +++ b/tests/mir-opt/simplify_if.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default #[inline(never)] fn noop() {} diff --git a/tests/mir-opt/simplify_locals_fixedpoint.rs b/tests/mir-opt/simplify_locals_fixedpoint.rs index 1fdba6e99..7c41e8b7c 100644 --- a/tests/mir-opt/simplify_locals_fixedpoint.rs +++ b/tests/mir-opt/simplify_locals_fixedpoint.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // compile-flags: -Zmir-opt-level=1 fn foo<T>() { diff --git a/tests/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.diff b/tests/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.diff index 0f8866f9c..ae2c774f2 100644 --- a/tests/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.diff +++ b/tests/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.diff @@ -56,7 +56,7 @@ + StorageDead(_3); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:20: +2:21 + _1 = use_zst(move _2) -> bb1; // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:5: +2:22 // mir::Constant - // + span: $DIR/simplify_locals_removes_unused_consts.rs:15:5: 15:12 + // + span: $DIR/simplify_locals_removes_unused_consts.rs:16:5: 16:12 // + literal: Const { ty: fn(((), ())) {use_zst}, val: Value(<ZST>) } } @@ -84,7 +84,7 @@ + StorageDead(_7); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:33: +4:34 + _5 = use_u8(move _6) -> bb2; // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:5: +4:35 // mir::Constant - // + span: $DIR/simplify_locals_removes_unused_consts.rs:17:5: 17:11 + // + span: $DIR/simplify_locals_removes_unused_consts.rs:18:5: 18:11 // + literal: Const { ty: fn(u8) {use_u8}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/simplify_locals_removes_unused_consts.rs b/tests/mir-opt/simplify_locals_removes_unused_consts.rs index 7a03a2837..983d8004e 100644 --- a/tests/mir-opt/simplify_locals_removes_unused_consts.rs +++ b/tests/mir-opt/simplify_locals_removes_unused_consts.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // unit-test: SimplifyLocals-before-const-prop // compile-flags: -C overflow-checks=no diff --git a/tests/mir-opt/simplify_match.main.ConstProp.diff b/tests/mir-opt/simplify_match.main.ConstProp.diff index b700adfb1..d2b9ac3cc 100644 --- a/tests/mir-opt/simplify_match.main.ConstProp.diff +++ b/tests/mir-opt/simplify_match.main.ConstProp.diff @@ -22,7 +22,7 @@ bb2: { _0 = noop() -> bb3; // scope 0 at $DIR/simplify_match.rs:+2:17: +2:23 // mir::Constant - // + span: $DIR/simplify_match.rs:7:17: 7:21 + // + span: $DIR/simplify_match.rs:8:17: 8:21 // + literal: Const { ty: fn() {noop}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/simplify_match.rs b/tests/mir-opt/simplify_match.rs index 216203f9f..6a2a6f217 100644 --- a/tests/mir-opt/simplify_match.rs +++ b/tests/mir-opt/simplify_match.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default #[inline(never)] fn noop() {} diff --git a/tests/mir-opt/slice_drop_shim.core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir b/tests/mir-opt/slice_drop_shim.core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir index 391b00eff..11115c96e 100644 --- a/tests/mir-opt/slice_drop_shim.core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir +++ b/tests/mir-opt/slice_drop_shim.core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir @@ -4,21 +4,13 @@ fn std::ptr::drop_in_place(_1: *mut [String]) -> () { let mut _0: (); // return place in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 let mut _2: usize; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 let mut _3: usize; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - let mut _4: usize; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - let mut _5: *mut std::string::String; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - let mut _6: bool; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - let mut _7: *mut std::string::String; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - let mut _8: bool; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - let mut _9: *mut std::string::String; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - let mut _10: *mut std::string::String; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - let mut _11: *mut std::string::String; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - let mut _12: bool; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - let mut _13: *mut std::string::String; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - let mut _14: bool; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - let mut _15: *mut [std::string::String]; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + let mut _4: *mut std::string::String; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + let mut _5: bool; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + let mut _6: *mut std::string::String; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + let mut _7: bool; // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 bb0: { - goto -> bb15; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + goto -> bb8; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 } bb1: { @@ -30,72 +22,34 @@ fn std::ptr::drop_in_place(_1: *mut [String]) -> () { } bb3 (cleanup): { - _5 = &raw mut (*_1)[_4]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - _4 = Add(move _4, const 1_usize); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - drop((*_5)) -> bb4; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + _4 = &raw mut (*_1)[_3]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + _3 = Add(move _3, const 1_usize); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + drop((*_4)) -> [return: bb4, unwind terminate]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 } bb4 (cleanup): { - _6 = Eq(_4, _3); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - switchInt(move _6) -> [0: bb3, otherwise: bb2]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + _5 = Eq(_3, _2); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + switchInt(move _5) -> [0: bb3, otherwise: bb2]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 } bb5: { - _7 = &raw mut (*_1)[_4]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - _4 = Add(move _4, const 1_usize); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - drop((*_7)) -> [return: bb6, unwind: bb4]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + _6 = &raw mut (*_1)[_3]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + _3 = Add(move _3, const 1_usize); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + drop((*_6)) -> [return: bb6, unwind: bb4]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 } bb6: { - _8 = Eq(_4, _3); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - switchInt(move _8) -> [0: bb5, otherwise: bb1]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + _7 = Eq(_3, _2); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + switchInt(move _7) -> [0: bb5, otherwise: bb1]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 } bb7: { - _4 = const 0_usize; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + _2 = Len((*_1)); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + _3 = const 0_usize; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 goto -> bb6; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 } bb8: { goto -> bb7; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 } - - bb9 (cleanup): { - _11 = _9; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - _9 = Offset(move _9, const 1_usize); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - drop((*_11)) -> bb10; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - } - - bb10 (cleanup): { - _12 = Eq(_9, _10); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - switchInt(move _12) -> [0: bb9, otherwise: bb2]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - } - - bb11: { - _13 = _9; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - _9 = Offset(move _9, const 1_usize); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - drop((*_13)) -> [return: bb12, unwind: bb10]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - } - - bb12: { - _14 = Eq(_9, _10); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - switchInt(move _14) -> [0: bb11, otherwise: bb1]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - } - - bb13: { - _15 = &raw mut (*_1); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - _9 = move _15 as *mut std::string::String (PtrToPtr); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - _10 = Offset(_9, move _3); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - goto -> bb12; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - } - - bb14: { - goto -> bb13; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - } - - bb15: { - _2 = SizeOf(std::string::String); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - _3 = Len((*_1)); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - switchInt(move _2) -> [0: bb8, otherwise: bb14]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 - } } diff --git a/tests/mir-opt/sroa.constant.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.constant.ScalarReplacementOfAggregates.diff deleted file mode 100644 index 9e33215f2..000000000 --- a/tests/mir-opt/sroa.constant.ScalarReplacementOfAggregates.diff +++ /dev/null @@ -1,46 +0,0 @@ -- // MIR for `constant` before ScalarReplacementOfAggregates -+ // MIR for `constant` after ScalarReplacementOfAggregates - - fn constant() -> () { - let mut _0: (); // return place in scope 0 at $DIR/sroa.rs:+0:15: +0:15 - let _1: (usize, u8); // in scope 0 at $DIR/sroa.rs:+2:9: +2:10 -+ let _4: usize; // in scope 0 at $DIR/sroa.rs:+2:9: +2:10 -+ let _5: u8; // in scope 0 at $DIR/sroa.rs:+2:9: +2:10 - scope 1 { -- debug y => _1; // in scope 1 at $DIR/sroa.rs:+2:9: +2:10 -+ debug y => (usize, u8){ .0 => _4, .1 => _5, }; // in scope 1 at $DIR/sroa.rs:+2:9: +2:10 - let _2: usize; // in scope 1 at $DIR/sroa.rs:+3:9: +3:10 - scope 2 { - debug t => _2; // in scope 2 at $DIR/sroa.rs:+3:9: +3:10 - let _3: u8; // in scope 2 at $DIR/sroa.rs:+4:9: +4:10 - scope 3 { - debug u => _3; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10 - } - } - } - - bb0: { -- StorageLive(_1); // scope 0 at $DIR/sroa.rs:+2:9: +2:10 -+ StorageLive(_4); // scope 0 at $DIR/sroa.rs:+2:9: +2:10 -+ StorageLive(_5); // scope 0 at $DIR/sroa.rs:+2:9: +2:10 -+ nop; // scope 0 at $DIR/sroa.rs:+2:9: +2:10 - _1 = const _; // scope 0 at $DIR/sroa.rs:+2:13: +2:14 -+ _4 = move (_1.0: usize); // scope 1 at $DIR/sroa.rs:+3:9: +3:10 -+ _5 = move (_1.1: u8); // scope 1 at $DIR/sroa.rs:+3:9: +3:10 - StorageLive(_2); // scope 1 at $DIR/sroa.rs:+3:9: +3:10 -- _2 = (_1.0: usize); // scope 1 at $DIR/sroa.rs:+3:13: +3:16 -+ _2 = _4; // scope 1 at $DIR/sroa.rs:+3:13: +3:16 - StorageLive(_3); // scope 2 at $DIR/sroa.rs:+4:9: +4:10 -- _3 = (_1.1: u8); // scope 2 at $DIR/sroa.rs:+4:13: +4:16 -+ _3 = _5; // scope 2 at $DIR/sroa.rs:+4:13: +4:16 - _0 = const (); // scope 0 at $DIR/sroa.rs:+0:15: +5:2 - StorageDead(_3); // scope 2 at $DIR/sroa.rs:+5:1: +5:2 - StorageDead(_2); // scope 1 at $DIR/sroa.rs:+5:1: +5:2 -- StorageDead(_1); // scope 0 at $DIR/sroa.rs:+5:1: +5:2 -+ StorageDead(_4); // scope 0 at $DIR/sroa.rs:+5:1: +5:2 -+ StorageDead(_5); // scope 0 at $DIR/sroa.rs:+5:1: +5:2 -+ nop; // scope 0 at $DIR/sroa.rs:+5:1: +5:2 - return; // scope 0 at $DIR/sroa.rs:+5:2: +5:2 - } - } - diff --git a/tests/mir-opt/sroa.copies.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.copies.ScalarReplacementOfAggregates.diff deleted file mode 100644 index 976f6d44b..000000000 --- a/tests/mir-opt/sroa.copies.ScalarReplacementOfAggregates.diff +++ /dev/null @@ -1,91 +0,0 @@ -- // MIR for `copies` before ScalarReplacementOfAggregates -+ // MIR for `copies` after ScalarReplacementOfAggregates - - fn copies(_1: Foo) -> () { - debug x => _1; // in scope 0 at $DIR/sroa.rs:+0:11: +0:12 - let mut _0: (); // return place in scope 0 at $DIR/sroa.rs:+0:19: +0:19 - let _2: Foo; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ let _11: u8; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ let _12: (); // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ let _13: &str; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ let _14: std::option::Option<isize>; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 - scope 1 { -- debug y => _2; // in scope 1 at $DIR/sroa.rs:+1:9: +1:10 -+ debug y => Foo{ .0 => _11, .1 => _12, .2 => _13, .3 => _14, }; // in scope 1 at $DIR/sroa.rs:+1:9: +1:10 - let _3: u8; // in scope 1 at $DIR/sroa.rs:+2:9: +2:10 - scope 2 { - debug t => _3; // in scope 2 at $DIR/sroa.rs:+2:9: +2:10 - let _4: &str; // in scope 2 at $DIR/sroa.rs:+3:9: +3:10 - scope 3 { - debug u => _4; // in scope 3 at $DIR/sroa.rs:+3:9: +3:10 - let _5: Foo; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10 -+ let _7: u8; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10 -+ let _8: (); // in scope 3 at $DIR/sroa.rs:+4:9: +4:10 -+ let _9: &str; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10 -+ let _10: std::option::Option<isize>; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10 - scope 4 { -- debug z => _5; // in scope 4 at $DIR/sroa.rs:+4:9: +4:10 -+ debug z => Foo{ .0 => _7, .1 => _8, .2 => _9, .3 => _10, }; // in scope 4 at $DIR/sroa.rs:+4:9: +4:10 - let _6: (); // in scope 4 at $DIR/sroa.rs:+5:9: +5:10 - scope 5 { - debug a => _6; // in scope 5 at $DIR/sroa.rs:+5:9: +5:10 - } - } - } - } - } - - bb0: { -- StorageLive(_2); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 -- _2 = _1; // scope 0 at $DIR/sroa.rs:+1:13: +1:14 -+ StorageLive(_11); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ StorageLive(_12); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ StorageLive(_13); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ StorageLive(_14); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ nop; // scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ _11 = (_1.0: u8); // scope 0 at $DIR/sroa.rs:+1:13: +1:14 -+ _12 = (_1.1: ()); // scope 0 at $DIR/sroa.rs:+1:13: +1:14 -+ _13 = (_1.2: &str); // scope 0 at $DIR/sroa.rs:+1:13: +1:14 -+ _14 = (_1.3: std::option::Option<isize>); // scope 0 at $DIR/sroa.rs:+1:13: +1:14 -+ nop; // scope 0 at $DIR/sroa.rs:+1:13: +1:14 - StorageLive(_3); // scope 1 at $DIR/sroa.rs:+2:9: +2:10 -- _3 = (_2.0: u8); // scope 1 at $DIR/sroa.rs:+2:13: +2:16 -+ _3 = _11; // scope 1 at $DIR/sroa.rs:+2:13: +2:16 - StorageLive(_4); // scope 2 at $DIR/sroa.rs:+3:9: +3:10 -- _4 = (_2.2: &str); // scope 2 at $DIR/sroa.rs:+3:13: +3:16 -- StorageLive(_5); // scope 3 at $DIR/sroa.rs:+4:9: +4:10 -- _5 = _2; // scope 3 at $DIR/sroa.rs:+4:13: +4:14 -+ _4 = _13; // scope 2 at $DIR/sroa.rs:+3:13: +3:16 -+ StorageLive(_7); // scope 3 at $DIR/sroa.rs:+4:9: +4:10 -+ StorageLive(_8); // scope 3 at $DIR/sroa.rs:+4:9: +4:10 -+ StorageLive(_9); // scope 3 at $DIR/sroa.rs:+4:9: +4:10 -+ StorageLive(_10); // scope 3 at $DIR/sroa.rs:+4:9: +4:10 -+ nop; // scope 3 at $DIR/sroa.rs:+4:9: +4:10 -+ _7 = _11; // scope 3 at $DIR/sroa.rs:+4:13: +4:14 -+ _8 = _12; // scope 3 at $DIR/sroa.rs:+4:13: +4:14 -+ _9 = _13; // scope 3 at $DIR/sroa.rs:+4:13: +4:14 -+ _10 = _14; // scope 3 at $DIR/sroa.rs:+4:13: +4:14 -+ nop; // scope 3 at $DIR/sroa.rs:+4:13: +4:14 - StorageLive(_6); // scope 4 at $DIR/sroa.rs:+5:9: +5:10 -- _6 = (_5.1: ()); // scope 4 at $DIR/sroa.rs:+5:13: +5:16 -+ _6 = _8; // scope 4 at $DIR/sroa.rs:+5:13: +5:16 - _0 = const (); // scope 0 at $DIR/sroa.rs:+0:19: +6:2 - StorageDead(_6); // scope 4 at $DIR/sroa.rs:+6:1: +6:2 -- StorageDead(_5); // scope 3 at $DIR/sroa.rs:+6:1: +6:2 -+ StorageDead(_7); // scope 3 at $DIR/sroa.rs:+6:1: +6:2 -+ StorageDead(_8); // scope 3 at $DIR/sroa.rs:+6:1: +6:2 -+ StorageDead(_9); // scope 3 at $DIR/sroa.rs:+6:1: +6:2 -+ StorageDead(_10); // scope 3 at $DIR/sroa.rs:+6:1: +6:2 -+ nop; // scope 3 at $DIR/sroa.rs:+6:1: +6:2 - StorageDead(_4); // scope 2 at $DIR/sroa.rs:+6:1: +6:2 - StorageDead(_3); // scope 1 at $DIR/sroa.rs:+6:1: +6:2 -- StorageDead(_2); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 -+ StorageDead(_11); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 -+ StorageDead(_12); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 -+ StorageDead(_13); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 -+ StorageDead(_14); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 -+ nop; // scope 0 at $DIR/sroa.rs:+6:1: +6:2 - return; // scope 0 at $DIR/sroa.rs:+6:2: +6:2 - } - } - diff --git a/tests/mir-opt/sroa.dropping.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.dropping.ScalarReplacementOfAggregates.diff deleted file mode 100644 index 17a89e7d8..000000000 --- a/tests/mir-opt/sroa.dropping.ScalarReplacementOfAggregates.diff +++ /dev/null @@ -1,44 +0,0 @@ -- // MIR for `dropping` before ScalarReplacementOfAggregates -+ // MIR for `dropping` after ScalarReplacementOfAggregates - - fn dropping() -> () { - let mut _0: (); // return place in scope 0 at $DIR/sroa.rs:+0:19: +0:19 - let _1: Tag; // in scope 0 at $DIR/sroa.rs:+1:5: +1:32 - let mut _2: S; // in scope 0 at $DIR/sroa.rs:+1:5: +1:30 - let mut _3: Tag; // in scope 0 at $DIR/sroa.rs:+1:7: +1:13 - let mut _4: Tag; // in scope 0 at $DIR/sroa.rs:+1:15: +1:21 - let mut _5: Tag; // in scope 0 at $DIR/sroa.rs:+1:23: +1:29 - - bb0: { - StorageLive(_1); // scope 0 at $DIR/sroa.rs:+1:5: +1:32 - StorageLive(_2); // scope 0 at $DIR/sroa.rs:+1:5: +1:30 - StorageLive(_3); // scope 0 at $DIR/sroa.rs:+1:7: +1:13 - _3 = Tag(const 0_usize); // scope 0 at $DIR/sroa.rs:+1:7: +1:13 - StorageLive(_4); // scope 0 at $DIR/sroa.rs:+1:15: +1:21 - _4 = Tag(const 1_usize); // scope 0 at $DIR/sroa.rs:+1:15: +1:21 - StorageLive(_5); // scope 0 at $DIR/sroa.rs:+1:23: +1:29 - _5 = Tag(const 2_usize); // scope 0 at $DIR/sroa.rs:+1:23: +1:29 - _2 = S(move _3, move _4, move _5); // scope 0 at $DIR/sroa.rs:+1:5: +1:30 - StorageDead(_5); // scope 0 at $DIR/sroa.rs:+1:29: +1:30 - StorageDead(_4); // scope 0 at $DIR/sroa.rs:+1:29: +1:30 - StorageDead(_3); // scope 0 at $DIR/sroa.rs:+1:29: +1:30 - _1 = move (_2.1: Tag); // scope 0 at $DIR/sroa.rs:+1:5: +1:32 - drop(_1) -> bb1; // scope 0 at $DIR/sroa.rs:+1:32: +1:33 - } - - bb1: { - drop((_2.0: Tag)) -> bb3; // scope 0 at $DIR/sroa.rs:+1:32: +1:33 - } - - bb2: { - StorageDead(_2); // scope 0 at $DIR/sroa.rs:+1:32: +1:33 - StorageDead(_1); // scope 0 at $DIR/sroa.rs:+1:32: +1:33 - _0 = const (); // scope 0 at $DIR/sroa.rs:+0:19: +2:2 - return; // scope 0 at $DIR/sroa.rs:+2:2: +2:2 - } - - bb3: { - drop((_2.2: Tag)) -> bb2; // scope 0 at $DIR/sroa.rs:+1:32: +1:33 - } - } - diff --git a/tests/mir-opt/sroa.enums.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.enums.ScalarReplacementOfAggregates.diff deleted file mode 100644 index 04d26162a..000000000 --- a/tests/mir-opt/sroa.enums.ScalarReplacementOfAggregates.diff +++ /dev/null @@ -1,43 +0,0 @@ -- // MIR for `enums` before ScalarReplacementOfAggregates -+ // MIR for `enums` after ScalarReplacementOfAggregates - - fn enums(_1: usize) -> usize { - debug a => _1; // in scope 0 at $DIR/sroa.rs:+0:14: +0:15 - let mut _0: usize; // return place in scope 0 at $DIR/sroa.rs:+0:27: +0:32 - let mut _2: std::option::Option<usize>; // in scope 0 at $DIR/sroa.rs:+1:22: +1:29 - let mut _3: usize; // in scope 0 at $DIR/sroa.rs:+1:27: +1:28 - let mut _4: isize; // in scope 0 at $DIR/sroa.rs:+1:12: +1:19 - scope 1 { - debug a => _5; // in scope 1 at $DIR/sroa.rs:+1:17: +1:18 - let _5: usize; // in scope 1 at $DIR/sroa.rs:+1:17: +1:18 - } - - bb0: { - StorageLive(_2); // scope 1 at $DIR/sroa.rs:+1:22: +1:29 - StorageLive(_3); // scope 1 at $DIR/sroa.rs:+1:27: +1:28 - _3 = _1; // scope 1 at $DIR/sroa.rs:+1:27: +1:28 - _2 = Option::<usize>::Some(move _3); // scope 1 at $DIR/sroa.rs:+1:22: +1:29 - StorageDead(_3); // scope 1 at $DIR/sroa.rs:+1:28: +1:29 - _4 = discriminant(_2); // scope 1 at $DIR/sroa.rs:+1:12: +1:19 - switchInt(move _4) -> [1: bb1, otherwise: bb2]; // scope 1 at $DIR/sroa.rs:+1:12: +1:19 - } - - bb1: { - StorageLive(_5); // scope 1 at $DIR/sroa.rs:+1:17: +1:18 - _5 = ((_2 as Some).0: usize); // scope 1 at $DIR/sroa.rs:+1:17: +1:18 - _0 = _5; // scope 1 at $DIR/sroa.rs:+1:32: +1:33 - StorageDead(_5); // scope 0 at $DIR/sroa.rs:+1:34: +1:35 - goto -> bb3; // scope 0 at $DIR/sroa.rs:+1:5: +1:46 - } - - bb2: { - _0 = const 0_usize; // scope 0 at $DIR/sroa.rs:+1:43: +1:44 - goto -> bb3; // scope 0 at $DIR/sroa.rs:+1:5: +1:46 - } - - bb3: { - StorageDead(_2); // scope 0 at $DIR/sroa.rs:+2:1: +2:2 - return; // scope 0 at $DIR/sroa.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/sroa.escaping.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.escaping.ScalarReplacementOfAggregates.diff deleted file mode 100644 index fd691fdd1..000000000 --- a/tests/mir-opt/sroa.escaping.ScalarReplacementOfAggregates.diff +++ /dev/null @@ -1,44 +0,0 @@ -- // MIR for `escaping` before ScalarReplacementOfAggregates -+ // MIR for `escaping` after ScalarReplacementOfAggregates - - fn escaping() -> () { - let mut _0: (); // return place in scope 0 at $DIR/sroa.rs:+0:19: +0:19 - let _1: (); // in scope 0 at $DIR/sroa.rs:+1:5: +1:42 - let mut _2: *const u32; // in scope 0 at $DIR/sroa.rs:+1:7: +1:41 - let _3: &u32; // in scope 0 at $DIR/sroa.rs:+1:7: +1:41 - let _4: Escaping; // in scope 0 at $DIR/sroa.rs:+1:8: +1:39 - let mut _5: u32; // in scope 0 at $DIR/sroa.rs:+1:34: +1:37 - - bb0: { - StorageLive(_1); // scope 0 at $DIR/sroa.rs:+1:5: +1:42 - StorageLive(_2); // scope 0 at $DIR/sroa.rs:+1:7: +1:41 - StorageLive(_3); // scope 0 at $DIR/sroa.rs:+1:7: +1:41 - StorageLive(_4); // scope 0 at $DIR/sroa.rs:+1:8: +1:39 - StorageLive(_5); // scope 0 at $DIR/sroa.rs:+1:34: +1:37 - _5 = g() -> bb1; // scope 0 at $DIR/sroa.rs:+1:34: +1:37 - // mir::Constant - // + span: $DIR/sroa.rs:78:34: 78:35 - // + literal: Const { ty: fn() -> u32 {g}, val: Value(<ZST>) } - } - - bb1: { - _4 = Escaping { a: const 1_u32, b: const 2_u32, c: move _5 }; // scope 0 at $DIR/sroa.rs:+1:8: +1:39 - StorageDead(_5); // scope 0 at $DIR/sroa.rs:+1:38: +1:39 - _3 = &(_4.0: u32); // scope 0 at $DIR/sroa.rs:+1:7: +1:41 - _2 = &raw const (*_3); // scope 0 at $DIR/sroa.rs:+1:7: +1:41 - _1 = f(move _2) -> bb2; // scope 0 at $DIR/sroa.rs:+1:5: +1:42 - // mir::Constant - // + span: $DIR/sroa.rs:78:5: 78:6 - // + literal: Const { ty: fn(*const u32) {f}, val: Value(<ZST>) } - } - - bb2: { - StorageDead(_2); // scope 0 at $DIR/sroa.rs:+1:41: +1:42 - StorageDead(_4); // scope 0 at $DIR/sroa.rs:+1:42: +1:43 - StorageDead(_3); // scope 0 at $DIR/sroa.rs:+1:42: +1:43 - StorageDead(_1); // scope 0 at $DIR/sroa.rs:+1:42: +1:43 - _0 = const (); // scope 0 at $DIR/sroa.rs:+0:19: +2:2 - return; // scope 0 at $DIR/sroa.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/sroa.flat.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.flat.ScalarReplacementOfAggregates.diff deleted file mode 100644 index 69631fc02..000000000 --- a/tests/mir-opt/sroa.flat.ScalarReplacementOfAggregates.diff +++ /dev/null @@ -1,80 +0,0 @@ -- // MIR for `flat` before ScalarReplacementOfAggregates -+ // MIR for `flat` after ScalarReplacementOfAggregates - - fn flat() -> () { - let mut _0: (); // return place in scope 0 at $DIR/sroa.rs:+0:15: +0:15 - let _1: u8; // in scope 0 at $DIR/sroa.rs:+1:15: +1:16 - let _2: (); // in scope 0 at $DIR/sroa.rs:+1:18: +1:19 - let _3: &str; // in scope 0 at $DIR/sroa.rs:+1:21: +1:22 - let _4: std::option::Option<isize>; // in scope 0 at $DIR/sroa.rs:+1:24: +1:25 - let mut _5: Foo; // in scope 0 at $DIR/sroa.rs:+1:30: +1:70 - let mut _6: (); // in scope 0 at $DIR/sroa.rs:+1:45: +1:47 - let mut _7: std::option::Option<isize>; // in scope 0 at $DIR/sroa.rs:+1:60: +1:68 -+ let mut _8: u8; // in scope 0 at $DIR/sroa.rs:+1:30: +1:70 -+ let mut _9: (); // in scope 0 at $DIR/sroa.rs:+1:30: +1:70 -+ let mut _10: &str; // in scope 0 at $DIR/sroa.rs:+1:30: +1:70 -+ let mut _11: std::option::Option<isize>; // in scope 0 at $DIR/sroa.rs:+1:30: +1:70 - scope 1 { - debug a => _1; // in scope 1 at $DIR/sroa.rs:+1:15: +1:16 - debug b => _2; // in scope 1 at $DIR/sroa.rs:+1:18: +1:19 - debug c => _3; // in scope 1 at $DIR/sroa.rs:+1:21: +1:22 - debug d => _4; // in scope 1 at $DIR/sroa.rs:+1:24: +1:25 - scope 2 { - scope 3 { - scope 4 { - scope 5 { - } - } - } - } - } - - bb0: { -- StorageLive(_5); // scope 0 at $DIR/sroa.rs:+1:30: +1:70 -+ StorageLive(_8); // scope 0 at $DIR/sroa.rs:+1:30: +1:70 -+ StorageLive(_9); // scope 0 at $DIR/sroa.rs:+1:30: +1:70 -+ StorageLive(_10); // scope 0 at $DIR/sroa.rs:+1:30: +1:70 -+ StorageLive(_11); // scope 0 at $DIR/sroa.rs:+1:30: +1:70 -+ nop; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 - StorageLive(_6); // scope 0 at $DIR/sroa.rs:+1:45: +1:47 - _6 = (); // scope 0 at $DIR/sroa.rs:+1:45: +1:47 - StorageLive(_7); // scope 0 at $DIR/sroa.rs:+1:60: +1:68 - _7 = Option::<isize>::Some(const -4_isize); // scope 0 at $DIR/sroa.rs:+1:60: +1:68 -- _5 = Foo { a: const 5_u8, b: move _6, c: const "a", d: move _7 }; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 -+ _8 = const 5_u8; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 -+ _9 = move _6; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 -+ _10 = const "a"; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 - // mir::Constant - // + span: $DIR/sroa.rs:53:52: 53:55 - // + literal: Const { ty: &str, val: Value(Slice(..)) } -+ _11 = move _7; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 -+ nop; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 - StorageDead(_7); // scope 0 at $DIR/sroa.rs:+1:69: +1:70 - StorageDead(_6); // scope 0 at $DIR/sroa.rs:+1:69: +1:70 - StorageLive(_1); // scope 0 at $DIR/sroa.rs:+1:15: +1:16 -- _1 = (_5.0: u8); // scope 0 at $DIR/sroa.rs:+1:15: +1:16 -+ _1 = _8; // scope 0 at $DIR/sroa.rs:+1:15: +1:16 - StorageLive(_2); // scope 0 at $DIR/sroa.rs:+1:18: +1:19 -- _2 = (_5.1: ()); // scope 0 at $DIR/sroa.rs:+1:18: +1:19 -+ _2 = _9; // scope 0 at $DIR/sroa.rs:+1:18: +1:19 - StorageLive(_3); // scope 0 at $DIR/sroa.rs:+1:21: +1:22 -- _3 = (_5.2: &str); // scope 0 at $DIR/sroa.rs:+1:21: +1:22 -+ _3 = _10; // scope 0 at $DIR/sroa.rs:+1:21: +1:22 - StorageLive(_4); // scope 0 at $DIR/sroa.rs:+1:24: +1:25 -- _4 = (_5.3: std::option::Option<isize>); // scope 0 at $DIR/sroa.rs:+1:24: +1:25 -- StorageDead(_5); // scope 0 at $DIR/sroa.rs:+1:70: +1:71 -+ _4 = _11; // scope 0 at $DIR/sroa.rs:+1:24: +1:25 -+ StorageDead(_8); // scope 0 at $DIR/sroa.rs:+1:70: +1:71 -+ StorageDead(_9); // scope 0 at $DIR/sroa.rs:+1:70: +1:71 -+ StorageDead(_10); // scope 0 at $DIR/sroa.rs:+1:70: +1:71 -+ StorageDead(_11); // scope 0 at $DIR/sroa.rs:+1:70: +1:71 -+ nop; // scope 0 at $DIR/sroa.rs:+1:70: +1:71 - _0 = const (); // scope 0 at $DIR/sroa.rs:+0:15: +6:2 - StorageDead(_4); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 - StorageDead(_3); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 - StorageDead(_2); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 - StorageDead(_1); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 - return; // scope 0 at $DIR/sroa.rs:+6:2: +6:2 - } - } - diff --git a/tests/mir-opt/sroa.ref_copies.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.ref_copies.ScalarReplacementOfAggregates.diff deleted file mode 100644 index f0d62220d..000000000 --- a/tests/mir-opt/sroa.ref_copies.ScalarReplacementOfAggregates.diff +++ /dev/null @@ -1,56 +0,0 @@ -- // MIR for `ref_copies` before ScalarReplacementOfAggregates -+ // MIR for `ref_copies` after ScalarReplacementOfAggregates - - fn ref_copies(_1: &Foo) -> () { - debug x => _1; // in scope 0 at $DIR/sroa.rs:+0:15: +0:16 - let mut _0: (); // return place in scope 0 at $DIR/sroa.rs:+0:24: +0:24 - let _2: Foo; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ let _5: u8; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ let _6: (); // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ let _7: &str; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ let _8: std::option::Option<isize>; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 - scope 1 { -- debug y => _2; // in scope 1 at $DIR/sroa.rs:+1:9: +1:10 -+ debug y => Foo{ .0 => _5, .1 => _6, .2 => _7, .3 => _8, }; // in scope 1 at $DIR/sroa.rs:+1:9: +1:10 - let _3: u8; // in scope 1 at $DIR/sroa.rs:+2:9: +2:10 - scope 2 { - debug t => _3; // in scope 2 at $DIR/sroa.rs:+2:9: +2:10 - let _4: &str; // in scope 2 at $DIR/sroa.rs:+3:9: +3:10 - scope 3 { - debug u => _4; // in scope 3 at $DIR/sroa.rs:+3:9: +3:10 - } - } - } - - bb0: { -- StorageLive(_2); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 -- _2 = (*_1); // scope 0 at $DIR/sroa.rs:+1:13: +1:15 -+ StorageLive(_5); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ StorageLive(_6); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ StorageLive(_7); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ StorageLive(_8); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ nop; // scope 0 at $DIR/sroa.rs:+1:9: +1:10 -+ _5 = ((*_1).0: u8); // scope 0 at $DIR/sroa.rs:+1:13: +1:15 -+ _6 = ((*_1).1: ()); // scope 0 at $DIR/sroa.rs:+1:13: +1:15 -+ _7 = ((*_1).2: &str); // scope 0 at $DIR/sroa.rs:+1:13: +1:15 -+ _8 = ((*_1).3: std::option::Option<isize>); // scope 0 at $DIR/sroa.rs:+1:13: +1:15 -+ nop; // scope 0 at $DIR/sroa.rs:+1:13: +1:15 - StorageLive(_3); // scope 1 at $DIR/sroa.rs:+2:9: +2:10 -- _3 = (_2.0: u8); // scope 1 at $DIR/sroa.rs:+2:13: +2:16 -+ _3 = _5; // scope 1 at $DIR/sroa.rs:+2:13: +2:16 - StorageLive(_4); // scope 2 at $DIR/sroa.rs:+3:9: +3:10 -- _4 = (_2.2: &str); // scope 2 at $DIR/sroa.rs:+3:13: +3:16 -+ _4 = _7; // scope 2 at $DIR/sroa.rs:+3:13: +3:16 - _0 = const (); // scope 0 at $DIR/sroa.rs:+0:24: +4:2 - StorageDead(_4); // scope 2 at $DIR/sroa.rs:+4:1: +4:2 - StorageDead(_3); // scope 1 at $DIR/sroa.rs:+4:1: +4:2 -- StorageDead(_2); // scope 0 at $DIR/sroa.rs:+4:1: +4:2 -+ StorageDead(_5); // scope 0 at $DIR/sroa.rs:+4:1: +4:2 -+ StorageDead(_6); // scope 0 at $DIR/sroa.rs:+4:1: +4:2 -+ StorageDead(_7); // scope 0 at $DIR/sroa.rs:+4:1: +4:2 -+ StorageDead(_8); // scope 0 at $DIR/sroa.rs:+4:1: +4:2 -+ nop; // scope 0 at $DIR/sroa.rs:+4:1: +4:2 - return; // scope 0 at $DIR/sroa.rs:+4:2: +4:2 - } - } - diff --git a/tests/mir-opt/sroa.structs.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.structs.ScalarReplacementOfAggregates.diff deleted file mode 100644 index 2c63d8b26..000000000 --- a/tests/mir-opt/sroa.structs.ScalarReplacementOfAggregates.diff +++ /dev/null @@ -1,33 +0,0 @@ -- // MIR for `structs` before ScalarReplacementOfAggregates -+ // MIR for `structs` after ScalarReplacementOfAggregates - - fn structs(_1: f32) -> f32 { - debug a => _1; // in scope 0 at $DIR/sroa.rs:+0:16: +0:17 - let mut _0: f32; // return place in scope 0 at $DIR/sroa.rs:+0:27: +0:30 - let mut _2: structs::U; // in scope 0 at $DIR/sroa.rs:+6:5: +6:21 - let mut _3: f32; // in scope 0 at $DIR/sroa.rs:+6:18: +6:19 -+ let mut _4: usize; // in scope 0 at $DIR/sroa.rs:+6:5: +6:21 -+ let mut _5: f32; // in scope 0 at $DIR/sroa.rs:+6:5: +6:21 - - bb0: { -- StorageLive(_2); // scope 0 at $DIR/sroa.rs:+6:5: +6:21 -+ StorageLive(_4); // scope 0 at $DIR/sroa.rs:+6:5: +6:21 -+ StorageLive(_5); // scope 0 at $DIR/sroa.rs:+6:5: +6:21 -+ nop; // scope 0 at $DIR/sroa.rs:+6:5: +6:21 - StorageLive(_3); // scope 0 at $DIR/sroa.rs:+6:18: +6:19 - _3 = _1; // scope 0 at $DIR/sroa.rs:+6:18: +6:19 -- _2 = U { _foo: const 0_usize, a: move _3 }; // scope 0 at $DIR/sroa.rs:+6:5: +6:21 -+ _4 = const 0_usize; // scope 0 at $DIR/sroa.rs:+6:5: +6:21 -+ _5 = move _3; // scope 0 at $DIR/sroa.rs:+6:5: +6:21 -+ nop; // scope 0 at $DIR/sroa.rs:+6:5: +6:21 - StorageDead(_3); // scope 0 at $DIR/sroa.rs:+6:20: +6:21 -- _0 = (_2.1: f32); // scope 0 at $DIR/sroa.rs:+6:5: +6:23 -- StorageDead(_2); // scope 0 at $DIR/sroa.rs:+7:1: +7:2 -+ _0 = _5; // scope 0 at $DIR/sroa.rs:+6:5: +6:23 -+ StorageDead(_4); // scope 0 at $DIR/sroa.rs:+7:1: +7:2 -+ StorageDead(_5); // scope 0 at $DIR/sroa.rs:+7:1: +7:2 -+ nop; // scope 0 at $DIR/sroa.rs:+7:1: +7:2 - return; // scope 0 at $DIR/sroa.rs:+7:2: +7:2 - } - } - diff --git a/tests/mir-opt/sroa.unions.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.unions.ScalarReplacementOfAggregates.diff deleted file mode 100644 index adfb01385..000000000 --- a/tests/mir-opt/sroa.unions.ScalarReplacementOfAggregates.diff +++ /dev/null @@ -1,23 +0,0 @@ -- // MIR for `unions` before ScalarReplacementOfAggregates -+ // MIR for `unions` after ScalarReplacementOfAggregates - - fn unions(_1: f32) -> u32 { - debug a => _1; // in scope 0 at $DIR/sroa.rs:+0:15: +0:16 - let mut _0: u32; // return place in scope 0 at $DIR/sroa.rs:+0:26: +0:29 - let mut _2: unions::Repr; // in scope 0 at $DIR/sroa.rs:+5:14: +5:27 - let mut _3: f32; // in scope 0 at $DIR/sroa.rs:+5:24: +5:25 - scope 1 { - } - - bb0: { - StorageLive(_2); // scope 1 at $DIR/sroa.rs:+5:14: +5:27 - StorageLive(_3); // scope 1 at $DIR/sroa.rs:+5:24: +5:25 - _3 = _1; // scope 1 at $DIR/sroa.rs:+5:24: +5:25 - _2 = Repr { f: move _3 }; // scope 1 at $DIR/sroa.rs:+5:14: +5:27 - StorageDead(_3); // scope 1 at $DIR/sroa.rs:+5:26: +5:27 - _0 = (_2.1: u32); // scope 1 at $DIR/sroa.rs:+5:14: +5:29 - StorageDead(_2); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 - return; // scope 0 at $DIR/sroa.rs:+6:2: +6:2 - } - } - diff --git a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..579587a43 --- /dev/null +++ b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff @@ -0,0 +1,214 @@ +- // MIR for `foo` before ScalarReplacementOfAggregates ++ // MIR for `foo` after ScalarReplacementOfAggregates + + fn foo() -> () { + let mut _0: (); // return place in scope 0 at $DIR/lifetimes.rs:+0:18: +0:18 + let _1: Foo<T>; // in scope 0 at $DIR/lifetimes.rs:+1:9: +1:12 + let mut _2: std::result::Result<std::boxed::Box<dyn std::fmt::Display>, <T as Err>::Err>; // in scope 0 at $DIR/lifetimes.rs:+2:12: +2:31 + let mut _3: std::boxed::Box<dyn std::fmt::Display>; // in scope 0 at $DIR/lifetimes.rs:+2:15: +2:30 + let mut _4: std::boxed::Box<u32>; // in scope 0 at $DIR/lifetimes.rs:+2:15: +2:30 + let mut _7: isize; // in scope 0 at $DIR/lifetimes.rs:+9:12: +9:17 + let _9: (); // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let _10: (); // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _11: std::fmt::Arguments<'_>; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _12: &[&str]; // in scope 0 at $DIR/lifetimes.rs:+10:19: +10:28 + let mut _13: &[&str; 3]; // in scope 0 at $DIR/lifetimes.rs:+10:19: +10:28 + let _14: &[&str; 3]; // in scope 0 at $DIR/lifetimes.rs:+10:19: +10:28 + let _15: [&str; 3]; // in scope 0 at $DIR/lifetimes.rs:+10:19: +10:28 + let mut _16: &[core::fmt::ArgumentV1<'_>]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _17: &[core::fmt::ArgumentV1<'_>; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let _18: &[core::fmt::ArgumentV1<'_>; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let _19: [core::fmt::ArgumentV1<'_>; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _20: core::fmt::ArgumentV1<'_>; // in scope 0 at $DIR/lifetimes.rs:+10:20: +10:23 + let mut _21: &std::boxed::Box<dyn std::fmt::Display>; // in scope 0 at $DIR/lifetimes.rs:+10:20: +10:23 + let _22: &std::boxed::Box<dyn std::fmt::Display>; // in scope 0 at $DIR/lifetimes.rs:+10:20: +10:23 + let mut _23: core::fmt::ArgumentV1<'_>; // in scope 0 at $DIR/lifetimes.rs:+10:24: +10:27 + let mut _24: &u32; // in scope 0 at $DIR/lifetimes.rs:+10:24: +10:27 + let _25: &u32; // in scope 0 at $DIR/lifetimes.rs:+10:24: +10:27 + let mut _27: bool; // in scope 0 at $DIR/lifetimes.rs:+12:1: +12:2 + let mut _28: isize; // in scope 0 at $DIR/lifetimes.rs:+12:1: +12:2 + let mut _29: isize; // in scope 0 at $DIR/lifetimes.rs:+12:1: +12:2 + let mut _30: isize; // in scope 0 at $DIR/lifetimes.rs:+12:1: +12:2 ++ let _31: std::result::Result<std::boxed::Box<dyn std::fmt::Display>, <T as Err>::Err>; // in scope 0 at $DIR/lifetimes.rs:+1:9: +1:12 ++ let _32: u32; // in scope 0 at $DIR/lifetimes.rs:+1:9: +1:12 + scope 1 { +- debug foo => _1; // in scope 1 at $DIR/lifetimes.rs:+1:9: +1:12 ++ debug foo => Foo<T>{ .0 => _31, .1 => _32, }; // in scope 1 at $DIR/lifetimes.rs:+1:9: +1:12 + let _5: std::result::Result<std::boxed::Box<dyn std::fmt::Display>, <T as Err>::Err>; // in scope 1 at $DIR/lifetimes.rs:+6:9: +6:10 + scope 2 { + debug x => _5; // in scope 2 at $DIR/lifetimes.rs:+6:9: +6:10 + let _6: u32; // in scope 2 at $DIR/lifetimes.rs:+7:9: +7:10 + scope 3 { + debug y => _6; // in scope 3 at $DIR/lifetimes.rs:+7:9: +7:10 + scope 4 { + debug x => _8; // in scope 4 at $DIR/lifetimes.rs:+9:15: +9:16 + let _8: std::boxed::Box<dyn std::fmt::Display>; // in scope 4 at $DIR/lifetimes.rs:+9:15: +9:16 + let mut _26: &[&str; 3]; // in scope 4 at $DIR/lifetimes.rs:+10:19: +10:28 + } + } + } + } + + bb0: { + _27 = const false; // scope 0 at $DIR/lifetimes.rs:+1:9: +1:12 +- StorageLive(_1); // scope 0 at $DIR/lifetimes.rs:+1:9: +1:12 ++ StorageLive(_31); // scope 0 at $DIR/lifetimes.rs:+1:9: +1:12 ++ StorageLive(_32); // scope 0 at $DIR/lifetimes.rs:+1:9: +1:12 ++ nop; // scope 0 at $DIR/lifetimes.rs:+1:9: +1:12 + StorageLive(_2); // scope 0 at $DIR/lifetimes.rs:+2:12: +2:31 + StorageLive(_3); // scope 0 at $DIR/lifetimes.rs:+2:15: +2:30 + StorageLive(_4); // scope 0 at $DIR/lifetimes.rs:+2:15: +2:30 + _4 = Box::<u32>::new(const 5_u32) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lifetimes.rs:+2:15: +2:30 + // mir::Constant + // + span: $DIR/lifetimes.rs:19:15: 19:23 + // + user_ty: UserType(1) + // + literal: Const { ty: fn(u32) -> Box<u32> {Box::<u32>::new}, val: Value(<ZST>) } + } + + bb1: { + _3 = move _4 as std::boxed::Box<dyn std::fmt::Display> (Pointer(Unsize)); // scope 0 at $DIR/lifetimes.rs:+2:15: +2:30 + StorageDead(_4); // scope 0 at $DIR/lifetimes.rs:+2:29: +2:30 + _2 = Result::<Box<dyn std::fmt::Display>, <T as Err>::Err>::Ok(move _3); // scope 0 at $DIR/lifetimes.rs:+2:12: +2:31 + StorageDead(_3); // scope 0 at $DIR/lifetimes.rs:+2:30: +2:31 +- _1 = Foo::<T> { x: move _2, y: const 7_u32 }; // scope 0 at $DIR/lifetimes.rs:+1:23: +4:6 ++ _31 = move _2; // scope 0 at $DIR/lifetimes.rs:+1:23: +4:6 ++ _32 = const 7_u32; // scope 0 at $DIR/lifetimes.rs:+1:23: +4:6 ++ nop; // scope 0 at $DIR/lifetimes.rs:+1:23: +4:6 + StorageDead(_2); // scope 0 at $DIR/lifetimes.rs:+4:5: +4:6 + StorageLive(_5); // scope 1 at $DIR/lifetimes.rs:+6:9: +6:10 + _27 = const true; // scope 1 at $DIR/lifetimes.rs:+6:13: +6:18 +- _5 = move (_1.0: std::result::Result<std::boxed::Box<dyn std::fmt::Display>, <T as Err>::Err>); // scope 1 at $DIR/lifetimes.rs:+6:13: +6:18 ++ _5 = move _31; // scope 1 at $DIR/lifetimes.rs:+6:13: +6:18 + StorageLive(_6); // scope 2 at $DIR/lifetimes.rs:+7:9: +7:10 +- _6 = (_1.1: u32); // scope 2 at $DIR/lifetimes.rs:+7:13: +7:18 ++ _6 = _32; // scope 2 at $DIR/lifetimes.rs:+7:13: +7:18 + _7 = discriminant(_5); // scope 4 at $DIR/lifetimes.rs:+9:12: +9:17 + switchInt(move _7) -> [0: bb2, otherwise: bb7]; // scope 4 at $DIR/lifetimes.rs:+9:12: +9:17 + } + + bb2: { + StorageLive(_8); // scope 4 at $DIR/lifetimes.rs:+9:15: +9:16 + _27 = const false; // scope 4 at $DIR/lifetimes.rs:+9:15: +9:16 + _8 = move ((_5 as Ok).0: std::boxed::Box<dyn std::fmt::Display>); // scope 4 at $DIR/lifetimes.rs:+9:15: +9:16 + StorageLive(_9); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_10); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_11); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_12); // scope 4 at $DIR/lifetimes.rs:+10:19: +10:28 + StorageLive(_13); // scope 4 at $DIR/lifetimes.rs:+10:19: +10:28 + StorageLive(_14); // scope 4 at $DIR/lifetimes.rs:+10:19: +10:28 + _26 = const _; // scope 4 at $DIR/lifetimes.rs:+10:19: +10:28 + // mir::Constant + // + span: $DIR/lifetimes.rs:27:19: 27:28 + // + literal: Const { ty: &[&str; 3], val: Unevaluated(foo, [T], Some(promoted[0])) } + _14 = &(*_26); // scope 4 at $DIR/lifetimes.rs:+10:19: +10:28 + _13 = &(*_14); // scope 4 at $DIR/lifetimes.rs:+10:19: +10:28 + _12 = move _13 as &[&str] (Pointer(Unsize)); // scope 4 at $DIR/lifetimes.rs:+10:19: +10:28 + StorageDead(_13); // scope 4 at $DIR/lifetimes.rs:+10:27: +10:28 + StorageLive(_16); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_17); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_18); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_19); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_20); // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 + StorageLive(_21); // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 + StorageLive(_22); // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 + _22 = &_8; // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 + _21 = &(*_22); // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 + _20 = core::fmt::ArgumentV1::<'_>::new_display::<Box<dyn std::fmt::Display>>(move _21) -> [return: bb3, unwind unreachable]; // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 + // mir::Constant + // + span: $DIR/lifetimes.rs:27:20: 27:23 + // + user_ty: UserType(4) + // + literal: Const { ty: for<'b> fn(&'b Box<dyn std::fmt::Display>) -> core::fmt::ArgumentV1<'b> {core::fmt::ArgumentV1::<'_>::new_display::<Box<dyn std::fmt::Display>>}, val: Value(<ZST>) } + } + + bb3: { + StorageDead(_21); // scope 4 at $DIR/lifetimes.rs:+10:22: +10:23 + StorageLive(_23); // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 + StorageLive(_24); // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 + StorageLive(_25); // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 + _25 = &_6; // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 + _24 = &(*_25); // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 + _23 = core::fmt::ArgumentV1::<'_>::new_display::<u32>(move _24) -> [return: bb4, unwind unreachable]; // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 + // mir::Constant + // + span: $DIR/lifetimes.rs:27:24: 27:27 + // + user_ty: UserType(5) + // + literal: Const { ty: for<'b> fn(&'b u32) -> core::fmt::ArgumentV1<'b> {core::fmt::ArgumentV1::<'_>::new_display::<u32>}, val: Value(<ZST>) } + } + + bb4: { + StorageDead(_24); // scope 4 at $DIR/lifetimes.rs:+10:26: +10:27 + _19 = [move _20, move _23]; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_23); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_20); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + _18 = &_19; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + _17 = &(*_18); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + _16 = move _17 as &[core::fmt::ArgumentV1<'_>] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_17); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + _11 = Arguments::<'_>::new_v1(move _12, move _16) -> [return: bb5, unwind unreachable]; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/std/src/macros.rs:LL:COL + // + user_ty: UserType(3) + // + literal: Const { ty: fn(&[&'static str], &[core::fmt::ArgumentV1<'_>]) -> Arguments<'_> {Arguments::<'_>::new_v1}, val: Value(<ZST>) } + } + + bb5: { + StorageDead(_16); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_12); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + _10 = _eprint(move _11) -> [return: bb6, unwind unreachable]; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/std/src/macros.rs:LL:COL + // + literal: Const { ty: for<'a> fn(Arguments<'a>) {_eprint}, val: Value(<ZST>) } + } + + bb6: { + StorageDead(_11); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_25); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_22); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_19); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_18); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_14); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_10); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + _9 = const (); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_9); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + _0 = const (); // scope 4 at $DIR/lifetimes.rs:+9:22: +11:6 + drop(_8) -> [return: bb8, unwind unreachable]; // scope 3 at $DIR/lifetimes.rs:+11:5: +11:6 + } + + bb7: { + _0 = const (); // scope 3 at $DIR/lifetimes.rs:+11:6: +11:6 + goto -> bb9; // scope 3 at $DIR/lifetimes.rs:+9:5: +11:6 + } + + bb8: { + StorageDead(_8); // scope 3 at $DIR/lifetimes.rs:+11:5: +11:6 + goto -> bb9; // scope 3 at $DIR/lifetimes.rs:+9:5: +11:6 + } + + bb9: { + StorageDead(_6); // scope 2 at $DIR/lifetimes.rs:+12:1: +12:2 + _28 = discriminant(_5); // scope 1 at $DIR/lifetimes.rs:+12:1: +12:2 + switchInt(move _28) -> [0: bb11, otherwise: bb13]; // scope 1 at $DIR/lifetimes.rs:+12:1: +12:2 + } + + bb10: { + _27 = const false; // scope 1 at $DIR/lifetimes.rs:+12:1: +12:2 + StorageDead(_5); // scope 1 at $DIR/lifetimes.rs:+12:1: +12:2 +- StorageDead(_1); // scope 0 at $DIR/lifetimes.rs:+12:1: +12:2 ++ StorageDead(_31); // scope 0 at $DIR/lifetimes.rs:+12:1: +12:2 ++ StorageDead(_32); // scope 0 at $DIR/lifetimes.rs:+12:1: +12:2 ++ nop; // scope 0 at $DIR/lifetimes.rs:+12:1: +12:2 + return; // scope 0 at $DIR/lifetimes.rs:+12:2: +12:2 + } + + bb11: { + switchInt(_27) -> [0: bb10, otherwise: bb12]; // scope 1 at $DIR/lifetimes.rs:+12:1: +12:2 + } + + bb12: { + drop(((_5 as Ok).0: std::boxed::Box<dyn std::fmt::Display>)) -> [return: bb10, unwind unreachable]; // scope 1 at $DIR/lifetimes.rs:+12:1: +12:2 + } + + bb13: { + drop(_5) -> [return: bb10, unwind unreachable]; // scope 1 at $DIR/lifetimes.rs:+12:1: +12:2 + } + } + diff --git a/tests/mir-opt/sroa/lifetimes.rs b/tests/mir-opt/sroa/lifetimes.rs new file mode 100644 index 000000000..2356d212f --- /dev/null +++ b/tests/mir-opt/sroa/lifetimes.rs @@ -0,0 +1,37 @@ +// unit-test: ScalarReplacementOfAggregates +// compile-flags: -Cpanic=abort +// no-prefer-dynamic + +trait Err { + type Err; +} + +struct Foo<T: Err> { + // Check that the `'static` lifetime is erased when creating the local for `x`, + // even if we fail to normalize the type. + x: Result<Box<dyn std::fmt::Display + 'static>, <T as Err>::Err>, + y: u32, +} + +// EMIT_MIR lifetimes.foo.ScalarReplacementOfAggregates.diff +fn foo<T: Err>() { + let foo: Foo<T> = Foo { + x: Ok(Box::new(5_u32)), + y: 7_u32, + }; + + let x = foo.x; + let y = foo.y; + + if let Ok(x) = x { + eprintln!("{x} {y}"); + } +} + +impl Err for () { + type Err = (); +} + +fn main() { + foo::<()>() +} diff --git a/tests/mir-opt/sroa/structs.constant.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/structs.constant.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..647681f0e --- /dev/null +++ b/tests/mir-opt/sroa/structs.constant.ScalarReplacementOfAggregates.diff @@ -0,0 +1,46 @@ +- // MIR for `constant` before ScalarReplacementOfAggregates ++ // MIR for `constant` after ScalarReplacementOfAggregates + + fn constant() -> () { + let mut _0: (); // return place in scope 0 at $DIR/structs.rs:+0:15: +0:15 + let _1: (usize, u8); // in scope 0 at $DIR/structs.rs:+2:9: +2:10 ++ let _4: usize; // in scope 0 at $DIR/structs.rs:+2:9: +2:10 ++ let _5: u8; // in scope 0 at $DIR/structs.rs:+2:9: +2:10 + scope 1 { +- debug y => _1; // in scope 1 at $DIR/structs.rs:+2:9: +2:10 ++ debug y => (usize, u8){ .0 => _4, .1 => _5, }; // in scope 1 at $DIR/structs.rs:+2:9: +2:10 + let _2: usize; // in scope 1 at $DIR/structs.rs:+3:9: +3:10 + scope 2 { + debug t => _2; // in scope 2 at $DIR/structs.rs:+3:9: +3:10 + let _3: u8; // in scope 2 at $DIR/structs.rs:+4:9: +4:10 + scope 3 { + debug u => _3; // in scope 3 at $DIR/structs.rs:+4:9: +4:10 + } + } + } + + bb0: { +- StorageLive(_1); // scope 0 at $DIR/structs.rs:+2:9: +2:10 ++ StorageLive(_4); // scope 0 at $DIR/structs.rs:+2:9: +2:10 ++ StorageLive(_5); // scope 0 at $DIR/structs.rs:+2:9: +2:10 ++ nop; // scope 0 at $DIR/structs.rs:+2:9: +2:10 + _1 = const _; // scope 0 at $DIR/structs.rs:+2:13: +2:14 ++ _4 = move (_1.0: usize); // scope 1 at $DIR/structs.rs:+3:9: +3:10 ++ _5 = move (_1.1: u8); // scope 1 at $DIR/structs.rs:+3:9: +3:10 + StorageLive(_2); // scope 1 at $DIR/structs.rs:+3:9: +3:10 +- _2 = (_1.0: usize); // scope 1 at $DIR/structs.rs:+3:13: +3:16 ++ _2 = _4; // scope 1 at $DIR/structs.rs:+3:13: +3:16 + StorageLive(_3); // scope 2 at $DIR/structs.rs:+4:9: +4:10 +- _3 = (_1.1: u8); // scope 2 at $DIR/structs.rs:+4:13: +4:16 ++ _3 = _5; // scope 2 at $DIR/structs.rs:+4:13: +4:16 + _0 = const (); // scope 0 at $DIR/structs.rs:+0:15: +5:2 + StorageDead(_3); // scope 2 at $DIR/structs.rs:+5:1: +5:2 + StorageDead(_2); // scope 1 at $DIR/structs.rs:+5:1: +5:2 +- StorageDead(_1); // scope 0 at $DIR/structs.rs:+5:1: +5:2 ++ StorageDead(_4); // scope 0 at $DIR/structs.rs:+5:1: +5:2 ++ StorageDead(_5); // scope 0 at $DIR/structs.rs:+5:1: +5:2 ++ nop; // scope 0 at $DIR/structs.rs:+5:1: +5:2 + return; // scope 0 at $DIR/structs.rs:+5:2: +5:2 + } + } + diff --git a/tests/mir-opt/sroa/structs.copies.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/structs.copies.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..b0b0da886 --- /dev/null +++ b/tests/mir-opt/sroa/structs.copies.ScalarReplacementOfAggregates.diff @@ -0,0 +1,91 @@ +- // MIR for `copies` before ScalarReplacementOfAggregates ++ // MIR for `copies` after ScalarReplacementOfAggregates + + fn copies(_1: Foo) -> () { + debug x => _1; // in scope 0 at $DIR/structs.rs:+0:11: +0:12 + let mut _0: (); // return place in scope 0 at $DIR/structs.rs:+0:19: +0:19 + let _2: Foo; // in scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ let _11: u8; // in scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ let _12: (); // in scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ let _13: &str; // in scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ let _14: std::option::Option<isize>; // in scope 0 at $DIR/structs.rs:+1:9: +1:10 + scope 1 { +- debug y => _2; // in scope 1 at $DIR/structs.rs:+1:9: +1:10 ++ debug y => Foo{ .0 => _11, .1 => _12, .2 => _13, .3 => _14, }; // in scope 1 at $DIR/structs.rs:+1:9: +1:10 + let _3: u8; // in scope 1 at $DIR/structs.rs:+2:9: +2:10 + scope 2 { + debug t => _3; // in scope 2 at $DIR/structs.rs:+2:9: +2:10 + let _4: &str; // in scope 2 at $DIR/structs.rs:+3:9: +3:10 + scope 3 { + debug u => _4; // in scope 3 at $DIR/structs.rs:+3:9: +3:10 + let _5: Foo; // in scope 3 at $DIR/structs.rs:+4:9: +4:10 ++ let _7: u8; // in scope 3 at $DIR/structs.rs:+4:9: +4:10 ++ let _8: (); // in scope 3 at $DIR/structs.rs:+4:9: +4:10 ++ let _9: &str; // in scope 3 at $DIR/structs.rs:+4:9: +4:10 ++ let _10: std::option::Option<isize>; // in scope 3 at $DIR/structs.rs:+4:9: +4:10 + scope 4 { +- debug z => _5; // in scope 4 at $DIR/structs.rs:+4:9: +4:10 ++ debug z => Foo{ .0 => _7, .1 => _8, .2 => _9, .3 => _10, }; // in scope 4 at $DIR/structs.rs:+4:9: +4:10 + let _6: (); // in scope 4 at $DIR/structs.rs:+5:9: +5:10 + scope 5 { + debug a => _6; // in scope 5 at $DIR/structs.rs:+5:9: +5:10 + } + } + } + } + } + + bb0: { +- StorageLive(_2); // scope 0 at $DIR/structs.rs:+1:9: +1:10 +- _2 = _1; // scope 0 at $DIR/structs.rs:+1:13: +1:14 ++ StorageLive(_11); // scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ StorageLive(_12); // scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ StorageLive(_13); // scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ StorageLive(_14); // scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ nop; // scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ _11 = (_1.0: u8); // scope 0 at $DIR/structs.rs:+1:13: +1:14 ++ _12 = (_1.1: ()); // scope 0 at $DIR/structs.rs:+1:13: +1:14 ++ _13 = (_1.2: &str); // scope 0 at $DIR/structs.rs:+1:13: +1:14 ++ _14 = (_1.3: std::option::Option<isize>); // scope 0 at $DIR/structs.rs:+1:13: +1:14 ++ nop; // scope 0 at $DIR/structs.rs:+1:13: +1:14 + StorageLive(_3); // scope 1 at $DIR/structs.rs:+2:9: +2:10 +- _3 = (_2.0: u8); // scope 1 at $DIR/structs.rs:+2:13: +2:16 ++ _3 = _11; // scope 1 at $DIR/structs.rs:+2:13: +2:16 + StorageLive(_4); // scope 2 at $DIR/structs.rs:+3:9: +3:10 +- _4 = (_2.2: &str); // scope 2 at $DIR/structs.rs:+3:13: +3:16 +- StorageLive(_5); // scope 3 at $DIR/structs.rs:+4:9: +4:10 +- _5 = _2; // scope 3 at $DIR/structs.rs:+4:13: +4:14 ++ _4 = _13; // scope 2 at $DIR/structs.rs:+3:13: +3:16 ++ StorageLive(_7); // scope 3 at $DIR/structs.rs:+4:9: +4:10 ++ StorageLive(_8); // scope 3 at $DIR/structs.rs:+4:9: +4:10 ++ StorageLive(_9); // scope 3 at $DIR/structs.rs:+4:9: +4:10 ++ StorageLive(_10); // scope 3 at $DIR/structs.rs:+4:9: +4:10 ++ nop; // scope 3 at $DIR/structs.rs:+4:9: +4:10 ++ _7 = _11; // scope 3 at $DIR/structs.rs:+4:13: +4:14 ++ _8 = _12; // scope 3 at $DIR/structs.rs:+4:13: +4:14 ++ _9 = _13; // scope 3 at $DIR/structs.rs:+4:13: +4:14 ++ _10 = _14; // scope 3 at $DIR/structs.rs:+4:13: +4:14 ++ nop; // scope 3 at $DIR/structs.rs:+4:13: +4:14 + StorageLive(_6); // scope 4 at $DIR/structs.rs:+5:9: +5:10 +- _6 = (_5.1: ()); // scope 4 at $DIR/structs.rs:+5:13: +5:16 ++ _6 = _8; // scope 4 at $DIR/structs.rs:+5:13: +5:16 + _0 = const (); // scope 0 at $DIR/structs.rs:+0:19: +6:2 + StorageDead(_6); // scope 4 at $DIR/structs.rs:+6:1: +6:2 +- StorageDead(_5); // scope 3 at $DIR/structs.rs:+6:1: +6:2 ++ StorageDead(_7); // scope 3 at $DIR/structs.rs:+6:1: +6:2 ++ StorageDead(_8); // scope 3 at $DIR/structs.rs:+6:1: +6:2 ++ StorageDead(_9); // scope 3 at $DIR/structs.rs:+6:1: +6:2 ++ StorageDead(_10); // scope 3 at $DIR/structs.rs:+6:1: +6:2 ++ nop; // scope 3 at $DIR/structs.rs:+6:1: +6:2 + StorageDead(_4); // scope 2 at $DIR/structs.rs:+6:1: +6:2 + StorageDead(_3); // scope 1 at $DIR/structs.rs:+6:1: +6:2 +- StorageDead(_2); // scope 0 at $DIR/structs.rs:+6:1: +6:2 ++ StorageDead(_11); // scope 0 at $DIR/structs.rs:+6:1: +6:2 ++ StorageDead(_12); // scope 0 at $DIR/structs.rs:+6:1: +6:2 ++ StorageDead(_13); // scope 0 at $DIR/structs.rs:+6:1: +6:2 ++ StorageDead(_14); // scope 0 at $DIR/structs.rs:+6:1: +6:2 ++ nop; // scope 0 at $DIR/structs.rs:+6:1: +6:2 + return; // scope 0 at $DIR/structs.rs:+6:2: +6:2 + } + } + diff --git a/tests/mir-opt/sroa/structs.dropping.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/structs.dropping.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..d378c260a --- /dev/null +++ b/tests/mir-opt/sroa/structs.dropping.ScalarReplacementOfAggregates.diff @@ -0,0 +1,44 @@ +- // MIR for `dropping` before ScalarReplacementOfAggregates ++ // MIR for `dropping` after ScalarReplacementOfAggregates + + fn dropping() -> () { + let mut _0: (); // return place in scope 0 at $DIR/structs.rs:+0:19: +0:19 + let _1: Tag; // in scope 0 at $DIR/structs.rs:+1:5: +1:32 + let mut _2: S; // in scope 0 at $DIR/structs.rs:+1:5: +1:30 + let mut _3: Tag; // in scope 0 at $DIR/structs.rs:+1:7: +1:13 + let mut _4: Tag; // in scope 0 at $DIR/structs.rs:+1:15: +1:21 + let mut _5: Tag; // in scope 0 at $DIR/structs.rs:+1:23: +1:29 + + bb0: { + StorageLive(_1); // scope 0 at $DIR/structs.rs:+1:5: +1:32 + StorageLive(_2); // scope 0 at $DIR/structs.rs:+1:5: +1:30 + StorageLive(_3); // scope 0 at $DIR/structs.rs:+1:7: +1:13 + _3 = Tag(const 0_usize); // scope 0 at $DIR/structs.rs:+1:7: +1:13 + StorageLive(_4); // scope 0 at $DIR/structs.rs:+1:15: +1:21 + _4 = Tag(const 1_usize); // scope 0 at $DIR/structs.rs:+1:15: +1:21 + StorageLive(_5); // scope 0 at $DIR/structs.rs:+1:23: +1:29 + _5 = Tag(const 2_usize); // scope 0 at $DIR/structs.rs:+1:23: +1:29 + _2 = S(move _3, move _4, move _5); // scope 0 at $DIR/structs.rs:+1:5: +1:30 + StorageDead(_5); // scope 0 at $DIR/structs.rs:+1:29: +1:30 + StorageDead(_4); // scope 0 at $DIR/structs.rs:+1:29: +1:30 + StorageDead(_3); // scope 0 at $DIR/structs.rs:+1:29: +1:30 + _1 = move (_2.1: Tag); // scope 0 at $DIR/structs.rs:+1:5: +1:32 + drop(_1) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/structs.rs:+1:32: +1:33 + } + + bb1: { + drop((_2.0: Tag)) -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/structs.rs:+1:32: +1:33 + } + + bb2: { + StorageDead(_2); // scope 0 at $DIR/structs.rs:+1:32: +1:33 + StorageDead(_1); // scope 0 at $DIR/structs.rs:+1:32: +1:33 + _0 = const (); // scope 0 at $DIR/structs.rs:+0:19: +2:2 + return; // scope 0 at $DIR/structs.rs:+2:2: +2:2 + } + + bb3: { + drop((_2.2: Tag)) -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/structs.rs:+1:32: +1:33 + } + } + diff --git a/tests/mir-opt/sroa/structs.enums.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/structs.enums.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..ff1e30c2d --- /dev/null +++ b/tests/mir-opt/sroa/structs.enums.ScalarReplacementOfAggregates.diff @@ -0,0 +1,43 @@ +- // MIR for `enums` before ScalarReplacementOfAggregates ++ // MIR for `enums` after ScalarReplacementOfAggregates + + fn enums(_1: usize) -> usize { + debug a => _1; // in scope 0 at $DIR/structs.rs:+0:14: +0:15 + let mut _0: usize; // return place in scope 0 at $DIR/structs.rs:+0:27: +0:32 + let mut _2: std::option::Option<usize>; // in scope 0 at $DIR/structs.rs:+1:22: +1:29 + let mut _3: usize; // in scope 0 at $DIR/structs.rs:+1:27: +1:28 + let mut _4: isize; // in scope 0 at $DIR/structs.rs:+1:12: +1:19 + scope 1 { + debug a => _5; // in scope 1 at $DIR/structs.rs:+1:17: +1:18 + let _5: usize; // in scope 1 at $DIR/structs.rs:+1:17: +1:18 + } + + bb0: { + StorageLive(_2); // scope 1 at $DIR/structs.rs:+1:22: +1:29 + StorageLive(_3); // scope 1 at $DIR/structs.rs:+1:27: +1:28 + _3 = _1; // scope 1 at $DIR/structs.rs:+1:27: +1:28 + _2 = Option::<usize>::Some(move _3); // scope 1 at $DIR/structs.rs:+1:22: +1:29 + StorageDead(_3); // scope 1 at $DIR/structs.rs:+1:28: +1:29 + _4 = discriminant(_2); // scope 1 at $DIR/structs.rs:+1:12: +1:19 + switchInt(move _4) -> [1: bb1, otherwise: bb2]; // scope 1 at $DIR/structs.rs:+1:12: +1:19 + } + + bb1: { + StorageLive(_5); // scope 1 at $DIR/structs.rs:+1:17: +1:18 + _5 = ((_2 as Some).0: usize); // scope 1 at $DIR/structs.rs:+1:17: +1:18 + _0 = _5; // scope 1 at $DIR/structs.rs:+1:32: +1:33 + StorageDead(_5); // scope 0 at $DIR/structs.rs:+1:34: +1:35 + goto -> bb3; // scope 0 at $DIR/structs.rs:+1:5: +1:46 + } + + bb2: { + _0 = const 0_usize; // scope 0 at $DIR/structs.rs:+1:43: +1:44 + goto -> bb3; // scope 0 at $DIR/structs.rs:+1:5: +1:46 + } + + bb3: { + StorageDead(_2); // scope 0 at $DIR/structs.rs:+2:1: +2:2 + return; // scope 0 at $DIR/structs.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/sroa/structs.escaping.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/structs.escaping.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..3074fcbdf --- /dev/null +++ b/tests/mir-opt/sroa/structs.escaping.ScalarReplacementOfAggregates.diff @@ -0,0 +1,44 @@ +- // MIR for `escaping` before ScalarReplacementOfAggregates ++ // MIR for `escaping` after ScalarReplacementOfAggregates + + fn escaping() -> () { + let mut _0: (); // return place in scope 0 at $DIR/structs.rs:+0:19: +0:19 + let _1: (); // in scope 0 at $DIR/structs.rs:+1:5: +1:42 + let mut _2: *const u32; // in scope 0 at $DIR/structs.rs:+1:7: +1:41 + let _3: &u32; // in scope 0 at $DIR/structs.rs:+1:7: +1:41 + let _4: Escaping; // in scope 0 at $DIR/structs.rs:+1:8: +1:39 + let mut _5: u32; // in scope 0 at $DIR/structs.rs:+1:34: +1:37 + + bb0: { + StorageLive(_1); // scope 0 at $DIR/structs.rs:+1:5: +1:42 + StorageLive(_2); // scope 0 at $DIR/structs.rs:+1:7: +1:41 + StorageLive(_3); // scope 0 at $DIR/structs.rs:+1:7: +1:41 + StorageLive(_4); // scope 0 at $DIR/structs.rs:+1:8: +1:39 + StorageLive(_5); // scope 0 at $DIR/structs.rs:+1:34: +1:37 + _5 = g() -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/structs.rs:+1:34: +1:37 + // mir::Constant + // + span: $DIR/structs.rs:78:34: 78:35 + // + literal: Const { ty: fn() -> u32 {g}, val: Value(<ZST>) } + } + + bb1: { + _4 = Escaping { a: const 1_u32, b: const 2_u32, c: move _5 }; // scope 0 at $DIR/structs.rs:+1:8: +1:39 + StorageDead(_5); // scope 0 at $DIR/structs.rs:+1:38: +1:39 + _3 = &(_4.0: u32); // scope 0 at $DIR/structs.rs:+1:7: +1:41 + _2 = &raw const (*_3); // scope 0 at $DIR/structs.rs:+1:7: +1:41 + _1 = f(move _2) -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/structs.rs:+1:5: +1:42 + // mir::Constant + // + span: $DIR/structs.rs:78:5: 78:6 + // + literal: Const { ty: fn(*const u32) {f}, val: Value(<ZST>) } + } + + bb2: { + StorageDead(_2); // scope 0 at $DIR/structs.rs:+1:41: +1:42 + StorageDead(_4); // scope 0 at $DIR/structs.rs:+1:42: +1:43 + StorageDead(_3); // scope 0 at $DIR/structs.rs:+1:42: +1:43 + StorageDead(_1); // scope 0 at $DIR/structs.rs:+1:42: +1:43 + _0 = const (); // scope 0 at $DIR/structs.rs:+0:19: +2:2 + return; // scope 0 at $DIR/structs.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/sroa/structs.flat.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/structs.flat.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..1aa11d17b --- /dev/null +++ b/tests/mir-opt/sroa/structs.flat.ScalarReplacementOfAggregates.diff @@ -0,0 +1,80 @@ +- // MIR for `flat` before ScalarReplacementOfAggregates ++ // MIR for `flat` after ScalarReplacementOfAggregates + + fn flat() -> () { + let mut _0: (); // return place in scope 0 at $DIR/structs.rs:+0:15: +0:15 + let _1: u8; // in scope 0 at $DIR/structs.rs:+1:15: +1:16 + let _2: (); // in scope 0 at $DIR/structs.rs:+1:18: +1:19 + let _3: &str; // in scope 0 at $DIR/structs.rs:+1:21: +1:22 + let _4: std::option::Option<isize>; // in scope 0 at $DIR/structs.rs:+1:24: +1:25 + let mut _5: Foo; // in scope 0 at $DIR/structs.rs:+1:30: +1:70 + let mut _6: (); // in scope 0 at $DIR/structs.rs:+1:45: +1:47 + let mut _7: std::option::Option<isize>; // in scope 0 at $DIR/structs.rs:+1:60: +1:68 ++ let mut _8: u8; // in scope 0 at $DIR/structs.rs:+1:30: +1:70 ++ let mut _9: (); // in scope 0 at $DIR/structs.rs:+1:30: +1:70 ++ let mut _10: &str; // in scope 0 at $DIR/structs.rs:+1:30: +1:70 ++ let mut _11: std::option::Option<isize>; // in scope 0 at $DIR/structs.rs:+1:30: +1:70 + scope 1 { + debug a => _1; // in scope 1 at $DIR/structs.rs:+1:15: +1:16 + debug b => _2; // in scope 1 at $DIR/structs.rs:+1:18: +1:19 + debug c => _3; // in scope 1 at $DIR/structs.rs:+1:21: +1:22 + debug d => _4; // in scope 1 at $DIR/structs.rs:+1:24: +1:25 + scope 2 { + scope 3 { + scope 4 { + scope 5 { + } + } + } + } + } + + bb0: { +- StorageLive(_5); // scope 0 at $DIR/structs.rs:+1:30: +1:70 ++ StorageLive(_8); // scope 0 at $DIR/structs.rs:+1:30: +1:70 ++ StorageLive(_9); // scope 0 at $DIR/structs.rs:+1:30: +1:70 ++ StorageLive(_10); // scope 0 at $DIR/structs.rs:+1:30: +1:70 ++ StorageLive(_11); // scope 0 at $DIR/structs.rs:+1:30: +1:70 ++ nop; // scope 0 at $DIR/structs.rs:+1:30: +1:70 + StorageLive(_6); // scope 0 at $DIR/structs.rs:+1:45: +1:47 + _6 = (); // scope 0 at $DIR/structs.rs:+1:45: +1:47 + StorageLive(_7); // scope 0 at $DIR/structs.rs:+1:60: +1:68 + _7 = Option::<isize>::Some(const -4_isize); // scope 0 at $DIR/structs.rs:+1:60: +1:68 +- _5 = Foo { a: const 5_u8, b: move _6, c: const "a", d: move _7 }; // scope 0 at $DIR/structs.rs:+1:30: +1:70 ++ _8 = const 5_u8; // scope 0 at $DIR/structs.rs:+1:30: +1:70 ++ _9 = move _6; // scope 0 at $DIR/structs.rs:+1:30: +1:70 ++ _10 = const "a"; // scope 0 at $DIR/structs.rs:+1:30: +1:70 + // mir::Constant + // + span: $DIR/structs.rs:53:52: 53:55 + // + literal: Const { ty: &str, val: Value(Slice(..)) } ++ _11 = move _7; // scope 0 at $DIR/structs.rs:+1:30: +1:70 ++ nop; // scope 0 at $DIR/structs.rs:+1:30: +1:70 + StorageDead(_7); // scope 0 at $DIR/structs.rs:+1:69: +1:70 + StorageDead(_6); // scope 0 at $DIR/structs.rs:+1:69: +1:70 + StorageLive(_1); // scope 0 at $DIR/structs.rs:+1:15: +1:16 +- _1 = (_5.0: u8); // scope 0 at $DIR/structs.rs:+1:15: +1:16 ++ _1 = _8; // scope 0 at $DIR/structs.rs:+1:15: +1:16 + StorageLive(_2); // scope 0 at $DIR/structs.rs:+1:18: +1:19 +- _2 = (_5.1: ()); // scope 0 at $DIR/structs.rs:+1:18: +1:19 ++ _2 = _9; // scope 0 at $DIR/structs.rs:+1:18: +1:19 + StorageLive(_3); // scope 0 at $DIR/structs.rs:+1:21: +1:22 +- _3 = (_5.2: &str); // scope 0 at $DIR/structs.rs:+1:21: +1:22 ++ _3 = _10; // scope 0 at $DIR/structs.rs:+1:21: +1:22 + StorageLive(_4); // scope 0 at $DIR/structs.rs:+1:24: +1:25 +- _4 = (_5.3: std::option::Option<isize>); // scope 0 at $DIR/structs.rs:+1:24: +1:25 +- StorageDead(_5); // scope 0 at $DIR/structs.rs:+1:70: +1:71 ++ _4 = _11; // scope 0 at $DIR/structs.rs:+1:24: +1:25 ++ StorageDead(_8); // scope 0 at $DIR/structs.rs:+1:70: +1:71 ++ StorageDead(_9); // scope 0 at $DIR/structs.rs:+1:70: +1:71 ++ StorageDead(_10); // scope 0 at $DIR/structs.rs:+1:70: +1:71 ++ StorageDead(_11); // scope 0 at $DIR/structs.rs:+1:70: +1:71 ++ nop; // scope 0 at $DIR/structs.rs:+1:70: +1:71 + _0 = const (); // scope 0 at $DIR/structs.rs:+0:15: +6:2 + StorageDead(_4); // scope 0 at $DIR/structs.rs:+6:1: +6:2 + StorageDead(_3); // scope 0 at $DIR/structs.rs:+6:1: +6:2 + StorageDead(_2); // scope 0 at $DIR/structs.rs:+6:1: +6:2 + StorageDead(_1); // scope 0 at $DIR/structs.rs:+6:1: +6:2 + return; // scope 0 at $DIR/structs.rs:+6:2: +6:2 + } + } + diff --git a/tests/mir-opt/sroa/structs.ref_copies.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/structs.ref_copies.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..7b09ac182 --- /dev/null +++ b/tests/mir-opt/sroa/structs.ref_copies.ScalarReplacementOfAggregates.diff @@ -0,0 +1,56 @@ +- // MIR for `ref_copies` before ScalarReplacementOfAggregates ++ // MIR for `ref_copies` after ScalarReplacementOfAggregates + + fn ref_copies(_1: &Foo) -> () { + debug x => _1; // in scope 0 at $DIR/structs.rs:+0:15: +0:16 + let mut _0: (); // return place in scope 0 at $DIR/structs.rs:+0:24: +0:24 + let _2: Foo; // in scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ let _5: u8; // in scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ let _6: (); // in scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ let _7: &str; // in scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ let _8: std::option::Option<isize>; // in scope 0 at $DIR/structs.rs:+1:9: +1:10 + scope 1 { +- debug y => _2; // in scope 1 at $DIR/structs.rs:+1:9: +1:10 ++ debug y => Foo{ .0 => _5, .1 => _6, .2 => _7, .3 => _8, }; // in scope 1 at $DIR/structs.rs:+1:9: +1:10 + let _3: u8; // in scope 1 at $DIR/structs.rs:+2:9: +2:10 + scope 2 { + debug t => _3; // in scope 2 at $DIR/structs.rs:+2:9: +2:10 + let _4: &str; // in scope 2 at $DIR/structs.rs:+3:9: +3:10 + scope 3 { + debug u => _4; // in scope 3 at $DIR/structs.rs:+3:9: +3:10 + } + } + } + + bb0: { +- StorageLive(_2); // scope 0 at $DIR/structs.rs:+1:9: +1:10 +- _2 = (*_1); // scope 0 at $DIR/structs.rs:+1:13: +1:15 ++ StorageLive(_5); // scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ StorageLive(_6); // scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ StorageLive(_7); // scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ StorageLive(_8); // scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ nop; // scope 0 at $DIR/structs.rs:+1:9: +1:10 ++ _5 = ((*_1).0: u8); // scope 0 at $DIR/structs.rs:+1:13: +1:15 ++ _6 = ((*_1).1: ()); // scope 0 at $DIR/structs.rs:+1:13: +1:15 ++ _7 = ((*_1).2: &str); // scope 0 at $DIR/structs.rs:+1:13: +1:15 ++ _8 = ((*_1).3: std::option::Option<isize>); // scope 0 at $DIR/structs.rs:+1:13: +1:15 ++ nop; // scope 0 at $DIR/structs.rs:+1:13: +1:15 + StorageLive(_3); // scope 1 at $DIR/structs.rs:+2:9: +2:10 +- _3 = (_2.0: u8); // scope 1 at $DIR/structs.rs:+2:13: +2:16 ++ _3 = _5; // scope 1 at $DIR/structs.rs:+2:13: +2:16 + StorageLive(_4); // scope 2 at $DIR/structs.rs:+3:9: +3:10 +- _4 = (_2.2: &str); // scope 2 at $DIR/structs.rs:+3:13: +3:16 ++ _4 = _7; // scope 2 at $DIR/structs.rs:+3:13: +3:16 + _0 = const (); // scope 0 at $DIR/structs.rs:+0:24: +4:2 + StorageDead(_4); // scope 2 at $DIR/structs.rs:+4:1: +4:2 + StorageDead(_3); // scope 1 at $DIR/structs.rs:+4:1: +4:2 +- StorageDead(_2); // scope 0 at $DIR/structs.rs:+4:1: +4:2 ++ StorageDead(_5); // scope 0 at $DIR/structs.rs:+4:1: +4:2 ++ StorageDead(_6); // scope 0 at $DIR/structs.rs:+4:1: +4:2 ++ StorageDead(_7); // scope 0 at $DIR/structs.rs:+4:1: +4:2 ++ StorageDead(_8); // scope 0 at $DIR/structs.rs:+4:1: +4:2 ++ nop; // scope 0 at $DIR/structs.rs:+4:1: +4:2 + return; // scope 0 at $DIR/structs.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/sroa.rs b/tests/mir-opt/sroa/structs.rs index fff92cf8d..7946eeaea 100644 --- a/tests/mir-opt/sroa.rs +++ b/tests/mir-opt/sroa/structs.rs @@ -111,12 +111,12 @@ fn main() { constant(); } -// EMIT_MIR sroa.dropping.ScalarReplacementOfAggregates.diff -// EMIT_MIR sroa.enums.ScalarReplacementOfAggregates.diff -// EMIT_MIR sroa.structs.ScalarReplacementOfAggregates.diff -// EMIT_MIR sroa.unions.ScalarReplacementOfAggregates.diff -// EMIT_MIR sroa.flat.ScalarReplacementOfAggregates.diff -// EMIT_MIR sroa.escaping.ScalarReplacementOfAggregates.diff -// EMIT_MIR sroa.copies.ScalarReplacementOfAggregates.diff -// EMIT_MIR sroa.ref_copies.ScalarReplacementOfAggregates.diff -// EMIT_MIR sroa.constant.ScalarReplacementOfAggregates.diff +// EMIT_MIR structs.dropping.ScalarReplacementOfAggregates.diff +// EMIT_MIR structs.enums.ScalarReplacementOfAggregates.diff +// EMIT_MIR structs.structs.ScalarReplacementOfAggregates.diff +// EMIT_MIR structs.unions.ScalarReplacementOfAggregates.diff +// EMIT_MIR structs.flat.ScalarReplacementOfAggregates.diff +// EMIT_MIR structs.escaping.ScalarReplacementOfAggregates.diff +// EMIT_MIR structs.copies.ScalarReplacementOfAggregates.diff +// EMIT_MIR structs.ref_copies.ScalarReplacementOfAggregates.diff +// EMIT_MIR structs.constant.ScalarReplacementOfAggregates.diff diff --git a/tests/mir-opt/sroa/structs.structs.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/structs.structs.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..c94e4b137 --- /dev/null +++ b/tests/mir-opt/sroa/structs.structs.ScalarReplacementOfAggregates.diff @@ -0,0 +1,33 @@ +- // MIR for `structs` before ScalarReplacementOfAggregates ++ // MIR for `structs` after ScalarReplacementOfAggregates + + fn structs(_1: f32) -> f32 { + debug a => _1; // in scope 0 at $DIR/structs.rs:+0:16: +0:17 + let mut _0: f32; // return place in scope 0 at $DIR/structs.rs:+0:27: +0:30 + let mut _2: structs::U; // in scope 0 at $DIR/structs.rs:+6:5: +6:21 + let mut _3: f32; // in scope 0 at $DIR/structs.rs:+6:18: +6:19 ++ let mut _4: usize; // in scope 0 at $DIR/structs.rs:+6:5: +6:21 ++ let mut _5: f32; // in scope 0 at $DIR/structs.rs:+6:5: +6:21 + + bb0: { +- StorageLive(_2); // scope 0 at $DIR/structs.rs:+6:5: +6:21 ++ StorageLive(_4); // scope 0 at $DIR/structs.rs:+6:5: +6:21 ++ StorageLive(_5); // scope 0 at $DIR/structs.rs:+6:5: +6:21 ++ nop; // scope 0 at $DIR/structs.rs:+6:5: +6:21 + StorageLive(_3); // scope 0 at $DIR/structs.rs:+6:18: +6:19 + _3 = _1; // scope 0 at $DIR/structs.rs:+6:18: +6:19 +- _2 = U { _foo: const 0_usize, a: move _3 }; // scope 0 at $DIR/structs.rs:+6:5: +6:21 ++ _4 = const 0_usize; // scope 0 at $DIR/structs.rs:+6:5: +6:21 ++ _5 = move _3; // scope 0 at $DIR/structs.rs:+6:5: +6:21 ++ nop; // scope 0 at $DIR/structs.rs:+6:5: +6:21 + StorageDead(_3); // scope 0 at $DIR/structs.rs:+6:20: +6:21 +- _0 = (_2.1: f32); // scope 0 at $DIR/structs.rs:+6:5: +6:23 +- StorageDead(_2); // scope 0 at $DIR/structs.rs:+7:1: +7:2 ++ _0 = _5; // scope 0 at $DIR/structs.rs:+6:5: +6:23 ++ StorageDead(_4); // scope 0 at $DIR/structs.rs:+7:1: +7:2 ++ StorageDead(_5); // scope 0 at $DIR/structs.rs:+7:1: +7:2 ++ nop; // scope 0 at $DIR/structs.rs:+7:1: +7:2 + return; // scope 0 at $DIR/structs.rs:+7:2: +7:2 + } + } + diff --git a/tests/mir-opt/sroa/structs.unions.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/structs.unions.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..5aa054589 --- /dev/null +++ b/tests/mir-opt/sroa/structs.unions.ScalarReplacementOfAggregates.diff @@ -0,0 +1,23 @@ +- // MIR for `unions` before ScalarReplacementOfAggregates ++ // MIR for `unions` after ScalarReplacementOfAggregates + + fn unions(_1: f32) -> u32 { + debug a => _1; // in scope 0 at $DIR/structs.rs:+0:15: +0:16 + let mut _0: u32; // return place in scope 0 at $DIR/structs.rs:+0:26: +0:29 + let mut _2: unions::Repr; // in scope 0 at $DIR/structs.rs:+5:14: +5:27 + let mut _3: f32; // in scope 0 at $DIR/structs.rs:+5:24: +5:25 + scope 1 { + } + + bb0: { + StorageLive(_2); // scope 1 at $DIR/structs.rs:+5:14: +5:27 + StorageLive(_3); // scope 1 at $DIR/structs.rs:+5:24: +5:25 + _3 = _1; // scope 1 at $DIR/structs.rs:+5:24: +5:25 + _2 = Repr { f: move _3 }; // scope 1 at $DIR/structs.rs:+5:14: +5:27 + StorageDead(_3); // scope 1 at $DIR/structs.rs:+5:26: +5:27 + _0 = (_2.1: u32); // scope 1 at $DIR/structs.rs:+5:14: +5:29 + StorageDead(_2); // scope 0 at $DIR/structs.rs:+6:1: +6:2 + return; // scope 0 at $DIR/structs.rs:+6:2: +6:2 + } + } + diff --git a/tests/mir-opt/try_identity_e2e.new.PreCodegen.after.mir b/tests/mir-opt/try_identity_e2e.new.PreCodegen.after.mir index b9cc10575..935dbb28b 100644 --- a/tests/mir-opt/try_identity_e2e.new.PreCodegen.after.mir +++ b/tests/mir-opt/try_identity_e2e.new.PreCodegen.after.mir @@ -26,37 +26,37 @@ fn new(_1: Result<T, E>) -> Result<T, E> { bb0: { StorageLive(_2); // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +7:10 _3 = discriminant(_1); // scope 0 at $DIR/try_identity_e2e.rs:+3:19: +3:20 - switchInt(move _3) -> [0: bb2, 1: bb1, otherwise: bb5]; // scope 0 at $DIR/try_identity_e2e.rs:+3:13: +3:20 + switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; // scope 0 at $DIR/try_identity_e2e.rs:+3:13: +3:20 } bb1: { _5 = move ((_1 as Err).0: E); // scope 0 at $DIR/try_identity_e2e.rs:+5:21: +5:22 _2 = ControlFlow::<E, T>::Break(move _5); // scope 2 at $DIR/try_identity_e2e.rs:+5:27: +5:48 - goto -> bb3; // scope 0 at $DIR/try_identity_e2e.rs:+5:47: +5:48 + goto -> bb4; // scope 0 at $DIR/try_identity_e2e.rs:+5:47: +5:48 } bb2: { + unreachable; // scope 0 at $DIR/try_identity_e2e.rs:+3:19: +3:20 + } + + bb3: { _4 = move ((_1 as Ok).0: T); // scope 0 at $DIR/try_identity_e2e.rs:+4:20: +4:21 _2 = ControlFlow::<E, T>::Continue(move _4); // scope 1 at $DIR/try_identity_e2e.rs:+4:26: +4:50 - goto -> bb3; // scope 0 at $DIR/try_identity_e2e.rs:+4:49: +4:50 + goto -> bb4; // scope 0 at $DIR/try_identity_e2e.rs:+4:49: +4:50 } - bb3: { + bb4: { _6 = discriminant(_2); // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +7:10 - switchInt(move _6) -> [0: bb6, 1: bb4, otherwise: bb5]; // scope 0 at $DIR/try_identity_e2e.rs:+2:9: +7:10 + switchInt(move _6) -> [0: bb6, 1: bb5, otherwise: bb2]; // scope 0 at $DIR/try_identity_e2e.rs:+2:9: +7:10 } - bb4: { + bb5: { _8 = move ((_2 as Break).0: E); // scope 0 at $DIR/try_identity_e2e.rs:+9:32: +9:33 _0 = Result::<T, E>::Err(move _8); // scope 4 at $DIR/try_identity_e2e.rs:+9:45: +9:51 StorageDead(_2); // scope 0 at $DIR/try_identity_e2e.rs:+12:1: +12:2 return; // scope 0 at $DIR/try_identity_e2e.rs:+12:1: +12:2 } - bb5: { - unreachable; // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +7:10 - } - bb6: { _7 = move ((_2 as Continue).0: T); // scope 0 at $DIR/try_identity_e2e.rs:+8:35: +8:36 _0 = Result::<T, E>::Ok(move _7); // scope 0 at $DIR/try_identity_e2e.rs:+1:5: +11:6 diff --git a/tests/mir-opt/uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir b/tests/mir-opt/uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir index 03f37b14b..a0b556640 100644 --- a/tests/mir-opt/uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir +++ b/tests/mir-opt/uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir @@ -34,7 +34,7 @@ fn main() -> () { StorageLive(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 _7 = Test2::D; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 _8 = discriminant(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 - switchInt(move _8) -> [4: bb5, 5: bb3, otherwise: bb4]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:5: +7:19 + switchInt(move _8) -> [4: bb4, 5: bb3, otherwise: bb2]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:5: +7:19 } bb2: { @@ -49,22 +49,18 @@ fn main() -> () { // + literal: Const { ty: &str, val: Value(Slice(..)) } _6 = &(*_9); // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:21: +9:24 StorageDead(_9); // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:23: +9:24 - goto -> bb6; // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:23: +9:24 + goto -> bb5; // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:23: +9:24 } bb4: { - unreachable; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 - } - - bb5: { _6 = const "D"; // scope 0 at $DIR/uninhabited_enum_branching.rs:+8:21: +8:24 // mir::Constant // + span: $DIR/uninhabited_enum_branching.rs:27:21: 27:24 // + literal: Const { ty: &str, val: Value(Slice(..)) } - goto -> bb6; // scope 0 at $DIR/uninhabited_enum_branching.rs:+8:21: +8:24 + goto -> bb5; // scope 0 at $DIR/uninhabited_enum_branching.rs:+8:21: +8:24 } - bb6: { + bb5: { StorageDead(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+10:6: +10:7 StorageDead(_6); // scope 0 at $DIR/uninhabited_enum_branching.rs:+10:6: +10:7 _0 = const (); // scope 0 at $DIR/uninhabited_enum_branching.rs:+0:11: +11:2 diff --git a/tests/mir-opt/uninhabited_enum_branching.main.UninhabitedEnumBranching.diff b/tests/mir-opt/uninhabited_enum_branching.main.UninhabitedEnumBranching.diff index 671e11622..58d6e4281 100644 --- a/tests/mir-opt/uninhabited_enum_branching.main.UninhabitedEnumBranching.diff +++ b/tests/mir-opt/uninhabited_enum_branching.main.UninhabitedEnumBranching.diff @@ -63,7 +63,7 @@ StorageLive(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 _7 = Test2::D; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 _8 = discriminant(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 - switchInt(move _8) -> [4: bb8, 5: bb6, otherwise: bb7]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:5: +7:19 + switchInt(move _8) -> [4: bb7, 5: bb6, otherwise: bb2]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:5: +7:19 } bb6: { @@ -74,22 +74,18 @@ // + literal: Const { ty: &str, val: Value(Slice(..)) } _6 = &(*_9); // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:21: +9:24 StorageDead(_9); // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:23: +9:24 - goto -> bb9; // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:23: +9:24 + goto -> bb8; // scope 0 at $DIR/uninhabited_enum_branching.rs:+9:23: +9:24 } bb7: { - unreachable; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 - } - - bb8: { _6 = const "D"; // scope 0 at $DIR/uninhabited_enum_branching.rs:+8:21: +8:24 // mir::Constant // + span: $DIR/uninhabited_enum_branching.rs:27:21: 27:24 // + literal: Const { ty: &str, val: Value(Slice(..)) } - goto -> bb9; // scope 0 at $DIR/uninhabited_enum_branching.rs:+8:21: +8:24 + goto -> bb8; // scope 0 at $DIR/uninhabited_enum_branching.rs:+8:21: +8:24 } - bb9: { + bb8: { StorageDead(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+10:6: +10:7 StorageDead(_6); // scope 0 at $DIR/uninhabited_enum_branching.rs:+10:6: +10:7 _0 = const (); // scope 0 at $DIR/uninhabited_enum_branching.rs:+0:11: +11:2 diff --git a/tests/mir-opt/uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir b/tests/mir-opt/uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir index eb2a76ed1..0368b5f18 100644 --- a/tests/mir-opt/uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir +++ b/tests/mir-opt/uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir @@ -63,7 +63,7 @@ fn main() -> () { StorageDead(_3); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+8:6: +8:7 StorageLive(_9); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:5: +15:6 _10 = discriminant((_1.1: Test1)); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:11: +10:21 - switchInt(move _10) -> [2: bb7, 3: bb5, otherwise: bb6]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:5: +10:21 + switchInt(move _10) -> [2: bb6, 3: bb5, otherwise: bb2]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:5: +10:21 } bb5: { @@ -74,14 +74,10 @@ fn main() -> () { // + literal: Const { ty: &str, val: Value(Slice(..)) } _9 = &(*_13); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:21: +14:24 StorageDead(_13); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:23: +14:24 - goto -> bb8; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:23: +14:24 + goto -> bb7; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:23: +14:24 } bb6: { - unreachable; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:11: +10:21 - } - - bb7: { StorageLive(_12); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:21: +13:24 _12 = const "C"; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:21: +13:24 // mir::Constant @@ -89,10 +85,10 @@ fn main() -> () { // + literal: Const { ty: &str, val: Value(Slice(..)) } _9 = &(*_12); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:21: +13:24 StorageDead(_12); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:23: +13:24 - goto -> bb8; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:23: +13:24 + goto -> bb7; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:23: +13:24 } - bb8: { + bb7: { StorageDead(_9); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+15:6: +15:7 _0 = const (); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+0:11: +16:2 StorageDead(_1); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+16:1: +16:2 diff --git a/tests/mir-opt/uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff b/tests/mir-opt/uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff index 4e797774d..73353941f 100644 --- a/tests/mir-opt/uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff +++ b/tests/mir-opt/uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff @@ -84,8 +84,8 @@ StorageDead(_3); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+8:6: +8:7 StorageLive(_9); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:5: +15:6 _10 = discriminant((_1.1: Test1)); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:11: +10:21 -- switchInt(move _10) -> [0: bb9, 1: bb10, 2: bb11, 3: bb7, otherwise: bb8]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:5: +10:21 -+ switchInt(move _10) -> [2: bb11, 3: bb7, otherwise: bb8]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:5: +10:21 +- switchInt(move _10) -> [0: bb8, 1: bb9, 2: bb10, 3: bb7, otherwise: bb2]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:5: +10:21 ++ switchInt(move _10) -> [2: bb10, 3: bb7, otherwise: bb2]; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:5: +10:21 } bb7: { @@ -96,22 +96,18 @@ // + literal: Const { ty: &str, val: Value(Slice(..)) } _9 = &(*_13); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:21: +14:24 StorageDead(_13); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:23: +14:24 - goto -> bb12; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:23: +14:24 + goto -> bb11; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+14:23: +14:24 } bb8: { - unreachable; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+10:11: +10:21 - } - - bb9: { _9 = const "A(Empty)"; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+11:24: +11:34 // mir::Constant // + span: $DIR/uninhabited_enum_branching2.rs:29:24: 29:34 // + literal: Const { ty: &str, val: Value(Slice(..)) } - goto -> bb12; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+11:24: +11:34 + goto -> bb11; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+11:24: +11:34 } - bb10: { + bb9: { StorageLive(_11); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+12:24: +12:34 _11 = const "B(Empty)"; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+12:24: +12:34 // mir::Constant @@ -119,10 +115,10 @@ // + literal: Const { ty: &str, val: Value(Slice(..)) } _9 = &(*_11); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+12:24: +12:34 StorageDead(_11); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+12:33: +12:34 - goto -> bb12; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+12:33: +12:34 + goto -> bb11; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+12:33: +12:34 } - bb11: { + bb10: { StorageLive(_12); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:21: +13:24 _12 = const "C"; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:21: +13:24 // mir::Constant @@ -130,10 +126,10 @@ // + literal: Const { ty: &str, val: Value(Slice(..)) } _9 = &(*_12); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:21: +13:24 StorageDead(_12); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:23: +13:24 - goto -> bb12; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:23: +13:24 + goto -> bb11; // scope 1 at $DIR/uninhabited_enum_branching2.rs:+13:23: +13:24 } - bb12: { + bb11: { StorageDead(_9); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+15:6: +15:7 _0 = const (); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+0:11: +16:2 StorageDead(_1); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+16:1: +16:2 diff --git a/tests/mir-opt/unreachable.main.UnreachablePropagation.diff b/tests/mir-opt/unreachable.main.UnreachablePropagation.diff index 848bff1d4..323b61346 100644 --- a/tests/mir-opt/unreachable.main.UnreachablePropagation.diff +++ b/tests/mir-opt/unreachable.main.UnreachablePropagation.diff @@ -21,7 +21,7 @@ StorageLive(_1); // scope 1 at $DIR/unreachable.rs:+1:23: +1:30 _1 = empty() -> bb1; // scope 1 at $DIR/unreachable.rs:+1:23: +1:30 // mir::Constant - // + span: $DIR/unreachable.rs:9:23: 9:28 + // + span: $DIR/unreachable.rs:10:23: 10:28 // + literal: Const { ty: fn() -> Option<Empty> {empty}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/unreachable.rs b/tests/mir-opt/unreachable.rs index 6098b525b..97093729d 100644 --- a/tests/mir-opt/unreachable.rs +++ b/tests/mir-opt/unreachable.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default enum Empty {} fn empty() -> Option<Empty> { diff --git a/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.diff b/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.diff index fb778470e..94bc63361 100644 --- a/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.diff +++ b/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.diff @@ -23,7 +23,7 @@ StorageLive(_2); // scope 2 at $DIR/unreachable_diverging.rs:+2:25: +2:32 _2 = empty() -> bb1; // scope 2 at $DIR/unreachable_diverging.rs:+2:25: +2:32 // mir::Constant - // + span: $DIR/unreachable_diverging.rs:14:25: 14:30 + // + span: $DIR/unreachable_diverging.rs:15:25: 15:30 // + literal: Const { ty: fn() -> Option<Empty> {empty}, val: Value(<ZST>) } } @@ -44,7 +44,7 @@ bb3: { _5 = loop_forever() -> bb5; // scope 2 at $DIR/unreachable_diverging.rs:+4:13: +4:27 // mir::Constant - // + span: $DIR/unreachable_diverging.rs:16:13: 16:25 + // + span: $DIR/unreachable_diverging.rs:17:13: 17:25 // + literal: Const { ty: fn() {loop_forever}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/unreachable_diverging.rs b/tests/mir-opt/unreachable_diverging.rs index bbf28efc7..24e776148 100644 --- a/tests/mir-opt/unreachable_diverging.rs +++ b/tests/mir-opt/unreachable_diverging.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default pub enum Empty {} fn empty() -> Option<Empty> { diff --git a/tests/mir-opt/unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir b/tests/mir-opt/unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir index ed9f3bdbd..c27a93e91 100644 --- a/tests/mir-opt/unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir +++ b/tests/mir-opt/unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir @@ -22,7 +22,7 @@ fn std::ptr::drop_in_place(_1: *mut Vec<i32>) -> () { } bb4 (cleanup): { - drop(((*_1).0: alloc::raw_vec::RawVec<i32>)) -> bb2; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 + drop(((*_1).0: alloc::raw_vec::RawVec<i32>)) -> [return: bb2, unwind terminate]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 } bb5: { diff --git a/tests/mir-opt/while_storage.rs b/tests/mir-opt/while_storage.rs index afd083acb..d10048dd9 100644 --- a/tests/mir-opt/while_storage.rs +++ b/tests/mir-opt/while_storage.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // Test that we correctly generate StorageDead statements for while loop // conditions on all branches diff --git a/tests/mir-opt/while_storage.while_loop.PreCodegen.after.mir b/tests/mir-opt/while_storage.while_loop.PreCodegen.after.mir index 318119bd4..811789a60 100644 --- a/tests/mir-opt/while_storage.while_loop.PreCodegen.after.mir +++ b/tests/mir-opt/while_storage.while_loop.PreCodegen.after.mir @@ -14,7 +14,7 @@ fn while_loop(_1: bool) -> () { StorageLive(_2); // scope 0 at $DIR/while_storage.rs:+1:11: +1:22 _2 = get_bool(_1) -> bb2; // scope 0 at $DIR/while_storage.rs:+1:11: +1:22 // mir::Constant - // + span: $DIR/while_storage.rs:10:11: 10:19 + // + span: $DIR/while_storage.rs:11:11: 11:19 // + literal: Const { ty: fn(bool) -> bool {get_bool}, val: Value(<ZST>) } } @@ -26,7 +26,7 @@ fn while_loop(_1: bool) -> () { StorageLive(_3); // scope 0 at $DIR/while_storage.rs:+2:12: +2:23 _3 = get_bool(_1) -> bb4; // scope 0 at $DIR/while_storage.rs:+2:12: +2:23 // mir::Constant - // + span: $DIR/while_storage.rs:11:12: 11:20 + // + span: $DIR/while_storage.rs:12:12: 12:20 // + literal: Const { ty: fn(bool) -> bool {get_bool}, val: Value(<ZST>) } } |