|
| 1 | +// RUN: %target-sil-opt -enable-sil-verify-all -generic-specializer %s | %FileCheck %s |
| 2 | + |
| 3 | +// REQUIRES: objc_interop |
| 4 | + |
| 5 | +sil_stage canonical |
| 6 | + |
| 7 | +import Builtin |
| 8 | +import Swift |
| 9 | +import SwiftShims |
| 10 | + |
| 11 | +import Foundation |
| 12 | + |
| 13 | +public enum ResultType : Equatable { |
| 14 | + case object(NSObject) |
| 15 | + case undefined |
| 16 | + internal init<T>(metatypeOf value: T) |
| 17 | +} |
| 18 | + |
| 19 | +// CHECK-LABEL: // specialized callee_anyobject |
| 20 | +// CHECK-LABEL: sil shared [ossa] @$s16callee_anyobjectyXl_Tt0g5 : |
| 21 | +// CHECK: checked_cast_addr_br |
| 22 | +// CHECK-LABEL: } // end sil function '$s16callee_anyobjectyXl_Tt0g5' |
| 23 | +sil hidden [ossa] @callee_anyobject : $@convention(method) <T> (@in T, @thin ResultType.Type) -> @owned ResultType { |
| 24 | +bb0(%0 : $*T, %1 : $@thin ResultType.Type): |
| 25 | + %3 = alloc_stack $T |
| 26 | + copy_addr %0 to [init] %3 |
| 27 | + %5 = alloc_stack $NSObject |
| 28 | + checked_cast_addr_br copy_on_success T in %3 to NSObject in %5, bb1, bb2 |
| 29 | + |
| 30 | +bb1: |
| 31 | + destroy_addr %0 |
| 32 | + %8 = enum $ResultType, #ResultType.undefined!enumelt |
| 33 | + destroy_addr %5 |
| 34 | + dealloc_stack %5 |
| 35 | + br bb5(%8) |
| 36 | + |
| 37 | +bb2: |
| 38 | + destroy_addr %0 |
| 39 | + dealloc_stack %5 |
| 40 | + %28 = enum $ResultType, #ResultType.undefined!enumelt |
| 41 | + br bb5(%28) |
| 42 | + |
| 43 | +bb5(%30 : @owned $ResultType): |
| 44 | + destroy_addr %3 |
| 45 | + dealloc_stack %3 |
| 46 | + %34 = move_value [lexical] %30 |
| 47 | + return %34 |
| 48 | +} |
| 49 | + |
| 50 | +sil hidden [ossa] @caller_anyobject : $@convention(thin) (@owned AnyObject) -> () { |
| 51 | +bb0(%0 : @owned $AnyObject): |
| 52 | + %1 = metatype $@thin ResultType.Type |
| 53 | + %2 = alloc_stack $AnyObject |
| 54 | + store %0 to [init] %2 |
| 55 | + %4 = function_ref @callee_anyobject : $@convention(method) <τ_0_0> (@in τ_0_0, @thin ResultType.Type) -> @owned ResultType |
| 56 | + %5 = apply %4<AnyObject>(%2, %1) : $@convention(method) <τ_0_0> (@in τ_0_0, @thin ResultType.Type) -> @owned ResultType |
| 57 | + dealloc_stack %2 |
| 58 | + destroy_value %5 |
| 59 | + %8 = tuple () |
| 60 | + return %8 |
| 61 | +} |
| 62 | + |
0 commit comments