about summary refs log tree commit diff
path: root/src/test/mir-opt/lower_array_len.array_len.NormalizeArrayLen.diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-10-07 11:34:40 +0000
committerbors <bors@rust-lang.org>2021-10-07 11:34:40 +0000
commit680ff86391f19e12b485293f01372036e85ba87c (patch)
tree408c58bd268e34156e8f42b8a4a36753277cba67 /src/test/mir-opt/lower_array_len.array_len.NormalizeArrayLen.diff
parentca8078d7b2e40c24a39e5fe2a910afef4c91ebfc (diff)
parenta31518fbf4843e7c998131a97f4a35beb60dd625 (diff)
downloadrust-680ff86391f19e12b485293f01372036e85ba87c.tar.gz
rust-680ff86391f19e12b485293f01372036e85ba87c.zip
Auto merge of #86525 - shamatar:array_len_opt, r=oli-obk
Array `.len()` MIR optimization pass

This pass kind-of works back the `[T; N].len()` call that at the moment is first coerced as `&[T; N]` -> `&[T]` and then uses `&[T].len()`. Depends on #86383
Diffstat (limited to 'src/test/mir-opt/lower_array_len.array_len.NormalizeArrayLen.diff')
-rw-r--r--src/test/mir-opt/lower_array_len.array_len.NormalizeArrayLen.diff30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/mir-opt/lower_array_len.array_len.NormalizeArrayLen.diff b/src/test/mir-opt/lower_array_len.array_len.NormalizeArrayLen.diff
new file mode 100644
index 00000000000..892fdda818e
--- /dev/null
+++ b/src/test/mir-opt/lower_array_len.array_len.NormalizeArrayLen.diff
@@ -0,0 +1,30 @@
+- // MIR for `array_len` before NormalizeArrayLen
++ // MIR for `array_len` after NormalizeArrayLen
+  
+  fn array_len(_1: &[u8; N]) -> usize {
+      debug arr => _1;                     // in scope 0 at $DIR/lower_array_len.rs:30:34: 30:37
+      let mut _0: usize;                   // return place in scope 0 at $DIR/lower_array_len.rs:30:52: 30:57
+      let mut _2: &[u8];                   // in scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
+      let mut _3: &[u8; N];                // in scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
++     let mut _4: &[u8; N];                // in scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
+  
+      bb0: {
+          StorageLive(_2);                 // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
+          StorageLive(_3);                 // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
+          _3 = &(*_1);                     // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
++         StorageLive(_4);                 // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
++         _4 = _3;                         // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
+          _2 = move _3 as &[u8] (Pointer(Unsize)); // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
+          StorageDead(_3);                 // scope 0 at $DIR/lower_array_len.rs:31:7: 31:8
+-         _0 = Len((*_2));                 // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
++         _0 = Len((*_4));                 // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
++         StorageDead(_4);                 // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
+          goto -> bb1;                     // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
+      }
+  
+      bb1: {
+          StorageDead(_2);                 // scope 0 at $DIR/lower_array_len.rs:31:13: 31:14
+          return;                          // scope 0 at $DIR/lower_array_len.rs:32:2: 32:2
+      }
+  }
+