Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FileCheck annotations to MIR-opt inlining tests #117029

Merged
merged 29 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
62fe807
FileCheck asm_unwind
rmehri01 Oct 20, 2023
2d0a34b
FileCheck caller_with_trivial_bound
rmehri01 Oct 20, 2023
2f9aa7d
FileCheck cycle
rmehri01 Oct 20, 2023
9b3f5e1
FileCheck dont_ice_on_generic_rust_call
rmehri01 Oct 20, 2023
76faae9
FileCheck dyn_trait
rmehri01 Oct 20, 2023
f005d23
FileCheck exponential_runtime
rmehri01 Oct 20, 2023
22679cd
FileCheck inline_any_operand
rmehri01 Oct 20, 2023
de56d2d
FileCheck inline_box_fn
rmehri01 Oct 20, 2023
9d61e6a
FileCheck inline_closure_borrows_arg
rmehri01 Oct 20, 2023
5caee41
FileCheck inline_closure_captures
rmehri01 Oct 20, 2023
7ee05d2
FileCheck inline_closure
rmehri01 Oct 20, 2023
d8f33ef
FileCheck inline_diverging
rmehri01 Oct 21, 2023
20e7caa
FileCheck inline_coroutine
rmehri01 Oct 21, 2023
19c36a9
FileCheck inline_instruction_set
rmehri01 Oct 21, 2023
de82551
FileCheck inline_into_box_place
rmehri01 Oct 21, 2023
3202d4e
FileCheck inline_options
rmehri01 Oct 21, 2023
21a4c39
FileCheck inline_retag
rmehri01 Oct 21, 2023
2532566
FileCheck inline_specialization
rmehri01 Oct 21, 2023
f7acf17
FileCheck inline_trait_method_2
rmehri01 Oct 21, 2023
1b9cb5d
FileCheck inline_trait_method
rmehri01 Oct 21, 2023
773dc62
FileCheck inline_as_ref_as_mut
rmehri01 Oct 21, 2023
bb69597
FileCheck inline_scopes_parenting
rmehri01 Oct 21, 2023
5cf65eb
FileCheck issue_78442
rmehri01 Oct 21, 2023
6e047c0
FileCheck unchecked_shifts
rmehri01 Oct 21, 2023
3faf05b
FileCheck unsized_argument
rmehri01 Oct 21, 2023
6ab66c3
FileCheck unwrap_unchecked
rmehri01 Oct 21, 2023
1ec10ec
address review comments
rmehri01 Oct 22, 2023
2fcb4d9
change inline_retag to after.mir
rmehri01 Oct 31, 2023
5f75326
fix spans for inline_couroutine panic-abort
rmehri01 Nov 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tests/mir-opt/inline/asm_unwind.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// skip-filecheck
// Tests inlining of `may_unwind` inline assembly.
//
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// needs-asm-support
// needs-unwind
// compile-flags: -Zinline-mir-hint-threshold=1000
#![feature(asm_unwind)]

Expand All @@ -20,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();
}
6 changes: 5 additions & 1 deletion tests/mir-opt/inline/caller_with_trivial_bound.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// needs-unwind

Expand All @@ -16,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>,
{
rmehri01 marked this conversation as resolved.
Show resolved Hide resolved
// CHECK-LABEL: fn foo(
// CHECK-NOT: (inlined bar::<T>)
let mut x: <IntFactory as Factory<T>>::Item = bar::<T>();
}

Expand Down
11 changes: 10 additions & 1 deletion tests/mir-opt/inline/cycle.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// compile-flags: -Zinline-mir-hint-threshold=1000

// 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);
rmehri01 marked this conversation as resolved.
Show resolved Hide resolved
}

// 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);
rmehri01 marked this conversation as resolved.
Show resolved Hide resolved
}
3 changes: 2 additions & 1 deletion tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// compile-flags: -Zmir-enable-passes=+Inline --crate-type=lib

Expand All @@ -8,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)
}
9 changes: 8 additions & 1 deletion tests/mir-opt/inline/dyn_trait.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
#![crate_type = "lib"]

Expand All @@ -20,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)
}
10 changes: 9 additions & 1 deletion tests/mir-opt/inline/exponential_runtime.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// Checks that code with exponential runtime does not have exponential behavior in inlining.

Expand Down Expand Up @@ -85,5 +84,14 @@ impl A for () {

// EMIT_MIR exponential_runtime.main.Inline.diff
fn main() {
// CHECK-LABEL: fn main(
// CHECK-NOT: inlined
rmehri01 marked this conversation as resolved.
Show resolved Hide resolved
// 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();
}
3 changes: 2 additions & 1 deletion tests/mir-opt/inline/inline_any_operand.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// skip-filecheck
// compile-flags: -Z span_free_formats

// Tests that MIR inliner works for any operand
Expand All @@ -9,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)
}
Expand Down
3 changes: 2 additions & 1 deletion tests/mir-opt/inline/inline_box_fn.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: Inline
// compile-flags: --crate-type=lib

// EMIT_MIR inline_box_fn.call.Inline.diff
fn call(x: Box<dyn Fn(i32)>) {
// CHECK-LABEL: fn call(
// CHECK-NOT: inlined
x(1);
}
4 changes: 3 additions & 1 deletion tests/mir-opt/inline/inline_closure.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// skip-filecheck
// compile-flags: -Z span_free_formats

// Tests that MIR inliner can handle closure arguments. (#45894)
Expand All @@ -10,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)
}
4 changes: 3 additions & 1 deletion tests/mir-opt/inline/inline_closure_borrows_arg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// skip-filecheck
// compile-flags: -Z span_free_formats -Zunsound-mir-opts

// Tests that MIR inliner can handle closure arguments,
Expand All @@ -14,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)
}
4 changes: 3 additions & 1 deletion tests/mir-opt/inline/inline_closure_captures.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// skip-filecheck
// compile-flags: -Z span_free_formats

// Tests that MIR inliner can handle closure captures.
Expand All @@ -10,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)
}
22 changes: 11 additions & 11 deletions tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
fn main() -> () {
let mut _0: ();
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 _3: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8};
let mut _4: {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: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:17:5: 17: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 {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;
+ }
+ }
+ }
+ scope 6 (inlined g::{closure#0}) {
+ 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 _8: i32;
+ }
Expand All @@ -34,22 +34,22 @@
StorageLive(_3);
StorageLive(_4);
- _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;
+ _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);
+ StorageLive(_5);
+ _5 = const false;
+ StorageLive(_6);
+ 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));
+ switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9];
}

bb1: {
- _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(_6);
+ StorageDead(_5);
Expand All @@ -59,7 +59,7 @@

bb2: {
- 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);
+ _0 = const ();
+ StorageDead(_1);
Expand Down
22 changes: 11 additions & 11 deletions tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
fn main() -> () {
let mut _0: ();
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 _3: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8};
let mut _4: {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: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:17:5: 17: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 {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;
+ }
+ }
+ }
+ scope 6 (inlined g::{closure#0}) {
+ 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 _8: i32;
+ }
Expand All @@ -37,20 +37,20 @@
- }
-
- 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;
- _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: {
+ _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);
- _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);
+ _5 = const false;
+ StorageLive(_6);
+ 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));
+ switchInt(move _7) -> [0: bb5, 1: bb9, 3: bb10, otherwise: bb11];
}
Expand Down
4 changes: 3 additions & 1 deletion tests/mir-opt/inline/inline_coroutine.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// compile-flags: -Zinline-mir-hint-threshold=1000
#![feature(coroutines, coroutine_trait)]
Expand All @@ -8,6 +7,9 @@ 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);
}

Expand Down
8 changes: 7 additions & 1 deletion tests/mir-opt/inline/inline_diverging.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// skip-filecheck
// Tests inlining of diverging calls.
//
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
Expand All @@ -7,6 +6,8 @@

// EMIT_MIR inline_diverging.f.Inline.diff
pub fn f() {
// CHECK-LABEL: fn f(
// CHECK: (inlined sleep)
sleep();
}

Expand All @@ -15,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);
}

Expand Down
Loading
Loading