Skip to content

Commit eccd4c2

Browse files
committed
Add LLVM codegen tests for new Rc implementation
1 parent b116283 commit eccd4c2

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//@ compile-flags: -O -Z merge-functions=disabled
2+
3+
#![crate_type = "lib"]
4+
5+
use std::rc::{self, Rc};
6+
7+
// Ensures that we can create array of `Weak`s using `memset`.
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+
// Ensures that we convert `&Option<Rc<T>>` to `Option<&T>` without checking for `None`.
19+
20+
#[no_mangle]
21+
pub fn option_rc_as_deref_no_cmp(rc: &Option<Rc<u32>>) -> Option<&u32> {
22+
// CHECK-LABEL: @option_rc_as_deref_no_cmp(ptr
23+
// CHECK-NEXT: start:
24+
// CHECK-NEXT: %[[RC:.+]] = load ptr, ptr %rc
25+
// CHECK-NEXT: ret ptr %[[RC]]
26+
rc.as_deref()
27+
}

0 commit comments

Comments
 (0)