]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/loads.rs
Rollup merge of #69106 - RReverser:wasi-fs-copy, r=KodrAus
[rust.git] / src / test / codegen / loads.rs
1 // compile-flags: -C no-prepopulate-passes
2
3 #![crate_type = "lib"]
4
5 pub struct Bytes {
6   a: u8,
7   b: u8,
8   c: u8,
9   d: u8,
10 }
11
12 // CHECK-LABEL: @borrow
13 #[no_mangle]
14 pub fn borrow(x: &i32) -> &i32 {
15 // CHECK: load {{(i32\*, )?}}i32** %x{{.*}}, !nonnull
16     &x; // keep variable in an alloca
17     x
18 }
19
20 // CHECK-LABEL: @_box
21 #[no_mangle]
22 pub fn _box(x: Box<i32>) -> i32 {
23 // CHECK: load {{(i32\*, )?}}i32** %x{{.*}}, !nonnull
24     *x
25 }
26
27 // CHECK-LABEL: small_array_alignment
28 // The array is loaded as i32, but its alignment is lower, go with 1 byte to avoid target
29 // dependent alignment
30 #[no_mangle]
31 pub fn small_array_alignment(x: [i8; 4]) -> [i8; 4] {
32 // CHECK: [[VAR:%[0-9]+]] = load {{(i32, )?}}i32* %{{.*}}, align 1
33 // CHECK: ret i32 [[VAR]]
34     x
35 }
36
37 // CHECK-LABEL: small_struct_alignment
38 // The struct is loaded as i32, but its alignment is lower, go with 1 byte to avoid target
39 // dependent alignment
40 #[no_mangle]
41 pub fn small_struct_alignment(x: Bytes) -> Bytes {
42 // CHECK: [[VAR:%[0-9]+]] = load {{(i32, )?}}i32* %{{.*}}, align 1
43 // CHECK: ret i32 [[VAR]]
44     x
45 }