Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 75b064d

Browse files
committedNov 1, 2023
Auto merge of rust-lang#117029 - rmehri01:mir_opt_filecheck_inline_tests, r=cjgillot
Add FileCheck annotations to MIR-opt inlining tests Part of rust-lang#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
2 parents b0a0759 + 5f75326 commit 75b064d

29 files changed

+156
-51
lines changed
 

‎tests/mir-opt/inline/asm_unwind.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// skip-filecheck
21
// Tests inlining of `may_unwind` inline assembly.
32
//
43
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
54
// needs-asm-support
5+
// needs-unwind
66
// compile-flags: -Zinline-mir-hint-threshold=1000
77
#![feature(asm_unwind)]
88

@@ -20,5 +20,9 @@ fn foo() {
2020

2121
// EMIT_MIR asm_unwind.main.Inline.diff
2222
pub fn main() {
23+
// CHECK-LABEL: fn main(
24+
// CHECK: (inlined foo)
25+
// CHECK: asm!("", options(MAY_UNWIND)) -> [return: {{bb.*}}, unwind: [[unwind:bb.*]]];
26+
// CHECK: [[unwind]] (cleanup)
2327
foo();
2428
}

‎tests/mir-opt/inline/caller_with_trivial_bound.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
32
// needs-unwind
43

@@ -16,8 +15,13 @@ impl<T> Factory<T> for IntFactory {
1615
// EMIT_MIR caller_with_trivial_bound.foo.Inline.diff
1716
pub fn foo<T>()
1817
where
18+
// Because of this trivial bound, the inliner fails to normalize
19+
// `<IntFactory as Factory<T>>::Item`.
20+
// Verify that we do not inline anything, which would cause validation ICEs.
1921
IntFactory: Factory<T>,
2022
{
23+
// CHECK-LABEL: fn foo(
24+
// CHECK-NOT: (inlined bar::<T>)
2125
let mut x: <IntFactory as Factory<T>>::Item = bar::<T>();
2226
}
2327

‎tests/mir-opt/inline/cycle.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1-
// skip-filecheck
21
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
32
// compile-flags: -Zinline-mir-hint-threshold=1000
43

54
// EMIT_MIR cycle.f.Inline.diff
65
#[inline(always)]
76
fn f(g: impl Fn()) {
7+
// CHECK-LABEL: fn f(
8+
// CHECK-NOT: inlined
89
g();
910
}
1011

1112
// EMIT_MIR cycle.g.Inline.diff
1213
#[inline(always)]
1314
fn g() {
15+
// CHECK-LABEL: fn g(
16+
// CHECK-NOT: inlined
17+
// CHECK: (inlined f::<fn() {main}>)
18+
// CHECK-NOT: inlined
1419
f(main);
1520
}
1621

1722
// EMIT_MIR cycle.main.Inline.diff
1823
fn main() {
24+
// CHECK-LABEL: fn main(
25+
// CHECK-NOT: inlined
26+
// CHECK: (inlined f::<fn() {g}>)
27+
// CHECK-NOT: inlined
1928
f(g);
2029
}

‎tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
32
// compile-flags: -Zmir-enable-passes=+Inline --crate-type=lib
43

@@ -8,5 +7,7 @@ use std::marker::Tuple;
87

98
// EMIT_MIR dont_ice_on_generic_rust_call.call.Inline.diff
109
pub fn call<I: Tuple>(mut mock: Box<dyn FnMut<I, Output = ()>>, input: I) {
10+
// CHECK-LABEL: fn call(
11+
// CHECK-NOT: inlined
1112
mock.call_mut(input)
1213
}

‎tests/mir-opt/inline/dyn_trait.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
32
#![crate_type = "lib"]
43

@@ -20,18 +19,26 @@ pub trait Query {
2019
// EMIT_MIR dyn_trait.mk_cycle.Inline.diff
2120
#[inline(always)]
2221
pub fn mk_cycle<V: Debug>(c: &dyn Cache<V = V>) {
22+
// CHECK-LABEL: fn mk_cycle(
23+
// CHECK-NOT: inlined
2324
c.store_nocache()
2425
}
2526

2627
// EMIT_MIR dyn_trait.try_execute_query.Inline.diff
2728
#[inline(always)]
2829
pub fn try_execute_query<C: Cache>(c: &C) {
30+
// CHECK-LABEL: fn try_execute_query(
31+
// CHECK: (inlined mk_cycle::<<C as Cache>::V>)
2932
mk_cycle(c)
3033
}
3134

3235
// EMIT_MIR dyn_trait.get_query.Inline.diff
3336
#[inline(always)]
3437
pub fn get_query<Q: Query, T>(t: &T) {
38+
// CHECK-LABEL: fn get_query(
39+
// CHECK-NOT: inlined
3540
let c = Q::cache(t);
41+
// CHECK: (inlined try_execute_query::<<Q as Query>::C>)
42+
// CHECK: (inlined mk_cycle::<<Q as Query>::V>)
3643
try_execute_query(c)
3744
}

‎tests/mir-opt/inline/exponential_runtime.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
32
// Checks that code with exponential runtime does not have exponential behavior in inlining.
43

@@ -85,5 +84,14 @@ impl A for () {
8584

8685
// EMIT_MIR exponential_runtime.main.Inline.diff
8786
fn main() {
87+
// CHECK-LABEL: fn main(
88+
// CHECK-NOT: inlined
89+
// CHECK: (inlined <() as G>::call)
90+
// CHECK: (inlined <() as F>::call)
91+
// CHECK: (inlined <() as E>::call)
92+
// CHECK: (inlined <() as D>::call)
93+
// CHECK: (inlined <() as C>::call)
94+
// CHECK: (inlined <() as B>::call)
95+
// CHECK-NOT: inlined
8896
<() as G>::call();
8997
}

‎tests/mir-opt/inline/inline_any_operand.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// compile-flags: -Z span_free_formats
32

43
// Tests that MIR inliner works for any operand
@@ -9,6 +8,8 @@ fn main() {
98

109
// EMIT_MIR inline_any_operand.bar.Inline.after.mir
1110
fn bar() -> bool {
11+
// CHECK-LABEL: fn bar(
12+
// CHECK: (inlined foo)
1213
let f = foo;
1314
f(1, -1)
1415
}

‎tests/mir-opt/inline/inline_box_fn.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// skip-filecheck
21
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
32
// unit-test: Inline
43
// compile-flags: --crate-type=lib
54

65
// EMIT_MIR inline_box_fn.call.Inline.diff
76
fn call(x: Box<dyn Fn(i32)>) {
7+
// CHECK-LABEL: fn call(
8+
// CHECK-NOT: inlined
89
x(1);
910
}

‎tests/mir-opt/inline/inline_closure.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// compile-flags: -Z span_free_formats
32

43
// Tests that MIR inliner can handle closure arguments. (#45894)
@@ -10,5 +9,8 @@ fn main() {
109
// EMIT_MIR inline_closure.foo.Inline.after.mir
1110
fn foo<T: Copy>(_t: T, q: i32) -> i32 {
1211
let x = |_t, _q| _t;
12+
13+
// CHECK-LABEL: fn foo(
14+
// CHECK: (inlined foo::<T>::{closure#0})
1315
x(q, q)
1416
}

‎tests/mir-opt/inline/inline_closure_borrows_arg.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// compile-flags: -Z span_free_formats -Zunsound-mir-opts
32

43
// Tests that MIR inliner can handle closure arguments,
@@ -14,5 +13,8 @@ fn foo<T: Copy>(_t: T, q: &i32) -> i32 {
1413
let variable = &*r;
1514
*variable
1615
};
16+
17+
// CHECK-LABEL: fn foo(
18+
// CHECK: (inlined foo::<T>::{closure#0})
1719
x(q, q)
1820
}

‎tests/mir-opt/inline/inline_closure_captures.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// compile-flags: -Z span_free_formats
32

43
// Tests that MIR inliner can handle closure captures.
@@ -10,5 +9,8 @@ fn main() {
109
// EMIT_MIR inline_closure_captures.foo.Inline.after.mir
1110
fn foo<T: Copy>(t: T, q: i32) -> (i32, T) {
1211
let x = |_q| (q, t);
12+
13+
// CHECK-LABEL: fn foo(
14+
// CHECK: (inlined foo::<T>::{closure#0})
1315
x(q)
1416
}

‎tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44
fn main() -> () {
55
let mut _0: ();
66
let _1: std::ops::CoroutineState<i32, bool>;
7-
let mut _2: std::pin::Pin<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>;
8-
let mut _3: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8};
9-
let mut _4: {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8};
7+
let mut _2: std::pin::Pin<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>;
8+
let mut _3: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8};
9+
let mut _4: {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8};
1010
+ let mut _5: bool;
1111
scope 1 {
1212
debug _r => _1;
1313
}
1414
+ scope 2 (inlined g) {
1515
+ }
16-
+ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new) {
16+
+ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new) {
1717
+ debug pointer => _3;
1818
+ scope 4 {
19-
+ scope 5 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new_unchecked) {
19+
+ scope 5 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new_unchecked) {
2020
+ debug pointer => _3;
2121
+ }
2222
+ }
2323
+ }
2424
+ scope 6 (inlined g::{closure#0}) {
2525
+ debug a => _5;
26-
+ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8};
26+
+ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8};
2727
+ let mut _7: u32;
2828
+ let mut _8: i32;
2929
+ }
@@ -34,22 +34,22 @@
3434
StorageLive(_3);
3535
StorageLive(_4);
3636
- _4 = g() -> [return: bb1, unwind unreachable];
37-
+ _4 = {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8 (#0)};
37+
+ _4 = {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8 (#0)};
3838
+ _3 = &mut _4;
39-
+ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}> { pointer: move _3 };
39+
+ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}> { pointer: move _3 };
4040
+ StorageDead(_3);
4141
+ StorageLive(_5);
4242
+ _5 = const false;
4343
+ StorageLive(_6);
4444
+ StorageLive(_7);
45-
+ _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8});
45+
+ _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8});
4646
+ _7 = discriminant((*_6));
4747
+ switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9];
4848
}
4949

5050
bb1: {
5151
- _3 = &mut _4;
52-
- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new(move _3) -> [return: bb2, unwind unreachable];
52+
- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new(move _3) -> [return: bb2, unwind unreachable];
5353
+ StorageDead(_7);
5454
+ StorageDead(_6);
5555
+ StorageDead(_5);
@@ -59,7 +59,7 @@
5959

6060
bb2: {
6161
- StorageDead(_3);
62-
- _1 = <{coroutine@$DIR/inline_coroutine.rs:17:5: 17:8} as Coroutine<bool>>::resume(move _2, const false) -> [return: bb3, unwind unreachable];
62+
- _1 = <{coroutine@$DIR/inline_coroutine.rs:19:5: 19:8} as Coroutine<bool>>::resume(move _2, const false) -> [return: bb3, unwind unreachable];
6363
+ StorageDead(_4);
6464
+ _0 = const ();
6565
+ StorageDead(_1);

‎tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44
fn main() -> () {
55
let mut _0: ();
66
let _1: std::ops::CoroutineState<i32, bool>;
7-
let mut _2: std::pin::Pin<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>;
8-
let mut _3: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8};
9-
let mut _4: {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8};
7+
let mut _2: std::pin::Pin<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>;
8+
let mut _3: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8};
9+
let mut _4: {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8};
1010
+ let mut _5: bool;
1111
scope 1 {
1212
debug _r => _1;
1313
}
1414
+ scope 2 (inlined g) {
1515
+ }
16-
+ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new) {
16+
+ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new) {
1717
+ debug pointer => _3;
1818
+ scope 4 {
19-
+ scope 5 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new_unchecked) {
19+
+ scope 5 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new_unchecked) {
2020
+ debug pointer => _3;
2121
+ }
2222
+ }
2323
+ }
2424
+ scope 6 (inlined g::{closure#0}) {
2525
+ debug a => _5;
26-
+ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8};
26+
+ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8};
2727
+ let mut _7: u32;
2828
+ let mut _8: i32;
2929
+ }
@@ -37,20 +37,20 @@
3737
- }
3838
-
3939
- bb1: {
40-
+ _4 = {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8 (#0)};
40+
+ _4 = {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8 (#0)};
4141
_3 = &mut _4;
42-
- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new(move _3) -> [return: bb2, unwind: bb5];
42+
- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new(move _3) -> [return: bb2, unwind: bb5];
4343
- }
4444
-
4545
- bb2: {
46-
+ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}> { pointer: move _3 };
46+
+ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}> { pointer: move _3 };
4747
StorageDead(_3);
48-
- _1 = <{coroutine@$DIR/inline_coroutine.rs:17:5: 17:8} as Coroutine<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb5];
48+
- _1 = <{coroutine@$DIR/inline_coroutine.rs:19:5: 19:8} as Coroutine<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb5];
4949
+ StorageLive(_5);
5050
+ _5 = const false;
5151
+ StorageLive(_6);
5252
+ StorageLive(_7);
53-
+ _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8});
53+
+ _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8});
5454
+ _7 = discriminant((*_6));
5555
+ switchInt(move _7) -> [0: bb5, 1: bb9, 3: bb10, otherwise: bb11];
5656
}

‎tests/mir-opt/inline/inline_coroutine.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
32
// compile-flags: -Zinline-mir-hint-threshold=1000
43
#![feature(coroutines, coroutine_trait)]
@@ -8,6 +7,9 @@ use std::pin::Pin;
87

98
// EMIT_MIR inline_coroutine.main.Inline.diff
109
fn main() {
10+
// CHECK-LABEL: fn main(
11+
// CHECK: (inlined g)
12+
// CHECK: (inlined g::{closure#0})
1113
let _r = Pin::new(&mut g()).resume(false);
1214
}
1315

‎tests/mir-opt/inline/inline_diverging.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// Tests inlining of diverging calls.
32
//
43
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
@@ -7,6 +6,8 @@
76

87
// EMIT_MIR inline_diverging.f.Inline.diff
98
pub fn f() {
9+
// CHECK-LABEL: fn f(
10+
// CHECK: (inlined sleep)
1011
sleep();
1112
}
1213

@@ -15,12 +16,17 @@ pub fn g(i: i32) -> u32 {
1516
if i > 0 {
1617
i as u32
1718
} else {
19+
// CHECK-LABEL: fn g(
20+
// CHECK: (inlined panic)
1821
panic();
1922
}
2023
}
2124

2225
// EMIT_MIR inline_diverging.h.Inline.diff
2326
pub fn h() {
27+
// CHECK-LABEL: fn h(
28+
// CHECK: (inlined call_twice::<!, fn() -> ! {sleep}>)
29+
// CHECK-NOT: inlined
2430
call_twice(sleep);
2531
}
2632

‎tests/mir-opt/inline/inline_instruction_set.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// Checks that only functions with the compatible instruction_set attributes are inlined.
32
//
43
// 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() {
4746
// EMIT_MIR inline_instruction_set.t32.Inline.diff
4847
#[instruction_set(arm::t32)]
4948
pub fn t32() {
49+
// CHECK-LABEL: fn t32(
50+
// CHECK-NOT: (inlined instruction_set_a32)
5051
instruction_set_a32();
52+
// CHECK: (inlined instruction_set_t32)
5153
instruction_set_t32();
54+
// CHECK: (inlined instruction_set_default)
5255
instruction_set_default();
56+
// CHECK-NOT: (inlined inline_always_and_using_inline_asm)
5357
inline_always_and_using_inline_asm();
5458
}
5559

5660
// EMIT_MIR inline_instruction_set.default.Inline.diff
5761
pub fn default() {
62+
// CHECK-LABEL: fn default(
63+
// CHECK-NOT: (inlined instruction_set_a32)
5864
instruction_set_a32();
65+
// CHECK-NOT: (inlined instruction_set_t32)
5966
instruction_set_t32();
67+
// CHECK: (inlined instruction_set_default)
6068
instruction_set_default();
69+
// CHECK: (inlined inline_always_and_using_inline_asm)
6170
inline_always_and_using_inline_asm();
6271
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
// skip-filecheck
21
// ignore-endian-big
32
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
43
// ignore-debug MIR alignment checks in std alter the diff, breaking the test
54
// compile-flags: -Zmir-opt-level=4 -Zinline-mir-hint-threshold=200
65

76
// EMIT_MIR inline_into_box_place.main.Inline.diff
87
fn main() {
8+
// CHECK-LABEL: fn main(
9+
// CHECK: (inlined Box::<Vec<u32>>::new)
910
let _x: Box<Vec<u32>> = Box::new(Vec::new());
1011
}

‎tests/mir-opt/inline/inline_options.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
32
// Checks that inlining threshold can be controlled with
43
// inline-mir-threshold and inline-hint-threshold options.
@@ -8,7 +7,10 @@
87

98
// EMIT_MIR inline_options.main.Inline.after.mir
109
fn main() {
10+
// CHECK-LABEL: fn main(
11+
// CHECK-NOT: (inlined not_inlined)
1112
not_inlined();
13+
// CHECK: (inlined inlined::<u32>)
1214
inlined::<u32>();
1315
}
1416

‎tests/mir-opt/inline/inline_retag.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// compile-flags: -Z span_free_formats -Z mir-emit-retag
32

43
// Tests that MIR inliner fixes up `Retag`'s `fn_entry` flag
@@ -9,6 +8,17 @@ fn main() {
98

109
// EMIT_MIR inline_retag.bar.Inline.after.mir
1110
fn bar() -> bool {
11+
// CHECK-LABEL: fn bar(
12+
// CHECK: (inlined foo)
13+
// CHECK: debug x => [[x:_.*]];
14+
// CHECK: debug y => [[y:_.*]];
15+
// CHECK: bb0: {
16+
// CHECK: Retag
17+
// CHECK: Retag
18+
// CHECK: Retag([[x]]);
19+
// CHECK: Retag([[y]]);
20+
// CHECK: return;
21+
// CHECK-NEXT: }
1222
let f = foo;
1323
f(&1, &-1)
1424
}

‎tests/mir-opt/inline/inline_specialization.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// skip-filecheck
21
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
32
#![feature(specialization)]
43

54
// EMIT_MIR inline_specialization.main.Inline.diff
65
fn main() {
6+
// CHECK-LABEL: fn main(
7+
// CHECK: (inlined <Vec<()> as Foo>::bar)
78
let x = <Vec::<()> as Foo>::bar();
89
}
910

‎tests/mir-opt/inline/inline_trait_method.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// skip-filecheck
1+
// Verify that we do not inline the default impl in a trait object.
22
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
33
// compile-flags: -Z span_free_formats
44

@@ -8,6 +8,8 @@ fn main() {
88

99
// EMIT_MIR inline_trait_method.test.Inline.after.mir
1010
fn test(x: &dyn X) -> u32 {
11+
// CHECK-LABEL: fn test(
12+
// CHECK-NOT: inlined
1113
x.y()
1214
}
1315

‎tests/mir-opt/inline/inline_trait_method_2.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
// skip-filecheck
21
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
32
// compile-flags: -Z span_free_formats -Z mir-opt-level=4
43

54
// EMIT_MIR inline_trait_method_2.test2.Inline.after.mir
65
fn test2(x: &dyn X) -> bool {
6+
// CHECK-LABEL: fn test2(
7+
// CHECK: (inlined test)
8+
// CHECK-NOT: (inlined <dyn X as X>::y)
79
test(x)
810
}
911

‎tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
// skip-filecheck
21
// EMIT_MIR issue_58867_inline_as_ref_as_mut.a.Inline.after.mir
32
pub fn a<T>(x: &mut [T]) -> &mut [T] {
3+
// CHECK-LABEL: fn a(
4+
// CHECK: (inlined <[T] as AsMut<[T]>>::as_mut)
45
x.as_mut()
56
}
67

78
// EMIT_MIR issue_58867_inline_as_ref_as_mut.b.Inline.after.mir
89
pub fn b<T>(x: &mut Box<T>) -> &mut T {
10+
// CHECK-LABEL: fn b(
11+
// CHECK: (inlined <Box<T> as AsMut<T>>::as_mut)
912
x.as_mut()
1013
}
1114

1215
// EMIT_MIR issue_58867_inline_as_ref_as_mut.c.Inline.after.mir
1316
pub fn c<T>(x: &[T]) -> &[T] {
17+
// CHECK-LABEL: fn c(
18+
// CHECK: (inlined <[T] as AsRef<[T]>>::as_ref)
1419
x.as_ref()
1520
}
1621

1722
// EMIT_MIR issue_58867_inline_as_ref_as_mut.d.Inline.after.mir
1823
pub fn d<T>(x: &Box<T>) -> &T {
24+
// CHECK-LABEL: fn d(
25+
// CHECK: (inlined <Box<T> as AsRef<T>>::as_ref)
1926
x.as_ref()
2027
}
2128

‎tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
fn main() -> () {
44
let mut _0: ();
5-
let _1: {closure@$DIR/issue_76997_inline_scopes_parenting.rs:6:13: 6:16};
6-
let mut _2: &{closure@$DIR/issue_76997_inline_scopes_parenting.rs:6:13: 6:16};
5+
let _1: {closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16};
6+
let mut _2: &{closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16};
77
let mut _3: ((),);
88
let mut _4: ();
99
let mut _5: ();
@@ -19,7 +19,7 @@ fn main() -> () {
1919

2020
bb0: {
2121
StorageLive(_1);
22-
_1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:6:13: 6:16};
22+
_1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16};
2323
StorageLive(_2);
2424
_2 = &_1;
2525
StorageLive(_3);
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
// skip-filecheck
21
// Tests that MIR inliner can handle `SourceScopeData` parenting correctly. (#76997)
32

43
// EMIT_MIR issue_76997_inline_scopes_parenting.main.Inline.after.mir
54
fn main() {
5+
// CHECK-LABEL: fn main(
6+
// CHECK: scope 1 {
7+
// CHECK-NEXT: debug f
8+
// CHECK-NEXT: scope 2 (inlined main::{closure#0}) {
9+
// CHECK-NEXT: debug x
10+
// CHECK-NEXT: scope 3 {
11+
// CHECK-NEXT: debug y
12+
// CHECK-NEXT: }
13+
// CHECK-NEXT: }
14+
// CHECK-NEXT: }
615
let f = |x| { let y = x; y };
716
f(())
817
}

‎tests/mir-opt/inline/issue_78442.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// compile-flags: -Z mir-opt-level=3 -Z inline-mir
32
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
43
#![crate_type = "lib"]
@@ -9,6 +8,11 @@ pub fn bar<P>(
98
// Error won't happen if "bar" is not generic
109
_baz: P,
1110
) {
11+
// CHECK-LABEL: fn bar(
12+
// CHECK: let mut {{.*}}: &fn() {foo};
13+
// CHECK: let {{.*}}: fn() {foo};
14+
// CHECK: (inlined hide_foo)
15+
// CHECK-NOT: inlined
1216
hide_foo()();
1317
}
1418

‎tests/mir-opt/inline/unchecked_shifts.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
32
#![crate_type = "lib"]
43
#![feature(unchecked_shifts)]
@@ -9,23 +8,31 @@
98
// EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff
109
// EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir
1110
pub unsafe fn unchecked_shl_unsigned_smaller(a: u16, b: u32) -> u16 {
11+
// CHECK-LABEL: fn unchecked_shl_unsigned_smaller(
12+
// CHECK: (inlined core::num::<impl u16>::unchecked_shl)
1213
a.unchecked_shl(b)
1314
}
1415

1516
// EMIT_MIR unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff
1617
// EMIT_MIR unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir
1718
pub unsafe fn unchecked_shr_signed_smaller(a: i16, b: u32) -> i16 {
19+
// CHECK-LABEL: fn unchecked_shr_signed_smaller(
20+
// CHECK: (inlined core::num::<impl i16>::unchecked_shr)
1821
a.unchecked_shr(b)
1922
}
2023

2124
// EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_bigger.Inline.diff
2225
// EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_bigger.PreCodegen.after.mir
2326
pub unsafe fn unchecked_shl_unsigned_bigger(a: u64, b: u32) -> u64 {
27+
// CHECK-LABEL: fn unchecked_shl_unsigned_bigger(
28+
// CHECK: (inlined core::num::<impl u64>::unchecked_shl)
2429
a.unchecked_shl(b)
2530
}
2631

2732
// EMIT_MIR unchecked_shifts.unchecked_shr_signed_bigger.Inline.diff
2833
// EMIT_MIR unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.mir
2934
pub unsafe fn unchecked_shr_signed_bigger(a: i64, b: u32) -> i64 {
35+
// CHECK-LABEL: fn unchecked_shr_signed_bigger(
36+
// CHECK: (inlined core::num::<impl i64>::unchecked_shr)
3037
a.unchecked_shr(b)
3138
}

‎tests/mir-opt/inline/unsized_argument.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// needs-unwind
32
#![feature(unsized_fn_params)]
43

@@ -7,6 +6,8 @@ fn callee(y: [i32]) {}
76

87
// EMIT_MIR unsized_argument.caller.Inline.diff
98
fn caller(x: Box<[i32]>) {
9+
// CHECK-LABEL: fn caller(
10+
// CHECK-NOT: (inlined callee)
1011
callee(*x);
1112
}
1213

‎tests/mir-opt/inline/unwrap_unchecked.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
#![crate_type = "lib"]
32

43
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
@@ -8,5 +7,7 @@
87
// EMIT_MIR unwrap_unchecked.unwrap_unchecked.Inline.diff
98
// EMIT_MIR unwrap_unchecked.unwrap_unchecked.PreCodegen.after.mir
109
pub unsafe fn unwrap_unchecked<T>(slf: Option<T>) -> T {
10+
// CHECK-LABEL: fn unwrap_unchecked(
11+
// CHECK: (inlined #[track_caller] Option::<T>::unwrap_unchecked)
1112
slf.unwrap_unchecked()
1213
}

0 commit comments

Comments
 (0)
Please sign in to comment.