mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Fixes a crash due to a wrong class type when creating a value_metatype instruction rdar://140926647
406 lines
18 KiB
Plaintext
406 lines
18 KiB
Plaintext
// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all %s -definite-init -raw-sil-inst-lowering -verify | %FileCheck %s
|
|
|
|
// This test only tests mark_uninitialized [delegatingself]
|
|
|
|
sil_stage raw
|
|
|
|
import Builtin
|
|
import Swift
|
|
|
|
protocol P {}
|
|
class C : P {}
|
|
struct MyStruct : P {}
|
|
|
|
struct MyStruct2 {
|
|
var x: P
|
|
init(delegate: ())
|
|
init()
|
|
}
|
|
|
|
sil @selfinit : $@convention(thin) () -> MyStruct // user: %7
|
|
|
|
class SomeClass {}
|
|
|
|
class RootClassWithNontrivialStoredProperties {
|
|
var x, y: SomeClass
|
|
init()
|
|
}
|
|
|
|
class DerivedClassWithNontrivialStoredProperties : RootClassWithNontrivialStoredProperties {
|
|
var a, b: SomeClass
|
|
override init()
|
|
}
|
|
|
|
sil @getThrowingValue : $@convention(thin) () -> (Int, @error any Error)
|
|
|
|
// CHECK-LABEL: @self_init_assert_instruction
|
|
// CHECK: apply
|
|
// CHECK-NEXT: store
|
|
// CHECK-NEXT: load
|
|
// CHECK: return
|
|
sil [ossa] @self_init_assert_instruction : $@convention(thin) (Int, @thin MyStruct.Type) -> MyStruct {
|
|
bb0(%0 : $Int, %1 : $@thin MyStruct.Type):
|
|
%2 = alloc_stack $MyStruct, var, name "sf"
|
|
%3 = mark_uninitialized [delegatingself] %2 : $*MyStruct
|
|
|
|
%6 = function_ref @selfinit : $@convention(thin) () -> MyStruct
|
|
%7 = apply %6() : $@convention(thin) () -> MyStruct
|
|
assign %7 to %3 : $*MyStruct
|
|
%9 = load [trivial] %3 : $*MyStruct
|
|
dealloc_stack %2 : $*MyStruct
|
|
return %9 : $MyStruct
|
|
}
|
|
|
|
sil [ossa] @selfinit_delegate : $@convention(thin) (@thin MyStruct2.Type) -> @out MyStruct2
|
|
|
|
// <rdar://problem/18089574> Protocol member in struct + delegating init miscompilation
|
|
// CHECK-LABEL: @self_init_copyaddr
|
|
sil [ossa] @self_init_copyaddr : $@convention(thin) (@thin MyStruct2.Type) -> @out MyStruct2 {
|
|
bb0(%0 : $*MyStruct2, %1 : $@thin MyStruct2.Type):
|
|
// CHECK: [[SELF:%[0-9]+]] = alloc_stack $MyStruct2
|
|
%2 = alloc_stack $MyStruct2, var, name "sf"
|
|
%3 = mark_uninitialized [delegatingself] %2 : $*MyStruct2
|
|
%6 = metatype $@thin MyStruct2.Type
|
|
%7 = function_ref @selfinit_delegate : $@convention(thin) (@thin MyStruct2.Type) -> @out MyStruct2
|
|
%8 = alloc_stack $MyStruct2
|
|
|
|
// Make sure this copy_addr ends up being an initialization.
|
|
apply %7(%8, %6) : $@convention(thin) (@thin MyStruct2.Type) -> @out MyStruct2
|
|
copy_addr [take] %8 to %3 : $*MyStruct2
|
|
dealloc_stack %8 : $*MyStruct2
|
|
|
|
// CHECK: apply
|
|
// CHECK-NEXT: copy_addr [take] {{.*}} to [init] [[SELF]] : $*MyStruct2
|
|
// CHECK-NEXT: dealloc_stack
|
|
|
|
copy_addr [take] %3 to [init] %0 : $*MyStruct2
|
|
%13 = tuple ()
|
|
dealloc_stack %2 : $*MyStruct2
|
|
return %13 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @test_delegating_box_release
|
|
// CHECK: bb0([[ARG:%.*]] : @owned $RootClassWithNontrivialStoredProperties):
|
|
// CHECK-NEXT: [[SELFBOX:%[0-9]+]] = alloc_box $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>
|
|
// CHECK-NEXT: [[PB:%[0-9]+]] = project_box [[SELFBOX]]
|
|
// CHECK-NEXT: store [[ARG]] to [init] [[PB]]
|
|
// CHECK-NEXT: [[SELF:%[0-9]+]] = load [take] [[PB]]
|
|
// CHECK-NEXT: [[METATYPE:%[0-9]+]] = value_metatype $@thick RootClassWithNontrivialStoredProperties.Type, [[SELF]] : $RootClassWithNontrivialStoredProperties
|
|
// CHECK-NEXT: dealloc_partial_ref [[SELF]] : $RootClassWithNontrivialStoredProperties, [[METATYPE]] : $@thick RootClassWithNontrivialStoredProperties.Type
|
|
// CHECK-NEXT: dealloc_box [[SELFBOX]]
|
|
sil [ossa] @test_delegating_box_release : $@convention(method) (@owned RootClassWithNontrivialStoredProperties) -> () {
|
|
bb0(%0 : @owned $RootClassWithNontrivialStoredProperties):
|
|
%2 = alloc_box $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>
|
|
%2a = mark_uninitialized [delegatingselfallocated] %2 : $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>
|
|
%4 = project_box %2a : $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>, 0
|
|
store %0 to [init] %4 : $*RootClassWithNontrivialStoredProperties
|
|
destroy_value %2a : $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>
|
|
|
|
%13 = tuple ()
|
|
return %13 : $()
|
|
}
|
|
|
|
|
|
// CHECK-LABEL: sil [ossa] @test_delegating_rvalue_release
|
|
// CHECK: bb0([[ARG:%.*]] : @owned $RootClassWithNontrivialStoredProperties):
|
|
// CHECK-NEXT: [[SELFBOX:%[0-9]+]] = alloc_box $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>
|
|
// CHECK-NEXT: [[PB:%[0-9]+]] = project_box [[SELFBOX]]
|
|
// CHECK-NEXT: store [[ARG]] to [init] [[PB]]
|
|
// CHECK-NEXT: [[SELF:%[0-9]+]] = load [take] [[PB]]
|
|
// CHECK-NEXT: [[METATYPE:%[0-9]+]] = value_metatype $@thick RootClassWithNontrivialStoredProperties.Type, [[SELF]] : $RootClassWithNontrivialStoredProperties
|
|
// CHECK-NEXT: dealloc_partial_ref [[SELF]] : $RootClassWithNontrivialStoredProperties, [[METATYPE]] : $@thick RootClassWithNontrivialStoredProperties.Type
|
|
// CHECK-NEXT: [[SELF2:%[0-9]+]] = load [take] [[PB]]
|
|
// CHECK-NEXT: [[METATYPE2:%[0-9]+]] = value_metatype $@thick RootClassWithNontrivialStoredProperties.Type, [[SELF2]] : $RootClassWithNontrivialStoredProperties
|
|
// CHECK-NEXT: dealloc_partial_ref [[SELF2]] : $RootClassWithNontrivialStoredProperties, [[METATYPE2]] : $@thick RootClassWithNontrivialStoredProperties.Type
|
|
// CHECK-NEXT: dealloc_box [[SELFBOX]]
|
|
sil [ossa] @test_delegating_rvalue_release : $@convention(method) (@owned RootClassWithNontrivialStoredProperties) -> () {
|
|
bb0(%0 : @owned $RootClassWithNontrivialStoredProperties):
|
|
%2 = alloc_box $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>
|
|
%2a = mark_uninitialized [delegatingselfallocated] %2 : $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>
|
|
%4 = project_box %2a : $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>, 0
|
|
store %0 to [init] %4 : $*RootClassWithNontrivialStoredProperties
|
|
%6 = load [take] %4 : $*RootClassWithNontrivialStoredProperties
|
|
destroy_value %6 : $RootClassWithNontrivialStoredProperties
|
|
destroy_value %2a : $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>
|
|
|
|
%13 = tuple ()
|
|
return %13 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @test_delegating_derived_release
|
|
// CHECK: bb0([[ARG:%.*]] : @owned $DerivedClassWithNontrivialStoredProperties):
|
|
// CHECK-NEXT: [[SELFBOX:%[0-9]+]] = alloc_stack $DerivedClassWithNontrivialStoredProperties
|
|
// CHECK-NEXT: store [[ARG]] to [init] [[SELFBOX]]
|
|
// CHECK-NEXT: [[SELF:%[0-9]+]] = load [take] [[SELFBOX]]
|
|
// CHECK-NEXT: [[METATYPE:%[0-9]+]] = value_metatype $@thick DerivedClassWithNontrivialStoredProperties.Type, [[SELF]] : $DerivedClassWithNontrivialStoredProperties
|
|
// CHECK-NEXT: dealloc_partial_ref [[SELF]] : $DerivedClassWithNontrivialStoredProperties, [[METATYPE]] : $@thick DerivedClassWithNontrivialStoredProperties.Type
|
|
// CHECK-NEXT: dealloc_stack [[SELFBOX]]
|
|
sil [ossa] @test_delegating_derived_release : $@convention(method) (@owned DerivedClassWithNontrivialStoredProperties) -> () {
|
|
bb0(%0 : @owned $DerivedClassWithNontrivialStoredProperties):
|
|
%2 = alloc_stack $DerivedClassWithNontrivialStoredProperties
|
|
%4 = mark_uninitialized [delegatingselfallocated] %2 : $*DerivedClassWithNontrivialStoredProperties
|
|
store %0 to [init] %4 : $*DerivedClassWithNontrivialStoredProperties
|
|
|
|
destroy_addr %4 : $*DerivedClassWithNontrivialStoredProperties
|
|
dealloc_stack %2 : $*DerivedClassWithNontrivialStoredProperties
|
|
|
|
%13 = tuple ()
|
|
return %13 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @test_delegating_derived_with_upcast :
|
|
// CHECK: bb0([[ARG:%.*]] : @owned $DerivedClassWithNontrivialStoredProperties):
|
|
// CHECK-NEXT: [[SELFBOX:%[0-9]+]] = alloc_stack $DerivedClassWithNontrivialStoredProperties
|
|
// CHECK-NEXT: store [[ARG]] to [init] [[SELFBOX]]
|
|
// CHECK-NEXT: [[SELF:%[0-9]+]] = load [take] [[SELFBOX]]
|
|
// CHECK-NEXT: [[UC:%[0-9]+]] = upcast [[SELF]]
|
|
// CHECK-NEXT: [[DC:%[0-9]+]] = unchecked_ref_cast [[UC]]
|
|
// CHECK-NEXT: [[METATYPE:%[0-9]+]] = value_metatype $@thick DerivedClassWithNontrivialStoredProperties.Type, [[DC]] : $DerivedClassWithNontrivialStoredProperties
|
|
// CHECK-NEXT: dealloc_partial_ref [[DC]] : $DerivedClassWithNontrivialStoredProperties, [[METATYPE]] : $@thick DerivedClassWithNontrivialStoredProperties.Type
|
|
// CHECK-NEXT: dealloc_stack [[SELFBOX]]
|
|
sil [ossa] @test_delegating_derived_with_upcast : $@convention(method) (@owned DerivedClassWithNontrivialStoredProperties) -> () {
|
|
bb0(%0 : @owned $DerivedClassWithNontrivialStoredProperties):
|
|
%1 = alloc_stack $DerivedClassWithNontrivialStoredProperties
|
|
%2 = mark_uninitialized [delegatingselfallocated] %1 : $*DerivedClassWithNontrivialStoredProperties
|
|
store %0 to [init] %2 : $*DerivedClassWithNontrivialStoredProperties
|
|
%4 = load [take] %2
|
|
%5 = upcast %4 to $RootClassWithNontrivialStoredProperties
|
|
|
|
destroy_value %5
|
|
dealloc_stack %1 : $*DerivedClassWithNontrivialStoredProperties
|
|
|
|
%13 = tuple ()
|
|
return %13 : $()
|
|
}
|
|
|
|
// <rdar://problem/20608881> DI miscompiles this testcase into a memory leak
|
|
struct MyStruct3 {
|
|
@_hasStorage var c: C
|
|
}
|
|
sil @selfinit_mystruct3 : $@convention(thin) () -> @owned MyStruct3
|
|
|
|
// CHECK-LABEL: sil hidden [ossa] @test_conditional_destroy_delegating_init
|
|
sil hidden [ossa] @test_conditional_destroy_delegating_init : $@convention(thin) (Builtin.Int1) -> () {
|
|
bb0(%0 : $Builtin.Int1):
|
|
// CHECK: [[CONTROL:%[0-9]+]] = alloc_stack $Builtin.Int1
|
|
// CHECK-NEXT: [[SELF_BOX:%[0-9]+]] = alloc_stack [dynamic_lifetime] $MyStruct3
|
|
|
|
%2 = alloc_stack $MyStruct3
|
|
%3 = mark_uninitialized [delegatingself] %2 : $*MyStruct3
|
|
|
|
// CHECK: cond_br %0, [[SUCCESS:bb[0-9]+]], [[EXIT:bb[0-9]+]]
|
|
cond_br %0, bb1, bb2
|
|
|
|
// CHECK: [[SUCCESS]]:
|
|
bb1:
|
|
%9 = function_ref @selfinit_mystruct3 : $@convention(thin) () -> @owned MyStruct3
|
|
%10 = apply %9() : $@convention(thin) () -> @owned MyStruct3
|
|
assign %10 to %3 : $*MyStruct3
|
|
|
|
// CHECK: [[NEW_SELF:%[0-9]+]] = apply {{.*}}() : $@convention(thin) () -> @owned MyStruct3
|
|
// CHECK-NEXT: [[SET:%[0-9]+]] = integer_literal $Builtin.Int1, -1
|
|
// CHECK-NEXT: store [[SET]] to [trivial] [[CONTROL]] : $*Builtin.Int1
|
|
// CHECK-NEXT: store [[NEW_SELF]] to [init] [[SELF_BOX]] : $*MyStruct3
|
|
|
|
// CHECK-NEXT: br [[CHECK:bb[0-9]+]]
|
|
br bb3
|
|
|
|
bb2:
|
|
br bb3
|
|
|
|
// CHECK: [[CHECK]]:
|
|
bb3:
|
|
|
|
// CHECK-NEXT: [[BIT:%[0-9]+]] = load [trivial] [[CONTROL]] : $*Builtin.Int1
|
|
// CHECK-NEXT: cond_br [[BIT]], [[INITIALIZED:bb[0-9]+]], [[UNINITIALIZED:bb[0-9]+]]
|
|
|
|
// CHECK: [[INITIALIZED]]:
|
|
// CHECK-NEXT: destroy_addr [[SELF_BOX]] : $*MyStruct3
|
|
// CHECK-NEXT: br [[EXIT:bb[0-9]+]]
|
|
|
|
// CHECK: [[UNINITIALIZED]]:
|
|
// CHECK-NEXT: br [[EXIT]]
|
|
|
|
// CHECK: [[EXIT]]:
|
|
|
|
destroy_addr %3 : $*MyStruct3
|
|
dealloc_stack %2 : $*MyStruct3
|
|
%15 = tuple ()
|
|
return %15 : $()
|
|
}
|
|
|
|
|
|
// <rdar://problem/21991742> DI miscompiles this testcase into a double free
|
|
class MyClass3 {
|
|
}
|
|
sil @selfinit_myclass3 : $@convention(thin) (@owned MyClass3) -> @owned MyClass3
|
|
|
|
// CHECK-LABEL: sil hidden [ossa] @test_conditional_destroy_class_delegating_init
|
|
sil hidden [ossa] @test_conditional_destroy_class_delegating_init : $@convention(thin) (Builtin.Int1, @owned MyClass3) -> () {
|
|
bb0(%0 : $Builtin.Int1, %1 : @owned $MyClass3):
|
|
// CHECK: [[CONTROL:%[0-9]+]] = alloc_stack $Builtin.Int2
|
|
// CHECK-NEXT: [[SELF_BOX:%[0-9]+]] = alloc_stack [dynamic_lifetime] $MyClass3
|
|
|
|
%2 = alloc_stack $MyClass3
|
|
%3 = mark_uninitialized [delegatingselfallocated] %2 : $*MyClass3
|
|
store %1 to [init] %3 : $*MyClass3
|
|
|
|
// CHECK: cond_br %0, [[SUCCESS:bb[0-9]+]], [[EXIT:bb[0-9]+]]
|
|
cond_br %0, bb1, bb2
|
|
|
|
// CHECK: [[SUCCESS]]:
|
|
bb1:
|
|
%4 = load [take] %3 : $*MyClass3
|
|
%5 = function_ref @selfinit_myclass3 : $@convention(thin) (@owned MyClass3) -> @owned MyClass3
|
|
%6 = apply %5(%4) : $@convention(thin) (@owned MyClass3) -> @owned MyClass3
|
|
store %6 to [init] %3 : $*MyClass3
|
|
|
|
// CHECK: [[SET:%[0-9]+]] = integer_literal $Builtin.Int2, -2
|
|
// CHECK-NEXT: [[OLD:%.*]] = load [trivial] [[CONTROL]]
|
|
// CHECK-NEXT: [[UPDATE:%.*]] = builtin "or_Int2"([[OLD]] : $Builtin.Int2, [[SET]] : $Builtin.Int2)
|
|
// CHECK-NEXT: store [[UPDATE]] to [trivial] [[CONTROL]] : $*Builtin.Int2
|
|
|
|
// CHECK: [[SET:%[0-9]+]] = integer_literal $Builtin.Int2, 1
|
|
// CHECK-NEXT: [[OLD:%.*]] = load [trivial] [[CONTROL]]
|
|
// CHECK-NEXT: [[UPDATE:%.*]] = builtin "or_Int2"([[OLD]] : $Builtin.Int2, [[SET]] : $Builtin.Int2)
|
|
// CHECK-NEXT: store [[UPDATE]] to [trivial] [[CONTROL]] : $*Builtin.Int2
|
|
|
|
// CHECK: [[NEW_SELF:%[0-9]+]] = apply {{.*}}({{.*}}) : $@convention(thin) (@owned MyClass3) -> @owned MyClass3
|
|
// CHECK-NEXT: store [[NEW_SELF]] to [init] [[SELF_BOX]] : $*MyClass3
|
|
|
|
// CHECK-NEXT: br [[CHECK:bb[0-9]+]]
|
|
br bb3
|
|
|
|
bb2:
|
|
br bb3
|
|
|
|
// CHECK: [[CHECK]]:
|
|
bb3:
|
|
|
|
// CHECK-NEXT: [[BIT:%.*]] = load [trivial] [[CONTROL]]
|
|
// CHECK-NEXT: [[COND:%.*]] = builtin "trunc_Int2_Int1"([[BIT]] : $Builtin.Int2) : $Builtin.Int1
|
|
// CHECK-NEXT: cond_br [[COND]], [[PARTIAL:bb[0-9]+]], [[UNINITIALIZED:bb[0-9]+]]
|
|
|
|
// CHECK: [[PARTIAL]]:
|
|
// CHECK-NEXT: [[BIT:%.*]] = load [trivial] [[CONTROL]]
|
|
// CHECK-NEXT: [[ONE:%.*]] = integer_literal $Builtin.Int2, 1
|
|
// CHECK-NEXT: [[SHIFTED:%.*]] = builtin "lshr_Int2"([[BIT]] : $Builtin.Int2, [[ONE]] : $Builtin.Int2) : $Builtin.Int2
|
|
// CHECK-NEXT: [[COND:%.*]] = builtin "trunc_Int2_Int1"([[SHIFTED]] : $Builtin.Int2) : $Builtin.Int1
|
|
// CHECK-NEXT: cond_br [[COND]], [[INITIALIZED:bb[0-9]+]], [[CONSUMED:bb[0-9]+]]
|
|
|
|
// CHECK: [[INITIALIZED]]:
|
|
// CHECK-NEXT: destroy_addr [[SELF_BOX]] : $*MyClass3
|
|
// CHECK-NEXT: br [[EXIT:bb[0-9]+]]
|
|
|
|
// CHECK: [[CONSUMED]]:
|
|
// CHECK-NEXT: br [[EXIT]]
|
|
|
|
// CHECK: [[UNINITIALIZED]]:
|
|
// CHECK-NEXT: [[OLD_SELF:%[0-9]+]] = load [take] [[SELF_BOX]] : $*MyClass3
|
|
// CHECK-NEXT: [[METATYPE:%[0-9]+]] = value_metatype $@thick MyClass3.Type, [[OLD_SELF]] : $MyClass3
|
|
// CHECK-NEXT: dealloc_partial_ref [[OLD_SELF]] : $MyClass3, [[METATYPE]] : $@thick MyClass3.Type
|
|
// CHECK-NEXT: br [[EXIT:bb[0-9]+]]
|
|
|
|
// CHECK: [[EXIT]]:
|
|
|
|
destroy_addr %3 : $*MyClass3
|
|
dealloc_stack %2 : $*MyClass3
|
|
%7 = tuple ()
|
|
return %7 : $()
|
|
}
|
|
|
|
// <rdar://51198592> DI was crashing as it wrongly detected a `type(of: self)`
|
|
// use in a delegating initializer, when there was none.
|
|
class MyClass4 {
|
|
}
|
|
|
|
sil hidden [ossa] @test_self_uninit_use_in_delegating_init : $@convention(method) (@thick MyClass4.Type) -> @owned MyClass4 {
|
|
bb0(%1 : $@thick MyClass4.Type):
|
|
%2 = alloc_stack $MyClass4, let, name "self"
|
|
%3 = mark_uninitialized [delegatingself] %2 : $*MyClass4
|
|
%5 = load_borrow %3 : $*MyClass4 // expected-error {{'self' used before 'self.init' call or assignment to 'self'}}
|
|
end_borrow %5 : $MyClass4
|
|
%7 = load [copy] %3 : $*MyClass4 // expected-error {{'self.init' isn't called on all paths before returning from initializer}}
|
|
destroy_addr %3 : $*MyClass4
|
|
dealloc_stack %2 : $*MyClass4
|
|
return %7 : $MyClass4
|
|
}
|
|
|
|
// A failable initializer: Int.init?(i:) that doesn't initialize along all paths.
|
|
sil hidden [ossa] @intInitExtension : $@convention(method) (Int, Bool) -> Optional<Int> {
|
|
bb0(%0 : $Int, %1 : $Bool):
|
|
%2 = alloc_stack $Int, var, name "self"
|
|
%3 = mark_uninitialized [delegatingself] %2 : $*Int
|
|
%5 = metatype $@thin Int.Type
|
|
%6 = struct_extract %1 : $Bool, #Bool._value
|
|
cond_br %6, bb1, bb2
|
|
|
|
bb1:
|
|
%14 = begin_access [modify] [static] %3 : $*Int
|
|
assign %0 to %14 : $*Int
|
|
end_access %14 : $*Int
|
|
br bb3
|
|
|
|
bb2:
|
|
br bb3
|
|
|
|
bb3:
|
|
%19 = load [trivial] %3 : $*Int // expected-error {{'self.init' isn't called on all paths before returning from initializer}}
|
|
%20 = enum $Optional<Int>, #Optional.some!enumelt, %19 : $Int
|
|
dealloc_stack %2 : $*Int
|
|
br bb5(%20 : $Optional<Int>)
|
|
|
|
bb4:
|
|
dealloc_stack %2 : $*Int
|
|
%24 = enum $Optional<Int>, #Optional.none!enumelt
|
|
br bb5(%24 : $Optional<Int>)
|
|
|
|
bb5(%26 : $Optional<Int>):
|
|
return %26 : $Optional<Int>
|
|
}
|
|
|
|
sil @selfinit_derivedclass_peerconvenience_init : $@convention (thin) (@owned DerivedClassWithNontrivialStoredProperties) -> @owned DerivedClassWithNontrivialStoredProperties
|
|
|
|
// Make sure that we do not error when we store back in the fail block here.
|
|
sil hidden [ossa] @convenience_init_with_throwing_argument : $@convention(method) (@owned DerivedClassWithNontrivialStoredProperties) -> @owned Optional<DerivedClassWithNontrivialStoredProperties> {
|
|
bb0(%0 : @owned $DerivedClassWithNontrivialStoredProperties):
|
|
%1 = alloc_stack $DerivedClassWithNontrivialStoredProperties, let, name "self"
|
|
%2 = mark_uninitialized [delegatingselfallocated] %1 : $*DerivedClassWithNontrivialStoredProperties
|
|
store %0 to [init] %2 : $*DerivedClassWithNontrivialStoredProperties
|
|
%6 = load [take] %2 : $*DerivedClassWithNontrivialStoredProperties
|
|
%7 = function_ref @getThrowingValue : $@convention(thin) () -> (Int, @error any Error)
|
|
try_apply %7() : $@convention(thin) () -> (Int, @error any Error), normal bb1, error bb5
|
|
|
|
bb1(%9 : $Int):
|
|
%10 = function_ref @selfinit_derivedclass_peerconvenience_init : $@convention (thin) (@owned DerivedClassWithNontrivialStoredProperties) -> @owned DerivedClassWithNontrivialStoredProperties
|
|
%11 = apply %10(%6) : $@convention (thin) (@owned DerivedClassWithNontrivialStoredProperties) -> @owned DerivedClassWithNontrivialStoredProperties
|
|
store %11 to [init] %2 : $*DerivedClassWithNontrivialStoredProperties
|
|
%13 = load [copy] %2 : $*DerivedClassWithNontrivialStoredProperties
|
|
%14 = enum $Optional<DerivedClassWithNontrivialStoredProperties>, #Optional.some!enumelt, %13 : $DerivedClassWithNontrivialStoredProperties
|
|
destroy_addr %2 : $*DerivedClassWithNontrivialStoredProperties
|
|
dealloc_stack %1 : $*DerivedClassWithNontrivialStoredProperties
|
|
br bb3(%14 : $Optional<DerivedClassWithNontrivialStoredProperties>)
|
|
|
|
bb2:
|
|
destroy_addr %2 : $*DerivedClassWithNontrivialStoredProperties
|
|
dealloc_stack %1 : $*DerivedClassWithNontrivialStoredProperties
|
|
%20 = enum $Optional<DerivedClassWithNontrivialStoredProperties>, #Optional.none!enumelt
|
|
br bb3(%20 : $Optional<DerivedClassWithNontrivialStoredProperties>)
|
|
|
|
bb3(%22 : @owned $Optional<DerivedClassWithNontrivialStoredProperties>):
|
|
return %22 : $Optional<DerivedClassWithNontrivialStoredProperties>
|
|
|
|
bb4(%24 : @owned $Error):
|
|
%25 = begin_borrow %24 : $Error
|
|
%26 = copy_value %25 : $Error
|
|
debug_value %26 : $Error, let, name "error"
|
|
destroy_value %26 : $Error
|
|
end_borrow %25 : $Error
|
|
destroy_value %24 : $Error
|
|
br bb2
|
|
|
|
bb5(%32 : @owned $Error):
|
|
store %6 to [init] %2 : $*DerivedClassWithNontrivialStoredProperties
|
|
br bb4(%32 : $Error)
|
|
}
|