diff options
| author | bors <bors@rust-lang.org> | 2024-12-30 23:46:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-12-30 23:46:42 +0000 |
| commit | 4e5fec2f1ea4b1cfecaa14304c9f56de59b344cb (patch) | |
| tree | 1e4e8feb7ca476d0960112846baf5a49c8028b2a /tests/codegen | |
| parent | 7f75bfa1ad4e9a9d33a179a90603001515e91991 (diff) | |
| parent | 3c0c1386878812780349be38080470c0b4fcdda2 (diff) | |
| download | rust-4e5fec2f1ea4b1cfecaa14304c9f56de59b344cb.tar.gz rust-4e5fec2f1ea4b1cfecaa14304c9f56de59b344cb.zip | |
Auto merge of #134757 - RalfJung:const_swap, r=scottmcm
stabilize const_swap libs-api FCP passed in https://github.com/rust-lang/rust/issues/83163. However, I only just realized that this actually involves an intrinsic. The intrinsic could be implemented entirely with existing stable const functionality, but we choose to make it a primitive to be able to detect more UB. So nominating for `@rust-lang/lang` to make sure they are aware; I leave it up to them whether they want to FCP this. While at it I also renamed the intrinsic to make the "nonoverlapping" constraint more clear. Fixes #83163
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/intrinsics/typed_swap.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/codegen/intrinsics/typed_swap.rs b/tests/codegen/intrinsics/typed_swap.rs index e73931d1d54..6b55078407a 100644 --- a/tests/codegen/intrinsics/typed_swap.rs +++ b/tests/codegen/intrinsics/typed_swap.rs @@ -8,14 +8,14 @@ #![crate_type = "lib"] #![feature(core_intrinsics)] -use std::intrinsics::typed_swap; +use std::intrinsics::typed_swap_nonoverlapping; // CHECK-LABEL: @swap_unit( #[no_mangle] pub unsafe fn swap_unit(x: &mut (), y: &mut ()) { // CHECK: start // CHECK-NEXT: ret void - typed_swap(x, y) + typed_swap_nonoverlapping(x, y) } // CHECK-LABEL: @swap_i32( @@ -32,7 +32,7 @@ pub unsafe fn swap_i32(x: &mut i32, y: &mut i32) { // OPT3: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %x, ptr align 4 %y, i64 4, i1 false) // CHECK: store i32 %[[TEMP]], ptr %y, align 4 // CHECK: ret void - typed_swap(x, y) + typed_swap_nonoverlapping(x, y) } // CHECK-LABEL: @swap_pair( @@ -47,7 +47,7 @@ pub unsafe fn swap_pair(x: &mut (i32, u32), y: &mut (i32, u32)) { // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %x, ptr align 4 %y, i64 8, i1 false) // CHECK: store i32 // CHECK: store i32 - typed_swap(x, y) + typed_swap_nonoverlapping(x, y) } // CHECK-LABEL: @swap_str( @@ -63,7 +63,7 @@ pub unsafe fn swap_str<'a>(x: &mut &'a str, y: &mut &'a str) { // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %x, ptr align 8 %y, i64 16, i1 false) // CHECK: store ptr // CHECK: store i64 - typed_swap(x, y) + typed_swap_nonoverlapping(x, y) } // OPT0-LABEL: @swap_string( @@ -73,5 +73,5 @@ pub unsafe fn swap_string(x: &mut String, y: &mut String) { // OPT0: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %[[TEMP]], ptr align 8 %x, i64 24, i1 false) // OPT0: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %x, ptr align 8 %y, i64 24, i1 false) // OPT0: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %y, ptr align 8 %[[TEMP]], i64 24, i1 false) - typed_swap(x, y) + typed_swap_nonoverlapping(x, y) } |
