Skip to content

Commit 7782401

Browse files
committed
add codegen test
1 parent 5b12d90 commit 7782401

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/codegen/placement-new.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
//@ compile-flags: -O
2+
//@ compile-flags: -Zmerge-functions=disabled
23
#![crate_type = "lib"]
34

45
// Test to check that types with "complex" destructors, but trivial `Default` impls
56
// are constructed directly into the allocation in `Box::default` and `Arc::default`.
67

8+
use std::rc::Rc;
79
use std::sync::Arc;
810

911
// CHECK-LABEL: @box_default_inplace
@@ -16,6 +18,16 @@ pub fn box_default_inplace() -> Box<(String, String)> {
1618
Box::default()
1719
}
1820

21+
// CHECK-LABEL: @rc_default_inplace
22+
#[no_mangle]
23+
pub fn rc_default_inplace() -> Rc<(String, String)> {
24+
// CHECK-NOT: alloca
25+
// CHECK: [[RC:%.*]] = {{.*}}call {{.*}}__rust_alloc(
26+
// CHECK-NOT: call void @llvm.memcpy
27+
// CHECK: ret ptr [[RC]]
28+
Rc::default()
29+
}
30+
1931
// CHECK-LABEL: @arc_default_inplace
2032
#[no_mangle]
2133
pub fn arc_default_inplace() -> Arc<(String, String)> {

0 commit comments

Comments
 (0)