Auto merge of #117029 - rmehri01:mir_opt_filecheck_inline_tests, r=cjgillot

Add FileCheck annotations to MIR-opt inlining tests

Part of #116971, adds FileCheck annotations to MIR-opt tests in `tests/mir-opt/inline`.

I left out a few (such as `inline_cycle`) where it mentioned that the particular outcome of inlining isn't important, just that the inliner doesn't get stuck in an infinite loop.

r? cjgillot
This commit is contained in:
bors 2023-11-01 20:37:38 +00:00
commit 75b064d269
29 changed files with 156 additions and 51 deletions

View File

@ -1,8 +1,8 @@
// skip-filecheck
// Tests inlining of `may_unwind` inline assembly. // Tests inlining of `may_unwind` inline assembly.
// //
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// needs-asm-support // needs-asm-support
// needs-unwind
// compile-flags: -Zinline-mir-hint-threshold=1000 // compile-flags: -Zinline-mir-hint-threshold=1000
#![feature(asm_unwind)] #![feature(asm_unwind)]
@ -20,5 +20,9 @@ fn foo() {
// EMIT_MIR asm_unwind.main.Inline.diff // EMIT_MIR asm_unwind.main.Inline.diff
pub fn main() { pub fn main() {
// CHECK-LABEL: fn main(
// CHECK: (inlined foo)
// CHECK: asm!("", options(MAY_UNWIND)) -> [return: {{bb.*}}, unwind: [[unwind:bb.*]]];
// CHECK: [[unwind]] (cleanup)
foo(); foo();
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// needs-unwind // needs-unwind
@ -16,8 +15,13 @@ impl<T> Factory<T> for IntFactory {
// EMIT_MIR caller_with_trivial_bound.foo.Inline.diff // EMIT_MIR caller_with_trivial_bound.foo.Inline.diff
pub fn foo<T>() pub fn foo<T>()
where 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>, IntFactory: Factory<T>,
{ {
// CHECK-LABEL: fn foo(
// CHECK-NOT: (inlined bar::<T>)
let mut x: <IntFactory as Factory<T>>::Item = bar::<T>(); let mut x: <IntFactory as Factory<T>>::Item = bar::<T>();
} }

View File

@ -1,20 +1,29 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// compile-flags: -Zinline-mir-hint-threshold=1000 // compile-flags: -Zinline-mir-hint-threshold=1000
// EMIT_MIR cycle.f.Inline.diff // EMIT_MIR cycle.f.Inline.diff
#[inline(always)] #[inline(always)]
fn f(g: impl Fn()) { fn f(g: impl Fn()) {
// CHECK-LABEL: fn f(
// CHECK-NOT: inlined
g(); g();
} }
// EMIT_MIR cycle.g.Inline.diff // EMIT_MIR cycle.g.Inline.diff
#[inline(always)] #[inline(always)]
fn g() { fn g() {
// CHECK-LABEL: fn g(
// CHECK-NOT: inlined
// CHECK: (inlined f::<fn() {main}>)
// CHECK-NOT: inlined
f(main); f(main);
} }
// EMIT_MIR cycle.main.Inline.diff // EMIT_MIR cycle.main.Inline.diff
fn main() { fn main() {
// CHECK-LABEL: fn main(
// CHECK-NOT: inlined
// CHECK: (inlined f::<fn() {g}>)
// CHECK-NOT: inlined
f(g); f(g);
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// compile-flags: -Zmir-enable-passes=+Inline --crate-type=lib // compile-flags: -Zmir-enable-passes=+Inline --crate-type=lib
@ -8,5 +7,7 @@ use std::marker::Tuple;
// EMIT_MIR dont_ice_on_generic_rust_call.call.Inline.diff // 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) { 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) mock.call_mut(input)
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
#![crate_type = "lib"] #![crate_type = "lib"]
@ -20,18 +19,26 @@ pub trait Query {
// EMIT_MIR dyn_trait.mk_cycle.Inline.diff // EMIT_MIR dyn_trait.mk_cycle.Inline.diff
#[inline(always)] #[inline(always)]
pub fn mk_cycle<V: Debug>(c: &dyn Cache<V = V>) { pub fn mk_cycle<V: Debug>(c: &dyn Cache<V = V>) {
// CHECK-LABEL: fn mk_cycle(
// CHECK-NOT: inlined
c.store_nocache() c.store_nocache()
} }
// EMIT_MIR dyn_trait.try_execute_query.Inline.diff // EMIT_MIR dyn_trait.try_execute_query.Inline.diff
#[inline(always)] #[inline(always)]
pub fn try_execute_query<C: Cache>(c: &C) { 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) mk_cycle(c)
} }
// EMIT_MIR dyn_trait.get_query.Inline.diff // EMIT_MIR dyn_trait.get_query.Inline.diff
#[inline(always)] #[inline(always)]
pub fn get_query<Q: Query, T>(t: &T) { pub fn get_query<Q: Query, T>(t: &T) {
// CHECK-LABEL: fn get_query(
// CHECK-NOT: inlined
let c = Q::cache(t); 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) try_execute_query(c)
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// Checks that code with exponential runtime does not have exponential behavior in inlining. // Checks that code with exponential runtime does not have exponential behavior in inlining.
@ -85,5 +84,14 @@ impl A for () {
// EMIT_MIR exponential_runtime.main.Inline.diff // EMIT_MIR exponential_runtime.main.Inline.diff
fn main() { 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(); <() as G>::call();
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// compile-flags: -Z span_free_formats // compile-flags: -Z span_free_formats
// Tests that MIR inliner works for any operand // Tests that MIR inliner works for any operand
@ -9,6 +8,8 @@ fn main() {
// EMIT_MIR inline_any_operand.bar.Inline.after.mir // EMIT_MIR inline_any_operand.bar.Inline.after.mir
fn bar() -> bool { fn bar() -> bool {
// CHECK-LABEL: fn bar(
// CHECK: (inlined foo)
let f = foo; let f = foo;
f(1, -1) f(1, -1)
} }

View File

@ -1,9 +1,10 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: Inline // unit-test: Inline
// compile-flags: --crate-type=lib // compile-flags: --crate-type=lib
// EMIT_MIR inline_box_fn.call.Inline.diff // EMIT_MIR inline_box_fn.call.Inline.diff
fn call(x: Box<dyn Fn(i32)>) { fn call(x: Box<dyn Fn(i32)>) {
// CHECK-LABEL: fn call(
// CHECK-NOT: inlined
x(1); x(1);
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// compile-flags: -Z span_free_formats // compile-flags: -Z span_free_formats
// Tests that MIR inliner can handle closure arguments. (#45894) // Tests that MIR inliner can handle closure arguments. (#45894)
@ -10,5 +9,8 @@ fn main() {
// EMIT_MIR inline_closure.foo.Inline.after.mir // EMIT_MIR inline_closure.foo.Inline.after.mir
fn foo<T: Copy>(_t: T, q: i32) -> i32 { fn foo<T: Copy>(_t: T, q: i32) -> i32 {
let x = |_t, _q| _t; let x = |_t, _q| _t;
// CHECK-LABEL: fn foo(
// CHECK: (inlined foo::<T>::{closure#0})
x(q, q) x(q, q)
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// compile-flags: -Z span_free_formats -Zunsound-mir-opts // compile-flags: -Z span_free_formats -Zunsound-mir-opts
// Tests that MIR inliner can handle closure arguments, // Tests that MIR inliner can handle closure arguments,
@ -14,5 +13,8 @@ fn foo<T: Copy>(_t: T, q: &i32) -> i32 {
let variable = &*r; let variable = &*r;
*variable *variable
}; };
// CHECK-LABEL: fn foo(
// CHECK: (inlined foo::<T>::{closure#0})
x(q, q) x(q, q)
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// compile-flags: -Z span_free_formats // compile-flags: -Z span_free_formats
// Tests that MIR inliner can handle closure captures. // Tests that MIR inliner can handle closure captures.
@ -10,5 +9,8 @@ fn main() {
// EMIT_MIR inline_closure_captures.foo.Inline.after.mir // EMIT_MIR inline_closure_captures.foo.Inline.after.mir
fn foo<T: Copy>(t: T, q: i32) -> (i32, T) { fn foo<T: Copy>(t: T, q: i32) -> (i32, T) {
let x = |_q| (q, t); let x = |_q| (q, t);
// CHECK-LABEL: fn foo(
// CHECK: (inlined foo::<T>::{closure#0})
x(q) x(q)
} }

View File

@ -4,26 +4,26 @@
fn main() -> () { fn main() -> () {
let mut _0: (); let mut _0: ();
let _1: std::ops::CoroutineState<i32, bool>; let _1: std::ops::CoroutineState<i32, bool>;
let mut _2: std::pin::Pin<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>; 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:17:5: 17:8}; let mut _3: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8};
let mut _4: {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}; let mut _4: {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8};
+ let mut _5: bool; + let mut _5: bool;
scope 1 { scope 1 {
debug _r => _1; debug _r => _1;
} }
+ scope 2 (inlined g) { + scope 2 (inlined g) {
+ } + }
+ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new) { + scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new) {
+ debug pointer => _3; + debug pointer => _3;
+ scope 4 { + scope 4 {
+ scope 5 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new_unchecked) { + scope 5 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new_unchecked) {
+ debug pointer => _3; + debug pointer => _3;
+ } + }
+ } + }
+ } + }
+ scope 6 (inlined g::{closure#0}) { + scope 6 (inlined g::{closure#0}) {
+ debug a => _5; + debug a => _5;
+ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}; + let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8};
+ let mut _7: u32; + let mut _7: u32;
+ let mut _8: i32; + let mut _8: i32;
+ } + }
@ -34,22 +34,22 @@
StorageLive(_3); StorageLive(_3);
StorageLive(_4); StorageLive(_4);
- _4 = g() -> [return: bb1, unwind unreachable]; - _4 = g() -> [return: bb1, unwind unreachable];
+ _4 = {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8 (#0)}; + _4 = {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8 (#0)};
+ _3 = &mut _4; + _3 = &mut _4;
+ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}> { pointer: move _3 }; + _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}> { pointer: move _3 };
+ StorageDead(_3); + StorageDead(_3);
+ StorageLive(_5); + StorageLive(_5);
+ _5 = const false; + _5 = const false;
+ StorageLive(_6); + StorageLive(_6);
+ StorageLive(_7); + StorageLive(_7);
+ _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}); + _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8});
+ _7 = discriminant((*_6)); + _7 = discriminant((*_6));
+ switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9]; + switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9];
} }
bb1: { bb1: {
- _3 = &mut _4; - _3 = &mut _4;
- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17: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(_7);
+ StorageDead(_6); + StorageDead(_6);
+ StorageDead(_5); + StorageDead(_5);
@ -59,7 +59,7 @@
bb2: { bb2: {
- StorageDead(_3); - StorageDead(_3);
- _1 = <{coroutine@$DIR/inline_coroutine.rs:17:5: 17:8} as Coroutine<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); + StorageDead(_4);
+ _0 = const (); + _0 = const ();
+ StorageDead(_1); + StorageDead(_1);

View File

@ -4,26 +4,26 @@
fn main() -> () { fn main() -> () {
let mut _0: (); let mut _0: ();
let _1: std::ops::CoroutineState<i32, bool>; let _1: std::ops::CoroutineState<i32, bool>;
let mut _2: std::pin::Pin<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>; 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:17:5: 17:8}; let mut _3: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8};
let mut _4: {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}; let mut _4: {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8};
+ let mut _5: bool; + let mut _5: bool;
scope 1 { scope 1 {
debug _r => _1; debug _r => _1;
} }
+ scope 2 (inlined g) { + scope 2 (inlined g) {
+ } + }
+ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new) { + scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new) {
+ debug pointer => _3; + debug pointer => _3;
+ scope 4 { + scope 4 {
+ scope 5 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new_unchecked) { + scope 5 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new_unchecked) {
+ debug pointer => _3; + debug pointer => _3;
+ } + }
+ } + }
+ } + }
+ scope 6 (inlined g::{closure#0}) { + scope 6 (inlined g::{closure#0}) {
+ debug a => _5; + debug a => _5;
+ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}; + let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8};
+ let mut _7: u32; + let mut _7: u32;
+ let mut _8: i32; + let mut _8: i32;
+ } + }
@ -37,20 +37,20 @@
- } - }
- -
- bb1: { - bb1: {
+ _4 = {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8 (#0)}; + _4 = {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8 (#0)};
_3 = &mut _4; _3 = &mut _4;
- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17: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: { - bb2: {
+ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}> { pointer: move _3 }; + _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}> { pointer: move _3 };
StorageDead(_3); StorageDead(_3);
- _1 = <{coroutine@$DIR/inline_coroutine.rs:17:5: 17:8} as Coroutine<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); + StorageLive(_5);
+ _5 = const false; + _5 = const false;
+ StorageLive(_6); + StorageLive(_6);
+ StorageLive(_7); + StorageLive(_7);
+ _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}); + _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8});
+ _7 = discriminant((*_6)); + _7 = discriminant((*_6));
+ switchInt(move _7) -> [0: bb5, 1: bb9, 3: bb10, otherwise: bb11]; + switchInt(move _7) -> [0: bb5, 1: bb9, 3: bb10, otherwise: bb11];
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// compile-flags: -Zinline-mir-hint-threshold=1000 // compile-flags: -Zinline-mir-hint-threshold=1000
#![feature(coroutines, coroutine_trait)] #![feature(coroutines, coroutine_trait)]
@ -8,6 +7,9 @@ use std::pin::Pin;
// EMIT_MIR inline_coroutine.main.Inline.diff // EMIT_MIR inline_coroutine.main.Inline.diff
fn main() { fn main() {
// CHECK-LABEL: fn main(
// CHECK: (inlined g)
// CHECK: (inlined g::{closure#0})
let _r = Pin::new(&mut g()).resume(false); let _r = Pin::new(&mut g()).resume(false);
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// Tests inlining of diverging calls. // Tests inlining of diverging calls.
// //
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
@ -7,6 +6,8 @@
// EMIT_MIR inline_diverging.f.Inline.diff // EMIT_MIR inline_diverging.f.Inline.diff
pub fn f() { pub fn f() {
// CHECK-LABEL: fn f(
// CHECK: (inlined sleep)
sleep(); sleep();
} }
@ -15,12 +16,17 @@ pub fn g(i: i32) -> u32 {
if i > 0 { if i > 0 {
i as u32 i as u32
} else { } else {
// CHECK-LABEL: fn g(
// CHECK: (inlined panic)
panic(); panic();
} }
} }
// EMIT_MIR inline_diverging.h.Inline.diff // EMIT_MIR inline_diverging.h.Inline.diff
pub fn h() { pub fn h() {
// CHECK-LABEL: fn h(
// CHECK: (inlined call_twice::<!, fn() -> ! {sleep}>)
// CHECK-NOT: inlined
call_twice(sleep); call_twice(sleep);
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// Checks that only functions with the compatible instruction_set attributes are inlined. // Checks that only functions with the compatible instruction_set attributes are inlined.
// //
// A function is "compatible" when the *callee* has the same attribute or no attribute. // A function is "compatible" when the *callee* has the same attribute or no attribute.
@ -47,16 +46,26 @@ fn inline_always_and_using_inline_asm() {
// EMIT_MIR inline_instruction_set.t32.Inline.diff // EMIT_MIR inline_instruction_set.t32.Inline.diff
#[instruction_set(arm::t32)] #[instruction_set(arm::t32)]
pub fn t32() { pub fn t32() {
// CHECK-LABEL: fn t32(
// CHECK-NOT: (inlined instruction_set_a32)
instruction_set_a32(); instruction_set_a32();
// CHECK: (inlined instruction_set_t32)
instruction_set_t32(); instruction_set_t32();
// CHECK: (inlined instruction_set_default)
instruction_set_default(); instruction_set_default();
// CHECK-NOT: (inlined inline_always_and_using_inline_asm)
inline_always_and_using_inline_asm(); inline_always_and_using_inline_asm();
} }
// EMIT_MIR inline_instruction_set.default.Inline.diff // EMIT_MIR inline_instruction_set.default.Inline.diff
pub fn default() { pub fn default() {
// CHECK-LABEL: fn default(
// CHECK-NOT: (inlined instruction_set_a32)
instruction_set_a32(); instruction_set_a32();
// CHECK-NOT: (inlined instruction_set_t32)
instruction_set_t32(); instruction_set_t32();
// CHECK: (inlined instruction_set_default)
instruction_set_default(); instruction_set_default();
// CHECK: (inlined inline_always_and_using_inline_asm)
inline_always_and_using_inline_asm(); inline_always_and_using_inline_asm();
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// ignore-endian-big // ignore-endian-big
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// ignore-debug MIR alignment checks in std alter the diff, breaking the test // ignore-debug MIR alignment checks in std alter the diff, breaking the test
@ -6,5 +5,7 @@
// EMIT_MIR inline_into_box_place.main.Inline.diff // EMIT_MIR inline_into_box_place.main.Inline.diff
fn main() { fn main() {
// CHECK-LABEL: fn main(
// CHECK: (inlined Box::<Vec<u32>>::new)
let _x: Box<Vec<u32>> = Box::new(Vec::new()); let _x: Box<Vec<u32>> = Box::new(Vec::new());
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// Checks that inlining threshold can be controlled with // Checks that inlining threshold can be controlled with
// inline-mir-threshold and inline-hint-threshold options. // inline-mir-threshold and inline-hint-threshold options.
@ -8,7 +7,10 @@
// EMIT_MIR inline_options.main.Inline.after.mir // EMIT_MIR inline_options.main.Inline.after.mir
fn main() { fn main() {
// CHECK-LABEL: fn main(
// CHECK-NOT: (inlined not_inlined)
not_inlined(); not_inlined();
// CHECK: (inlined inlined::<u32>)
inlined::<u32>(); inlined::<u32>();
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// compile-flags: -Z span_free_formats -Z mir-emit-retag // compile-flags: -Z span_free_formats -Z mir-emit-retag
// Tests that MIR inliner fixes up `Retag`'s `fn_entry` flag // Tests that MIR inliner fixes up `Retag`'s `fn_entry` flag
@ -9,6 +8,17 @@ fn main() {
// EMIT_MIR inline_retag.bar.Inline.after.mir // EMIT_MIR inline_retag.bar.Inline.after.mir
fn bar() -> bool { 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; let f = foo;
f(&1, &-1) f(&1, &-1)
} }

View File

@ -1,9 +1,10 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
#![feature(specialization)] #![feature(specialization)]
// EMIT_MIR inline_specialization.main.Inline.diff // EMIT_MIR inline_specialization.main.Inline.diff
fn main() { fn main() {
// CHECK-LABEL: fn main(
// CHECK: (inlined <Vec<()> as Foo>::bar)
let x = <Vec::<()> as Foo>::bar(); let x = <Vec::<()> as Foo>::bar();
} }

View File

@ -1,4 +1,4 @@
// skip-filecheck // Verify that we do not inline the default impl in a trait object.
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// compile-flags: -Z span_free_formats // compile-flags: -Z span_free_formats
@ -8,6 +8,8 @@ fn main() {
// EMIT_MIR inline_trait_method.test.Inline.after.mir // EMIT_MIR inline_trait_method.test.Inline.after.mir
fn test(x: &dyn X) -> u32 { fn test(x: &dyn X) -> u32 {
// CHECK-LABEL: fn test(
// CHECK-NOT: inlined
x.y() x.y()
} }

View File

@ -1,9 +1,11 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// compile-flags: -Z span_free_formats -Z mir-opt-level=4 // compile-flags: -Z span_free_formats -Z mir-opt-level=4
// EMIT_MIR inline_trait_method_2.test2.Inline.after.mir // EMIT_MIR inline_trait_method_2.test2.Inline.after.mir
fn test2(x: &dyn X) -> bool { fn test2(x: &dyn X) -> bool {
// CHECK-LABEL: fn test2(
// CHECK: (inlined test)
// CHECK-NOT: (inlined <dyn X as X>::y)
test(x) test(x)
} }

View File

@ -1,21 +1,28 @@
// skip-filecheck
// EMIT_MIR issue_58867_inline_as_ref_as_mut.a.Inline.after.mir // EMIT_MIR issue_58867_inline_as_ref_as_mut.a.Inline.after.mir
pub fn a<T>(x: &mut [T]) -> &mut [T] { pub fn a<T>(x: &mut [T]) -> &mut [T] {
// CHECK-LABEL: fn a(
// CHECK: (inlined <[T] as AsMut<[T]>>::as_mut)
x.as_mut() x.as_mut()
} }
// EMIT_MIR issue_58867_inline_as_ref_as_mut.b.Inline.after.mir // EMIT_MIR issue_58867_inline_as_ref_as_mut.b.Inline.after.mir
pub fn b<T>(x: &mut Box<T>) -> &mut T { 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() x.as_mut()
} }
// EMIT_MIR issue_58867_inline_as_ref_as_mut.c.Inline.after.mir // EMIT_MIR issue_58867_inline_as_ref_as_mut.c.Inline.after.mir
pub fn c<T>(x: &[T]) -> &[T] { pub fn c<T>(x: &[T]) -> &[T] {
// CHECK-LABEL: fn c(
// CHECK: (inlined <[T] as AsRef<[T]>>::as_ref)
x.as_ref() x.as_ref()
} }
// EMIT_MIR issue_58867_inline_as_ref_as_mut.d.Inline.after.mir // EMIT_MIR issue_58867_inline_as_ref_as_mut.d.Inline.after.mir
pub fn d<T>(x: &Box<T>) -> &T { pub fn d<T>(x: &Box<T>) -> &T {
// CHECK-LABEL: fn d(
// CHECK: (inlined <Box<T> as AsRef<T>>::as_ref)
x.as_ref() x.as_ref()
} }

View File

@ -2,8 +2,8 @@
fn main() -> () { fn main() -> () {
let mut _0: (); let mut _0: ();
let _1: {closure@$DIR/issue_76997_inline_scopes_parenting.rs:6:13: 6: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:6:13: 6:16}; let mut _2: &{closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16};
let mut _3: ((),); let mut _3: ((),);
let mut _4: (); let mut _4: ();
let mut _5: (); let mut _5: ();
@ -19,7 +19,7 @@ fn main() -> () {
bb0: { bb0: {
StorageLive(_1); StorageLive(_1);
_1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:6:13: 6:16}; _1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16};
StorageLive(_2); StorageLive(_2);
_2 = &_1; _2 = &_1;
StorageLive(_3); StorageLive(_3);

View File

@ -1,8 +1,17 @@
// skip-filecheck
// Tests that MIR inliner can handle `SourceScopeData` parenting correctly. (#76997) // Tests that MIR inliner can handle `SourceScopeData` parenting correctly. (#76997)
// EMIT_MIR issue_76997_inline_scopes_parenting.main.Inline.after.mir // EMIT_MIR issue_76997_inline_scopes_parenting.main.Inline.after.mir
fn main() { 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 }; let f = |x| { let y = x; y };
f(()) f(())
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// compile-flags: -Z mir-opt-level=3 -Z inline-mir // compile-flags: -Z mir-opt-level=3 -Z inline-mir
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
#![crate_type = "lib"] #![crate_type = "lib"]
@ -9,6 +8,11 @@ pub fn bar<P>(
// Error won't happen if "bar" is not generic // Error won't happen if "bar" is not generic
_baz: P, _baz: P,
) { ) {
// CHECK-LABEL: fn bar(
// CHECK: let mut {{.*}}: &fn() {foo};
// CHECK: let {{.*}}: fn() {foo};
// CHECK: (inlined hide_foo)
// CHECK-NOT: inlined
hide_foo()(); hide_foo()();
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(unchecked_shifts)] #![feature(unchecked_shifts)]
@ -9,23 +8,31 @@
// EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff // EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff
// EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir // EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir
pub unsafe fn unchecked_shl_unsigned_smaller(a: u16, b: u32) -> u16 { 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) a.unchecked_shl(b)
} }
// EMIT_MIR unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff // EMIT_MIR unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff
// EMIT_MIR unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir // EMIT_MIR unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir
pub unsafe fn unchecked_shr_signed_smaller(a: i16, b: u32) -> i16 { 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) a.unchecked_shr(b)
} }
// EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_bigger.Inline.diff // EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_bigger.Inline.diff
// EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_bigger.PreCodegen.after.mir // EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_bigger.PreCodegen.after.mir
pub unsafe fn unchecked_shl_unsigned_bigger(a: u64, b: u32) -> u64 { 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) a.unchecked_shl(b)
} }
// EMIT_MIR unchecked_shifts.unchecked_shr_signed_bigger.Inline.diff // EMIT_MIR unchecked_shifts.unchecked_shr_signed_bigger.Inline.diff
// EMIT_MIR unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.mir // EMIT_MIR unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.mir
pub unsafe fn unchecked_shr_signed_bigger(a: i64, b: u32) -> i64 { 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) a.unchecked_shr(b)
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
// needs-unwind // needs-unwind
#![feature(unsized_fn_params)] #![feature(unsized_fn_params)]
@ -7,6 +6,8 @@ fn callee(y: [i32]) {}
// EMIT_MIR unsized_argument.caller.Inline.diff // EMIT_MIR unsized_argument.caller.Inline.diff
fn caller(x: Box<[i32]>) { fn caller(x: Box<[i32]>) {
// CHECK-LABEL: fn caller(
// CHECK-NOT: (inlined callee)
callee(*x); callee(*x);
} }

View File

@ -1,4 +1,3 @@
// skip-filecheck
#![crate_type = "lib"] #![crate_type = "lib"]
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
@ -8,5 +7,7 @@
// EMIT_MIR unwrap_unchecked.unwrap_unchecked.Inline.diff // EMIT_MIR unwrap_unchecked.unwrap_unchecked.Inline.diff
// EMIT_MIR unwrap_unchecked.unwrap_unchecked.PreCodegen.after.mir // EMIT_MIR unwrap_unchecked.unwrap_unchecked.PreCodegen.after.mir
pub unsafe fn unwrap_unchecked<T>(slf: Option<T>) -> T { 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() slf.unwrap_unchecked()
} }