File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
tests/codegen-llvm/lib-optimizations Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 33#![ crate_type = "lib" ]
44
55use std:: rc:: { self , Rc } ;
6+ use std:: sync:: { self , Arc } ;
67
78// Ensures that we can create array of `Weak`s using `memset`.
89
@@ -15,7 +16,17 @@ pub fn array_of_rc_weak() -> [rc::Weak<u32>; 100] {
1516 [ ( ) ; 100 ] . map ( |( ) | rc:: Weak :: new ( ) )
1617}
1718
18- // Ensures that we convert `&Option<Rc<T>>` to `Option<&T>` without checking for `None`.
19+ #[ no_mangle]
20+ pub fn array_of_sync_weak ( ) -> [ sync:: Weak < u32 > ; 100 ] {
21+ // CHECK-LABEL: @array_of_sync_weak(
22+ // CHECK-NEXT: start:
23+ // CHECK-NEXT: call void @llvm.memset.
24+ // CHECK-NEXT: ret void
25+ [ ( ) ; 100 ] . map ( |( ) | sync:: Weak :: new ( ) )
26+ }
27+
28+ // Ensures that we convert `&Option<Rc<T>>` and `&Option<Arc<T>>` to `Option<&T>` without checking
29+ // for `None`.
1930
2031#[ no_mangle]
2132pub fn option_rc_as_deref_no_cmp ( rc : & Option < Rc < u32 > > ) -> Option < & u32 > {
@@ -25,3 +36,12 @@ pub fn option_rc_as_deref_no_cmp(rc: &Option<Rc<u32>>) -> Option<&u32> {
2536 // CHECK-NEXT: ret ptr %[[RC]]
2637 rc. as_deref ( )
2738}
39+
40+ #[ no_mangle]
41+ pub fn option_arc_as_deref_no_cmp ( arc : & Option < Arc < u32 > > ) -> Option < & u32 > {
42+ // CHECK-LABEL: @option_arc_as_deref_no_cmp(ptr
43+ // CHECK-NEXT: start:
44+ // CHECK-NEXT: %[[ARC:.+]] = load ptr, ptr %arc
45+ // CHECK-NEXT: ret ptr %[[ARC]]
46+ arc. as_deref ( )
47+ }
You can’t perform that action at this time.
0 commit comments