Skip to content

Commit

Permalink
add codegen test
Browse files Browse the repository at this point in the history
  • Loading branch information
slanterns committed Oct 22, 2024
1 parent 5b12d90 commit 52581f5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/codegen/placement-new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// Test to check that types with "complex" destructors, but trivial `Default` impls
// are constructed directly into the allocation in `Box::default` and `Arc::default`.

use std::rc::Rc;
use std::sync::Arc;

// CHECK-LABEL: @box_default_inplace
Expand All @@ -16,6 +17,16 @@ pub fn box_default_inplace() -> Box<(String, String)> {
Box::default()
}

// CHECK-LABEL: @rc_default_inplace
#[no_mangle]
pub fn rc_default_inplace() -> Rc<(String, String)> {
// CHECK-NOT: alloca
// CHECK: [[RC:%.*]] = {{.*}}call {{.*}}__rust_alloc(
// CHECK-NOT: call void @llvm.memcpy
// CHECK: ret ptr [[RC]]
Rc::default()
}

// CHECK-LABEL: @arc_default_inplace
#[no_mangle]
pub fn arc_default_inplace() -> Arc<(String, String)> {
Expand Down

0 comments on commit 52581f5

Please sign in to comment.