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 3
3
#![ crate_type = "lib" ]
4
4
5
5
use std:: rc:: { self , Rc } ;
6
+ use std:: sync:: { self , Arc } ;
6
7
7
8
// Ensures that we can create array of `Weak`s using `memset`.
8
9
@@ -15,7 +16,17 @@ pub fn array_of_rc_weak() -> [rc::Weak<u32>; 100] {
15
16
[ ( ) ; 100 ] . map ( |( ) | rc:: Weak :: new ( ) )
16
17
}
17
18
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`.
19
30
20
31
#[ no_mangle]
21
32
pub 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> {
25
36
// CHECK-NEXT: ret ptr %[[RC]]
26
37
rc. as_deref ( )
27
38
}
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