]> git.lizzy.rs Git - rust.git/blob - tests/codegen/mem-replace-direct-memcpy.rs
Merge commit '7d53619064ab7045c383644cb445052d2a3d46db' into sync_cg_clif-2023-02-09
[rust.git] / tests / 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 // ignore-debug: the debug assertions get in the way
8
9 #![crate_type = "lib"]
10
11 pub fn replace_byte(dst: &mut u8, src: u8) -> u8 {
12     std::mem::replace(dst, src)
13 }
14
15 // NOTE(eddyb) the `CHECK-NOT`s ensure that the only calls of `@llvm.memcpy` in
16 // the entire output, are the two direct calls we want, from `ptr::replace`.
17
18 // CHECK-NOT: call void @llvm.memcpy
19 // CHECK: ; core::mem::replace
20 // CHECK-NOT: call void @llvm.memcpy
21 // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %{{.*}}, i{{.*}} 1, i1 false)
22 // CHECK-NOT: call void @llvm.memcpy
23 // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %{{.*}}, i{{.*}} 1, i1 false)
24 // CHECK-NOT: call void @llvm.memcpy