]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/zst-offset.rs
Merge commit '40dd3e2b7089b5e96714e064b731f6dbf17c61a9' into sync_cg_clif-2021-05-27
[rust.git] / src / test / codegen / zst-offset.rs
1 // compile-flags: -C no-prepopulate-passes
2
3 #![crate_type = "lib"]
4 #![feature(repr_simd)]
5
6 // Hack to get the correct size for the length part in slices
7 // CHECK: @helper([[USIZE:i[0-9]+]] %_1)
8 #[no_mangle]
9 pub fn helper(_: usize) {
10 }
11
12 // Check that we correctly generate a GEP for a ZST that is not included in Scalar layout
13 // CHECK-LABEL: @scalar_layout
14 #[no_mangle]
15 pub fn scalar_layout(s: &(u64, ())) {
16 // CHECK: [[X0:%[0-9]+]] = bitcast i64* %s to i8*
17 // CHECK-NEXT: [[X1:%[0-9]+]] = getelementptr i8, i8* [[X0]], [[USIZE]] 8
18     let x = &s.1;
19     &x; // keep variable in an alloca
20 }
21
22 // Check that we correctly generate a GEP for a ZST that is not included in ScalarPair layout
23 // CHECK-LABEL: @scalarpair_layout
24 #[no_mangle]
25 pub fn scalarpair_layout(s: &(u64, u32, ())) {
26 // CHECK: [[X0:%[0-9]+]] = bitcast { i64, i32 }* %s to i8*
27 // CHECK-NEXT: [[X1:%[0-9]+]] = getelementptr i8, i8* [[X0]], [[USIZE]] 12
28     let x = &s.2;
29     &x; // keep variable in an alloca
30 }
31
32 #[repr(simd)]
33 pub struct U64x4(u64, u64, u64, u64);
34
35 // Check that we correctly generate a GEP for a ZST that is not included in Vector layout
36 // CHECK-LABEL: @vector_layout
37 #[no_mangle]
38 pub fn vector_layout(s: &(U64x4, ())) {
39 // CHECK: [[X0:%[0-9]+]] = bitcast <4 x i64>* %s to i8*
40 // CHECK-NEXT: [[X1:%[0-9]+]] = getelementptr i8, i8* [[X0]], [[USIZE]] 32
41     let x = &s.1;
42     &x; // keep variable in an alloca
43 }