about summary refs log tree commit diff
path: root/tests/codegen-llvm/uninit-repeat-in-aggregate.rs
blob: 0fa2eb7d56cd857e7026b2a764dff3a30bc892a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//@ compile-flags: -Copt-level=3

#![crate_type = "lib"]

use std::mem::MaybeUninit;

// We need to make sure len is at offset 0, otherwise codegen needs an extra instruction
#[repr(C)]
pub struct SmallVec<T> {
    pub len: u64,
    pub arr: [MaybeUninit<T>; 24],
}

// CHECK-LABEL: @uninit_arr_via_const
#[no_mangle]
pub fn uninit_arr_via_const() -> SmallVec<String> {
    // CHECK-NEXT: start:
    // CHECK-NEXT: store i64 0,
    // CHECK-NEXT: ret
    SmallVec { len: 0, arr: [const { MaybeUninit::uninit() }; 24] }
}