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).
6 // compile-flags: -C no-prepopulate-passes
10 pub fn replace_byte(dst: &mut u8, src: u8) -> u8 {
11 std::mem::replace(dst, src)
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}`.
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.{{.+}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} 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.{{.+}}({{i8\*|ptr}} align 1 %dst, {{i8\*|ptr}} align 1 %src, i{{.*}} 1, i1 false)
25 // CHECK-NOT: call void @llvm.memcpy