Skip to content

Commit b4c219b

Browse files
committed
SILGen: Upstream back_deployed_attr_maccatalyst.swift test.
This test was missed in swiftlang#75432.
1 parent 467f259 commit b4c219b

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// RUN: %target-swift-emit-sil -parse-as-library -module-name back_deploy %s -target %target-cpu-apple-ios13.1-macabi -verify
2+
// RUN: %target-swift-emit-silgen -parse-as-library -module-name back_deploy %s -target %target-cpu-apple-ios13.1-macabi | %FileCheck %s
3+
4+
// REQUIRES: OS=macosx || OS=maccatalyst
5+
6+
// -- Original definition of trivialFunc_macOS()
7+
// CHECK-LABEL: sil [ossa] @$s11back_deploy17trivialFunc_macOSyyF : $@convention(thin) () -> ()
8+
@backDeployed(before: macOS 10.53)
9+
public func trivialFunc_macOS() {}
10+
11+
// -- Fallback definition of trivialFunc_iOS_macOS()
12+
// CHECK-LABEL: sil non_abi [serialized] [ossa] @$s11back_deploy019trivialFunc_iOS_macE0yyFTwB : $@convention(thin) () -> ()
13+
// CHECK: bb0:
14+
// CHECK: [[RESULT:%.*]] = tuple ()
15+
// CHECK: return [[RESULT]] : $()
16+
17+
// -- Back deployment thunk for trivialFunc_iOS_macOS()
18+
// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy019trivialFunc_iOS_macE0yyFTwb : $@convention(thin) () -> ()
19+
// CHECK: bb0:
20+
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 51
21+
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 1
22+
// CHECK: [[PATCH:%.*]] = integer_literal $Builtin.Word, 0
23+
// CHECK: [[OSVFN:%.*]] = function_ref @$ss33_stdlib_isVariantOSVersionAtLeastyBi1_Bw_BwBwtF : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
24+
// CHECK: [[AVAIL:%.*]] = apply [[OSVFN]]([[MAJOR]], [[MINOR]], [[PATCH]]) : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
25+
// CHECK: cond_br [[AVAIL]], [[AVAIL_BB:bb[0-9]+]], [[UNAVAIL_BB:bb[0-9]+]]
26+
//
27+
// CHECK: [[UNAVAIL_BB]]:
28+
// CHECK: [[FALLBACKFN:%.*]] = function_ref @$s11back_deploy019trivialFunc_iOS_macE0yyFTwB : $@convention(thin) () -> ()
29+
// CHECK: {{%.*}} = apply [[FALLBACKFN]]() : $@convention(thin) () -> ()
30+
// CHECK: br [[RETURN_BB:bb[0-9]+]]
31+
//
32+
// CHECK: [[AVAIL_BB]]:
33+
// CHECK: [[ORIGFN:%.*]] = function_ref @$s11back_deploy019trivialFunc_iOS_macE0yyF : $@convention(thin) () -> ()
34+
// CHECK: {{%.*}} = apply [[ORIGFN]]() : $@convention(thin) () -> ()
35+
// CHECK: br [[RETURN_BB]]
36+
//
37+
// CHECK: [[RETURN_BB]]
38+
// CHECK: [[RESULT:%.*]] = tuple ()
39+
// CHECK: return [[RESULT]] : $()
40+
41+
// -- Original definition of trivialFunc_iOS_macOS()
42+
// CHECK-LABEL: sil [available 51.1] [ossa] @$s11back_deploy019trivialFunc_iOS_macE0yyF : $@convention(thin) () -> ()
43+
@backDeployed(before: iOS 51.1, macOS 10.53)
44+
public func trivialFunc_iOS_macOS() {}
45+
46+
// -- Fallback definition of trivialFunc_iOS_macOS_macCatalyst()
47+
// CHECK-LABEL: sil non_abi [serialized] [ossa] @$s11back_deploy019trivialFunc_iOS_mace1_F8CatalystyyFTwB : $@convention(thin) () -> ()
48+
// CHECK: bb0:
49+
// CHECK: [[RESULT:%.*]] = tuple ()
50+
// CHECK: return [[RESULT]] : $()
51+
52+
// -- Back deployment thunk for trivialFunc_iOS_macOS_macCatalyst()
53+
// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy019trivialFunc_iOS_mace1_F8CatalystyyFTwb : $@convention(thin) () -> ()
54+
// CHECK: bb0:
55+
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 53
56+
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 2
57+
// CHECK: [[PATCH:%.*]] = integer_literal $Builtin.Word, 0
58+
// CHECK: [[OSVFN:%.*]] = function_ref @$ss33_stdlib_isVariantOSVersionAtLeastyBi1_Bw_BwBwtF : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
59+
// CHECK: [[AVAIL:%.*]] = apply [[OSVFN]]([[MAJOR]], [[MINOR]], [[PATCH]]) : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
60+
// CHECK: cond_br [[AVAIL]], [[AVAIL_BB:bb[0-9]+]], [[UNAVAIL_BB:bb[0-9]+]]
61+
//
62+
// CHECK: [[UNAVAIL_BB]]:
63+
// CHECK: [[FALLBACKFN:%.*]] = function_ref @$s11back_deploy019trivialFunc_iOS_mace1_F8CatalystyyFTwB : $@convention(thin) () -> ()
64+
// CHECK: {{%.*}} = apply [[FALLBACKFN]]() : $@convention(thin) () -> ()
65+
// CHECK: br [[RETURN_BB:bb[0-9]+]]
66+
//
67+
// CHECK: [[AVAIL_BB]]:
68+
// CHECK: [[ORIGFN:%.*]] = function_ref @$s11back_deploy019trivialFunc_iOS_mace1_F8CatalystyyF : $@convention(thin) () -> ()
69+
// CHECK: {{%.*}} = apply [[ORIGFN]]() : $@convention(thin) () -> ()
70+
// CHECK: br [[RETURN_BB]]
71+
//
72+
// CHECK: [[RETURN_BB]]
73+
// CHECK: [[RESULT:%.*]] = tuple ()
74+
// CHECK: return [[RESULT]] : $()
75+
76+
// -- Original definition of trivialFunc_iOS_macOS_macCatalyst()
77+
// CHECK-LABEL: sil [available 53.2] [ossa] @$s11back_deploy019trivialFunc_iOS_mace1_F8CatalystyyF : $@convention(thin) () -> ()
78+
@backDeployed(before: iOS 51.1, macOS 10.53, macCatalyst 53.2)
79+
public func trivialFunc_iOS_macOS_macCatalyst() {}
80+
81+
// CHECK-LABEL: sil hidden [ossa] @$s11back_deploy6calleryyF : $@convention(thin) () -> ()
82+
func caller() {
83+
// -- Verify the thunk is not called
84+
// The function is not back deployed on iOS so it should be called directly.
85+
// CHECK: {{%.*}} = function_ref @$s11back_deploy17trivialFunc_macOSyyF : $@convention(thin) () -> ()
86+
trivialFunc_macOS()
87+
88+
// -- Verify the thunk is called
89+
// CHECK: {{%.*}} = function_ref @$s11back_deploy019trivialFunc_iOS_macE0yyFTwb : $@convention(thin) () -> ()
90+
trivialFunc_iOS_macOS()
91+
// CHECK: {{%.*}} = function_ref @$s11back_deploy019trivialFunc_iOS_mace1_F8CatalystyyFTwb : $@convention(thin) () -> ()
92+
trivialFunc_iOS_macOS_macCatalyst()
93+
}

0 commit comments

Comments
 (0)