|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file %s %t --leading-lines |
| 3 | +// REQUIRES: objc_interop |
| 4 | + |
| 5 | +/// Build a minimal version of Foundation defining only NSError |
| 6 | +// RUN: %target-swift-frontend -emit-module %t/Foundation.swift \ |
| 7 | +// RUN: -o %t/Foundation.swiftmodule |
| 8 | +// RUN: %target-swift-frontend -emit-module %t/FoundationExporter.swift -I%t \ |
| 9 | +// RUN: -o %t/FoundationExporter.swiftmodule |
| 10 | + |
| 11 | +/// Enabled existential to NSError optimization |
| 12 | +// CHECK-OPTIMIZED: $NSError |
| 13 | + |
| 14 | +/// Optimize Foundation itself |
| 15 | +// RUN: %target-swift-frontend -emit-module -emit-sil -I%t \ |
| 16 | +// RUN: -swift-version 5 -enable-library-evolution \ |
| 17 | +// RUN: %t/Foundation.swift > %t/main.sil |
| 18 | +// RUN: %FileCheck --check-prefix CHECK-OPTIMIZED --input-file %t/main.sil %s |
| 19 | + |
| 20 | +/// Public import or non-resilient modules |
| 21 | +// RUN: %target-swift-frontend -emit-module -emit-sil -I%t \ |
| 22 | +// RUN: -swift-version 5 -enable-library-evolution \ |
| 23 | +// RUN: %t/inlinable-public.swift > %t/main.sil |
| 24 | +// RUN: %FileCheck --check-prefix CHECK-OPTIMIZED --input-file %t/main.sil %s |
| 25 | +// RUN: %target-swift-frontend -emit-module -emit-sil -I%t \ |
| 26 | +// RUN: %t/inlinable-public.swift > %t/main.sil |
| 27 | +// RUN: %FileCheck --check-prefix CHECK-OPTIMIZED --input-file %t/main.sil %s |
| 28 | +// RUN: %target-swift-frontend -emit-module -emit-sil -I%t \ |
| 29 | +// RUN: %t/inlinable-internal.swift > %t/main.sil |
| 30 | +// RUN: %FileCheck --check-prefix CHECK-OPTIMIZED --input-file %t/main.sil %s |
| 31 | + |
| 32 | +/// Foundation is imported from a different file |
| 33 | +// RUN: %target-swift-frontend -emit-module -emit-sil -I%t -module-name main \ |
| 34 | +// RUN: %t/inlinable-not-imported-fileA.swift \ |
| 35 | +// RUN: %t/inlinable-not-imported-fileB.swift > %t/main.sil |
| 36 | +// RUN: %FileCheck --check-prefix CHECK-OPTIMIZED --input-file %t/main.sil %s |
| 37 | +// RUN: %target-swift-frontend -emit-module -emit-sil -I%t -module-name main \ |
| 38 | +// RUN: -swift-version 5 -enable-library-evolution \ |
| 39 | +// RUN: %t/inlinable-not-imported-fileA.swift \ |
| 40 | +// RUN: %t/inlinable-not-imported-fileB.swift > %t/main.sil |
| 41 | +// RUN: %FileCheck --check-prefix CHECK-OPTIMIZED --input-file %t/main.sil %s |
| 42 | + |
| 43 | +/// Foundation is imported via a transitive dependency |
| 44 | +// RUN: %target-swift-frontend -emit-module -emit-sil -I%t -module-name main \ |
| 45 | +// RUN: %t/inlinable-imported-transitive.swift > %t/main.sil |
| 46 | +// RUN: %FileCheck --check-prefix CHECK-OPTIMIZED --input-file %t/main.sil %s |
| 47 | + |
| 48 | +/// Any non-inlinable uses |
| 49 | +// RUN: %target-swift-frontend -emit-module -emit-sil -I%t \ |
| 50 | +// RUN: %t/non-inlinable-public.swift > %t/main.sil |
| 51 | +// RUN: %FileCheck --check-prefix CHECK-OPTIMIZED --input-file %t/main.sil %s |
| 52 | +// RUN: %target-swift-frontend -emit-module -emit-sil -I%t \ |
| 53 | +// RUN: %t/non-inlinable-ioi.swift > %t/main.sil |
| 54 | +// RUN: %FileCheck --check-prefix CHECK-OPTIMIZED --input-file %t/main.sil %s |
| 55 | +// RUN: %target-swift-frontend -emit-module -emit-sil -I%t \ |
| 56 | +// RUN: %t/non-inlinable-internal.swift > %t/main.sil |
| 57 | +// RUN: %FileCheck --check-prefix CHECK-OPTIMIZED --input-file %t/main.sil %s |
| 58 | +// RUN: %target-swift-frontend -emit-module -emit-sil -I%t -module-name main \ |
| 59 | +// RUN: %t/non-inlinable-not-imported-fileA.swift \ |
| 60 | +// RUN: %t/non-inlinable-not-imported-fileB.swift > %t/main.sil |
| 61 | +// RUN: %FileCheck --check-prefix CHECK-OPTIMIZED --input-file %t/main.sil %s |
| 62 | +// RUN: %target-swift-frontend -emit-module -emit-sil -I%t -module-name main \ |
| 63 | +// RUN: -swift-version 5 -enable-library-evolution \ |
| 64 | +// RUN: %t/non-inlinable-not-imported-fileA.swift \ |
| 65 | +// RUN: %t/non-inlinable-not-imported-fileB.swift > %t/main.sil |
| 66 | +// RUN: %FileCheck --check-prefix CHECK-OPTIMIZED --input-file %t/main.sil %s |
| 67 | + |
| 68 | +/// Disabled existential to NSError optimization |
| 69 | +// CHECK-NOT-OPTIMIZED-NOT: $NSError |
| 70 | + |
| 71 | +/// Implementation-only import |
| 72 | +// RUN: %target-swift-frontend -emit-module -emit-sil -I%t \ |
| 73 | +// RUN: %t/inlinable-ioi.swift > %t/main.sil |
| 74 | +// RUN: %FileCheck --check-prefix CHECK-NOT-OPTIMIZED --input-file %t/main.sil %s |
| 75 | +// RUN: %target-swift-frontend -emit-module -emit-sil -I%t \ |
| 76 | +// RUN: -swift-version 5 -enable-library-evolution \ |
| 77 | +// RUN: %t/inlinable-ioi.swift > %t/main.sil |
| 78 | +// RUN: %FileCheck --check-prefix CHECK-NOT-OPTIMIZED --input-file %t/main.sil %s |
| 79 | + |
| 80 | +/// Internal import from resilient module |
| 81 | +// RUN: %target-swift-frontend -emit-module -emit-sil -I%t \ |
| 82 | +// RUN: -swift-version 5 -enable-library-evolution \ |
| 83 | +// RUN: %t/inlinable-internal.swift > %t/main.sil |
| 84 | +// RUN: %FileCheck --check-prefix CHECK-NOT-OPTIMIZED --input-file %t/main.sil %s |
| 85 | + |
| 86 | +//--- Foundation.swift |
| 87 | + |
| 88 | +class NSError {} |
| 89 | + |
| 90 | +@inlinable public func foo<E: Error>(e: E) -> Error { |
| 91 | + return e |
| 92 | +} |
| 93 | + |
| 94 | +//--- FoundationExporter.swift |
| 95 | + |
| 96 | +@_exported import Foundation |
| 97 | + |
| 98 | +//--- inlinable-public.swift |
| 99 | +public import Foundation |
| 100 | + |
| 101 | +@inlinable public func foo<E: Error>(e: E) -> Error { |
| 102 | + return e |
| 103 | +} |
| 104 | + |
| 105 | +//--- inlinable-ioi.swift |
| 106 | +@_implementationOnly import Foundation |
| 107 | + |
| 108 | +@inlinable public func foo<E: Error>(e: E) -> Error { |
| 109 | + return e |
| 110 | +} |
| 111 | + |
| 112 | +//--- inlinable-internal.swift |
| 113 | +internal import Foundation |
| 114 | + |
| 115 | +@inlinable public func foo<E: Error>(e: E) -> Error { |
| 116 | + return e |
| 117 | +} |
| 118 | + |
| 119 | +//--- inlinable-not-imported-fileA.swift |
| 120 | +@inlinable public func foo<E: Error>(e: E) -> Error { |
| 121 | + return e |
| 122 | +} |
| 123 | +//--- inlinable-not-imported-fileB.swift |
| 124 | +import Foundation |
| 125 | + |
| 126 | +//--- inlinable-imported-transitive.swift |
| 127 | +public import FoundationExporter |
| 128 | + |
| 129 | +@inlinable public func foo<E: Error>(e: E) -> Error { |
| 130 | + return e |
| 131 | +} |
| 132 | + |
| 133 | +//--- non-inlinable-public.swift |
| 134 | +public import Foundation |
| 135 | + |
| 136 | +public func foo<E: Error>(e: E) -> Error { |
| 137 | + return e |
| 138 | +} |
| 139 | + |
| 140 | +//--- non-inlinable-ioi.swift |
| 141 | +@_implementationOnly import Foundation |
| 142 | + |
| 143 | +public func foo<E: Error>(e: E) -> Error { |
| 144 | + return e |
| 145 | +} |
| 146 | + |
| 147 | +//--- non-inlinable-internal.swift |
| 148 | +internal import Foundation |
| 149 | + |
| 150 | +public func foo<E: Error>(e: E) -> Error { |
| 151 | + return e |
| 152 | +} |
| 153 | + |
| 154 | +//--- non-inlinable-not-imported-fileA.swift |
| 155 | +public func foo<E: Error>(e: E) -> Error { |
| 156 | + return e |
| 157 | +} |
| 158 | +//--- non-inlinable-not-imported-fileB.swift |
| 159 | +import Foundation |
0 commit comments