address review comments
This commit is contained in:
parent
6ab66c3f37
commit
1ec10ec77f
@ -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)]
|
||||
|
||||
@ -21,5 +22,7 @@ fn foo() {
|
||||
pub fn main() {
|
||||
// CHECK-LABEL: fn main(
|
||||
// CHECK: (inlined foo)
|
||||
// CHECK: asm!("", options(MAY_UNWIND)) -> [return: {{bb.*}}, unwind: [[unwind:bb.*]]];
|
||||
// CHECK: [[unwind]] (cleanup)
|
||||
foo();
|
||||
}
|
||||
|
@ -15,6 +15,9 @@ 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(
|
||||
|
@ -13,6 +13,7 @@ fn f(g: impl Fn()) {
|
||||
#[inline(always)]
|
||||
fn g() {
|
||||
// CHECK-LABEL: fn g(
|
||||
// CHECK-NOT: inlined
|
||||
// CHECK: (inlined f::<fn() {main}>)
|
||||
// CHECK-NOT: inlined
|
||||
f(main);
|
||||
@ -21,6 +22,7 @@ fn g() {
|
||||
// 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);
|
||||
|
@ -8,6 +8,6 @@ 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 <Box<dyn FnMut<I, Output = ()>> as FnMut<I>>::call_mut)
|
||||
// CHECK-NOT: inlined
|
||||
mock.call_mut(input)
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ pub trait Query {
|
||||
#[inline(always)]
|
||||
pub fn mk_cycle<V: Debug>(c: &dyn Cache<V = V>) {
|
||||
// CHECK-LABEL: fn mk_cycle(
|
||||
// CHECK-NOT: (inlined <dyn Cache<V = V> as Cache>::store_nocache)
|
||||
// CHECK-NOT: inlined
|
||||
c.store_nocache()
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ pub fn try_execute_query<C: Cache>(c: &C) {
|
||||
#[inline(always)]
|
||||
pub fn get_query<Q: Query, T>(t: &T) {
|
||||
// CHECK-LABEL: fn get_query(
|
||||
// CHECK-NOT: (inlined <Q as Query>::cache::<T>)
|
||||
// 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>)
|
||||
|
@ -85,6 +85,7 @@ 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)
|
||||
|
@ -5,6 +5,6 @@
|
||||
// EMIT_MIR inline_box_fn.call.Inline.diff
|
||||
fn call(x: Box<dyn Fn(i32)>) {
|
||||
// CHECK-LABEL: fn call(
|
||||
// CHECK-NOT: (inlined <Box<dyn Fn(i32)> as Fn<(i32,)>>::call)
|
||||
// CHECK-NOT: inlined
|
||||
x(1);
|
||||
}
|
||||
|
@ -1,59 +0,0 @@
|
||||
// MIR for `bar` after Inline
|
||||
|
||||
fn bar() -> bool {
|
||||
let mut _0: bool;
|
||||
let _1: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo};
|
||||
let mut _2: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo};
|
||||
let mut _3: &i32;
|
||||
let _4: &i32;
|
||||
let _5: i32;
|
||||
let mut _6: &i32;
|
||||
let _7: &i32;
|
||||
let _8: i32;
|
||||
scope 1 {
|
||||
debug f => _1;
|
||||
let mut _9: &i32;
|
||||
let mut _10: &i32;
|
||||
scope 2 (inlined foo) {
|
||||
debug x => _3;
|
||||
debug y => _6;
|
||||
let mut _11: i32;
|
||||
let mut _12: i32;
|
||||
}
|
||||
}
|
||||
|
||||
bb0: {
|
||||
StorageLive(_1);
|
||||
_1 = foo;
|
||||
StorageLive(_2);
|
||||
_2 = _1;
|
||||
StorageLive(_3);
|
||||
StorageLive(_4);
|
||||
_10 = const _;
|
||||
Retag(_10);
|
||||
_4 = &(*_10);
|
||||
_3 = &(*_4);
|
||||
StorageLive(_6);
|
||||
StorageLive(_7);
|
||||
_9 = const _;
|
||||
Retag(_9);
|
||||
_7 = &(*_9);
|
||||
_6 = &(*_7);
|
||||
Retag(_3);
|
||||
Retag(_6);
|
||||
StorageLive(_11);
|
||||
_11 = (*_3);
|
||||
StorageLive(_12);
|
||||
_12 = (*_6);
|
||||
_0 = Eq(move _11, move _12);
|
||||
StorageDead(_12);
|
||||
StorageDead(_11);
|
||||
StorageDead(_6);
|
||||
StorageDead(_3);
|
||||
StorageDead(_2);
|
||||
StorageDead(_1);
|
||||
StorageDead(_7);
|
||||
StorageDead(_4);
|
||||
return;
|
||||
}
|
||||
}
|
65
tests/mir-opt/inline/inline_retag.bar.Inline.diff
Normal file
65
tests/mir-opt/inline/inline_retag.bar.Inline.diff
Normal file
@ -0,0 +1,65 @@
|
||||
- // MIR for `bar` before Inline
|
||||
+ // MIR for `bar` after Inline
|
||||
|
||||
fn bar() -> bool {
|
||||
let mut _0: bool;
|
||||
let _1: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo};
|
||||
let mut _2: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo};
|
||||
let mut _3: &i32;
|
||||
let _4: &i32;
|
||||
let _5: i32;
|
||||
let mut _6: &i32;
|
||||
let _7: &i32;
|
||||
let _8: i32;
|
||||
scope 1 {
|
||||
debug f => _1;
|
||||
let mut _9: &i32;
|
||||
let mut _10: &i32;
|
||||
+ scope 2 (inlined foo) {
|
||||
+ debug x => _3;
|
||||
+ debug y => _6;
|
||||
+ let mut _11: i32;
|
||||
+ let mut _12: i32;
|
||||
+ }
|
||||
}
|
||||
|
||||
bb0: {
|
||||
StorageLive(_1);
|
||||
_1 = foo;
|
||||
StorageLive(_2);
|
||||
_2 = _1;
|
||||
StorageLive(_3);
|
||||
StorageLive(_4);
|
||||
_10 = const _;
|
||||
Retag(_10);
|
||||
_4 = &(*_10);
|
||||
_3 = &(*_4);
|
||||
StorageLive(_6);
|
||||
StorageLive(_7);
|
||||
_9 = const _;
|
||||
Retag(_9);
|
||||
_7 = &(*_9);
|
||||
_6 = &(*_7);
|
||||
- _0 = move _2(move _3, move _6) -> [return: bb1, unwind continue];
|
||||
- }
|
||||
-
|
||||
- bb1: {
|
||||
+ Retag(_3);
|
||||
+ Retag(_6);
|
||||
+ StorageLive(_11);
|
||||
+ _11 = (*_3);
|
||||
+ StorageLive(_12);
|
||||
+ _12 = (*_6);
|
||||
+ _0 = Eq(move _11, move _12);
|
||||
+ StorageDead(_12);
|
||||
+ StorageDead(_11);
|
||||
StorageDead(_6);
|
||||
StorageDead(_3);
|
||||
StorageDead(_2);
|
||||
StorageDead(_1);
|
||||
StorageDead(_7);
|
||||
StorageDead(_4);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,19 @@ fn main() {
|
||||
println!("{}", bar());
|
||||
}
|
||||
|
||||
// EMIT_MIR inline_retag.bar.Inline.after.mir
|
||||
// EMIT_MIR inline_retag.bar.Inline.diff
|
||||
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)
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
@ -8,7 +9,7 @@ fn main() {
|
||||
// EMIT_MIR inline_trait_method.test.Inline.after.mir
|
||||
fn test(x: &dyn X) -> u32 {
|
||||
// CHECK-LABEL: fn test(
|
||||
// CHECK-NOT: (inlined <dyn X as X>::y)
|
||||
// CHECK-NOT: inlined
|
||||
x.y()
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
fn main() -> () {
|
||||
let mut _0: ();
|
||||
let _1: {closure@$DIR/issue_76997_inline_scopes_parenting.rs:10:13: 10:16};
|
||||
let mut _2: &{closure@$DIR/issue_76997_inline_scopes_parenting.rs:10:13: 10: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:10:13: 10:16};
|
||||
_1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16};
|
||||
StorageLive(_2);
|
||||
_2 = &_1;
|
||||
StorageLive(_3);
|
||||
|
@ -3,10 +3,15 @@
|
||||
// EMIT_MIR issue_76997_inline_scopes_parenting.main.Inline.after.mir
|
||||
fn main() {
|
||||
// CHECK-LABEL: fn main(
|
||||
// CHECK: scope 2
|
||||
// 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: scope 3 {
|
||||
// CHECK-NEXT: debug y
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: }
|
||||
let f = |x| { let y = x; y };
|
||||
f(())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user