about summary refs log tree commit diff
path: root/src/test/mir-opt/dataflow-const-prop
diff options
context:
space:
mode:
authorJannis Christopher Köhl <mail@koehl.dev>2022-10-07 01:17:43 +0200
committerJannis Christopher Köhl <mail@koehl.dev>2022-11-07 10:35:21 +0100
commitb9dbb81b5e4f62be117fd196723a85e45b84341d (patch)
tree49497342bcb06908446639257fc4cdb59e099588 /src/test/mir-opt/dataflow-const-prop
parent7a52e7350e3772ea9c04610f4d5ccd2b5b72403f (diff)
downloadrust-b9dbb81b5e4f62be117fd196723a85e45b84341d.tar.gz
rust-b9dbb81b5e4f62be117fd196723a85e45b84341d.zip
Improve example used for SB tests
Diffstat (limited to 'src/test/mir-opt/dataflow-const-prop')
-rw-r--r--src/test/mir-opt/dataflow-const-prop/ref_with_sb.main.DataflowConstProp.diff30
-rw-r--r--src/test/mir-opt/dataflow-const-prop/ref_with_sb.rs4
-rw-r--r--src/test/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff28
-rw-r--r--src/test/mir-opt/dataflow-const-prop/ref_without_sb.rs4
4 files changed, 47 insertions, 19 deletions
diff --git a/src/test/mir-opt/dataflow-const-prop/ref_with_sb.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/ref_with_sb.main.DataflowConstProp.diff
index 6a9de6af8c5..81aa0a1a93d 100644
--- a/src/test/mir-opt/dataflow-const-prop/ref_with_sb.main.DataflowConstProp.diff
+++ b/src/test/mir-opt/dataflow-const-prop/ref_with_sb.main.DataflowConstProp.diff
@@ -7,11 +7,12 @@
       let _2: ();                          // in scope 0 at $DIR/ref_with_sb.rs:+2:5: +2:15
       let mut _3: &i32;                    // in scope 0 at $DIR/ref_with_sb.rs:+2:12: +2:14
       let _4: &i32;                        // in scope 0 at $DIR/ref_with_sb.rs:+2:12: +2:14
+      let _5: ();                          // in scope 0 at $DIR/ref_with_sb.rs:+4:5: +4:20
       scope 1 {
           debug a => _1;                   // in scope 1 at $DIR/ref_with_sb.rs:+1:9: +1:14
-          let _5: i32;                     // in scope 1 at $DIR/ref_with_sb.rs:+6:9: +6:10
+          let _6: i32;                     // in scope 1 at $DIR/ref_with_sb.rs:+7:9: +7:10
           scope 2 {
-              debug b => _5;               // in scope 2 at $DIR/ref_with_sb.rs:+6:9: +6:10
+              debug b => _6;               // in scope 2 at $DIR/ref_with_sb.rs:+7:9: +7:10
           }
       }
   
@@ -25,7 +26,7 @@
           _3 = &(*_4);                     // scope 1 at $DIR/ref_with_sb.rs:+2:12: +2:14
           _2 = escape::<i32>(move _3) -> bb1; // scope 1 at $DIR/ref_with_sb.rs:+2:5: +2:15
                                            // mir::Constant
-                                           // + span: $DIR/ref_with_sb.rs:10:5: 10:11
+                                           // + span: $DIR/ref_with_sb.rs:13:5: 13:11
                                            // + literal: Const { ty: for<'a> fn(&'a i32) {escape::<i32>}, val: Value(<ZST>) }
       }
   
@@ -34,13 +35,22 @@
           StorageDead(_4);                 // scope 1 at $DIR/ref_with_sb.rs:+2:15: +2:16
           StorageDead(_2);                 // scope 1 at $DIR/ref_with_sb.rs:+2:15: +2:16
           _1 = const 1_i32;                // scope 1 at $DIR/ref_with_sb.rs:+3:5: +3:10
-          StorageLive(_5);                 // scope 1 at $DIR/ref_with_sb.rs:+6:9: +6:10
--         _5 = _1;                         // scope 1 at $DIR/ref_with_sb.rs:+6:13: +6:14
-+         _5 = const 1_i32;                // scope 1 at $DIR/ref_with_sb.rs:+6:13: +6:14
-          _0 = const ();                   // scope 0 at $DIR/ref_with_sb.rs:+0:11: +7:2
-          StorageDead(_5);                 // scope 1 at $DIR/ref_with_sb.rs:+7:1: +7:2
-          StorageDead(_1);                 // scope 0 at $DIR/ref_with_sb.rs:+7:1: +7:2
-          return;                          // scope 0 at $DIR/ref_with_sb.rs:+7:2: +7:2
+          StorageLive(_5);                 // scope 1 at $DIR/ref_with_sb.rs:+4:5: +4:20
+          _5 = some_function() -> bb2;     // scope 1 at $DIR/ref_with_sb.rs:+4:5: +4:20
+                                           // mir::Constant
+                                           // + span: $DIR/ref_with_sb.rs:15:5: 15:18
+                                           // + literal: Const { ty: fn() {some_function}, val: Value(<ZST>) }
+      }
+  
+      bb2: {
+          StorageDead(_5);                 // scope 1 at $DIR/ref_with_sb.rs:+4:20: +4:21
+          StorageLive(_6);                 // scope 1 at $DIR/ref_with_sb.rs:+7:9: +7:10
+-         _6 = _1;                         // scope 1 at $DIR/ref_with_sb.rs:+7:13: +7:14
++         _6 = const 1_i32;                // scope 1 at $DIR/ref_with_sb.rs:+7:13: +7:14
+          _0 = const ();                   // scope 0 at $DIR/ref_with_sb.rs:+0:11: +8:2
+          StorageDead(_6);                 // scope 1 at $DIR/ref_with_sb.rs:+8:1: +8:2
+          StorageDead(_1);                 // scope 0 at $DIR/ref_with_sb.rs:+8:1: +8:2
+          return;                          // scope 0 at $DIR/ref_with_sb.rs:+8:2: +8:2
       }
   }
   
diff --git a/src/test/mir-opt/dataflow-const-prop/ref_with_sb.rs b/src/test/mir-opt/dataflow-const-prop/ref_with_sb.rs
index 05f18dab4cd..060aa6ab794 100644
--- a/src/test/mir-opt/dataflow-const-prop/ref_with_sb.rs
+++ b/src/test/mir-opt/dataflow-const-prop/ref_with_sb.rs
@@ -4,11 +4,15 @@
 #[inline(never)]
 fn escape<T>(x: &T) {}
 
+#[inline(never)]
+fn some_function() {}
+
 // EMIT_MIR ref_with_sb.main.DataflowConstProp.diff
 fn main() {
     let mut a = 0;
     escape(&a);
     a = 1;
+    some_function();
     // With `-Zunsound-mir-opt`, this should be propagated
     // (because we assume Stacked Borrows).
     let b = a;
diff --git a/src/test/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff
index 66b05cdb7c1..dc6a6a8a759 100644
--- a/src/test/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff
+++ b/src/test/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff
@@ -7,11 +7,12 @@
       let _2: ();                          // in scope 0 at $DIR/ref_without_sb.rs:+2:5: +2:15
       let mut _3: &i32;                    // in scope 0 at $DIR/ref_without_sb.rs:+2:12: +2:14
       let _4: &i32;                        // in scope 0 at $DIR/ref_without_sb.rs:+2:12: +2:14
+      let _5: ();                          // in scope 0 at $DIR/ref_without_sb.rs:+4:5: +4:20
       scope 1 {
           debug a => _1;                   // in scope 1 at $DIR/ref_without_sb.rs:+1:9: +1:14
-          let _5: i32;                     // in scope 1 at $DIR/ref_without_sb.rs:+6:9: +6:10
+          let _6: i32;                     // in scope 1 at $DIR/ref_without_sb.rs:+7:9: +7:10
           scope 2 {
-              debug b => _5;               // in scope 2 at $DIR/ref_without_sb.rs:+6:9: +6:10
+              debug b => _6;               // in scope 2 at $DIR/ref_without_sb.rs:+7:9: +7:10
           }
       }
   
@@ -25,7 +26,7 @@
           _3 = &(*_4);                     // scope 1 at $DIR/ref_without_sb.rs:+2:12: +2:14
           _2 = escape::<i32>(move _3) -> bb1; // scope 1 at $DIR/ref_without_sb.rs:+2:5: +2:15
                                            // mir::Constant
-                                           // + span: $DIR/ref_without_sb.rs:9:5: 9:11
+                                           // + span: $DIR/ref_without_sb.rs:12:5: 12:11
                                            // + literal: Const { ty: for<'a> fn(&'a i32) {escape::<i32>}, val: Value(<ZST>) }
       }
   
@@ -34,12 +35,21 @@
           StorageDead(_4);                 // scope 1 at $DIR/ref_without_sb.rs:+2:15: +2:16
           StorageDead(_2);                 // scope 1 at $DIR/ref_without_sb.rs:+2:15: +2:16
           _1 = const 1_i32;                // scope 1 at $DIR/ref_without_sb.rs:+3:5: +3:10
-          StorageLive(_5);                 // scope 1 at $DIR/ref_without_sb.rs:+6:9: +6:10
-          _5 = _1;                         // scope 1 at $DIR/ref_without_sb.rs:+6:13: +6:14
-          _0 = const ();                   // scope 0 at $DIR/ref_without_sb.rs:+0:11: +7:2
-          StorageDead(_5);                 // scope 1 at $DIR/ref_without_sb.rs:+7:1: +7:2
-          StorageDead(_1);                 // scope 0 at $DIR/ref_without_sb.rs:+7:1: +7:2
-          return;                          // scope 0 at $DIR/ref_without_sb.rs:+7:2: +7:2
+          StorageLive(_5);                 // scope 1 at $DIR/ref_without_sb.rs:+4:5: +4:20
+          _5 = some_function() -> bb2;     // scope 1 at $DIR/ref_without_sb.rs:+4:5: +4:20
+                                           // mir::Constant
+                                           // + span: $DIR/ref_without_sb.rs:14:5: 14:18
+                                           // + literal: Const { ty: fn() {some_function}, val: Value(<ZST>) }
+      }
+  
+      bb2: {
+          StorageDead(_5);                 // scope 1 at $DIR/ref_without_sb.rs:+4:20: +4:21
+          StorageLive(_6);                 // scope 1 at $DIR/ref_without_sb.rs:+7:9: +7:10
+          _6 = _1;                         // scope 1 at $DIR/ref_without_sb.rs:+7:13: +7:14
+          _0 = const ();                   // scope 0 at $DIR/ref_without_sb.rs:+0:11: +8:2
+          StorageDead(_6);                 // scope 1 at $DIR/ref_without_sb.rs:+8:1: +8:2
+          StorageDead(_1);                 // scope 0 at $DIR/ref_without_sb.rs:+8:1: +8:2
+          return;                          // scope 0 at $DIR/ref_without_sb.rs:+8:2: +8:2
       }
   }
   
diff --git a/src/test/mir-opt/dataflow-const-prop/ref_without_sb.rs b/src/test/mir-opt/dataflow-const-prop/ref_without_sb.rs
index 4ef027a9b4d..4789eb69cda 100644
--- a/src/test/mir-opt/dataflow-const-prop/ref_without_sb.rs
+++ b/src/test/mir-opt/dataflow-const-prop/ref_without_sb.rs
@@ -3,11 +3,15 @@
 #[inline(never)]
 fn escape<T>(x: &T) {}
 
+#[inline(never)]
+fn some_function() {}
+
 // EMIT_MIR ref_without_sb.main.DataflowConstProp.diff
 fn main() {
     let mut a = 0;
     escape(&a);
     a = 1;
+    some_function();
     // Without `-Zunsound-mir-opt`, this should not be propagated
     // (because we do not assume Stacked Borrows).
     let b = a;