about summary refs log tree commit diff
path: root/tests/mir-opt/nll
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2024-12-01 20:14:04 -0800
committerScott McMurray <scottmcm@users.noreply.github.com>2024-12-03 11:05:45 -0800
commit612adbb6bf88ecf549fb93cb1f4edcf793bca88e (patch)
tree3f37a1552ccefe3df0da67281b5e060bcc2d3d21 /tests/mir-opt/nll
parent490b2cc09860dd62a7595bb07364d71c12ce4e60 (diff)
downloadrust-612adbb6bf88ecf549fb93cb1f4edcf793bca88e.tar.gz
rust-612adbb6bf88ecf549fb93cb1f4edcf793bca88e.zip
Bounds-check with PtrMetadata instead of Len in MIR
Diffstat (limited to 'tests/mir-opt/nll')
-rw-r--r--tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir47
-rw-r--r--tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir47
2 files changed, 46 insertions, 48 deletions
diff --git a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir
index 7294302609a..35e44b2314a 100644
--- a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir
+++ b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir
@@ -27,20 +27,19 @@ fn main() -> () {
     let mut _0: ();
     let mut _1: [usize; ValTree(Leaf(0x00000003): usize)];
     let _3: usize;
-    let mut _4: usize;
-    let mut _5: bool;
-    let mut _7: bool;
-    let _8: bool;
-    let mut _9: usize;
-    let _10: bool;
+    let mut _4: bool;
+    let mut _6: bool;
+    let _7: bool;
+    let mut _8: usize;
+    let _9: bool;
     scope 1 {
         debug v => _1;
         let _2: &'?3 usize;
         scope 2 {
             debug p => _2;
-            let _6: &'?4 usize;
+            let _5: &'?4 usize;
             scope 3 {
-                debug q => _6;
+                debug q => _5;
             }
         }
     }
@@ -52,50 +51,50 @@ fn main() -> () {
         StorageLive(_2);
         StorageLive(_3);
         _3 = const ConstValue(Scalar(0x00000000): usize);
-        _4 = Len(_1);
-        _5 = Lt(copy _3, copy _4);
-        assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, copy _3) -> [success: bb1, unwind: bb7];
+        FakeRead(ForIndex, _1);
+        _4 = Lt(copy _3, const ConstValue(Scalar(0x00000003): usize));
+        assert(move _4, "index out of bounds: the length is {} but the index is {}", const ConstValue(Scalar(0x00000003): usize), copy _3) -> [success: bb1, unwind: bb7];
     }
 
     bb1: {
         _2 = &'?2 _1[_3];
         FakeRead(ForLet(None), _2);
+        StorageLive(_5);
+        _5 = copy _2;
+        FakeRead(ForLet(None), _5);
         StorageLive(_6);
-        _6 = copy _2;
-        FakeRead(ForLet(None), _6);
-        StorageLive(_7);
-        _7 = const ConstValue(Scalar(0x01): bool);
-        switchInt(move _7) -> [0: bb4, otherwise: bb2];
+        _6 = const ConstValue(Scalar(0x01): bool);
+        switchInt(move _6) -> [0: bb4, otherwise: bb2];
     }
 
     bb2: {
+        StorageLive(_7);
         StorageLive(_8);
-        StorageLive(_9);
-        _9 = copy (*_6);
-        _8 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(move _9) -> [return: bb3, unwind: bb7];
+        _8 = copy (*_5);
+        _7 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(move _8) -> [return: bb3, unwind: bb7];
     }
 
     bb3: {
-        StorageDead(_9);
         StorageDead(_8);
+        StorageDead(_7);
         _0 = const ConstValue(ZeroSized: ());
         goto -> bb6;
     }
 
     bb4: {
-        StorageLive(_10);
-        _10 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(const ConstValue(Scalar(0x00000016): usize)) -> [return: bb5, unwind: bb7];
+        StorageLive(_9);
+        _9 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(const ConstValue(Scalar(0x00000016): usize)) -> [return: bb5, unwind: bb7];
     }
 
     bb5: {
-        StorageDead(_10);
+        StorageDead(_9);
         _0 = const ConstValue(ZeroSized: ());
         goto -> bb6;
     }
 
     bb6: {
-        StorageDead(_7);
         StorageDead(_6);
+        StorageDead(_5);
         StorageDead(_3);
         StorageDead(_2);
         StorageDead(_1);
diff --git a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir
index 85b89a013c4..6d415f42d06 100644
--- a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir
+++ b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir
@@ -27,20 +27,19 @@ fn main() -> () {
     let mut _0: ();
     let mut _1: [usize; ValTree(Leaf(0x0000000000000003): usize)];
     let _3: usize;
-    let mut _4: usize;
-    let mut _5: bool;
-    let mut _7: bool;
-    let _8: bool;
-    let mut _9: usize;
-    let _10: bool;
+    let mut _4: bool;
+    let mut _6: bool;
+    let _7: bool;
+    let mut _8: usize;
+    let _9: bool;
     scope 1 {
         debug v => _1;
         let _2: &'?3 usize;
         scope 2 {
             debug p => _2;
-            let _6: &'?4 usize;
+            let _5: &'?4 usize;
             scope 3 {
-                debug q => _6;
+                debug q => _5;
             }
         }
     }
@@ -52,50 +51,50 @@ fn main() -> () {
         StorageLive(_2);
         StorageLive(_3);
         _3 = const ConstValue(Scalar(0x0000000000000000): usize);
-        _4 = Len(_1);
-        _5 = Lt(copy _3, copy _4);
-        assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, copy _3) -> [success: bb1, unwind: bb7];
+        FakeRead(ForIndex, _1);
+        _4 = Lt(copy _3, const ConstValue(Scalar(0x0000000000000003): usize));
+        assert(move _4, "index out of bounds: the length is {} but the index is {}", const ConstValue(Scalar(0x0000000000000003): usize), copy _3) -> [success: bb1, unwind: bb7];
     }
 
     bb1: {
         _2 = &'?2 _1[_3];
         FakeRead(ForLet(None), _2);
+        StorageLive(_5);
+        _5 = copy _2;
+        FakeRead(ForLet(None), _5);
         StorageLive(_6);
-        _6 = copy _2;
-        FakeRead(ForLet(None), _6);
-        StorageLive(_7);
-        _7 = const ConstValue(Scalar(0x01): bool);
-        switchInt(move _7) -> [0: bb4, otherwise: bb2];
+        _6 = const ConstValue(Scalar(0x01): bool);
+        switchInt(move _6) -> [0: bb4, otherwise: bb2];
     }
 
     bb2: {
+        StorageLive(_7);
         StorageLive(_8);
-        StorageLive(_9);
-        _9 = copy (*_6);
-        _8 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(move _9) -> [return: bb3, unwind: bb7];
+        _8 = copy (*_5);
+        _7 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(move _8) -> [return: bb3, unwind: bb7];
     }
 
     bb3: {
-        StorageDead(_9);
         StorageDead(_8);
+        StorageDead(_7);
         _0 = const ConstValue(ZeroSized: ());
         goto -> bb6;
     }
 
     bb4: {
-        StorageLive(_10);
-        _10 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(const ConstValue(Scalar(0x0000000000000016): usize)) -> [return: bb5, unwind: bb7];
+        StorageLive(_9);
+        _9 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(const ConstValue(Scalar(0x0000000000000016): usize)) -> [return: bb5, unwind: bb7];
     }
 
     bb5: {
-        StorageDead(_10);
+        StorageDead(_9);
         _0 = const ConstValue(ZeroSized: ());
         goto -> bb6;
     }
 
     bb6: {
-        StorageDead(_7);
         StorageDead(_6);
+        StorageDead(_5);
         StorageDead(_3);
         StorageDead(_2);
         StorageDead(_1);