]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/mem-replace-direct-memcpy.rs
Auto merge of #93626 - wesleywiser:fix_hashmap_natvis, r=michaelwoerister
[rust.git] / src / test / codegen / mem-replace-direct-memcpy.rs
1 // This test ensures that `mem::replace::<T>` only ever calls `@llvm.memcpy`
2 // with `size_of::<T>()` as the size, and never goes through any wrapper that
3 // may e.g. multiply `size_of::<T>()` with a variable "count" (which is only
4 // known to be `1` after inlining).
5
6 // compile-flags: -C no-prepopulate-passes
7
8 #![crate_type = "lib"]
9
10 pub fn replace_byte(dst: &mut u8, src: u8) -> u8 {
11     std::mem::replace(dst, src)
12 }
13
14 // NOTE(eddyb) the `CHECK-NOT`s ensure that the only calls of `@llvm.memcpy` in
15 // the entire output, are the two direct calls we want, from `ptr::{read,write}`.
16
17 // CHECK-NOT: call void @llvm.memcpy
18 // CHECK: ; core::ptr::read
19 // CHECK-NOT: call void @llvm.memcpy
20 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i{{.*}}(i8* align 1 %{{.*}}, i8* align 1 %src, i{{.*}} 1, i1 false)
21 // CHECK-NOT: call void @llvm.memcpy
22 // CHECK: ; core::ptr::write
23 // CHECK-NOT: call void @llvm.memcpy
24 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i{{.*}}(i8* align 1 %dst, i8* align 1 %src, i{{.*}} 1, i1 false)
25 // CHECK-NOT: call void @llvm.memcpy