Skip to content

Commit 3361247

Browse files
authored
Rollup merge of #106292 - Nilstrieb:box-uninit-test, r=RalfJung
Add codegen test for `Box::new(uninit)` of big arrays Closes #58201 r? `@RalfJung`
2 parents fbfaeb6 + 2675848 commit 3361247

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/test/codegen/box-maybe-uninit-llvm14.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Once we're done with llvm 14 and earlier, this test can be deleted.
44

5-
#![crate_type="lib"]
5+
#![crate_type = "lib"]
66

77
use std::mem::MaybeUninit;
88

@@ -17,8 +17,16 @@ pub fn box_uninitialized() -> Box<MaybeUninit<usize>> {
1717
Box::new(MaybeUninit::uninit())
1818
}
1919

20-
// FIXME: add a test for a bigger box. Currently broken, see
21-
// https://github.com/rust-lang/rust/issues/58201.
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+
}
2230

2331
// Hide the LLVM 15+ `allocalign` attribute in the declaration of __rust_alloc
2432
// from the CHECK-NOT above. We don't check the attributes here because we can't rely

src/test/codegen/box-maybe-uninit.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags: -O
22
// min-llvm-version: 15.0
3-
#![crate_type="lib"]
3+
#![crate_type = "lib"]
44

55
use std::mem::MaybeUninit;
66

@@ -15,8 +15,16 @@ pub fn box_uninitialized() -> Box<MaybeUninit<usize>> {
1515
Box::new(MaybeUninit::uninit())
1616
}
1717

18-
// FIXME: add a test for a bigger box. Currently broken, see
19-
// https://github.com/rust-lang/rust/issues/58201.
18+
// https://github.com/rust-lang/rust/issues/58201
19+
#[no_mangle]
20+
pub fn box_uninitialized2() -> Box<MaybeUninit<[usize; 1024 * 1024]>> {
21+
// CHECK-LABEL: @box_uninitialized2
22+
// CHECK-NOT: store
23+
// CHECK-NOT: alloca
24+
// CHECK-NOT: memcpy
25+
// CHECK-NOT: memset
26+
Box::new(MaybeUninit::uninit())
27+
}
2028

2129
// Hide the `allocalign` attribute in the declaration of __rust_alloc
2230
// from the CHECK-NOT above, and also verify the attributes got set reasonably.

0 commit comments

Comments
 (0)