2024-10-09 13:24:05 -05:00
|
|
|
//@ compile-flags: -O
|
2024-10-22 03:33:22 -05:00
|
|
|
//@ compile-flags: -Zmerge-functions=disabled
|
2024-10-09 13:24:05 -05:00
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
|
|
|
// Test to check that types with "complex" destructors, but trivial `Default` impls
|
|
|
|
// are constructed directly into the allocation in `Box::default` and `Arc::default`.
|
|
|
|
|
2024-10-22 03:33:22 -05:00
|
|
|
use std::rc::Rc;
|
2024-10-09 13:24:05 -05:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
// CHECK-LABEL: @box_default_inplace
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn box_default_inplace() -> Box<(String, String)> {
|
2024-10-09 13:24:05 -05:00
|
|
|
// CHECK-NOT: alloca
|
2024-10-09 13:24:05 -05:00
|
|
|
// CHECK: [[BOX:%.*]] = {{.*}}call {{.*}}__rust_alloc(
|
2024-10-09 13:24:05 -05:00
|
|
|
// CHECK-NOT: call void @llvm.memcpy
|
2024-10-09 13:24:05 -05:00
|
|
|
// CHECK: ret ptr [[BOX]]
|
|
|
|
Box::default()
|
|
|
|
}
|
|
|
|
|
2024-10-22 03:33:22 -05:00
|
|
|
// 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()
|
|
|
|
}
|
|
|
|
|
2024-10-09 13:24:05 -05:00
|
|
|
// CHECK-LABEL: @arc_default_inplace
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn arc_default_inplace() -> Arc<(String, String)> {
|
2024-10-09 13:24:05 -05:00
|
|
|
// CHECK-NOT: alloca
|
2024-10-09 13:24:05 -05:00
|
|
|
// CHECK: [[ARC:%.*]] = {{.*}}call {{.*}}__rust_alloc(
|
2024-10-09 13:24:05 -05:00
|
|
|
// CHECK-NOT: call void @llvm.memcpy
|
2024-10-09 13:24:05 -05:00
|
|
|
// CHECK: ret ptr [[ARC]]
|
|
|
|
Arc::default()
|
|
|
|
}
|