blob: 837256e53694206f927b932eb5f69b5253086f93 [file] [log] [blame]
Björn Steinbrink67736752015-05-24 16:07:521// compile-flags: -C no-prepopulate-passes
Simon Jakobi3ea62cb52021-04-03 11:05:112//
Björn Steinbrink67736752015-05-24 16:07:523
Richard Diamond9a240252015-09-15 21:22:164#![crate_type = "lib"]
5
Björn Steinbrink67736752015-05-24 16:07:526pub struct Bytes {
7 a: u8,
8 b: u8,
9 c: u8,
10 d: u8,
11}
12
13// CHECK-LABEL: small_array_alignment
14// The array is stored as i32, but its alignment is lower, go with 1 byte to avoid target
15// dependent alignment
16#[no_mangle]
Eduard Burtescubffb0de2016-03-06 12:28:1117pub fn small_array_alignment(x: &mut [i8; 4], y: [i8; 4]) {
Eduard Burtescue2528652016-06-07 21:35:0118// CHECK: [[TMP:%.+]] = alloca i32
Björn Steinbrink0473a4f2017-10-11 18:49:3619// CHECK: %y = alloca [4 x i8]
Nikita Popov4d7ff4e2022-02-21 10:21:2320// CHECK: store i32 %0, {{i32\*|ptr}} [[TMP]]
21// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 1 {{.+}}, {{i8\*|ptr}} align 4 {{.+}}, i{{[0-9]+}} 4, i1 false)
Eduard Burtescubffb0de2016-03-06 12:28:1122 *x = y;
Björn Steinbrink67736752015-05-24 16:07:5223}
24
25// CHECK-LABEL: small_struct_alignment
26// The struct is stored as i32, but its alignment is lower, go with 1 byte to avoid target
27// dependent alignment
28#[no_mangle]
Eduard Burtescubffb0de2016-03-06 12:28:1129pub fn small_struct_alignment(x: &mut Bytes, y: Bytes) {
Eduard Burtescue2528652016-06-07 21:35:0130// CHECK: [[TMP:%.+]] = alloca i32
Björn Steinbrink0473a4f2017-10-11 18:49:3631// CHECK: %y = alloca %Bytes
Nikita Popov4d7ff4e2022-02-21 10:21:2332// CHECK: store i32 %0, {{i32\*|ptr}} [[TMP]]
33// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 1 {{.+}}, {{i8\*|ptr}} align 4 {{.+}}, i{{[0-9]+}} 4, i1 false)
Eduard Burtescubffb0de2016-03-06 12:28:1134 *x = y;
Björn Steinbrink67736752015-05-24 16:07:5235}