summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/inline
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /tests/mir-opt/inline
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/mir-opt/inline')
-rw-r--r--tests/mir-opt/inline/asm_unwind.rs5
-rw-r--r--tests/mir-opt/inline/caller_with_trivial_bound.rs5
-rw-r--r--tests/mir-opt/inline/cycle.rs10
-rw-r--r--tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs2
-rw-r--r--tests/mir-opt/inline/dyn_trait.rs8
-rw-r--r--tests/mir-opt/inline/exponential_runtime.rs9
-rw-r--r--tests/mir-opt/inline/inline_any_operand.rs2
-rw-r--r--tests/mir-opt/inline/inline_async.rs3
-rw-r--r--tests/mir-opt/inline/inline_box_fn.rs2
-rw-r--r--tests/mir-opt/inline/inline_closure.rs3
-rw-r--r--tests/mir-opt/inline/inline_closure_borrows_arg.rs3
-rw-r--r--tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir4
-rw-r--r--tests/mir-opt/inline/inline_closure_captures.rs3
-rw-r--r--tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-abort.diff21
-rw-r--r--tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff21
-rw-r--r--tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-abort.diff21
-rw-r--r--tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff21
-rw-r--r--tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-abort.diff22
-rw-r--r--tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-unwind.diff22
-rw-r--r--tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-abort.diff19
-rw-r--r--tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-unwind.diff19
-rw-r--r--tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-abort.diff19
-rw-r--r--tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-unwind.diff19
-rw-r--r--tests/mir-opt/inline/inline_compatibility.rs63
-rw-r--r--tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff (renamed from tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff)34
-rw-r--r--tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff (renamed from tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff)34
-rw-r--r--tests/mir-opt/inline/inline_coroutine.rs20
-rw-r--r--tests/mir-opt/inline/inline_cycle.rs1
-rw-r--r--tests/mir-opt/inline/inline_cycle_generic.rs1
-rw-r--r--tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff4
-rw-r--r--tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff2
-rw-r--r--tests/mir-opt/inline/inline_diverging.rs7
-rw-r--r--tests/mir-opt/inline/inline_generator.rs17
-rw-r--r--tests/mir-opt/inline/inline_instruction_set.rs10
-rw-r--r--tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff10
-rw-r--r--tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff10
-rw-r--r--tests/mir-opt/inline/inline_into_box_place.rs2
-rw-r--r--tests/mir-opt/inline/inline_options.rs3
-rw-r--r--tests/mir-opt/inline/inline_retag.rs11
-rw-r--r--tests/mir-opt/inline/inline_shims.rs4
-rw-r--r--tests/mir-opt/inline/inline_specialization.rs2
-rw-r--r--tests/mir-opt/inline/inline_trait_method.rs3
-rw-r--r--tests/mir-opt/inline/inline_trait_method_2.rs3
-rw-r--r--tests/mir-opt/inline/issue_106141.outer.Inline.panic-abort.diff2
-rw-r--r--tests/mir-opt/inline/issue_106141.outer.Inline.panic-unwind.diff2
-rw-r--r--tests/mir-opt/inline/issue_106141.rs7
-rw-r--r--tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir4
-rw-r--r--tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir4
-rw-r--r--tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs8
-rw-r--r--tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir6
-rw-r--r--tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs10
-rw-r--r--tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff22
-rw-r--r--tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff31
-rw-r--r--tests/mir-opt/inline/issue_78442.rs5
-rw-r--r--tests/mir-opt/inline/polymorphic_recursion.rs1
-rw-r--r--tests/mir-opt/inline/unchecked_shifts.rs10
-rw-r--r--tests/mir-opt/inline/unit_test.rs19
-rw-r--r--tests/mir-opt/inline/unsized_argument.caller.Inline.diff24
-rw-r--r--tests/mir-opt/inline/unsized_argument.rs2
-rw-r--r--tests/mir-opt/inline/unwrap_unchecked.rs2
-rw-r--r--tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff18
-rw-r--r--tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff30
-rw-r--r--tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir19
-rw-r--r--tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir19
64 files changed, 392 insertions, 357 deletions
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<T> Factory<T> for IntFactory {
// EMIT_MIR caller_with_trivial_bound.foo.Inline.diff
pub fn foo<T>()
where
+ // Because of this trivial bound, the inliner fails to normalize
+ // `<IntFactory as Factory<T>>::Item`.
+ // Verify that we do not inline anything, which would cause validation ICEs.
IntFactory: Factory<T>,
{
+ // CHECK-LABEL: fn foo(
+ // CHECK-NOT: (inlined bar::<T>)
let mut x: <IntFactory as Factory<T>>::Item = bar::<T>();
}
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::<fn() {main}>)
+ // CHECK-NOT: inlined
f(main);
}
// EMIT_MIR cycle.main.Inline.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK-NOT: inlined
+ // CHECK: (inlined f::<fn() {g}>)
+ // 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<I: Tuple>(mut mock: Box<dyn FnMut<I, Output = ()>>, 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<V: Debug>(c: &dyn Cache<V = V>) {
+ // 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: Cache>(c: &C) {
+ // CHECK-LABEL: fn try_execute_query(
+ // CHECK: (inlined mk_cycle::<<C as Cache>::V>)
mk_cycle(c)
}
// EMIT_MIR dyn_trait.get_query.Inline.diff
#[inline(always)]
pub fn get_query<Q: Query, T>(t: &T) {
+ // CHECK-LABEL: fn get_query(
+ // CHECK-NOT: inlined
let c = Q::cache(t);
+ // CHECK: (inlined try_execute_query::<<Q as Query>::C>)
+ // CHECK: (inlined mk_cycle::<<Q as Query>::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<dyn Fn(i32)>) {
+ // 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: Copy>(_t: T, q: i32) -> i32 {
let x = |_t, _q| _t;
+
+ // CHECK-LABEL: fn foo(
+ // CHECK: (inlined foo::<T>::{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: Copy>(_t: T, q: &i32) -> i32 {
let variable = &*r;
*variable
};
+
+ // CHECK-LABEL: fn foo(
+ // CHECK: (inlined foo::<T>::{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: Copy>(t: T, q: i32) -> (i32, T) {
let x = |_q| (q, t);
+
+ // CHECK-LABEL: fn foo(
+ // CHECK: (inlined foo::<T>::{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_generator.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff
index 6779003b6..40eeda539 100644
--- a/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff
+++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff
@@ -3,27 +3,27 @@
fn main() -> () {
let mut _0: ();
- let _1: std::ops::GeneratorState<i32, bool>;
- 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 _1: std::ops::CoroutineState<i32, bool>;
+ 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 {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new) {
++ 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 {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new_unchecked) {
++ 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 {generator@$DIR/inline_generator.rs:16:5: 16:8};
++ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8};
+ let mut _7: u32;
+ let mut _8: i32;
+ }
@@ -34,20 +34,24 @@
StorageLive(_3);
StorageLive(_4);
- _4 = g() -> [return: bb1, unwind unreachable];
-+ _4 = {generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)};
++ _4 = {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8 (#0)};
+ _3 = &mut _4;
-+ _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}> { pointer: move _3 };
++ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}> { pointer: move _3 };
+ StorageDead(_3);
+ StorageLive(_5);
+ _5 = const false;
-+ _6 = (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8});
++ 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 {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new(move _3) -> [return: bb2, unwind unreachable];
+- _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];
@@ -55,7 +59,7 @@
bb2: {
- StorageDead(_3);
-- _1 = <{generator@$DIR/inline_generator.rs:16:5: 16:8} as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind unreachable];
+- _1 = <{coroutine@$DIR/inline_coroutine.rs:19:5: 19:8} as Coroutine<bool>>::resume(move _2, const false) -> [return: bb3, unwind unreachable];
+ StorageDead(_4);
+ _0 = const ();
+ StorageDead(_1);
@@ -84,19 +88,19 @@
+ }
+
+ bb6: {
-+ _1 = GeneratorState::<i32, bool>::Yielded(move _8);
++ _1 = CoroutineState::<i32, bool>::Yielded(move _8);
+ discriminant((*_6)) = 3;
+ goto -> bb1;
+ }
+
+ bb7: {
-+ assert(const false, "generator resumed after completion") -> [success: bb7, unwind unreachable];
++ assert(const false, "coroutine resumed after completion") -> [success: bb7, unwind unreachable];
+ }
+
+ bb8: {
+ StorageLive(_8);
+ StorageDead(_8);
-+ _1 = GeneratorState::<i32, bool>::Complete(_5);
++ _1 = CoroutineState::<i32, bool>::Complete(_5);
+ discriminant((*_6)) = 1;
+ goto -> bb1;
+ }
diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff
index 31744be99..fdb42bf3d 100644
--- a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff
+++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff
@@ -3,27 +3,27 @@
fn main() -> () {
let mut _0: ();
- let _1: std::ops::GeneratorState<i32, bool>;
- 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 _1: std::ops::CoroutineState<i32, bool>;
+ 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 {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new) {
++ 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 {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new_unchecked) {
++ 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 {generator@$DIR/inline_generator.rs:16:5: 16:8};
++ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8};
+ let mut _7: u32;
+ let mut _8: i32;
+ }
@@ -37,24 +37,28 @@
- }
-
- bb1: {
-+ _4 = {generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)};
++ _4 = {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8 (#0)};
_3 = &mut _4;
-- _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new(move _3) -> [return: bb2, unwind: bb5];
+- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new(move _3) -> [return: bb2, unwind: bb5];
- }
-
- bb2: {
-+ _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}> { pointer: move _3 };
++ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}> { pointer: move _3 };
StorageDead(_3);
-- _1 = <{generator@$DIR/inline_generator.rs:16:5: 16:8} as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb5];
+- _1 = <{coroutine@$DIR/inline_coroutine.rs:19:5: 19:8} as Coroutine<bool>>::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});
++ 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];
@@ -96,19 +100,19 @@
+ }
+
+ bb8: {
-+ _1 = GeneratorState::<i32, bool>::Yielded(move _8);
++ _1 = CoroutineState::<i32, bool>::Yielded(move _8);
+ discriminant((*_6)) = 3;
+ goto -> bb1;
+ }
+
+ bb9: {
-+ assert(const false, "generator resumed after completion") -> [success: bb9, unwind: bb3];
++ assert(const false, "coroutine resumed after completion") -> [success: bb9, unwind: bb3];
+ }
+
+ bb10: {
+ StorageLive(_8);
+ StorageDead(_8);
-+ _1 = GeneratorState::<i32, bool>::Complete(_5);
++ _1 = CoroutineState::<i32, bool>::Complete(_5);
+ discriminant((*_6)) = 1;
+ goto -> bb1;
+ }
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<bool> {
+ #[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::<!, fn() -> ! {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::<!, fn() -> ! {sleep}>)
+ // CHECK-NOT: inlined
call_twice(sleep);
}
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<bool> {
- #[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::<u32> { buf: move _3, len: const 0_usize };
+ StorageDead(_3);
++ StorageLive(_4);
++ StorageLive(_5);
++ StorageLive(_6);
++ StorageLive(_7);
+ _4 = SizeOf(std::vec::Vec<u32>);
+ _5 = AlignOf(std::vec::Vec<u32>);
+ 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<u32>);
+ _7 = (((_1.0: std::ptr::Unique<std::vec::Vec<u32>>).0: std::ptr::NonNull<std::vec::Vec<u32>>).0: *const std::vec::Vec<u32>);
+ (*_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::<u32> { buf: move _3, len: const 0_usize };
+ StorageDead(_3);
++ StorageLive(_4);
++ StorageLive(_5);
++ StorageLive(_6);
++ StorageLive(_7);
+ _4 = SizeOf(std::vec::Vec<u32>);
+ _5 = AlignOf(std::vec::Vec<u32>);
+ 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<u32>);
+ _7 = (((_1.0: std::ptr::Unique<std::vec::Vec<u32>>).0: std::ptr::NonNull<std::vec::Vec<u32>>).0: *const std::vec::Vec<u32>);
+ (*_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::<Vec<u32>>::new)
let _x: Box<Vec<u32>> = 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::<u32>)
inlined::<u32>();
}
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<A, B>(f: fn(A, B)) -> fn(A, B) {
+ // CHECK-LABEL: fn clone(
+ // CHECK: (inlined <fn(A, B) as Clone>::clone - shim(fn(A, B)))
f.clone()
}
// EMIT_MIR inline_shims.drop.Inline.diff
pub fn drop<A, B>(a: *mut Vec<A>, b: *mut Option<B>) {
+ // CHECK-LABEL: fn drop(
+ // CHECK: (inlined std::ptr::drop_in_place::<Option<B>> - shim(Some(Option<B>)))
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 <Vec<()> as Foo>::bar)
let x = <Vec::<()> 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 <dyn X as X>::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<T>) -> &mut T {
StorageLive(_3);
StorageLive(_4);
_4 = &mut (*_1);
+ StorageLive(_5);
+ StorageLive(_6);
_5 = deref_copy (*_4);
_6 = (((_5.0: std::ptr::Unique<T>).0: std::ptr::NonNull<T>).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>) -> &T {
StorageLive(_2);
StorageLive(_3);
_3 = &(*_1);
+ StorageLive(_4);
+ StorageLive(_5);
_4 = deref_copy (*_3);
_5 = (((_4.0: std::ptr::Unique<T>).0: std::ptr::NonNull<T>).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<T>(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<T>(x: &mut Box<T>) -> &mut T {
+ // CHECK-LABEL: fn b(
+ // CHECK: (inlined <Box<T> as AsMut<T>>::as_mut)
x.as_mut()
}
// EMIT_MIR issue_58867_inline_as_ref_as_mut.c.Inline.after.mir
pub fn c<T>(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<T>(x: &Box<T>) -> &T {
+ // CHECK-LABEL: fn d(
+ // CHECK: (inlined <Box<T> as AsRef<T>>::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 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind unreachable];
+- _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind unreachable];
++ _2 = <fn() {foo} as Fn<()>>::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 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb4];
+- _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb4];
++ _2 = <fn() {foo} as Fn<()>>::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<P>(
// 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::<impl u16>::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::<impl i16>::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::<impl u64>::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::<impl i64>::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 = <Box<[i32]> as Drop>::drop(move _4) -> [return: bb2, unwind: bb1];
+ bb3 (cleanup): {
+ drop(_3) -> [return: bb4, unwind terminate(cleanup)];
}
bb4 (cleanup): {
- _8 = &mut _3;
- _9 = <Box<[i32]> 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<T>(slf: Option<T>) -> T {
+ // CHECK-LABEL: fn unwrap_unchecked(
+ // CHECK: (inlined #[track_caller] Option::<T>::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<T>;
+ let mut _4: isize;
++ let mut _5: bool;
+ scope 2 {
+ debug val => _0;
+ }
@@ -29,17 +30,18 @@
StorageLive(_2);
_2 = move _1;
- _0 = Option::<T>::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<T>;
+ let mut _4: isize;
++ let mut _5: bool;
+ scope 2 {
+ debug val => _0;
+ }
@@ -29,24 +30,25 @@
StorageLive(_2);
_2 = move _1;
- _0 = Option::<T>::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>) -> T {
scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) {
debug self => _1;
let mut _2: isize;
- let mut _3: &std::option::Option<T>;
+ let mut _3: bool;
+ let mut _4: &std::option::Option<T>;
scope 2 {
debug val => _0;
}
@@ -19,23 +20,21 @@ fn unwrap_unchecked(_1: Option<T>) -> T {
}
}
scope 4 (inlined Option::<T>::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>) -> T {
scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) {
debug self => _1;
let mut _2: isize;
- let mut _3: &std::option::Option<T>;
+ let mut _3: bool;
+ let mut _4: &std::option::Option<T>;
scope 2 {
debug val => _0;
}
@@ -19,23 +20,21 @@ fn unwrap_unchecked(_1: Option<T>) -> T {
}
}
scope 4 (inlined Option::<T>::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;
- }
}