|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file %s %t |
| 3 | +// RUN: %target-swift-frontend -emit-module %t/Library.swift -parse-as-library -module-name Library -enable-library-evolution -emit-module-path %t/Library.swiftmodule |
| 4 | +// RUN: %target-swift-frontend -emit-silgen -primary-file %t/Primary.swift %t/Other.swift -parse-as-library -module-name Test -I %t | %FileCheck %s --check-prefixes CHECK,CHECK-PRIMARY,CHECK-COMMON |
| 5 | +// RUN: %target-swift-frontend -emit-silgen %t/Primary.swift %t/Other.swift -parse-as-library -module-name Test -I %t | %FileCheck %s --check-prefixes CHECK,CHECK-WHOLE-MODULE,CHECK-COMMON |
| 6 | +// RUN: %target-swift-frontend -emit-silgen -primary-file %t/Primary.swift %t/Other.swift -parse-as-library -module-name Test -I %t -experimental-lazy-typecheck | %FileCheck %s --check-prefixes CHECK,CHECK-PRIMARY,CHECK-COMMON |
| 7 | +// RUN: %target-swift-frontend -emit-silgen -primary-file %t/Primary.swift %t/Other.swift -parse-as-library -module-name Test -I %t -experimental-skip-non-inlinable-function-bodies | %FileCheck %s --check-prefixes CHECK-SKIP,CHECK-COMMON |
| 8 | + |
| 9 | +//--- Library.swift |
| 10 | + |
| 11 | +public protocol P {} |
| 12 | + |
| 13 | +@usableFromInline struct LibraryStruct: P { |
| 14 | + @usableFromInline init() {} |
| 15 | +} |
| 16 | + |
| 17 | +public func returnsLibraryStruct() -> some P { |
| 18 | + return LibraryStruct() |
| 19 | +} |
| 20 | + |
| 21 | +@inlinable public func inlinableReturnsLibraryStruct() -> some P { |
| 22 | + return LibraryStruct() |
| 23 | +} |
| 24 | + |
| 25 | +//--- Other.swift |
| 26 | + |
| 27 | +import Library |
| 28 | + |
| 29 | +struct OtherStruct: P {} |
| 30 | + |
| 31 | +public func returnsOtherStruct() -> some P { |
| 32 | + return OtherStruct() |
| 33 | +} |
| 34 | + |
| 35 | +//--- Primary.swift |
| 36 | + |
| 37 | +import Library |
| 38 | + |
| 39 | +public struct PrimaryStruct: P { |
| 40 | + public init() {} |
| 41 | +} |
| 42 | + |
| 43 | +// CHECK-LABEL: sil{{.*}} @$s4Test20returnsPrimaryStructQryF : $@convention(thin) @substituted <τ_0_0> () -> @out τ_0_0 for <@_opaqueReturnTypeOf("$s4Test20returnsPrimaryStructQryF", 0) __> { |
| 44 | +// CHECK: bb0(%0 : $*PrimaryStruct): |
| 45 | +// CHECK: } // end sil function '$s4Test20returnsPrimaryStructQryF' |
| 46 | +public func returnsPrimaryStruct() -> some P { |
| 47 | + return PrimaryStruct() |
| 48 | +} |
| 49 | + |
| 50 | +// CHECK-COMMON-LABEL: sil{{.*}} @$s4Test024inlinableReturnsResultOfC13PrimaryStructQryF : $@convention(thin) @substituted <τ_0_0> () -> @out τ_0_0 for <@_opaqueReturnTypeOf("$s4Test024inlinableReturnsResultOfC13PrimaryStructQryF", 0) __> { |
| 51 | +// CHECK: bb0(%0 : $*PrimaryStruct): |
| 52 | +// CHECK-SKIP: bb0(%0 : $*@_opaqueReturnTypeOf("$s4Test20returnsPrimaryStructQryF", 0) __): |
| 53 | +// CHECK-COMMON: } // end sil function '$s4Test024inlinableReturnsResultOfC13PrimaryStructQryF' |
| 54 | +@inlinable public func inlinableReturnsResultOfReturnsPrimaryStruct() -> some P { |
| 55 | + return returnsPrimaryStruct() |
| 56 | +} |
| 57 | + |
| 58 | +// CHECK-LABEL: sil{{.*}} @$s4Test19returnsNestedStructQryF : $@convention(thin) @substituted <τ_0_0> () -> @out τ_0_0 for <@_opaqueReturnTypeOf("$s4Test19returnsNestedStructQryF", 0) __> { |
| 59 | +// CHECK: bb0(%0 : $*NestedStruct): |
| 60 | +// CHECK: } // end sil function '$s4Test19returnsNestedStructQryF' |
| 61 | +public func returnsNestedStruct() -> some P { |
| 62 | + struct NestedStruct: P {} |
| 63 | + return NestedStruct() |
| 64 | +} |
| 65 | + |
| 66 | +// CHECK-LABEL: sil{{.*}} @$s4Test34returnsResultOfReturnsNestedStructQryF : $@convention(thin) @substituted <τ_0_0> () -> @out τ_0_0 for <@_opaqueReturnTypeOf("$s4Test34returnsResultOfReturnsNestedStructQryF", 0) __> { |
| 67 | +// CHECK: bb0(%0 : $*NestedStruct): |
| 68 | +// CHECK: } // end sil function '$s4Test34returnsResultOfReturnsNestedStructQryF' |
| 69 | +public func returnsResultOfReturnsNestedStruct() -> some P { |
| 70 | + return returnsNestedStruct() |
| 71 | +} |
| 72 | + |
| 73 | +// CHECK-LABEL: sil{{.*}} @$s4Test33returnsResultOfReturnsOtherStructQryF : $@convention(thin) @substituted <τ_0_0> () -> @out τ_0_0 for <@_opaqueReturnTypeOf("$s4Test33returnsResultOfReturnsOtherStructQryF", 0) __> { |
| 74 | +// CHECK-PRIMARY: bb0(%0 : $*@_opaqueReturnTypeOf("$s4Test18returnsOtherStructQryF", 0) __): |
| 75 | +// CHECK-WHOLE-MODULE: bb0(%0 : $*OtherStruct): |
| 76 | +// CHECK: } // end sil function '$s4Test33returnsResultOfReturnsOtherStructQryF' |
| 77 | +public func returnsResultOfReturnsOtherStruct() -> some P { |
| 78 | + return returnsOtherStruct() |
| 79 | +} |
| 80 | + |
| 81 | +// CHECK-LABEL: sil{{.*}} @$s4Test35returnsResultOfReturnsLibraryStructQryF : $@convention(thin) @substituted <τ_0_0> () -> @out τ_0_0 for <@_opaqueReturnTypeOf("$s4Test35returnsResultOfReturnsLibraryStructQryF", 0) __> { |
| 82 | +// CHECK: bb0(%0 : $*@_opaqueReturnTypeOf("$s7Library07returnsA6StructQryF", 0) __): |
| 83 | +// CHECK: } // end sil function '$s4Test35returnsResultOfReturnsLibraryStructQryF' |
| 84 | +public func returnsResultOfReturnsLibraryStruct() -> some P { |
| 85 | + return returnsLibraryStruct() |
| 86 | +} |
| 87 | + |
| 88 | +// CHECK-LABEL: sil{{.*}} @$s4Test44returnsResulfOfInlinableReturnsLibraryStructQryF : $@convention(thin) @substituted <τ_0_0> () -> @out τ_0_0 for <@_opaqueReturnTypeOf("$s4Test44returnsResulfOfInlinableReturnsLibraryStructQryF", 0) __> { |
| 89 | +// CHECK: bb0(%0 : $*LibraryStruct): |
| 90 | +// CHECK: } // end sil function '$s4Test44returnsResulfOfInlinableReturnsLibraryStructQryF' |
| 91 | +public func returnsResulfOfInlinableReturnsLibraryStruct() -> some P { |
| 92 | + return inlinableReturnsLibraryStruct() |
| 93 | +} |
0 commit comments