diff options
| author | bors <bors@rust-lang.org> | 2023-04-26 15:52:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-04-26 15:52:33 +0000 |
| commit | 9c044d77a334609513f3b615e0763a40cc02424d (patch) | |
| tree | ae444821302a827fe1af2cc2a2da4396e099c6c3 /tests | |
| parent | 8763965a2c7b68a33af5fc55999f9eff26749fd6 (diff) | |
| parent | 05a665f21a6f9763d136a9d2d7c0255de6d333fb (diff) | |
| download | rust-9c044d77a334609513f3b615e0763a40cc02424d.tar.gz rust-9c044d77a334609513f3b615e0763a40cc02424d.zip | |
Auto merge of #110822 - scottmcm:lower-offset-to-mir, r=compiler-errors
Lower `intrinsics::offset` to `mir::BinOp::Offset` They're [semantically the same](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.Rvalue.html#variant.BinaryOp), so this means the backends don't need to handle the intrinsic and means fewer MIR basic blocks in pointer arithmetic code.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff | 30 | ||||
| -rw-r--r-- | tests/mir-opt/lower_intrinsics.rs | 5 |
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff new file mode 100644 index 00000000000..f342bf30d02 --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff @@ -0,0 +1,30 @@ +- // MIR for `ptr_offset` before LowerIntrinsics ++ // MIR for `ptr_offset` after LowerIntrinsics + + fn ptr_offset(_1: *const i32, _2: isize) -> *const i32 { + debug p => _1; // in scope 0 at $DIR/lower_intrinsics.rs:+0:26: +0:27 + debug d => _2; // in scope 0 at $DIR/lower_intrinsics.rs:+0:41: +0:42 + let mut _0: *const i32; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:54: +0:64 + let mut _3: *const i32; // in scope 0 at $DIR/lower_intrinsics.rs:+1:30: +1:31 + let mut _4: isize; // in scope 0 at $DIR/lower_intrinsics.rs:+1:33: +1:34 + + bb0: { + StorageLive(_3); // scope 0 at $DIR/lower_intrinsics.rs:+1:30: +1:31 + _3 = _1; // scope 0 at $DIR/lower_intrinsics.rs:+1:30: +1:31 + StorageLive(_4); // scope 0 at $DIR/lower_intrinsics.rs:+1:33: +1:34 + _4 = _2; // scope 0 at $DIR/lower_intrinsics.rs:+1:33: +1:34 +- _0 = offset::<i32>(move _3, move _4) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:35 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:140:5: 140:29 +- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const i32, isize) -> *const i32 {offset::<i32>}, val: Value(<ZST>) } ++ _0 = Offset(move _3, move _4); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:35 ++ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:35 + } + + bb1: { + StorageDead(_4); // scope 0 at $DIR/lower_intrinsics.rs:+1:34: +1:35 + StorageDead(_3); // scope 0 at $DIR/lower_intrinsics.rs:+1:34: +1:35 + return; // scope 0 at $DIR/lower_intrinsics.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/lower_intrinsics.rs b/tests/mir-opt/lower_intrinsics.rs index 33fef930ad3..ad690f803c4 100644 --- a/tests/mir-opt/lower_intrinsics.rs +++ b/tests/mir-opt/lower_intrinsics.rs @@ -134,3 +134,8 @@ pub fn option_payload(o: &Option<usize>, p: &Option<String>) { let _y = core::intrinsics::option_payload_ptr(p); } } + +// EMIT_MIR lower_intrinsics.ptr_offset.LowerIntrinsics.diff +pub unsafe fn ptr_offset(p: *const i32, d: isize) -> *const i32 { + core::intrinsics::offset(p, d) +} |
