summaryrefslogtreecommitdiffstats
path: root/src/test/codegen/zst-offset.rs
blob: 29d2a1754a3afb7f6202bada58ffd11eae9875ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// compile-flags: -C no-prepopulate-passes

#![crate_type = "lib"]
#![feature(repr_simd)]

// Hack to get the correct size for the length part in slices
// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
#[no_mangle]
pub fn helper(_: usize) {
}

// Check that we correctly generate a GEP for a ZST that is not included in Scalar layout
// CHECK-LABEL: @scalar_layout
#[no_mangle]
pub fn scalar_layout(s: &(u64, ())) {
// CHECK: getelementptr i8, {{.+}}, [[USIZE]] 8
    let x = &s.1;
    &x; // keep variable in an alloca
}

// Check that we correctly generate a GEP for a ZST that is not included in ScalarPair layout
// CHECK-LABEL: @scalarpair_layout
#[no_mangle]
pub fn scalarpair_layout(s: &(u64, u32, ())) {
// CHECK: getelementptr i8, {{.+}}, [[USIZE]] 12
    let x = &s.2;
    &x; // keep variable in an alloca
}

#[repr(simd)]
pub struct U64x4(u64, u64, u64, u64);

// Check that we correctly generate a GEP for a ZST that is not included in Vector layout
// CHECK-LABEL: @vector_layout
#[no_mangle]
pub fn vector_layout(s: &(U64x4, ())) {
// CHECK: getelementptr i8, {{.+}}, [[USIZE]] 32
    let x = &s.1;
    &x; // keep variable in an alloca
}