]> git.lizzy.rs Git - rust.git/blob - tests/codegen/box-maybe-uninit-llvm14.rs
Rollup merge of #106886 - dtolnay:fastinstall, r=Mark-Simulacrum
[rust.git] / tests / 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 // https://github.com/rust-lang/rust/issues/58201
21 #[no_mangle]
22 pub fn box_uninitialized2() -> Box<MaybeUninit<[usize; 1024 * 1024]>> {
23     // CHECK-LABEL: @box_uninitialized2
24     // CHECK-NOT: store
25     // CHECK-NOT: alloca
26     // CHECK-NOT: memcpy
27     // CHECK-NOT: memset
28     Box::new(MaybeUninit::uninit())
29 }
30
31 // Hide the LLVM 15+ `allocalign` attribute in the declaration of __rust_alloc
32 // from the CHECK-NOT above. We don't check the attributes here because we can't rely
33 // on all of them being set until LLVM 15.
34 // CHECK: declare noalias{{.*}} @__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+.*}} noundef)