From ef24de24a82fe681581cc130f342363c47c0969a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 07:48:48 +0200 Subject: Merging upstream version 1.75.0+dfsg1. Signed-off-by: Daniel Baumann --- tests/mir-opt/inline/asm_unwind.rs | 5 + tests/mir-opt/inline/caller_with_trivial_bound.rs | 5 + tests/mir-opt/inline/cycle.rs | 10 ++ .../inline/dont_ice_on_generic_rust_call.rs | 2 + tests/mir-opt/inline/dyn_trait.rs | 8 ++ tests/mir-opt/inline/exponential_runtime.rs | 9 ++ tests/mir-opt/inline/inline_any_operand.rs | 2 + tests/mir-opt/inline/inline_async.rs | 3 +- tests/mir-opt/inline/inline_box_fn.rs | 2 + tests/mir-opt/inline/inline_closure.rs | 3 + tests/mir-opt/inline/inline_closure_borrows_arg.rs | 3 + .../inline_closure_captures.foo.Inline.after.mir | 4 + tests/mir-opt/inline/inline_closure_captures.rs | 3 + ...ity.inlined_no_sanitize.Inline.panic-abort.diff | 21 ---- ...ty.inlined_no_sanitize.Inline.panic-unwind.diff | 21 ---- ....inlined_target_feature.Inline.panic-abort.diff | 21 ---- ...inlined_target_feature.Inline.panic-unwind.diff | 21 ---- ....not_inlined_c_variadic.Inline.panic-abort.diff | 22 ---- ...not_inlined_c_variadic.Inline.panic-unwind.diff | 22 ---- ...not_inlined_no_sanitize.Inline.panic-abort.diff | 19 ---- ...ot_inlined_no_sanitize.Inline.panic-unwind.diff | 19 ---- ..._inlined_target_feature.Inline.panic-abort.diff | 19 ---- ...inlined_target_feature.Inline.panic-unwind.diff | 19 ---- tests/mir-opt/inline/inline_compatibility.rs | 63 +++++++---- .../inline_coroutine.main.Inline.panic-abort.diff | 112 +++++++++++++++++++ .../inline_coroutine.main.Inline.panic-unwind.diff | 124 +++++++++++++++++++++ tests/mir-opt/inline/inline_coroutine.rs | 20 ++++ tests/mir-opt/inline/inline_cycle.rs | 1 + tests/mir-opt/inline/inline_cycle_generic.rs | 1 + .../inline_diverging.h.Inline.panic-abort.diff | 4 +- .../inline_diverging.h.Inline.panic-unwind.diff | 2 +- tests/mir-opt/inline/inline_diverging.rs | 7 ++ .../inline_generator.main.Inline.panic-abort.diff | 108 ------------------ .../inline_generator.main.Inline.panic-unwind.diff | 120 -------------------- tests/mir-opt/inline/inline_generator.rs | 17 --- tests/mir-opt/inline/inline_instruction_set.rs | 10 ++ ...ine_into_box_place.main.Inline.panic-abort.diff | 10 ++ ...ne_into_box_place.main.Inline.panic-unwind.diff | 10 ++ tests/mir-opt/inline/inline_into_box_place.rs | 2 + tests/mir-opt/inline/inline_options.rs | 3 + tests/mir-opt/inline/inline_retag.rs | 11 ++ tests/mir-opt/inline/inline_shims.rs | 4 + tests/mir-opt/inline/inline_specialization.rs | 2 + tests/mir-opt/inline/inline_trait_method.rs | 3 + tests/mir-opt/inline/inline_trait_method_2.rs | 3 + .../issue_106141.outer.Inline.panic-abort.diff | 2 + .../issue_106141.outer.Inline.panic-unwind.diff | 2 + tests/mir-opt/inline/issue_106141.rs | 7 ++ ...e_58867_inline_as_ref_as_mut.b.Inline.after.mir | 4 + ...e_58867_inline_as_ref_as_mut.d.Inline.after.mir | 4 + .../inline/issue_58867_inline_as_ref_as_mut.rs | 8 ++ ...7_inline_scopes_parenting.main.Inline.after.mir | 6 +- .../inline/issue_76997_inline_scopes_parenting.rs | 10 ++ .../inline/issue_78442.bar.Inline.panic-abort.diff | 22 ++-- .../issue_78442.bar.Inline.panic-unwind.diff | 31 ++++-- tests/mir-opt/inline/issue_78442.rs | 5 + tests/mir-opt/inline/polymorphic_recursion.rs | 1 + tests/mir-opt/inline/unchecked_shifts.rs | 10 +- tests/mir-opt/inline/unit_test.rs | 19 ++++ .../inline/unsized_argument.caller.Inline.diff | 24 ++-- tests/mir-opt/inline/unsized_argument.rs | 2 + tests/mir-opt/inline/unwrap_unchecked.rs | 2 + ...hecked.unwrap_unchecked.Inline.panic-abort.diff | 18 +-- ...ecked.unwrap_unchecked.Inline.panic-unwind.diff | 30 ++--- ...wrap_unchecked.PreCodegen.after.panic-abort.mir | 19 ++-- ...rap_unchecked.PreCodegen.after.panic-unwind.mir | 19 ++-- 66 files changed, 590 insertions(+), 555 deletions(-) delete mode 100644 tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-abort.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-abort.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-abort.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-unwind.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-abort.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-unwind.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-abort.diff delete mode 100644 tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-unwind.diff create mode 100644 tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff create mode 100644 tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff create mode 100644 tests/mir-opt/inline/inline_coroutine.rs delete mode 100644 tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff delete mode 100644 tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff delete mode 100644 tests/mir-opt/inline/inline_generator.rs create mode 100644 tests/mir-opt/inline/unit_test.rs (limited to 'tests/mir-opt/inline') diff --git a/tests/mir-opt/inline/asm_unwind.rs b/tests/mir-opt/inline/asm_unwind.rs index 573ae1ba6..0ae20e522 100644 --- a/tests/mir-opt/inline/asm_unwind.rs +++ b/tests/mir-opt/inline/asm_unwind.rs @@ -2,6 +2,7 @@ // // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // needs-asm-support +// needs-unwind // compile-flags: -Zinline-mir-hint-threshold=1000 #![feature(asm_unwind)] @@ -19,5 +20,9 @@ fn foo() { // EMIT_MIR asm_unwind.main.Inline.diff pub fn main() { + // CHECK-LABEL: fn main( + // CHECK: (inlined foo) + // CHECK: asm!("", options(MAY_UNWIND)) -> [return: {{bb.*}}, unwind: [[unwind:bb.*]]]; + // CHECK: [[unwind]] (cleanup) foo(); } diff --git a/tests/mir-opt/inline/caller_with_trivial_bound.rs b/tests/mir-opt/inline/caller_with_trivial_bound.rs index a8f101d48..40f7f4bba 100644 --- a/tests/mir-opt/inline/caller_with_trivial_bound.rs +++ b/tests/mir-opt/inline/caller_with_trivial_bound.rs @@ -15,8 +15,13 @@ impl Factory for IntFactory { // EMIT_MIR caller_with_trivial_bound.foo.Inline.diff pub fn foo() where + // Because of this trivial bound, the inliner fails to normalize + // `>::Item`. + // Verify that we do not inline anything, which would cause validation ICEs. IntFactory: Factory, { + // CHECK-LABEL: fn foo( + // CHECK-NOT: (inlined bar::) let mut x: >::Item = bar::(); } diff --git a/tests/mir-opt/inline/cycle.rs b/tests/mir-opt/inline/cycle.rs index 1b74d8184..350724235 100644 --- a/tests/mir-opt/inline/cycle.rs +++ b/tests/mir-opt/inline/cycle.rs @@ -4,16 +4,26 @@ // EMIT_MIR cycle.f.Inline.diff #[inline(always)] fn f(g: impl Fn()) { + // CHECK-LABEL: fn f( + // CHECK-NOT: inlined g(); } // EMIT_MIR cycle.g.Inline.diff #[inline(always)] fn g() { + // CHECK-LABEL: fn g( + // CHECK-NOT: inlined + // CHECK: (inlined f::) + // CHECK-NOT: inlined f(main); } // EMIT_MIR cycle.main.Inline.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK-NOT: inlined + // CHECK: (inlined f::) + // CHECK-NOT: inlined f(g); } diff --git a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs index 971223c72..ce5e1855a 100644 --- a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs +++ b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs @@ -7,5 +7,7 @@ use std::marker::Tuple; // EMIT_MIR dont_ice_on_generic_rust_call.call.Inline.diff pub fn call(mut mock: Box>, input: I) { + // CHECK-LABEL: fn call( + // CHECK-NOT: inlined mock.call_mut(input) } diff --git a/tests/mir-opt/inline/dyn_trait.rs b/tests/mir-opt/inline/dyn_trait.rs index 0faeec0bb..ecf220a85 100644 --- a/tests/mir-opt/inline/dyn_trait.rs +++ b/tests/mir-opt/inline/dyn_trait.rs @@ -19,18 +19,26 @@ pub trait Query { // EMIT_MIR dyn_trait.mk_cycle.Inline.diff #[inline(always)] pub fn mk_cycle(c: &dyn Cache) { + // CHECK-LABEL: fn mk_cycle( + // CHECK-NOT: inlined c.store_nocache() } // EMIT_MIR dyn_trait.try_execute_query.Inline.diff #[inline(always)] pub fn try_execute_query(c: &C) { + // CHECK-LABEL: fn try_execute_query( + // CHECK: (inlined mk_cycle::<::V>) mk_cycle(c) } // EMIT_MIR dyn_trait.get_query.Inline.diff #[inline(always)] pub fn get_query(t: &T) { + // CHECK-LABEL: fn get_query( + // CHECK-NOT: inlined let c = Q::cache(t); + // CHECK: (inlined try_execute_query::<::C>) + // CHECK: (inlined mk_cycle::<::V>) try_execute_query(c) } diff --git a/tests/mir-opt/inline/exponential_runtime.rs b/tests/mir-opt/inline/exponential_runtime.rs index cfa9ff210..1199ce4e5 100644 --- a/tests/mir-opt/inline/exponential_runtime.rs +++ b/tests/mir-opt/inline/exponential_runtime.rs @@ -84,5 +84,14 @@ impl A for () { // EMIT_MIR exponential_runtime.main.Inline.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK-NOT: inlined + // CHECK: (inlined <() as G>::call) + // CHECK: (inlined <() as F>::call) + // CHECK: (inlined <() as E>::call) + // CHECK: (inlined <() as D>::call) + // CHECK: (inlined <() as C>::call) + // CHECK: (inlined <() as B>::call) + // CHECK-NOT: inlined <() as G>::call(); } diff --git a/tests/mir-opt/inline/inline_any_operand.rs b/tests/mir-opt/inline/inline_any_operand.rs index fb0de020f..659b7c3a0 100644 --- a/tests/mir-opt/inline/inline_any_operand.rs +++ b/tests/mir-opt/inline/inline_any_operand.rs @@ -8,6 +8,8 @@ fn main() { // EMIT_MIR inline_any_operand.bar.Inline.after.mir fn bar() -> bool { + // CHECK-LABEL: fn bar( + // CHECK: (inlined foo) let f = foo; f(1, -1) } diff --git a/tests/mir-opt/inline/inline_async.rs b/tests/mir-opt/inline/inline_async.rs index 5c838159b..1de87e1e4 100644 --- a/tests/mir-opt/inline/inline_async.rs +++ b/tests/mir-opt/inline/inline_async.rs @@ -1,4 +1,5 @@ -// Checks that inliner doesn't introduce cycles when optimizing generators. +// skip-filecheck +// Checks that inliner doesn't introduce cycles when optimizing coroutines. // The outcome of optimization is not verfied, just the absence of the cycle. // Regression test for #76181. // diff --git a/tests/mir-opt/inline/inline_box_fn.rs b/tests/mir-opt/inline/inline_box_fn.rs index 348f0e77f..d2da23939 100644 --- a/tests/mir-opt/inline/inline_box_fn.rs +++ b/tests/mir-opt/inline/inline_box_fn.rs @@ -4,5 +4,7 @@ // EMIT_MIR inline_box_fn.call.Inline.diff fn call(x: Box) { + // CHECK-LABEL: fn call( + // CHECK-NOT: inlined x(1); } diff --git a/tests/mir-opt/inline/inline_closure.rs b/tests/mir-opt/inline/inline_closure.rs index 715fd0138..65f55d49a 100644 --- a/tests/mir-opt/inline/inline_closure.rs +++ b/tests/mir-opt/inline/inline_closure.rs @@ -9,5 +9,8 @@ fn main() { // EMIT_MIR inline_closure.foo.Inline.after.mir fn foo(_t: T, q: i32) -> i32 { let x = |_t, _q| _t; + + // CHECK-LABEL: fn foo( + // CHECK: (inlined foo::::{closure#0}) x(q, q) } diff --git a/tests/mir-opt/inline/inline_closure_borrows_arg.rs b/tests/mir-opt/inline/inline_closure_borrows_arg.rs index d76bc33f5..1570ab057 100644 --- a/tests/mir-opt/inline/inline_closure_borrows_arg.rs +++ b/tests/mir-opt/inline/inline_closure_borrows_arg.rs @@ -13,5 +13,8 @@ fn foo(_t: T, q: &i32) -> i32 { let variable = &*r; *variable }; + + // CHECK-LABEL: fn foo( + // CHECK: (inlined foo::::{closure#0}) x(q, q) } 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 721fac27d..10b81e59b 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 @@ -41,6 +41,8 @@ fn foo(_1: T, _2: i32) -> (i32, T) { _7 = (move _8,); StorageLive(_9); _9 = move (_7.0: i32); + StorageLive(_10); + StorageLive(_12); StorageLive(_11); _10 = ((*_6).0: &i32); _11 = (*_10); @@ -50,6 +52,8 @@ fn foo(_1: T, _2: i32) -> (i32, T) { _0 = (move _11, move _13); StorageDead(_13); StorageDead(_11); + StorageDead(_12); + StorageDead(_10); StorageDead(_9); StorageDead(_8); StorageDead(_7); diff --git a/tests/mir-opt/inline/inline_closure_captures.rs b/tests/mir-opt/inline/inline_closure_captures.rs index 52b6817e4..2b08b1068 100644 --- a/tests/mir-opt/inline/inline_closure_captures.rs +++ b/tests/mir-opt/inline/inline_closure_captures.rs @@ -9,5 +9,8 @@ fn main() { // EMIT_MIR inline_closure_captures.foo.Inline.after.mir fn foo(t: T, q: i32) -> (i32, T) { let x = |_q| (q, t); + + // CHECK-LABEL: fn foo( + // CHECK: (inlined foo::::{closure#0}) x(q) } diff --git a/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-abort.diff deleted file mode 100644 index eac51000c..000000000 --- a/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-abort.diff +++ /dev/null @@ -1,21 +0,0 @@ -- // MIR for `inlined_no_sanitize` before Inline -+ // MIR for `inlined_no_sanitize` after Inline - - fn inlined_no_sanitize() -> () { - let mut _0: (); - let _1: (); -+ scope 1 (inlined no_sanitize) { -+ } - - bb0: { - StorageLive(_1); -- _1 = no_sanitize() -> [return: bb1, unwind unreachable]; -- } -- -- bb1: { - StorageDead(_1); - _0 = const (); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff deleted file mode 100644 index eba5ad9cf..000000000 --- a/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff +++ /dev/null @@ -1,21 +0,0 @@ -- // MIR for `inlined_no_sanitize` before Inline -+ // MIR for `inlined_no_sanitize` after Inline - - fn inlined_no_sanitize() -> () { - let mut _0: (); - let _1: (); -+ scope 1 (inlined no_sanitize) { -+ } - - bb0: { - StorageLive(_1); -- _1 = no_sanitize() -> [return: bb1, unwind continue]; -- } -- -- bb1: { - StorageDead(_1); - _0 = const (); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-abort.diff deleted file mode 100644 index c2a81b980..000000000 --- a/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-abort.diff +++ /dev/null @@ -1,21 +0,0 @@ -- // MIR for `inlined_target_feature` before Inline -+ // MIR for `inlined_target_feature` after Inline - - fn inlined_target_feature() -> () { - let mut _0: (); - let _1: (); -+ scope 1 (inlined target_feature) { -+ } - - bb0: { - StorageLive(_1); -- _1 = target_feature() -> [return: bb1, unwind unreachable]; -- } -- -- bb1: { - StorageDead(_1); - _0 = const (); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff deleted file mode 100644 index 24457819b..000000000 --- a/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff +++ /dev/null @@ -1,21 +0,0 @@ -- // MIR for `inlined_target_feature` before Inline -+ // MIR for `inlined_target_feature` after Inline - - fn inlined_target_feature() -> () { - let mut _0: (); - let _1: (); -+ scope 1 (inlined target_feature) { -+ } - - bb0: { - StorageLive(_1); -- _1 = target_feature() -> [return: bb1, unwind continue]; -- } -- -- bb1: { - StorageDead(_1); - _0 = const (); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-abort.diff deleted file mode 100644 index 791c5a0f2..000000000 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-abort.diff +++ /dev/null @@ -1,22 +0,0 @@ -- // MIR for `not_inlined_c_variadic` before Inline -+ // MIR for `not_inlined_c_variadic` after Inline - - fn not_inlined_c_variadic() -> () { - let mut _0: (); - let _1: u32; - scope 1 { - debug s => _1; - } - - bb0: { - StorageLive(_1); - _1 = sum(const 4_u32, const 4_u32, const 30_u32, const 200_u32, const 1000_u32) -> [return: bb1, unwind unreachable]; - } - - bb1: { - _0 = const (); - StorageDead(_1); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-unwind.diff deleted file mode 100644 index 364acab6d..000000000 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-unwind.diff +++ /dev/null @@ -1,22 +0,0 @@ -- // MIR for `not_inlined_c_variadic` before Inline -+ // MIR for `not_inlined_c_variadic` after Inline - - fn not_inlined_c_variadic() -> () { - let mut _0: (); - let _1: u32; - scope 1 { - debug s => _1; - } - - bb0: { - StorageLive(_1); - _1 = sum(const 4_u32, const 4_u32, const 30_u32, const 200_u32, const 1000_u32) -> [return: bb1, unwind continue]; - } - - bb1: { - _0 = const (); - StorageDead(_1); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-abort.diff deleted file mode 100644 index b9d0946b7..000000000 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-abort.diff +++ /dev/null @@ -1,19 +0,0 @@ -- // MIR for `not_inlined_no_sanitize` before Inline -+ // MIR for `not_inlined_no_sanitize` after Inline - - fn not_inlined_no_sanitize() -> () { - let mut _0: (); - let _1: (); - - bb0: { - StorageLive(_1); - _1 = no_sanitize() -> [return: bb1, unwind unreachable]; - } - - bb1: { - StorageDead(_1); - _0 = const (); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-unwind.diff deleted file mode 100644 index 965b7ddca..000000000 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-unwind.diff +++ /dev/null @@ -1,19 +0,0 @@ -- // MIR for `not_inlined_no_sanitize` before Inline -+ // MIR for `not_inlined_no_sanitize` after Inline - - fn not_inlined_no_sanitize() -> () { - let mut _0: (); - let _1: (); - - bb0: { - StorageLive(_1); - _1 = no_sanitize() -> [return: bb1, unwind continue]; - } - - bb1: { - StorageDead(_1); - _0 = const (); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-abort.diff deleted file mode 100644 index 7c689a734..000000000 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-abort.diff +++ /dev/null @@ -1,19 +0,0 @@ -- // MIR for `not_inlined_target_feature` before Inline -+ // MIR for `not_inlined_target_feature` after Inline - - fn not_inlined_target_feature() -> () { - let mut _0: (); - let _1: (); - - bb0: { - StorageLive(_1); - _1 = target_feature() -> [return: bb1, unwind unreachable]; - } - - bb1: { - StorageDead(_1); - _0 = const (); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-unwind.diff deleted file mode 100644 index bcdbd6e33..000000000 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-unwind.diff +++ /dev/null @@ -1,19 +0,0 @@ -- // MIR for `not_inlined_target_feature` before Inline -+ // MIR for `not_inlined_target_feature` after Inline - - fn not_inlined_target_feature() -> () { - let mut _0: (); - let _1: (); - - bb0: { - StorageLive(_1); - _1 = target_feature() -> [return: bb1, unwind continue]; - } - - bb1: { - StorageDead(_1); - _0 = const (); - return; - } - } - diff --git a/tests/mir-opt/inline/inline_compatibility.rs b/tests/mir-opt/inline/inline_compatibility.rs index 1527fea1c..3ad880715 100644 --- a/tests/mir-opt/inline/inline_compatibility.rs +++ b/tests/mir-opt/inline/inline_compatibility.rs @@ -1,50 +1,71 @@ // Checks that only functions with compatible attributes are inlined. -// // only-x86_64 -// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// compile-flags: -Cpanic=abort #![crate_type = "lib"] #![feature(no_sanitize)] #![feature(target_feature_11)] #![feature(c_variadic)] -// EMIT_MIR inline_compatibility.inlined_target_feature.Inline.diff +#[inline] +#[target_feature(enable = "sse2")] +unsafe fn sse2() {} + +#[inline] +fn nop() {} + +// CHECK-LABEL: fn f0() +// CHECK: bb0: { +// CHECK-NEXT: return; #[target_feature(enable = "sse2")] -pub unsafe fn inlined_target_feature() { - target_feature(); +pub unsafe fn f0() { + sse2(); } -// EMIT_MIR inline_compatibility.not_inlined_target_feature.Inline.diff -pub unsafe fn not_inlined_target_feature() { - target_feature(); +// CHECK-LABEL: fn f1() +// CHECK: bb0: { +// CHECK-NEXT: sse2() +pub unsafe fn f1() { + sse2(); } -// EMIT_MIR inline_compatibility.inlined_no_sanitize.Inline.diff +// CHECK-LABEL: fn f2() +// CHECK: bb0: { +// CHECK-NEXT: nop() +#[target_feature(enable = "avx")] +pub unsafe fn f2() { + nop(); +} + +#[inline] +#[no_sanitize(address)] +pub unsafe fn no_sanitize() {} + +// CHECK-LABEL: fn inlined_no_sanitize() +// CHECK: bb0: { +// CHECK-NEXT: return; #[no_sanitize(address)] pub unsafe fn inlined_no_sanitize() { no_sanitize(); } -// EMIT_MIR inline_compatibility.not_inlined_no_sanitize.Inline.diff +// CHECK-LABEL: fn not_inlined_no_sanitize() +// CHECK: bb0: { +// CHECK-NEXT: no_sanitize() pub unsafe fn not_inlined_no_sanitize() { no_sanitize(); } -#[inline] -#[target_feature(enable = "sse2")] -pub unsafe fn target_feature() {} - -#[inline] -#[no_sanitize(address)] -pub unsafe fn no_sanitize() {} - -// EMIT_MIR inline_compatibility.not_inlined_c_variadic.Inline.diff +// CHECK-LABEL: fn not_inlined_c_variadic() +// CHECK: bb0: { +// CHECK-NEXT: StorageLive(_1) +// CHECK-NEXT: _1 = sum pub unsafe fn not_inlined_c_variadic() { - let s = sum(4u32, 4u32, 30u32, 200u32, 1000u32); + let _ = sum(4u32, 4u32, 30u32, 200u32, 1000u32); } -#[no_mangle] #[inline(always)] +#[no_mangle] unsafe extern "C" fn sum(n: u32, mut vs: ...) -> u32 { let mut s = 0; let mut i = 0; diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff new file mode 100644 index 000000000..40eeda539 --- /dev/null +++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff @@ -0,0 +1,112 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); + let _1: std::ops::CoroutineState; + let mut _2: std::pin::Pin<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>; + let mut _3: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}; + let mut _4: {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}; ++ let mut _5: bool; + scope 1 { + debug _r => _1; + } ++ scope 2 (inlined g) { ++ } ++ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new) { ++ debug pointer => _3; ++ scope 4 { ++ scope 5 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new_unchecked) { ++ debug pointer => _3; ++ } ++ } ++ } ++ scope 6 (inlined g::{closure#0}) { ++ debug a => _5; ++ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}; ++ let mut _7: u32; ++ let mut _8: i32; ++ } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); +- _4 = g() -> [return: bb1, unwind unreachable]; ++ _4 = {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8 (#0)}; ++ _3 = &mut _4; ++ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}> { pointer: move _3 }; ++ StorageDead(_3); ++ StorageLive(_5); ++ _5 = const false; ++ StorageLive(_6); ++ StorageLive(_7); ++ _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}); ++ _7 = discriminant((*_6)); ++ switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9]; + } + + bb1: { +- _3 = &mut _4; +- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new(move _3) -> [return: bb2, unwind unreachable]; ++ StorageDead(_7); ++ StorageDead(_6); ++ StorageDead(_5); ++ StorageDead(_2); ++ drop(_4) -> [return: bb2, unwind unreachable]; + } + + bb2: { +- StorageDead(_3); +- _1 = <{coroutine@$DIR/inline_coroutine.rs:19:5: 19:8} as Coroutine>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; ++ StorageDead(_4); ++ _0 = const (); ++ StorageDead(_1); ++ return; + } + + bb3: { +- StorageDead(_2); +- drop(_4) -> [return: bb4, unwind unreachable]; ++ StorageLive(_8); ++ switchInt(_5) -> [0: bb4, otherwise: bb5]; + } + + bb4: { +- StorageDead(_4); +- _0 = const (); +- StorageDead(_1); +- return; ++ _8 = const 13_i32; ++ goto -> bb6; ++ } ++ ++ bb5: { ++ _8 = const 7_i32; ++ goto -> bb6; ++ } ++ ++ bb6: { ++ _1 = CoroutineState::::Yielded(move _8); ++ discriminant((*_6)) = 3; ++ goto -> bb1; ++ } ++ ++ bb7: { ++ assert(const false, "coroutine resumed after completion") -> [success: bb7, unwind unreachable]; ++ } ++ ++ bb8: { ++ StorageLive(_8); ++ StorageDead(_8); ++ _1 = CoroutineState::::Complete(_5); ++ discriminant((*_6)) = 1; ++ goto -> bb1; ++ } ++ ++ bb9: { ++ unreachable; + } + } + diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff new file mode 100644 index 000000000..fdb42bf3d --- /dev/null +++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff @@ -0,0 +1,124 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); + let _1: std::ops::CoroutineState; + let mut _2: std::pin::Pin<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>; + let mut _3: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}; + let mut _4: {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}; ++ let mut _5: bool; + scope 1 { + debug _r => _1; + } ++ scope 2 (inlined g) { ++ } ++ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new) { ++ debug pointer => _3; ++ scope 4 { ++ scope 5 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new_unchecked) { ++ debug pointer => _3; ++ } ++ } ++ } ++ scope 6 (inlined g::{closure#0}) { ++ debug a => _5; ++ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}; ++ let mut _7: u32; ++ let mut _8: i32; ++ } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); +- _4 = g() -> [return: bb1, unwind continue]; +- } +- +- bb1: { ++ _4 = {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8 (#0)}; + _3 = &mut _4; +- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new(move _3) -> [return: bb2, unwind: bb5]; +- } +- +- bb2: { ++ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}> { pointer: move _3 }; + StorageDead(_3); +- _1 = <{coroutine@$DIR/inline_coroutine.rs:19:5: 19:8} as Coroutine>::resume(move _2, const false) -> [return: bb3, unwind: bb5]; ++ StorageLive(_5); ++ _5 = const false; ++ StorageLive(_6); ++ StorageLive(_7); ++ _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}); ++ _7 = discriminant((*_6)); ++ switchInt(move _7) -> [0: bb5, 1: bb9, 3: bb10, otherwise: bb11]; + } + +- bb3: { ++ bb1: { ++ StorageDead(_7); ++ StorageDead(_6); ++ StorageDead(_5); + StorageDead(_2); +- drop(_4) -> [return: bb4, unwind: bb6]; ++ drop(_4) -> [return: bb2, unwind: bb4]; + } + +- bb4: { ++ bb2: { + StorageDead(_4); + _0 = const (); + StorageDead(_1); + return; + } + +- bb5 (cleanup): { +- drop(_4) -> [return: bb6, unwind terminate(cleanup)]; ++ bb3 (cleanup): { ++ drop(_4) -> [return: bb4, unwind terminate(cleanup)]; + } + +- bb6 (cleanup): { ++ bb4 (cleanup): { + resume; ++ } ++ ++ bb5: { ++ StorageLive(_8); ++ switchInt(_5) -> [0: bb6, otherwise: bb7]; ++ } ++ ++ bb6: { ++ _8 = const 13_i32; ++ goto -> bb8; ++ } ++ ++ bb7: { ++ _8 = const 7_i32; ++ goto -> bb8; ++ } ++ ++ bb8: { ++ _1 = CoroutineState::::Yielded(move _8); ++ discriminant((*_6)) = 3; ++ goto -> bb1; ++ } ++ ++ bb9: { ++ assert(const false, "coroutine resumed after completion") -> [success: bb9, unwind: bb3]; ++ } ++ ++ bb10: { ++ StorageLive(_8); ++ StorageDead(_8); ++ _1 = CoroutineState::::Complete(_5); ++ discriminant((*_6)) = 1; ++ goto -> bb1; ++ } ++ ++ bb11: { ++ unreachable; + } + } + diff --git a/tests/mir-opt/inline/inline_coroutine.rs b/tests/mir-opt/inline/inline_coroutine.rs new file mode 100644 index 000000000..a82586bf2 --- /dev/null +++ b/tests/mir-opt/inline/inline_coroutine.rs @@ -0,0 +1,20 @@ +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// compile-flags: -Zinline-mir-hint-threshold=1000 +#![feature(coroutines, coroutine_trait)] + +use std::ops::Coroutine; +use std::pin::Pin; + +// EMIT_MIR inline_coroutine.main.Inline.diff +fn main() { + // CHECK-LABEL: fn main( + // CHECK: (inlined g) + // CHECK: (inlined g::{closure#0}) + let _r = Pin::new(&mut g()).resume(false); +} + +#[inline] +pub fn g() -> impl Coroutine { + #[inline] + |a| { yield if a { 7 } else { 13 } } +} diff --git a/tests/mir-opt/inline/inline_cycle.rs b/tests/mir-opt/inline/inline_cycle.rs index 42a6914c9..e3dd08255 100644 --- a/tests/mir-opt/inline/inline_cycle.rs +++ b/tests/mir-opt/inline/inline_cycle.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Check that inliner handles various forms of recursion and doesn't fall into // an infinite inlining cycle. The particular outcome of inlining is not diff --git a/tests/mir-opt/inline/inline_cycle_generic.rs b/tests/mir-opt/inline/inline_cycle_generic.rs index ef261b04c..667bf7f92 100644 --- a/tests/mir-opt/inline/inline_cycle_generic.rs +++ b/tests/mir-opt/inline/inline_cycle_generic.rs @@ -1,3 +1,4 @@ +// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Check that inliner handles various forms of recursion and doesn't fall into // an infinite inlining cycle. The particular outcome of inlining is not diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff index 7d5553b2f..da45ebcb4 100644 --- a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff @@ -8,11 +8,11 @@ + scope 1 (inlined call_twice:: ! {sleep}>) { + debug f => _2; + let mut _3: &fn() -> ! {sleep}; -+ let mut _4: !; ++ let _4: !; + let mut _5: &fn() -> ! {sleep}; -+ let mut _6: !; + scope 2 { + debug a => _4; ++ let _6: !; + scope 3 { + debug b => _6; + } diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff index 9f8c5806c..d65c65e5f 100644 --- a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff @@ -10,10 +10,10 @@ + let mut _3: &fn() -> ! {sleep}; + let _4: !; + let mut _5: &fn() -> ! {sleep}; -+ let mut _6: !; + let mut _7: !; + scope 2 { + debug a => _4; ++ let _6: !; + scope 3 { + debug b => _6; + } diff --git a/tests/mir-opt/inline/inline_diverging.rs b/tests/mir-opt/inline/inline_diverging.rs index e01c4c1dd..25a5b9c5c 100644 --- a/tests/mir-opt/inline/inline_diverging.rs +++ b/tests/mir-opt/inline/inline_diverging.rs @@ -6,6 +6,8 @@ // EMIT_MIR inline_diverging.f.Inline.diff pub fn f() { + // CHECK-LABEL: fn f( + // CHECK: (inlined sleep) sleep(); } @@ -14,12 +16,17 @@ pub fn g(i: i32) -> u32 { if i > 0 { i as u32 } else { + // CHECK-LABEL: fn g( + // CHECK: (inlined panic) panic(); } } // EMIT_MIR inline_diverging.h.Inline.diff pub fn h() { + // CHECK-LABEL: fn h( + // CHECK: (inlined call_twice:: ! {sleep}>) + // CHECK-NOT: inlined call_twice(sleep); } diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff deleted file mode 100644 index 6779003b6..000000000 --- a/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff +++ /dev/null @@ -1,108 +0,0 @@ -- // MIR for `main` before Inline -+ // MIR for `main` after Inline - - fn main() -> () { - let mut _0: (); - let _1: std::ops::GeneratorState; - let mut _2: std::pin::Pin<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>; - let mut _3: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}; - let mut _4: {generator@$DIR/inline_generator.rs:16:5: 16:8}; -+ let mut _5: bool; - scope 1 { - debug _r => _1; - } -+ scope 2 (inlined g) { -+ } -+ scope 3 (inlined Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new) { -+ debug pointer => _3; -+ scope 4 { -+ scope 5 (inlined Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new_unchecked) { -+ debug pointer => _3; -+ } -+ } -+ } -+ scope 6 (inlined g::{closure#0}) { -+ debug a => _5; -+ let mut _6: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}; -+ let mut _7: u32; -+ let mut _8: i32; -+ } - - bb0: { - StorageLive(_1); - StorageLive(_2); - StorageLive(_3); - StorageLive(_4); -- _4 = g() -> [return: bb1, unwind unreachable]; -+ _4 = {generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)}; -+ _3 = &mut _4; -+ _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}> { pointer: move _3 }; -+ StorageDead(_3); -+ StorageLive(_5); -+ _5 = const false; -+ _6 = (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}); -+ _7 = discriminant((*_6)); -+ switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9]; - } - - bb1: { -- _3 = &mut _4; -- _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new(move _3) -> [return: bb2, unwind unreachable]; -+ StorageDead(_5); -+ StorageDead(_2); -+ drop(_4) -> [return: bb2, unwind unreachable]; - } - - bb2: { -- StorageDead(_3); -- _1 = <{generator@$DIR/inline_generator.rs:16:5: 16:8} as Generator>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; -+ StorageDead(_4); -+ _0 = const (); -+ StorageDead(_1); -+ return; - } - - bb3: { -- StorageDead(_2); -- drop(_4) -> [return: bb4, unwind unreachable]; -+ StorageLive(_8); -+ switchInt(_5) -> [0: bb4, otherwise: bb5]; - } - - bb4: { -- StorageDead(_4); -- _0 = const (); -- StorageDead(_1); -- return; -+ _8 = const 13_i32; -+ goto -> bb6; -+ } -+ -+ bb5: { -+ _8 = const 7_i32; -+ goto -> bb6; -+ } -+ -+ bb6: { -+ _1 = GeneratorState::::Yielded(move _8); -+ discriminant((*_6)) = 3; -+ goto -> bb1; -+ } -+ -+ bb7: { -+ assert(const false, "generator resumed after completion") -> [success: bb7, unwind unreachable]; -+ } -+ -+ bb8: { -+ StorageLive(_8); -+ StorageDead(_8); -+ _1 = GeneratorState::::Complete(_5); -+ discriminant((*_6)) = 1; -+ goto -> bb1; -+ } -+ -+ bb9: { -+ unreachable; - } - } - diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff deleted file mode 100644 index 31744be99..000000000 --- a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff +++ /dev/null @@ -1,120 +0,0 @@ -- // MIR for `main` before Inline -+ // MIR for `main` after Inline - - fn main() -> () { - let mut _0: (); - let _1: std::ops::GeneratorState; - let mut _2: std::pin::Pin<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>; - let mut _3: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}; - let mut _4: {generator@$DIR/inline_generator.rs:16:5: 16:8}; -+ let mut _5: bool; - scope 1 { - debug _r => _1; - } -+ scope 2 (inlined g) { -+ } -+ scope 3 (inlined Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new) { -+ debug pointer => _3; -+ scope 4 { -+ scope 5 (inlined Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new_unchecked) { -+ debug pointer => _3; -+ } -+ } -+ } -+ scope 6 (inlined g::{closure#0}) { -+ debug a => _5; -+ let mut _6: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}; -+ let mut _7: u32; -+ let mut _8: i32; -+ } - - bb0: { - StorageLive(_1); - StorageLive(_2); - StorageLive(_3); - StorageLive(_4); -- _4 = g() -> [return: bb1, unwind continue]; -- } -- -- bb1: { -+ _4 = {generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)}; - _3 = &mut _4; -- _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new(move _3) -> [return: bb2, unwind: bb5]; -- } -- -- bb2: { -+ _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}> { pointer: move _3 }; - StorageDead(_3); -- _1 = <{generator@$DIR/inline_generator.rs:16:5: 16:8} as Generator>::resume(move _2, const false) -> [return: bb3, unwind: bb5]; -+ StorageLive(_5); -+ _5 = const false; -+ _6 = (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}); -+ _7 = discriminant((*_6)); -+ switchInt(move _7) -> [0: bb5, 1: bb9, 3: bb10, otherwise: bb11]; - } - -- bb3: { -+ bb1: { -+ StorageDead(_5); - StorageDead(_2); -- drop(_4) -> [return: bb4, unwind: bb6]; -+ drop(_4) -> [return: bb2, unwind: bb4]; - } - -- bb4: { -+ bb2: { - StorageDead(_4); - _0 = const (); - StorageDead(_1); - return; - } - -- bb5 (cleanup): { -- drop(_4) -> [return: bb6, unwind terminate(cleanup)]; -+ bb3 (cleanup): { -+ drop(_4) -> [return: bb4, unwind terminate(cleanup)]; - } - -- bb6 (cleanup): { -+ bb4 (cleanup): { - resume; -+ } -+ -+ bb5: { -+ StorageLive(_8); -+ switchInt(_5) -> [0: bb6, otherwise: bb7]; -+ } -+ -+ bb6: { -+ _8 = const 13_i32; -+ goto -> bb8; -+ } -+ -+ bb7: { -+ _8 = const 7_i32; -+ goto -> bb8; -+ } -+ -+ bb8: { -+ _1 = GeneratorState::::Yielded(move _8); -+ discriminant((*_6)) = 3; -+ goto -> bb1; -+ } -+ -+ bb9: { -+ assert(const false, "generator resumed after completion") -> [success: bb9, unwind: bb3]; -+ } -+ -+ bb10: { -+ StorageLive(_8); -+ StorageDead(_8); -+ _1 = GeneratorState::::Complete(_5); -+ discriminant((*_6)) = 1; -+ goto -> bb1; -+ } -+ -+ bb11: { -+ unreachable; - } - } - diff --git a/tests/mir-opt/inline/inline_generator.rs b/tests/mir-opt/inline/inline_generator.rs deleted file mode 100644 index 2d71458c1..000000000 --- a/tests/mir-opt/inline/inline_generator.rs +++ /dev/null @@ -1,17 +0,0 @@ -// EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// compile-flags: -Zinline-mir-hint-threshold=1000 -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::pin::Pin; - -// EMIT_MIR inline_generator.main.Inline.diff -fn main() { - let _r = Pin::new(&mut g()).resume(false); -} - -#[inline] -pub fn g() -> impl Generator { - #[inline] - |a| { yield if a { 7 } else { 13 } } -} diff --git a/tests/mir-opt/inline/inline_instruction_set.rs b/tests/mir-opt/inline/inline_instruction_set.rs index 5dfb04943..7cb596455 100644 --- a/tests/mir-opt/inline/inline_instruction_set.rs +++ b/tests/mir-opt/inline/inline_instruction_set.rs @@ -46,16 +46,26 @@ fn inline_always_and_using_inline_asm() { // EMIT_MIR inline_instruction_set.t32.Inline.diff #[instruction_set(arm::t32)] pub fn t32() { + // CHECK-LABEL: fn t32( + // CHECK-NOT: (inlined instruction_set_a32) instruction_set_a32(); + // CHECK: (inlined instruction_set_t32) instruction_set_t32(); + // CHECK: (inlined instruction_set_default) instruction_set_default(); + // CHECK-NOT: (inlined inline_always_and_using_inline_asm) inline_always_and_using_inline_asm(); } // EMIT_MIR inline_instruction_set.default.Inline.diff pub fn default() { + // CHECK-LABEL: fn default( + // CHECK-NOT: (inlined instruction_set_a32) instruction_set_a32(); + // CHECK-NOT: (inlined instruction_set_t32) instruction_set_t32(); + // CHECK: (inlined instruction_set_default) instruction_set_default(); + // CHECK: (inlined inline_always_and_using_inline_asm) inline_always_and_using_inline_asm(); } diff --git a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff index dc0ab255a..b90e0505c 100644 --- a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff @@ -122,9 +122,14 @@ + _3 = const _; + _2 = Vec:: { buf: move _3, len: const 0_usize }; + StorageDead(_3); ++ StorageLive(_4); ++ StorageLive(_5); ++ StorageLive(_6); ++ StorageLive(_7); + _4 = SizeOf(std::vec::Vec); + _5 = AlignOf(std::vec::Vec); + StorageLive(_8); ++ StorageLive(_10); + StorageLive(_11); + StorageLive(_12); + StorageLive(_13); @@ -178,10 +183,15 @@ + StorageDead(_13); + StorageDead(_12); + StorageDead(_11); ++ StorageDead(_10); + StorageDead(_8); + _1 = ShallowInitBox(move _6, std::vec::Vec); + _7 = (((_1.0: std::ptr::Unique>).0: std::ptr::NonNull>).0: *const std::vec::Vec); + (*_7) = move _2; ++ StorageDead(_7); ++ StorageDead(_6); ++ StorageDead(_5); ++ StorageDead(_4); StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb3, unwind unreachable]; diff --git a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff index 675292f06..f9c637caa 100644 --- a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff @@ -122,9 +122,14 @@ + _3 = const _; + _2 = Vec:: { buf: move _3, len: const 0_usize }; + StorageDead(_3); ++ StorageLive(_4); ++ StorageLive(_5); ++ StorageLive(_6); ++ StorageLive(_7); + _4 = SizeOf(std::vec::Vec); + _5 = AlignOf(std::vec::Vec); + StorageLive(_8); ++ StorageLive(_10); + StorageLive(_11); + StorageLive(_12); + StorageLive(_13); @@ -195,10 +200,15 @@ + StorageDead(_13); + StorageDead(_12); + StorageDead(_11); ++ StorageDead(_10); + StorageDead(_8); + _1 = ShallowInitBox(move _6, std::vec::Vec); + _7 = (((_1.0: std::ptr::Unique>).0: std::ptr::NonNull>).0: *const std::vec::Vec); + (*_7) = move _2; ++ StorageDead(_7); ++ StorageDead(_6); ++ StorageDead(_5); ++ StorageDead(_4); + StorageDead(_2); + _0 = const (); + drop(_1) -> [return: bb1, unwind: bb2]; diff --git a/tests/mir-opt/inline/inline_into_box_place.rs b/tests/mir-opt/inline/inline_into_box_place.rs index 56f174e51..65f8e2916 100644 --- a/tests/mir-opt/inline/inline_into_box_place.rs +++ b/tests/mir-opt/inline/inline_into_box_place.rs @@ -5,5 +5,7 @@ // EMIT_MIR inline_into_box_place.main.Inline.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: (inlined Box::>::new) let _x: Box> = Box::new(Vec::new()); } diff --git a/tests/mir-opt/inline/inline_options.rs b/tests/mir-opt/inline/inline_options.rs index b247ecd0b..b940c64f0 100644 --- a/tests/mir-opt/inline/inline_options.rs +++ b/tests/mir-opt/inline/inline_options.rs @@ -7,7 +7,10 @@ // EMIT_MIR inline_options.main.Inline.after.mir fn main() { + // CHECK-LABEL: fn main( + // CHECK-NOT: (inlined not_inlined) not_inlined(); + // CHECK: (inlined inlined::) inlined::(); } diff --git a/tests/mir-opt/inline/inline_retag.rs b/tests/mir-opt/inline/inline_retag.rs index c6950f269..9fb6f7092 100644 --- a/tests/mir-opt/inline/inline_retag.rs +++ b/tests/mir-opt/inline/inline_retag.rs @@ -8,6 +8,17 @@ fn main() { // EMIT_MIR inline_retag.bar.Inline.after.mir fn bar() -> bool { + // CHECK-LABEL: fn bar( + // CHECK: (inlined foo) + // CHECK: debug x => [[x:_.*]]; + // CHECK: debug y => [[y:_.*]]; + // CHECK: bb0: { + // CHECK: Retag + // CHECK: Retag + // CHECK: Retag([[x]]); + // CHECK: Retag([[y]]); + // CHECK: return; + // CHECK-NEXT: } let f = foo; f(&1, &-1) } diff --git a/tests/mir-opt/inline/inline_shims.rs b/tests/mir-opt/inline/inline_shims.rs index eafbb962e..a223c2d26 100644 --- a/tests/mir-opt/inline/inline_shims.rs +++ b/tests/mir-opt/inline/inline_shims.rs @@ -3,11 +3,15 @@ // EMIT_MIR inline_shims.clone.Inline.diff pub fn clone(f: fn(A, B)) -> fn(A, B) { + // CHECK-LABEL: fn clone( + // CHECK: (inlined ::clone - shim(fn(A, B))) f.clone() } // EMIT_MIR inline_shims.drop.Inline.diff pub fn drop(a: *mut Vec, b: *mut Option) { + // CHECK-LABEL: fn drop( + // CHECK: (inlined std::ptr::drop_in_place::> - shim(Some(Option))) unsafe { std::ptr::drop_in_place(a) } unsafe { std::ptr::drop_in_place(b) } } diff --git a/tests/mir-opt/inline/inline_specialization.rs b/tests/mir-opt/inline/inline_specialization.rs index 0311531dc..6453abc00 100644 --- a/tests/mir-opt/inline/inline_specialization.rs +++ b/tests/mir-opt/inline/inline_specialization.rs @@ -3,6 +3,8 @@ // EMIT_MIR inline_specialization.main.Inline.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: (inlined as Foo>::bar) let x = as Foo>::bar(); } diff --git a/tests/mir-opt/inline/inline_trait_method.rs b/tests/mir-opt/inline/inline_trait_method.rs index a9d2168c2..b39355637 100644 --- a/tests/mir-opt/inline/inline_trait_method.rs +++ b/tests/mir-opt/inline/inline_trait_method.rs @@ -1,3 +1,4 @@ +// Verify that we do not inline the default impl in a trait object. // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Z span_free_formats @@ -7,6 +8,8 @@ fn main() { // EMIT_MIR inline_trait_method.test.Inline.after.mir fn test(x: &dyn X) -> u32 { + // CHECK-LABEL: fn test( + // CHECK-NOT: inlined x.y() } diff --git a/tests/mir-opt/inline/inline_trait_method_2.rs b/tests/mir-opt/inline/inline_trait_method_2.rs index 62ec7ebde..b0b6a7b9b 100644 --- a/tests/mir-opt/inline/inline_trait_method_2.rs +++ b/tests/mir-opt/inline/inline_trait_method_2.rs @@ -3,6 +3,9 @@ // EMIT_MIR inline_trait_method_2.test2.Inline.after.mir fn test2(x: &dyn X) -> bool { + // CHECK-LABEL: fn test2( + // CHECK: (inlined test) + // CHECK-NOT: (inlined ::y) test(x) } diff --git a/tests/mir-opt/inline/issue_106141.outer.Inline.panic-abort.diff b/tests/mir-opt/inline/issue_106141.outer.Inline.panic-abort.diff index 3d0c10725..688ab9c56 100644 --- a/tests/mir-opt/inline/issue_106141.outer.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/issue_106141.outer.Inline.panic-abort.diff @@ -18,6 +18,7 @@ bb0: { - _0 = inner() -> [return: bb1, unwind unreachable]; + StorageLive(_1); ++ StorageLive(_2); + _1 = const _; + _0 = index() -> [return: bb1, unwind unreachable]; } @@ -40,6 +41,7 @@ + + bb4: { + StorageDead(_3); ++ StorageDead(_2); + StorageDead(_1); return; } diff --git a/tests/mir-opt/inline/issue_106141.outer.Inline.panic-unwind.diff b/tests/mir-opt/inline/issue_106141.outer.Inline.panic-unwind.diff index 16a19f4a3..e4d2b1a7f 100644 --- a/tests/mir-opt/inline/issue_106141.outer.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/issue_106141.outer.Inline.panic-unwind.diff @@ -18,6 +18,7 @@ bb0: { - _0 = inner() -> [return: bb1, unwind continue]; + StorageLive(_1); ++ StorageLive(_2); + _1 = const _; + _0 = index() -> [return: bb1, unwind continue]; } @@ -40,6 +41,7 @@ + + bb4: { + StorageDead(_3); ++ StorageDead(_2); + StorageDead(_1); return; } diff --git a/tests/mir-opt/inline/issue_106141.rs b/tests/mir-opt/inline/issue_106141.rs index eed1d8917..592b4d9b7 100644 --- a/tests/mir-opt/inline/issue_106141.rs +++ b/tests/mir-opt/inline/issue_106141.rs @@ -1,14 +1,21 @@ +// Verify that we do not ICE inlining a function which uses _0 as an index. // EMIT_MIR_FOR_EACH_PANIC_STRATEGY + pub fn outer() -> usize { + // CHECK-LABEL: fn outer( + // CHECK: = {{.*}}[_0]; inner() } +#[inline(never)] fn index() -> usize { loop {} } #[inline] fn inner() -> usize { + // CHECK-LABEL: fn inner( + // CHECK: = {{.*}}[_0]; let buffer = &[true]; let index = index(); if buffer[index] { diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir index 6837da27a..62d7e839f 100644 --- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir +++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir @@ -17,9 +17,13 @@ fn b(_1: &mut Box) -> &mut T { StorageLive(_3); StorageLive(_4); _4 = &mut (*_1); + StorageLive(_5); + StorageLive(_6); _5 = deref_copy (*_4); _6 = (((_5.0: std::ptr::Unique).0: std::ptr::NonNull).0: *const T); _3 = &mut (*_6); + StorageDead(_6); + StorageDead(_5); _2 = &mut (*_3); StorageDead(_4); _0 = &mut (*_2); diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir index d09bfc33f..bc0aa06a7 100644 --- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir +++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir @@ -15,9 +15,13 @@ fn d(_1: &Box) -> &T { StorageLive(_2); StorageLive(_3); _3 = &(*_1); + StorageLive(_4); + StorageLive(_5); _4 = deref_copy (*_3); _5 = (((_4.0: std::ptr::Unique).0: std::ptr::NonNull).0: *const T); _2 = &(*_5); + StorageDead(_5); + StorageDead(_4); _0 = &(*_2); StorageDead(_3); StorageDead(_2); diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs index 94f926d39..4517c88d7 100644 --- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs +++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs @@ -1,20 +1,28 @@ // EMIT_MIR issue_58867_inline_as_ref_as_mut.a.Inline.after.mir pub fn a(x: &mut [T]) -> &mut [T] { + // CHECK-LABEL: fn a( + // CHECK: (inlined <[T] as AsMut<[T]>>::as_mut) x.as_mut() } // EMIT_MIR issue_58867_inline_as_ref_as_mut.b.Inline.after.mir pub fn b(x: &mut Box) -> &mut T { + // CHECK-LABEL: fn b( + // CHECK: (inlined as AsMut>::as_mut) x.as_mut() } // EMIT_MIR issue_58867_inline_as_ref_as_mut.c.Inline.after.mir pub fn c(x: &[T]) -> &[T] { + // CHECK-LABEL: fn c( + // CHECK: (inlined <[T] as AsRef<[T]>>::as_ref) x.as_ref() } // EMIT_MIR issue_58867_inline_as_ref_as_mut.d.Inline.after.mir pub fn d(x: &Box) -> &T { + // CHECK-LABEL: fn d( + // CHECK: (inlined as AsRef>::as_ref) x.as_ref() } 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 4d170c41f..ba4f91b28 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 @@ -2,8 +2,8 @@ fn main() -> () { let mut _0: (); - let _1: {closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16}; - let mut _2: &{closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16}; + let _1: {closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16}; + let mut _2: &{closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16}; let mut _3: ((),); let mut _4: (); let mut _5: (); @@ -19,7 +19,7 @@ fn main() -> () { bb0: { StorageLive(_1); - _1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16}; + _1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16}; StorageLive(_2); _2 = &_1; StorageLive(_3); diff --git a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs index 76d806acc..2fb363c19 100644 --- a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs +++ b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs @@ -2,6 +2,16 @@ // EMIT_MIR issue_76997_inline_scopes_parenting.main.Inline.after.mir fn main() { + // CHECK-LABEL: fn main( + // CHECK: scope 1 { + // CHECK-NEXT: debug f + // CHECK-NEXT: scope 2 (inlined main::{closure#0}) { + // CHECK-NEXT: debug x + // CHECK-NEXT: scope 3 { + // CHECK-NEXT: debug y + // CHECK-NEXT: } + // CHECK-NEXT: } + // CHECK-NEXT: } let f = |x| { let y = x; y }; f(()) } diff --git a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff index bee01a5f9..b9f268df3 100644 --- a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff @@ -8,31 +8,37 @@ let mut _3: &fn() {foo}; let _4: fn() {foo}; let mut _5: (); ++ scope 1 (inlined hide_foo) { ++ } bb0: { StorageLive(_2); StorageLive(_3); StorageLive(_4); - _4 = hide_foo() -> [return: bb1, unwind unreachable]; - } - - bb1: { +- _4 = hide_foo() -> [return: bb1, unwind unreachable]; +- } +- +- bb1: { _3 = &_4; StorageLive(_5); _5 = (); - _2 = >::call(move _3, move _5) -> [return: bb2, unwind unreachable]; +- _2 = >::call(move _3, move _5) -> [return: bb2, unwind unreachable]; ++ _2 = >::call(move _3, move _5) -> [return: bb1, unwind unreachable]; } - bb2: { +- bb2: { ++ bb1: { StorageDead(_5); StorageDead(_3); StorageDead(_4); StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb3, unwind unreachable]; +- drop(_1) -> [return: bb3, unwind unreachable]; ++ drop(_1) -> [return: bb2, unwind unreachable]; } - bb3: { +- bb3: { ++ bb2: { return; } } diff --git a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff index 5a946712e..8495164df 100644 --- a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff @@ -8,39 +8,48 @@ let mut _3: &fn() {foo}; let _4: fn() {foo}; let mut _5: (); ++ scope 1 (inlined hide_foo) { ++ } bb0: { StorageLive(_2); StorageLive(_3); StorageLive(_4); - _4 = hide_foo() -> [return: bb1, unwind: bb4]; - } - - bb1: { +- _4 = hide_foo() -> [return: bb1, unwind: bb4]; +- } +- +- bb1: { _3 = &_4; StorageLive(_5); _5 = (); - _2 = >::call(move _3, move _5) -> [return: bb2, unwind: bb4]; +- _2 = >::call(move _3, move _5) -> [return: bb2, unwind: bb4]; ++ _2 = >::call(move _3, move _5) -> [return: bb1, unwind: bb3]; } - bb2: { +- bb2: { ++ bb1: { StorageDead(_5); StorageDead(_3); StorageDead(_4); StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb3, unwind: bb5]; +- drop(_1) -> [return: bb3, unwind: bb5]; ++ drop(_1) -> [return: bb2, unwind: bb4]; } - bb3: { +- bb3: { ++ bb2: { return; } - bb4 (cleanup): { - drop(_1) -> [return: bb5, unwind terminate(cleanup)]; +- bb4 (cleanup): { +- drop(_1) -> [return: bb5, unwind terminate(cleanup)]; ++ bb3 (cleanup): { ++ drop(_1) -> [return: bb4, unwind terminate(cleanup)]; } - bb5 (cleanup): { +- bb5 (cleanup): { ++ bb4 (cleanup): { resume; } } diff --git a/tests/mir-opt/inline/issue_78442.rs b/tests/mir-opt/inline/issue_78442.rs index d956e6241..f9a523428 100644 --- a/tests/mir-opt/inline/issue_78442.rs +++ b/tests/mir-opt/inline/issue_78442.rs @@ -8,6 +8,11 @@ pub fn bar

( // Error won't happen if "bar" is not generic _baz: P, ) { + // CHECK-LABEL: fn bar( + // CHECK: let mut {{.*}}: &fn() {foo}; + // CHECK: let {{.*}}: fn() {foo}; + // CHECK: (inlined hide_foo) + // CHECK-NOT: inlined hide_foo()(); } diff --git a/tests/mir-opt/inline/polymorphic_recursion.rs b/tests/mir-opt/inline/polymorphic_recursion.rs index 7388722b7..f71e382e8 100644 --- a/tests/mir-opt/inline/polymorphic_recursion.rs +++ b/tests/mir-opt/inline/polymorphic_recursion.rs @@ -1,3 +1,4 @@ +// skip-filecheck // Make sure that the MIR inliner does not loop indefinitely on polymorphic recursion. // compile-flags: --crate-type lib diff --git a/tests/mir-opt/inline/unchecked_shifts.rs b/tests/mir-opt/inline/unchecked_shifts.rs index 22f84e44a..0de80641c 100644 --- a/tests/mir-opt/inline/unchecked_shifts.rs +++ b/tests/mir-opt/inline/unchecked_shifts.rs @@ -1,6 +1,6 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] -#![feature(unchecked_math)] +#![feature(unchecked_shifts)] // ignore-debug: the debug assertions prevent the inlining we are testing for // compile-flags: -Zmir-opt-level=2 -Zinline-mir @@ -8,23 +8,31 @@ // 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 { + // CHECK-LABEL: fn unchecked_shl_unsigned_smaller( + // CHECK: (inlined core::num::::unchecked_shl) 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 { + // CHECK-LABEL: fn unchecked_shr_signed_smaller( + // CHECK: (inlined core::num::::unchecked_shr) a.unchecked_shr(b) } // EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_bigger.Inline.diff // EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_bigger.PreCodegen.after.mir pub unsafe fn unchecked_shl_unsigned_bigger(a: u64, b: u32) -> u64 { + // CHECK-LABEL: fn unchecked_shl_unsigned_bigger( + // CHECK: (inlined core::num::::unchecked_shl) a.unchecked_shl(b) } // EMIT_MIR unchecked_shifts.unchecked_shr_signed_bigger.Inline.diff // EMIT_MIR unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.mir pub unsafe fn unchecked_shr_signed_bigger(a: i64, b: u32) -> i64 { + // CHECK-LABEL: fn unchecked_shr_signed_bigger( + // CHECK: (inlined core::num::::unchecked_shr) a.unchecked_shr(b) } diff --git a/tests/mir-opt/inline/unit_test.rs b/tests/mir-opt/inline/unit_test.rs new file mode 100644 index 000000000..0d877bb10 --- /dev/null +++ b/tests/mir-opt/inline/unit_test.rs @@ -0,0 +1,19 @@ +// Check that `-Zmir-enable-passes=+Inline` does not ICE because of stolen MIR. +// unit-test: Inline +// skip-filecheck +#![crate_type = "lib"] + +// Randomize `def_path_hash` by defining them under a module with different names +macro_rules! emit { + ($($m:ident)*) => {$( + pub mod $m { + pub fn main() { + let func = || 123u8; + func(); + } + } + )*}; +} + +// Increase the chance of triggering the bug +emit!(m00 m01 m02 m03 m04 m05 m06 m07 m08 m09 m10 m11 m12 m13 m14 m15 m16 m17 m18 m19); diff --git a/tests/mir-opt/inline/unsized_argument.caller.Inline.diff b/tests/mir-opt/inline/unsized_argument.caller.Inline.diff index ab81f7071..37083973f 100644 --- a/tests/mir-opt/inline/unsized_argument.caller.Inline.diff +++ b/tests/mir-opt/inline/unsized_argument.caller.Inline.diff @@ -6,24 +6,18 @@ let mut _0: (); let _2: (); let mut _3: std::boxed::Box<[i32]>; - let mut _4: &mut std::boxed::Box<[i32]>; - let mut _5: (); - let mut _6: &mut std::boxed::Box<[i32]>; - let mut _7: (); - let mut _8: &mut std::boxed::Box<[i32]>; - let mut _9: (); - let mut _10: *const [i32]; + let mut _4: *const [i32]; bb0: { StorageLive(_2); StorageLive(_3); _3 = move _1; - _10 = (((_3.0: std::ptr::Unique<[i32]>).0: std::ptr::NonNull<[i32]>).0: *const [i32]); - _2 = callee(move (*_10)) -> [return: bb3, unwind: bb4]; + _4 = (((_3.0: std::ptr::Unique<[i32]>).0: std::ptr::NonNull<[i32]>).0: *const [i32]); + _2 = callee(move (*_4)) -> [return: bb1, unwind: bb3]; } - bb1 (cleanup): { - resume; + bb1: { + drop(_3) -> [return: bb2, unwind: bb4]; } bb2: { @@ -33,14 +27,12 @@ return; } - bb3: { - _4 = &mut _3; - _5 = as Drop>::drop(move _4) -> [return: bb2, unwind: bb1]; + bb3 (cleanup): { + drop(_3) -> [return: bb4, unwind terminate(cleanup)]; } bb4 (cleanup): { - _8 = &mut _3; - _9 = as Drop>::drop(move _8) -> [return: bb1, unwind terminate(cleanup)]; + resume; } } diff --git a/tests/mir-opt/inline/unsized_argument.rs b/tests/mir-opt/inline/unsized_argument.rs index b2c51407f..e8c2bc10b 100644 --- a/tests/mir-opt/inline/unsized_argument.rs +++ b/tests/mir-opt/inline/unsized_argument.rs @@ -6,6 +6,8 @@ fn callee(y: [i32]) {} // EMIT_MIR unsized_argument.caller.Inline.diff fn caller(x: Box<[i32]>) { + // CHECK-LABEL: fn caller( + // CHECK-NOT: (inlined callee) callee(*x); } diff --git a/tests/mir-opt/inline/unwrap_unchecked.rs b/tests/mir-opt/inline/unwrap_unchecked.rs index f28aef7a8..be133706e 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.rs +++ b/tests/mir-opt/inline/unwrap_unchecked.rs @@ -7,5 +7,7 @@ // EMIT_MIR unwrap_unchecked.unwrap_unchecked.Inline.diff // EMIT_MIR unwrap_unchecked.unwrap_unchecked.PreCodegen.after.mir pub unsafe fn unwrap_unchecked(slf: Option) -> T { + // CHECK-LABEL: fn unwrap_unchecked( + // CHECK: (inlined #[track_caller] Option::::unwrap_unchecked) slf.unwrap_unchecked() } diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff index e3c573473..2a36ad923 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff @@ -9,6 +9,7 @@ + debug self => _2; + let mut _3: &std::option::Option; + let mut _4: isize; ++ let mut _5: bool; + scope 2 { + debug val => _0; + } @@ -29,17 +30,18 @@ StorageLive(_2); _2 = move _1; - _0 = Option::::unwrap_unchecked(move _2) -> [return: bb1, unwind unreachable]; +- } +- +- bb1: { + StorageLive(_3); ++ StorageLive(_4); ++ StorageLive(_5); + _4 = discriminant(_2); -+ switchInt(move _4) -> [1: bb2, otherwise: bb1]; - } - - bb1: { -+ unreachable; -+ } -+ -+ bb2: { ++ _5 = Eq(_4, const 1_isize); ++ assume(move _5); + _0 = move ((_2 as Some).0: T); ++ StorageDead(_5); ++ StorageDead(_4); + StorageDead(_3); StorageDead(_2); return; diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff index fc638cb3a..14c8c671d 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff @@ -9,6 +9,7 @@ + debug self => _2; + let mut _3: &std::option::Option; + let mut _4: isize; ++ let mut _5: bool; + scope 2 { + debug val => _0; + } @@ -29,24 +30,25 @@ StorageLive(_2); _2 = move _1; - _0 = Option::::unwrap_unchecked(move _2) -> [return: bb1, unwind: bb2]; +- } +- +- bb1: { + StorageLive(_3); ++ StorageLive(_4); ++ StorageLive(_5); + _4 = discriminant(_2); -+ switchInt(move _4) -> [1: bb2, otherwise: bb1]; - } - - bb1: { -- StorageDead(_2); -- return; -+ unreachable; - } - -- bb2 (cleanup): { -- resume; -+ bb2: { ++ _5 = Eq(_4, const 1_isize); ++ assume(move _5); + _0 = move ((_2 as Some).0: T); ++ StorageDead(_5); ++ StorageDead(_4); + StorageDead(_3); -+ StorageDead(_2); -+ return; + StorageDead(_2); + return; +- } +- +- bb2 (cleanup): { +- resume; } } diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir index fcc4d43ce..aeb93bd33 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir @@ -6,7 +6,8 @@ fn unwrap_unchecked(_1: Option) -> T { scope 1 (inlined #[track_caller] Option::::unwrap_unchecked) { debug self => _1; let mut _2: isize; - let mut _3: &std::option::Option; + let mut _3: bool; + let mut _4: &std::option::Option; scope 2 { debug val => _0; } @@ -19,23 +20,21 @@ fn unwrap_unchecked(_1: Option) -> T { } } scope 4 (inlined Option::::is_some) { - debug self => _3; + debug self => _4; } } bb0: { + StorageLive(_4); + StorageLive(_2); StorageLive(_3); _2 = discriminant(_1); - switchInt(move _2) -> [1: bb1, otherwise: bb2]; - } - - bb1: { + _3 = Eq(_2, const 1_isize); + assume(move _3); _0 = move ((_1 as Some).0: T); StorageDead(_3); + StorageDead(_2); + StorageDead(_4); return; } - - bb2: { - unreachable; - } } diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir index fcc4d43ce..aeb93bd33 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir @@ -6,7 +6,8 @@ fn unwrap_unchecked(_1: Option) -> T { scope 1 (inlined #[track_caller] Option::::unwrap_unchecked) { debug self => _1; let mut _2: isize; - let mut _3: &std::option::Option; + let mut _3: bool; + let mut _4: &std::option::Option; scope 2 { debug val => _0; } @@ -19,23 +20,21 @@ fn unwrap_unchecked(_1: Option) -> T { } } scope 4 (inlined Option::::is_some) { - debug self => _3; + debug self => _4; } } bb0: { + StorageLive(_4); + StorageLive(_2); StorageLive(_3); _2 = discriminant(_1); - switchInt(move _2) -> [1: bb1, otherwise: bb2]; - } - - bb1: { + _3 = Eq(_2, const 1_isize); + assume(move _3); _0 = move ((_1 as Some).0: T); StorageDead(_3); + StorageDead(_2); + StorageDead(_4); return; } - - bb2: { - unreachable; - } } -- cgit v1.2.3