@@ -148,6 +148,31 @@ bb0(%0 : @owned $DerivedClassWithNontrivialStoredProperties):
148148 return %13 : $()
149149}
150150
151+ // CHECK-LABEL: sil [ossa] @test_delegating_derived_with_upcast :
152+ // CHECK: bb0([[ARG:%.*]] : @owned $DerivedClassWithNontrivialStoredProperties):
153+ // CHECK-NEXT: [[SELFBOX:%[0-9]+]] = alloc_stack $DerivedClassWithNontrivialStoredProperties
154+ // CHECK-NEXT: store [[ARG]] to [init] [[SELFBOX]]
155+ // CHECK-NEXT: [[SELF:%[0-9]+]] = load [take] [[SELFBOX]]
156+ // CHECK-NEXT: [[UC:%[0-9]+]] = upcast [[SELF]]
157+ // CHECK-NEXT: [[DC:%[0-9]+]] = unchecked_ref_cast [[UC]]
158+ // CHECK-NEXT: [[METATYPE:%[0-9]+]] = value_metatype $@thick DerivedClassWithNontrivialStoredProperties.Type, [[DC]] : $DerivedClassWithNontrivialStoredProperties
159+ // CHECK-NEXT: dealloc_partial_ref [[DC]] : $DerivedClassWithNontrivialStoredProperties, [[METATYPE]] : $@thick DerivedClassWithNontrivialStoredProperties.Type
160+ // CHECK-NEXT: dealloc_stack [[SELFBOX]]
161+ sil [ossa] @test_delegating_derived_with_upcast : $@convention(method) (@owned DerivedClassWithNontrivialStoredProperties) -> () {
162+ bb0(%0 : @owned $DerivedClassWithNontrivialStoredProperties):
163+ %1 = alloc_stack $DerivedClassWithNontrivialStoredProperties
164+ %2 = mark_uninitialized [delegatingselfallocated] %1 : $*DerivedClassWithNontrivialStoredProperties
165+ store %0 to [init] %2 : $*DerivedClassWithNontrivialStoredProperties
166+ %4 = load [take] %2 : $*DerivedClassWithNontrivialStoredProperties
167+ %5 = upcast %4 : $DerivedClassWithNontrivialStoredProperties to $RootClassWithNontrivialStoredProperties
168+
169+ destroy_value %5 : $RootClassWithNontrivialStoredProperties
170+ dealloc_stack %1 : $*DerivedClassWithNontrivialStoredProperties
171+
172+ %13 = tuple ()
173+ return %13 : $()
174+ }
175+
151176// <rdar://problem/20608881> DI miscompiles this testcase into a memory leak
152177struct MyStruct3 {
153178 @_hasStorage var c: C
0 commit comments