Skip to content

Commit 2a19b70

Browse files
committed
Add LLVM codegen tests for new Rc implementation
1 parent ffc2356 commit 2a19b70

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Ensures that we can create an array of `Weak`s using `memset`.
2+
3+
//@ compile-flags: -Z merge-functions=disabled
4+
5+
#![crate_type = "lib"]
6+
7+
use std::{rc, sync};
8+
9+
#[no_mangle]
10+
pub fn array_of_rc_weak() -> [rc::Weak<u32>; 100] {
11+
// CHECK-LABEL: @array_of_rc_weak(
12+
// CHECK-NEXT: start:
13+
// CHECK-NEXT: call void @llvm.memset.
14+
// CHECK-NEXT: ret void
15+
[(); 100].map(|()| rc::Weak::new())
16+
}
17+
18+
#[no_mangle]
19+
pub fn array_of_sync_weak() -> [sync::Weak<u32>; 100] {
20+
// CHECK-LABEL: @array_of_sync_weak(
21+
// CHECK-NEXT: start:
22+
// CHECK-NEXT: call void @llvm.memset.
23+
// CHECK-NEXT: ret void
24+
[(); 100].map(|()| sync::Weak::new())
25+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Ensures that we can acquire `Option<&T>` from `&Option<Rc<T>>` without checking for `None`.
2+
3+
//@ compile-flags: -Z merge-functions=disabled
4+
5+
#![crate_type = "lib"]
6+
7+
use std::rc::Rc;
8+
9+
#[no_mangle]
10+
pub fn option_rc_as_deref_no_cmp(rc: &Option<Rc<u32>>) -> Option<&u32> {
11+
// CHECK-LABEL: @option_rc_as_deref_no_cmp(ptr
12+
// CHECK-NEXT: start:
13+
// CHECK-NEXT: %[[RC:.+]] = load ptr, ptr %rc
14+
// CHECK-NEXT: ret ptr %[[RC]]
15+
rc.as_deref()
16+
}

0 commit comments

Comments
 (0)