]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/stores.rs
Rollup merge of #65389 - ecstatic-morse:zero-sized-array-no-drop, r=eddyb
[rust.git] / src / test / codegen / stores.rs
1 // compile-flags: -C no-prepopulate-passes
2 // ignore-tidy-linelength
3 // min-llvm-version 7.0
4
5 #![crate_type = "lib"]
6
7 pub struct Bytes {
8   a: u8,
9   b: u8,
10   c: u8,
11   d: u8,
12 }
13
14 // CHECK-LABEL: small_array_alignment
15 // The array is stored as i32, but its alignment is lower, go with 1 byte to avoid target
16 // dependent alignment
17 #[no_mangle]
18 pub fn small_array_alignment(x: &mut [i8; 4], y: [i8; 4]) {
19 // CHECK: [[TMP:%.+]] = alloca i32
20 // CHECK: %y = alloca [4 x i8]
21 // CHECK: store i32 %0, i32* [[TMP]]
22 // CHECK: [[Y8:%[0-9]+]] = bitcast [4 x i8]* %y to i8*
23 // CHECK: [[TMP8:%[0-9]+]] = bitcast i32* [[TMP]] to i8*
24 // CHECK: call void @llvm.memcpy.{{.*}}(i8* align 1 [[Y8]], i8* align 4 [[TMP8]], i{{[0-9]+}} 4, i1 false)
25     *x = y;
26 }
27
28 // CHECK-LABEL: small_struct_alignment
29 // The struct is stored as i32, but its alignment is lower, go with 1 byte to avoid target
30 // dependent alignment
31 #[no_mangle]
32 pub fn small_struct_alignment(x: &mut Bytes, y: Bytes) {
33 // CHECK: [[TMP:%.+]] = alloca i32
34 // CHECK: %y = alloca %Bytes
35 // CHECK: store i32 %0, i32* [[TMP]]
36 // CHECK: [[Y8:%[0-9]+]] = bitcast %Bytes* %y to i8*
37 // CHECK: [[TMP8:%[0-9]+]] = bitcast i32* [[TMP]] to i8*
38 // CHECK: call void @llvm.memcpy.{{.*}}(i8* align 1 [[Y8]], i8* align 4 [[TMP8]], i{{[0-9]+}} 4, i1 false)
39     *x = y;
40 }