]> git.lizzy.rs Git - rust.git/blob - tests/codegen/zst-offset.rs
Rollup merge of #107731 - RalfJung:interpret-discriminant, r=cjgillot
[rust.git] / tests / codegen / zst-offset.rs
1 // compile-flags: -C no-prepopulate-passes -Copt-level=0
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: getelementptr i8, {{.+}}, [[USIZE]] 8
17     let x = &s.1;
18     witness(&x); // keep variable in an alloca
19 }
20
21 // Check that we correctly generate a GEP for a ZST that is not included in ScalarPair layout
22 // CHECK-LABEL: @scalarpair_layout
23 #[no_mangle]
24 pub fn scalarpair_layout(s: &(u64, u32, ())) {
25 // CHECK: getelementptr i8, {{.+}}, [[USIZE]] 12
26     let x = &s.2;
27     witness(&x); // keep variable in an alloca
28 }
29
30 #[repr(simd)]
31 pub struct U64x4(u64, u64, u64, u64);
32
33 // Check that we correctly generate a GEP for a ZST that is not included in Vector layout
34 // CHECK-LABEL: @vector_layout
35 #[no_mangle]
36 pub fn vector_layout(s: &(U64x4, ())) {
37 // CHECK: getelementptr i8, {{.+}}, [[USIZE]] 32
38     let x = &s.1;
39     witness(&x); // keep variable in an alloca
40 }
41
42 #[inline(never)]
43 fn witness(_: &impl Sized) {}