blob: 5f09e2674d6523f6dc40a748766aa089f2473cd8 [file] [log] [blame]
// RUN: %target-sil-opt -mandatory-combine -sil-mandatory-combine-enable-canon-and-simple-dce %s | %FileCheck %s
// Tests for when the mandatory combiner is running with optimizations
// enabled. Only put tests here for functionality that only occurs when the
// Mandatory Combiner runs in between the diagnostics/perf pipeline at -O,
// -Osize.
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
}
// 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
// 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
// Optional support
enum FakeOptional<T> {
case none
case some(T)
}
///////////
// Tests //
///////////
// CHECK-LABEL: sil [ossa] @eliminate_simple_arc_traffic : $@convention(thin) (@guaranteed Klass) -> () {
// CHECK-NOT: copy_value
// CHECK-NOT: destroy_value
// CHECK-NOT: enum
// CHECK-NOT: end_borrow
// CHECK: } // end sil function 'eliminate_simple_arc_traffic'
sil [ossa] @eliminate_simple_arc_traffic : $@convention(thin) (@guaranteed Klass) -> () {
bb0(%0 : @guaranteed $Klass):
%1 = copy_value %0 : $Klass
destroy_value %1 : $Klass
%2 = enum $FakeOptional<Klass>, #FakeOptional.none!enumelt
end_borrow %2 : $FakeOptional<Klass>
%9999 = tuple()
return %9999 : $()
}