@@ -21,6 +21,17 @@ class RootClassWithNontrivialStoredProperties {
2121}
2222
2323class SomeClass {}
24+
25+ final class IntClass {
26+ var i: Int
27+ init(_ i: Int)
28+ }
29+
30+ final class GenericClass<T> {
31+ var t: T
32+ init(_ t: T)
33+ }
34+
2435sil @getSomeClass : $@convention(thin) () -> @owned SomeClass
2536sil @getSomeOptionalClass : $@convention(thin) () -> Optional<SomeClass>
2637
@@ -131,3 +142,45 @@ bb0(%0 : @owned $RootClassWithNontrivialStoredProperties):
131142 %13 = tuple ()
132143 return %13 : $()
133144}
145+
146+ // CHECK-LABEL: sil [ossa] @init_IntClass :
147+ // CHECK: [[ACCESS:%.*]] = begin_access [init] [static]
148+ // CHECK: store %0 to [trivial] [[ACCESS]]
149+ // CHECK: [[ACCESS2:%.*]] = begin_access [modify] [dynamic]
150+ // CHECK: store %0 to [trivial] [[ACCESS2]]
151+ // CHECK: } // end sil function 'init_IntClass'
152+ sil [ossa] @init_IntClass : $@convention(method) (Int, @owned IntClass) -> @owned IntClass {
153+ bb0(%0 : $Int, %1 : @owned $IntClass):
154+ %4 = mark_uninitialized [rootself] %1 : $IntClass
155+ %5 = begin_borrow %4 : $IntClass
156+ %6 = ref_element_addr %5 : $IntClass, #IntClass.i
157+ %7 = begin_access [modify] [dynamic] %6 : $*Int
158+ assign %0 to %7 : $*Int
159+ end_access %7 : $*Int
160+ %10 = begin_access [modify] [dynamic] %6 : $*Int
161+ assign %0 to %10 : $*Int
162+ end_access %10 : $*Int
163+ end_borrow %5 : $IntClass
164+ return %4 : $IntClass
165+ }
166+
167+ // CHECK-LABEL: sil [ossa] @init_GenericClass :
168+ // CHECK: [[ACCESS:%.*]] = begin_access [init] [static]
169+ // CHECK: copy_addr %0 to [init] [[ACCESS]]
170+ // CHECK: [[ACCESS2:%.*]] = begin_access [modify] [dynamic]
171+ // CHECK: copy_addr [take] %0 to [[ACCESS2]]
172+ // CHECK: } // end sil function 'init_GenericClass'
173+ sil [ossa] @init_GenericClass : $@convention(method) <T> (@in T, @owned GenericClass<T>) -> @owned GenericClass<T> {
174+ bb0(%0 : $*T, %1 : @owned $GenericClass<T>):
175+ %4 = mark_uninitialized [rootself] %1 : $GenericClass<T>
176+ %5 = begin_borrow %4 : $GenericClass<T>
177+ %8 = ref_element_addr %5 : $GenericClass<T>, #GenericClass.t
178+ %9 = begin_access [modify] [dynamic] %8 : $*T
179+ copy_addr %0 to %9 : $*T
180+ end_access %9 : $*T
181+ %12 = begin_access [modify] [dynamic] %8 : $*T
182+ copy_addr [take] %0 to %12 : $*T
183+ end_access %12 : $*T
184+ end_borrow %5 : $GenericClass<T>
185+ return %4 : $GenericClass<T>
186+ }
0 commit comments