about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRyan Mehri <ryan.mehri1@gmail.com>2023-10-22 09:27:43 -0700
committerRyan Mehri <ryan.mehri1@gmail.com>2023-10-25 15:25:38 -0700
commit1ec10ec77f6fa64de7c03150bfbb831dec376357 (patch)
tree2b9b8dd1798ab1d23de134fe1da8d6141ee1dbf3
parent6ab66c3f3724e71d228d498a52f02cb358f9247e (diff)
downloadrust-1ec10ec77f6fa64de7c03150bfbb831dec376357.tar.gz
rust-1ec10ec77f6fa64de7c03150bfbb831dec376357.zip
address review comments
-rw-r--r--tests/mir-opt/inline/asm_unwind.rs3
-rw-r--r--tests/mir-opt/inline/caller_with_trivial_bound.rs3
-rw-r--r--tests/mir-opt/inline/cycle.rs2
-rw-r--r--tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs2
-rw-r--r--tests/mir-opt/inline/dyn_trait.rs4
-rw-r--r--tests/mir-opt/inline/exponential_runtime.rs1
-rw-r--r--tests/mir-opt/inline/inline_box_fn.rs2
-rw-r--r--tests/mir-opt/inline/inline_retag.bar.Inline.after.mir59
-rw-r--r--tests/mir-opt/inline/inline_retag.bar.Inline.diff65
-rw-r--r--tests/mir-opt/inline/inline_retag.rs11
-rw-r--r--tests/mir-opt/inline/inline_trait_method.rs3
-rw-r--r--tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir6
-rw-r--r--tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs9
13 files changed, 100 insertions, 70 deletions
diff --git a/tests/mir-opt/inline/asm_unwind.rs b/tests/mir-opt/inline/asm_unwind.rs
index 596a4592f25..0ae20e52211 100644
--- a/tests/mir-opt/inline/asm_unwind.rs
+++ b/tests/mir-opt/inline/asm_unwind.rs
@@ -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();
 }
diff --git a/tests/mir-opt/inline/caller_with_trivial_bound.rs b/tests/mir-opt/inline/caller_with_trivial_bound.rs
index 722c7f6724e..40f7f4bbab2 100644
--- a/tests/mir-opt/inline/caller_with_trivial_bound.rs
+++ b/tests/mir-opt/inline/caller_with_trivial_bound.rs
@@ -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(
diff --git a/tests/mir-opt/inline/cycle.rs b/tests/mir-opt/inline/cycle.rs
index 8716b44b3dc..350724235ba 100644
--- a/tests/mir-opt/inline/cycle.rs
+++ b/tests/mir-opt/inline/cycle.rs
@@ -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);
diff --git a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs
index 3307a1408fb..ce5e1855a71 100644
--- a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs
+++ b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs
@@ -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)
 }
diff --git a/tests/mir-opt/inline/dyn_trait.rs b/tests/mir-opt/inline/dyn_trait.rs
index 005cf155fdb..ecf220a85e6 100644
--- a/tests/mir-opt/inline/dyn_trait.rs
+++ b/tests/mir-opt/inline/dyn_trait.rs
@@ -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>)
diff --git a/tests/mir-opt/inline/exponential_runtime.rs b/tests/mir-opt/inline/exponential_runtime.rs
index 499bec33ffc..1199ce4e558 100644
--- a/tests/mir-opt/inline/exponential_runtime.rs
+++ b/tests/mir-opt/inline/exponential_runtime.rs
@@ -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)
diff --git a/tests/mir-opt/inline/inline_box_fn.rs b/tests/mir-opt/inline/inline_box_fn.rs
index 7686477c291..d2da2393992 100644
--- a/tests/mir-opt/inline/inline_box_fn.rs
+++ b/tests/mir-opt/inline/inline_box_fn.rs
@@ -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);
 }
diff --git a/tests/mir-opt/inline/inline_retag.bar.Inline.after.mir b/tests/mir-opt/inline/inline_retag.bar.Inline.after.mir
deleted file mode 100644
index 8c3f3a4589e..00000000000
--- a/tests/mir-opt/inline/inline_retag.bar.Inline.after.mir
+++ /dev/null
@@ -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;
-    }
-}
diff --git a/tests/mir-opt/inline/inline_retag.bar.Inline.diff b/tests/mir-opt/inline/inline_retag.bar.Inline.diff
new file mode 100644
index 00000000000..8f53f6342ec
--- /dev/null
+++ b/tests/mir-opt/inline/inline_retag.bar.Inline.diff
@@ -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;
+      }
+  }
+  
diff --git a/tests/mir-opt/inline/inline_retag.rs b/tests/mir-opt/inline/inline_retag.rs
index c90c0b819b7..b9058905892 100644
--- a/tests/mir-opt/inline/inline_retag.rs
+++ b/tests/mir-opt/inline/inline_retag.rs
@@ -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)
 }
diff --git a/tests/mir-opt/inline/inline_trait_method.rs b/tests/mir-opt/inline/inline_trait_method.rs
index ea09966a2aa..b39355637a1 100644
--- a/tests/mir-opt/inline/inline_trait_method.rs
+++ b/tests/mir-opt/inline/inline_trait_method.rs
@@ -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()
 }
 
diff --git a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir
index ba5eb757cf9..ba4f91b28d5 100644
--- a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir
+++ b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir
@@ -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);
diff --git a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs
index 2a7c931a659..2fb363c1904 100644
--- a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs
+++ b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs
@@ -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(())
 }