|
1 | 1 | // RUN: %empty-directory(%t)
|
2 | 2 | // RUN: %target-swift-frontend %S/Inputs/specialize_opaque_type_archetypes_2.swift -module-name External -emit-module -emit-module-path %t/External.swiftmodule
|
3 | 3 | // RUN: %target-swift-frontend %S/Inputs/specialize_opaque_type_archetypes_3.swift -enable-library-evolution -module-name External2 -emit-module -emit-module-path %t/External2.swiftmodule
|
| 4 | +// RUN: %target-swift-frontend %S/Inputs/specialize_opaque_type_archetypes_4.swift -I %t -enable-library-evolution -module-name External3 -emit-module -emit-module-path %t/External3.swiftmodule |
4 | 5 | // RUN: %target-swift-frontend -I %t -module-name A -enforce-exclusivity=checked -Osize -emit-sil -sil-verify-all %s | %FileCheck %s
|
5 | 6 | // RUN: %target-swift-frontend -I %t -module-name A -enforce-exclusivity=checked -enable-library-evolution -Osize -emit-sil -sil-verify-all %s | %FileCheck %s
|
6 | 7 | import External
|
7 | 8 | import External2
|
| 9 | +import External3 |
8 | 10 |
|
9 | 11 | public protocol P {
|
10 | 12 | func myValue() -> Int64
|
@@ -260,3 +262,39 @@ extension P3 {
|
260 | 262 | return Adapter(inner: self)
|
261 | 263 | }
|
262 | 264 | }
|
| 265 | + |
| 266 | +// We should specialize the opaque type because the resilient function is |
| 267 | +// inlineable. |
| 268 | + |
| 269 | +// CHECK-LABEL: sil @$s1A21useExternalResilient2yyF : $@convention(thin) () -> () |
| 270 | +// CHECK: [[RES:%.*]] = alloc_stack $Int64 |
| 271 | +// CHECK: [[FUN:%.*]] = function_ref @$s9External226inlinableExternalResilientQryF : $@convention(thin) () -> @out @_opaqueReturnTypeOf("$s9External226inlinableExternalResilientQryF", 0) |
| 272 | +// CHECK: [[RES2:%.*]] = unchecked_addr_cast [[RES]] : $*Int64 to $*@_opaqueReturnTypeOf("$s9External226inlinableExternalResilientQryF", 0) |
| 273 | +// CHECK: apply [[FUN]]([[RES2]]) |
| 274 | +// CHECK: return |
| 275 | +public func useExternalResilient2() { |
| 276 | + let e = inlinableExternalResilient() |
| 277 | + useP(e.myValue3()) |
| 278 | +} |
| 279 | + |
| 280 | +// In this case we should only 'peel' one layer of opaque archetypes. |
| 281 | +// CHECK-LABEL: sil @$s1A21useExternalResilient3yyF |
| 282 | +// CHECK: [[RES:%.*]] = alloc_stack $@_opaqueReturnTypeOf("$s9External217externalResilientQryF", 0) |
| 283 | +// CHECK: [[FUN:%.*]] = function_ref @$s9External3031inlinableExternalResilientCallsD0QryF : $@convention(thin) () -> @out @_opaqueReturnTypeOf("$s9External3031inlinableExternalResilientCallsD0QryF", 0) |
| 284 | +// CHECK: [[RES2:%.*]] = unchecked_addr_cast [[RES]] : $*@_opaqueReturnTypeOf("$s9External217externalResilientQryF", 0){{.*}}to $*@_opaqueReturnTypeOf("$s9External3031inlinableExternalResilientCallsD0QryF", 0) |
| 285 | +// CHECK: apply [[FUN]]([[RES2]]) |
| 286 | +public func useExternalResilient3() { |
| 287 | + let e = inlinableExternalResilientCallsResilient() |
| 288 | + useP(e.myValue3()) |
| 289 | +} |
| 290 | + |
| 291 | +// Check that we can look throught two layers of inlinable resilient functions. |
| 292 | +// CHECK-LABEL: sil @$s1A21useExternalResilient4yyF |
| 293 | +// CHECK: [[RES:%.*]] = alloc_stack $Int64 |
| 294 | +// CHECK: [[FUN:%.*]] = function_ref @$s9External3040inlinableExternalResilientCallsInlinablecD0QryF : $@convention(thin) () -> @out @_opaqueReturnTypeOf("$s9External3040inlinableExternalResilientCallsInlinablecD0QryF", 0) |
| 295 | +// CHECK: [[RES2:%.*]] = unchecked_addr_cast [[RES]] : $*Int64 to $*@_opaqueReturnTypeOf("$s9External3040inlinableExternalResilientCallsInlinablecD0QryF", 0) |
| 296 | +// CHECK: apply [[FUN]]([[RES2]]) |
| 297 | +public func useExternalResilient4() { |
| 298 | + let e = inlinableExternalResilientCallsInlinableExternalResilient() |
| 299 | + useP(e.myValue3()) |
| 300 | +} |
0 commit comments