Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rmehri01 committed Oct 22, 2023
1 parent f474cf4 commit 840e2fd
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 70 deletions.
3 changes: 3 additions & 0 deletions tests/mir-opt/inline/asm_unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

Expand All @@ -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();
}
3 changes: 3 additions & 0 deletions tests/mir-opt/inline/caller_with_trivial_bound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions tests/mir-opt/inline/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions tests/mir-opt/inline/dyn_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand All @@ -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>)
Expand Down
1 change: 1 addition & 0 deletions tests/mir-opt/inline/exponential_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl A for () {

// EMIT_MIR exponential_runtime.main.Inline.diff
fn main() {
// CHECK-NOT: inlined
// CHECK-LABEL: fn main(
// CHECK: (inlined <() as G>::call)
// CHECK: (inlined <() as F>::call)
Expand Down
2 changes: 1 addition & 1 deletion tests/mir-opt/inline/inline_box_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
59 changes: 0 additions & 59 deletions tests/mir-opt/inline/inline_retag.bar.Inline.after.mir

This file was deleted.

65 changes: 65 additions & 0 deletions tests/mir-opt/inline/inline_retag.bar.Inline.diff
Original file line number Diff line number Diff line change
@@ -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;
}
}

11 changes: 10 additions & 1 deletion tests/mir-opt/inline/inline_retag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion tests/mir-opt/inline/inline_trait_method.rs
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: ();
Expand All @@ -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);
Expand Down
9 changes: 7 additions & 2 deletions tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

0 comments on commit 840e2fd

Please sign in to comment.