11// RUN: %target-swift-frontend -target %target-cpu-apple-macos10.15 -emit-sil %s | %FileCheck --check-prefix=CHECK-macosx10_15 %s
22// 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
44// RUN: %target-swift-frontend -O -target %target-cpu-apple-macos10.14 -emit-sil %s | %FileCheck --check-prefix=CHECK-macosx10_14 %s
55
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+
610// REQUIRES: OS=macosx
711
812@available ( macOS 10 . 15 , * )
@@ -24,13 +28,31 @@ public func testAvailabilityPropagation() -> Int {
2428 }
2529}
2630
31+ @inlinable
32+ public func testInlinable( ) -> Int {
33+ if #available( macOS 10 . 15 , * ) {
34+ return newFunction ( )
35+ } else {
36+ return 0
37+ }
38+ }
39+
2740// CHECK-macosx10_15-LABEL: sil @$s33constant_propagation_availability27testAvailabilityPropagationSiyF : $@convention(thin) () -> Int {
2841// CHECK-macosx10_15-NOT: apply
2942// CHECK-macosx10_15: [[F:%.*]] = function_ref @$s33constant_propagation_availability11newFunctionSiyF
3043// CHECK-macosx10_15: apply [[F]]() : $@convention(thin) () -> Int
3144// CHECK-macosx10_15-NOT: apply
3245// CHECK-macosx10_15: } // end sil function '$s33constant_propagation_availability27testAvailabilityPropagationSiyF'
3346
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+
3456// CHECK-macosx10_14-LABEL: sil @$s33constant_propagation_availability27testAvailabilityPropagationSiyF : $@convention(thin) () -> Int {
3557// CHECK-macosx10_14: [[F:%.*]] = function_ref @$ss26_stdlib_isOSVersionAtLeastyBi1_Bw_BwBwtF
3658// CHECK-macosx10_14: apply [[F]]
@@ -41,3 +63,10 @@ public func testAvailabilityPropagation() -> Int {
4163// CHECK-macosx10_14: } // end sil function '$s33constant_propagation_availability27testAvailabilityPropagationSiyF'
4264
4365// 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