]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/box-maybe-uninit-llvm14.rs
Auto merge of #102900 - abrachet:master, r=bjorn3
[rust.git] / src / test / codegen / box-maybe-uninit-llvm14.rs
1 // compile-flags: -O
2
3 // Once we're done with llvm 14 and earlier, this test can be deleted.
4
5 #![crate_type="lib"]
6
7 use std::mem::MaybeUninit;
8
9 // Boxing a `MaybeUninit` value should not copy junk from the stack
10 #[no_mangle]
11 pub fn box_uninitialized() -> Box<MaybeUninit<usize>> {
12     // CHECK-LABEL: @box_uninitialized
13     // CHECK-NOT: store
14     // CHECK-NOT: alloca
15     // CHECK-NOT: memcpy
16     // CHECK-NOT: memset
17     Box::new(MaybeUninit::uninit())
18 }
19
20 // FIXME: add a test for a bigger box. Currently broken, see
21 // https://github.com/rust-lang/rust/issues/58201.
22
23 // Hide the LLVM 15+ `allocalign` attribute in the declaration of __rust_alloc
24 // from the CHECK-NOT above. We don't check the attributes here because we can't rely
25 // on all of them being set until LLVM 15.
26 // CHECK: declare noalias{{.*}} @__rust_alloc(i{{[0-9]+}}, i{{[0-9]+.*}})