]> git.lizzy.rs Git - rust.git/blob - tests/codegen/issue-56927.rs
Merge commit '598f0909568a51de8a2d1148f55a644fd8dffad0' into sync_cg_clif-2023-01-24
[rust.git] / tests / codegen / issue-56927.rs
1 // compile-flags: -C no-prepopulate-passes
2
3 #![crate_type="rlib"]
4
5 #[repr(align(16))]
6 pub struct S {
7     arr: [u32; 4],
8 }
9
10 // CHECK-LABEL: @test1
11 // CHECK: store i32 0, {{i32\*|ptr}} %{{.+}}, align 16
12 // CHECK: store i32 1, {{i32\*|ptr}} %{{.+}}, align 4
13 // CHECK: store i32 2, {{i32\*|ptr}} %{{.+}}, align 8
14 // CHECK: store i32 3, {{i32\*|ptr}} %{{.+}}, align 4
15 #[no_mangle]
16 pub fn test1(s: &mut S) {
17     s.arr[0] = 0;
18     s.arr[1] = 1;
19     s.arr[2] = 2;
20     s.arr[3] = 3;
21 }
22
23 // CHECK-LABEL: @test2
24 // CHECK: store i32 4, {{i32\*|ptr}} %{{.+}}, align 4
25 #[allow(unconditional_panic)]
26 #[no_mangle]
27 pub fn test2(s: &mut S) {
28     s.arr[usize::MAX / 4 + 1] = 4;
29 }
30
31 // CHECK-LABEL: @test3
32 // CHECK: store i32 5, {{i32\*|ptr}} %{{.+}}, align 4
33 #[no_mangle]
34 pub fn test3(s: &mut S, i: usize) {
35     s.arr[i] = 5;
36 }
37
38 // CHECK-LABEL: @test4
39 // CHECK: store i32 6, {{i32\*|ptr}} %{{.+}}, align 4
40 #[no_mangle]
41 pub fn test4(s: &mut S) {
42     s.arr = [6; 4];
43 }