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