Skip to content

Commit 1f35769

Browse files
committed
address review comments
1 parent f474cf4 commit 1f35769

13 files changed

+100
-70
lines changed

tests/mir-opt/inline/asm_unwind.rs

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//
33
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
44
// needs-asm-support
5+
// needs-unwind
56
// compile-flags: -Zinline-mir-hint-threshold=1000
67
#![feature(asm_unwind)]
78

@@ -21,5 +22,7 @@ fn foo() {
2122
pub fn main() {
2223
// CHECK-LABEL: fn main(
2324
// CHECK: (inlined foo)
25+
// CHECK: asm!("", options(MAY_UNWIND)) -> [return: {{bb.*}}, unwind: [[unwind:bb.*]]];
26+
// CHECK: [[unwind]] (cleanup)
2427
foo();
2528
}

tests/mir-opt/inline/caller_with_trivial_bound.rs

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ impl<T> Factory<T> for IntFactory {
1515
// EMIT_MIR caller_with_trivial_bound.foo.Inline.diff
1616
pub fn foo<T>()
1717
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.
1821
IntFactory: Factory<T>,
1922
{
2023
// CHECK-LABEL: fn foo(

tests/mir-opt/inline/cycle.rs

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ fn f(g: impl Fn()) {
1313
#[inline(always)]
1414
fn g() {
1515
// CHECK-LABEL: fn g(
16+
// CHECK-NOT: inlined
1617
// CHECK: (inlined f::<fn() {main}>)
1718
// CHECK-NOT: inlined
1819
f(main);
@@ -21,6 +22,7 @@ fn g() {
2122
// EMIT_MIR cycle.main.Inline.diff
2223
fn main() {
2324
// CHECK-LABEL: fn main(
25+
// CHECK-NOT: inlined
2426
// CHECK: (inlined f::<fn() {g}>)
2527
// CHECK-NOT: inlined
2628
f(g);

tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ use std::marker::Tuple;
88
// EMIT_MIR dont_ice_on_generic_rust_call.call.Inline.diff
99
pub fn call<I: Tuple>(mut mock: Box<dyn FnMut<I, Output = ()>>, input: I) {
1010
// CHECK-LABEL: fn call(
11-
// CHECK-NOT: (inlined <Box<dyn FnMut<I, Output = ()>> as FnMut<I>>::call_mut)
11+
// CHECK-NOT: inlined
1212
mock.call_mut(input)
1313
}

tests/mir-opt/inline/dyn_trait.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub trait Query {
2020
#[inline(always)]
2121
pub fn mk_cycle<V: Debug>(c: &dyn Cache<V = V>) {
2222
// CHECK-LABEL: fn mk_cycle(
23-
// CHECK-NOT: (inlined <dyn Cache<V = V> as Cache>::store_nocache)
23+
// CHECK-NOT: inlined
2424
c.store_nocache()
2525
}
2626

@@ -36,7 +36,7 @@ pub fn try_execute_query<C: Cache>(c: &C) {
3636
#[inline(always)]
3737
pub fn get_query<Q: Query, T>(t: &T) {
3838
// CHECK-LABEL: fn get_query(
39-
// CHECK-NOT: (inlined <Q as Query>::cache::<T>)
39+
// CHECK-NOT: inlined
4040
let c = Q::cache(t);
4141
// CHECK: (inlined try_execute_query::<<Q as Query>::C>)
4242
// CHECK: (inlined mk_cycle::<<Q as Query>::V>)

tests/mir-opt/inline/exponential_runtime.rs

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ impl A for () {
8585
// EMIT_MIR exponential_runtime.main.Inline.diff
8686
fn main() {
8787
// CHECK-LABEL: fn main(
88+
// CHECK-NOT: inlined
8889
// CHECK: (inlined <() as G>::call)
8990
// CHECK: (inlined <() as F>::call)
9091
// CHECK: (inlined <() as E>::call)

tests/mir-opt/inline/inline_box_fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
// EMIT_MIR inline_box_fn.call.Inline.diff
66
fn call(x: Box<dyn Fn(i32)>) {
77
// CHECK-LABEL: fn call(
8-
// CHECK-NOT: (inlined <Box<dyn Fn(i32)> as Fn<(i32,)>>::call)
8+
// CHECK-NOT: inlined
99
x(1);
1010
}

tests/mir-opt/inline/inline_retag.bar.Inline.after.mir

-59
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
- // MIR for `bar` before Inline
2+
+ // MIR for `bar` after Inline
3+
4+
fn bar() -> bool {
5+
let mut _0: bool;
6+
let _1: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo};
7+
let mut _2: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo};
8+
let mut _3: &i32;
9+
let _4: &i32;
10+
let _5: i32;
11+
let mut _6: &i32;
12+
let _7: &i32;
13+
let _8: i32;
14+
scope 1 {
15+
debug f => _1;
16+
let mut _9: &i32;
17+
let mut _10: &i32;
18+
+ scope 2 (inlined foo) {
19+
+ debug x => _3;
20+
+ debug y => _6;
21+
+ let mut _11: i32;
22+
+ let mut _12: i32;
23+
+ }
24+
}
25+
26+
bb0: {
27+
StorageLive(_1);
28+
_1 = foo;
29+
StorageLive(_2);
30+
_2 = _1;
31+
StorageLive(_3);
32+
StorageLive(_4);
33+
_10 = const _;
34+
Retag(_10);
35+
_4 = &(*_10);
36+
_3 = &(*_4);
37+
StorageLive(_6);
38+
StorageLive(_7);
39+
_9 = const _;
40+
Retag(_9);
41+
_7 = &(*_9);
42+
_6 = &(*_7);
43+
- _0 = move _2(move _3, move _6) -> [return: bb1, unwind continue];
44+
- }
45+
-
46+
- bb1: {
47+
+ Retag(_3);
48+
+ Retag(_6);
49+
+ StorageLive(_11);
50+
+ _11 = (*_3);
51+
+ StorageLive(_12);
52+
+ _12 = (*_6);
53+
+ _0 = Eq(move _11, move _12);
54+
+ StorageDead(_12);
55+
+ StorageDead(_11);
56+
StorageDead(_6);
57+
StorageDead(_3);
58+
StorageDead(_2);
59+
StorageDead(_1);
60+
StorageDead(_7);
61+
StorageDead(_4);
62+
return;
63+
}
64+
}
65+

tests/mir-opt/inline/inline_retag.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,19 @@ fn main() {
66
println!("{}", bar());
77
}
88

9-
// EMIT_MIR inline_retag.bar.Inline.after.mir
9+
// EMIT_MIR inline_retag.bar.Inline.diff
1010
fn bar() -> bool {
1111
// CHECK-LABEL: fn bar(
1212
// 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: }
1322
let f = foo;
1423
f(&1, &-1)
1524
}

tests/mir-opt/inline/inline_trait_method.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Verify that we do not inline the default impl in a trait object.
12
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
23
// compile-flags: -Z span_free_formats
34

@@ -8,7 +9,7 @@ fn main() {
89
// EMIT_MIR inline_trait_method.test.Inline.after.mir
910
fn test(x: &dyn X) -> u32 {
1011
// CHECK-LABEL: fn test(
11-
// CHECK-NOT: (inlined <dyn X as X>::y)
12+
// CHECK-NOT: inlined
1213
x.y()
1314
}
1415

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

+3-3
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:10:13: 10:16};
6-
let mut _2: &{closure@$DIR/issue_76997_inline_scopes_parenting.rs:10:13: 10: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:10:13: 10:16};
22+
_1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16};
2323
StorageLive(_2);
2424
_2 = &_1;
2525
StorageLive(_3);

tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
// EMIT_MIR issue_76997_inline_scopes_parenting.main.Inline.after.mir
44
fn main() {
55
// CHECK-LABEL: fn main(
6-
// CHECK: scope 2
6+
// CHECK: scope 1 {
7+
// CHECK-NEXT: debug f
8+
// CHECK-NEXT: scope 2 (inlined main::{closure#0}) {
79
// CHECK-NEXT: debug x
8-
// CHECK-NEXT: scope 3
10+
// CHECK-NEXT: scope 3 {
911
// CHECK-NEXT: debug y
12+
// CHECK-NEXT: }
13+
// CHECK-NEXT: }
14+
// CHECK-NEXT: }
1015
let f = |x| { let y = x; y };
1116
f(())
1217
}

0 commit comments

Comments
 (0)