1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
// RUN: %target-sil-opt -enable-sil-verify-all -sil-combine %s | %FileCheck %s
sil_stage canonical
import Builtin
// Trivial declarations
struct MyInt {
var value: Builtin.Int64
}
// Generic declarations
protocol Addable {
static var an: Self { get }
}
// Class declarations
class Klass {
init()
deinit
}
class SubKlass : Klass {}
sil @use_klass_unowned : $@convention(thin) (Klass) -> ()
// Existential declarations
protocol Proto {
static var an: Proto { get }
}
// Trivial support
sil @first_of_three_ints : $@convention(thin) (MyInt, MyInt, MyInt) -> MyInt
sil @constant_zero : $@convention(thin) () -> MyInt
sil @identity_int : $@convention(thin) (MyInt) -> MyInt
// Generic support
sil @first_of_three_addables : $@convention(thin) <A where A : Addable> (@in_guaranteed A, @guaranteed <τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <A>, @guaranteed <τ_0_0 where τ_0_0 : Addable> { var τ_0_0 } <A>) -> @
out A
// Class support
sil [exact_self_class] @klass_alloc_init : $@convention(method) (@thick Klass.Type) -> @owned Klass
// Klass.init()
sil @klass_init : $@convention(method) (@owned Klass) -> @owned Klass
// Klass.deinit
sil @klass_deinit : $@convention(method) (@guaranteed Klass) -> @owned Builtin.NativeObject
// Klass.__deallocating_deinit
sil @klass_dealloc_deinit : $@convention(method) (@owned Klass) -> ()
sil_vtable Klass {
#Klass.init!allocator: (Klass.Type) -> () -> Klass : @klass_alloc_init
#Klass.deinit!deallocator: @klass_dealloc_deinit
}
sil @first_of_three_klasses : $@convention(thin) (@guaranteed Klass, @guaranteed Klass, @guaranteed Klass) -> @owned Klass
sil @use_klass_guaranteed : $@convention(thin) (@guaranteed Klass) -> ()
// Existential support
sil @first_of_three_protos : $@convention(thin) (@in_guaranteed Proto, @guaranteed { var Proto }, @guaranteed { var Proto }) -> @out Proto
sil @get_proto : $@convention(thin) () -> @out Proto
// Mixed support
sil @proto_from_proto_and_myint : $@convention(thin) (@in_guaranteed Proto, MyInt) -> @out Proto
sil @myint_from_myint_and_proto : $@convention(thin) (MyInt, @guaranteed { var Proto }) -> MyInt
sil @myint_from_proto_and_myint : $@convention(thin) (@guaranteed { var Proto }, MyInt) -> MyInt
// Enum support
enum FakeOptional<T> {
case none
case some(T)
}
sil @use_fakeoptional_klass_guaranteed : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> ()
///////////
// Tests //
///////////
// CHECK-LABEL: sil [ossa] @testUnneededDestroyOfForwardingInst : $@convention(thin) (@owned Klass) -> () {
// CHECK-NOT: unchecked_ref_cast
// CHECK: } // end sil function 'testUnneededDestroyOfForwardingInst'
sil [ossa] @testUnneededDestroyOfForwardingInst : $@convention(thin) (@owned Klass) -> () {
bb0(%0 : @owned $Klass):
%1 = unchecked_ref_cast %0 : $Klass to $Builtin.NativeObject
destroy_value %1 : $Builtin.NativeObject
%9999 = tuple()
return %9999 : $()
}
|