1
1
// RUN: %target-swift-frontend -target %target-cpu-apple-macos10.15 -emit-sil %s | %FileCheck --check-prefix=CHECK-macosx10_15 %s
2
2
// RUN: %target-swift-frontend -target %target-cpu-apple-macos10.14 -emit-sil %s | %FileCheck --check-prefix=CHECK-macosx10_14 %s
3
- // RUN: %target-swift-frontend -O -target %target-cpu-apple-macos10.15 -emit-sil %s | %FileCheck --check-prefix=CHECK-macosx10_15 %s
3
+ // RUN: %target-swift-frontend -O -target %target-cpu-apple-macos10.15 -emit-sil %s | %FileCheck --check-prefix=CHECK-macosx10_15 --check-prefix=CHECK-macosx10_15_opt %s
4
4
// RUN: %target-swift-frontend -O -target %target-cpu-apple-macos10.14 -emit-sil %s | %FileCheck --check-prefix=CHECK-macosx10_14 %s
5
5
6
+ // RUN: %empty-directory(%t)
7
+ // RUN: %target-swift-frontend -O -target %target-cpu-apple-macos10.15 -module-name=Test -emit-module -emit-module-path %t/Test.swiftmodule %s
8
+ // RUN: %sil-opt -target %target-cpu-apple-macos10.15 %t/Test.swiftmodule | %FileCheck --check-prefix=CHECK-inlinable %s
9
+
6
10
// REQUIRES: OS=macosx
7
11
8
12
@available ( macOS 10 . 15 , * )
@@ -24,13 +28,31 @@ public func testAvailabilityPropagation() -> Int {
24
28
}
25
29
}
26
30
31
+ @inlinable
32
+ public func testInlinable( ) -> Int {
33
+ if #available( macOS 10 . 15 , * ) {
34
+ return newFunction ( )
35
+ } else {
36
+ return 0
37
+ }
38
+ }
39
+
27
40
// CHECK-macosx10_15-LABEL: sil @$s33constant_propagation_availability27testAvailabilityPropagationSiyF : $@convention(thin) () -> Int {
28
41
// CHECK-macosx10_15-NOT: apply
29
42
// CHECK-macosx10_15: [[F:%.*]] = function_ref @$s33constant_propagation_availability11newFunctionSiyF
30
43
// CHECK-macosx10_15: apply [[F]]() : $@convention(thin) () -> Int
31
44
// CHECK-macosx10_15-NOT: apply
32
45
// CHECK-macosx10_15: } // end sil function '$s33constant_propagation_availability27testAvailabilityPropagationSiyF'
33
46
47
+ // After serialization, availability checks can be constant folded.
48
+
49
+ // CHECK-macosx10_15_opt-LABEL: sil @$s33constant_propagation_availability13testInlinableSiyF : $@convention(thin) () -> Int {
50
+ // CHECK-macosx10_15_opt-NOT: apply
51
+ // CHECK-macosx10_15_opt: [[F:%.*]] = function_ref @$s33constant_propagation_availability11newFunctionSiyF
52
+ // CHECK-macosx10_15_opt: apply [[F]]() : $@convention(thin) () -> Int
53
+ // CHECK-macosx10_15_opt-NOT: apply
54
+ // CHECK-macosx10_15_opt: } // end sil function '$s33constant_propagation_availability13testInlinableSiyF'
55
+
34
56
// CHECK-macosx10_14-LABEL: sil @$s33constant_propagation_availability27testAvailabilityPropagationSiyF : $@convention(thin) () -> Int {
35
57
// CHECK-macosx10_14: [[F:%.*]] = function_ref @$ss26_stdlib_isOSVersionAtLeastyBi1_Bw_BwBwtF
36
58
// CHECK-macosx10_14: apply [[F]]
@@ -41,3 +63,10 @@ public func testAvailabilityPropagation() -> Int {
41
63
// CHECK-macosx10_14: } // end sil function '$s33constant_propagation_availability27testAvailabilityPropagationSiyF'
42
64
43
65
// CHECK-macosx10_14: sil [readnone] [_semantics "availability.osversion"] @$ss26_stdlib_isOSVersionAtLeastyBi1_Bw_BwBwtF
66
+
67
+ // CHECK-inlinable-LABEL: sil {{.*}} @$s4Test13testInlinableSiyF : $@convention(thin) () -> Int {
68
+ // CHECK-inlinable: [[F:%.*]] = function_ref @$ss26_stdlib_isOSVersionAtLeastyBi1_Bw_BwBwtF
69
+ // CHECK-inlinable: apply [[F]]
70
+ // CHECK-inlinable: [[F:%.*]] = function_ref @$s4Test11newFunctionSiyF
71
+ // CHECK-inlinable: apply [[F]]() : $@convention(thin) () -> Int
72
+ // CHECK-inlinable: } // end sil function '$s4Test13testInlinableSiyF'
0 commit comments