]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/mem-replace-direct-memcpy.rs
Rollup merge of #98441 - calebzulawski:simd_as, r=oli-obk
[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 -Zinline-mir=no
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::replace`.
16
17 // CHECK-NOT: call void @llvm.memcpy
18 // CHECK: ; core::mem::replace
19 // CHECK-NOT: call void @llvm.memcpy
20 // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %dest, i{{.*}} 1, i1 false)
21 // CHECK-NOT: call void @llvm.memcpy
22 // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 1 %dest, {{i8\*|ptr}} align 1 %src{{.*}}, i{{.*}} 1, i1 false)
23 // CHECK-NOT: call void @llvm.memcpy