|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-swift-frontend -disable-availability-checking -primary-file %S/Inputs/specialize_opaque_result_types.swift -enable-library-evolution -module-name A -emit-sib -o %t/A.sib |
| 3 | +// RUN: %target-swift-frontend -emit-sil -primary-file %s -enable-library-evolution -O -module-name A %t/A.sib -o - | %FileCheck %s |
| 4 | + |
| 5 | +// REQUIRES: CPU=x86_64 |
| 6 | + |
| 7 | +sil_stage canonical |
| 8 | + |
| 9 | +import Builtin |
| 10 | +import Swift |
| 11 | +import SwiftShims |
| 12 | + |
| 13 | +typealias SomeButt = @_opaqueReturnTypeOf("$s1A19exportsOpaqueReturnQryF", 0) opaque |
| 14 | + |
| 15 | +sil @$foobar : $@convention(thin) () -> @out SomeButt { |
| 16 | +bb0(%0 : $*Int): |
| 17 | + %1 = integer_literal $Builtin.Int64, 0 // user: %2 |
| 18 | + %2 = struct $Int (%1 : $Builtin.Int64) // user: %3 |
| 19 | + store %2 to %0 : $*Int // id: %3 |
| 20 | + %4 = tuple () // user: %5 |
| 21 | + return %4 : $() // id: %5 |
| 22 | +} |
| 23 | + |
| 24 | +sil @getGenericClosure_closure : $@convention(thin) <T> (@owned <τ_0_0> { var τ_0_0 } <T>) -> @out T |
| 25 | + |
| 26 | +sil [noinline] @getGenericClosure : $@convention(thin) <T> (@in T) -> @owned @callee_owned () -> @out T { |
| 27 | +bb0(%0 : $*T): |
| 28 | + debug_value_addr %0 : $*T, let, name "t" // id: %1 |
| 29 | + %2 = function_ref @getGenericClosure_closure : $@convention(thin) <τ_0_0> (@owned <τ_0_0> { var τ_0_0 } <τ_0_0>) -> @out τ_0_0 // user: %5 |
| 30 | + %3 = alloc_box $<τ_0_0> { var τ_0_0 } <T> // users: %4, %5, %5 |
| 31 | + %3a = project_box %3 : $<τ_0_0> { var τ_0_0 } <T>, 0 |
| 32 | + copy_addr %0 to [initialization] %3a : $*T // id: %4 |
| 33 | + %5 = partial_apply %2<T>(%3) : $@convention(thin) <τ_0_0> (@owned <τ_0_0> { var τ_0_0 } <τ_0_0>) -> @out τ_0_0 // user: %7 |
| 34 | + destroy_addr %0 : $*T // id: %6 |
| 35 | + return %5 : $@callee_owned () -> @out T // id: %7 |
| 36 | +} |
| 37 | + |
| 38 | +// CHECK-LABEL: sil shared [noinline] @$s17getGenericClosure1A19exportsOpaqueReturnQryFQOyQo__Tg5 : $@convention(thin) (Int) -> @owned @callee_owned () -> @out Int { |
| 39 | +// CHECK: alloc_box $<τ_0_0> { var τ_0_0 } <Int> |
| 40 | +// CHECK: } // end sil function '$s17getGenericClosure1A19exportsOpaqueReturnQryFQOyQo__Tg5' |
| 41 | + |
| 42 | +sil [transparent] [serialized] @specializePartialApplies : $@convention(thin) (@in SomeButt) -> () { |
| 43 | +bb0(%0 : $*SomeButt): |
| 44 | + %5 = function_ref @getGenericClosure : $@convention(thin) <τ_0_0> (@in τ_0_0) -> @owned @callee_owned () -> @out τ_0_0 |
| 45 | + %8 = apply %5<SomeButt>(%0) : $@convention(thin) <τ_0_0> (@in τ_0_0) -> @owned @callee_owned () -> @out τ_0_0 |
| 46 | + %15 = tuple() |
| 47 | + return %15 : $() |
| 48 | +} |
0 commit comments