Skip to content

Commit 8502c89

Browse files
committed
SIL: Print thunk kind attribute for @backDeployed thunks.
As promised in the FIXME, update the SIL printer and parser to handle the new thunk kind for `@backDeployed` thunks. Follow up to #76135.
1 parent a9120c3 commit 8502c89

13 files changed

+20
-15
lines changed

docs/SIL.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,7 @@ information when inlined.
11771177
sil-function-thunk ::= 'thunk'
11781178
sil-function-thunk ::= 'signature_optimized_thunk'
11791179
sil-function-thunk ::= 'reabstraction_thunk'
1180+
sil-function-thunk ::= 'back_deployed_thunk'
11801181

11811182
The function is a compiler generated thunk.
11821183
::

lib/SIL/IR/SILPrinter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3387,7 +3387,9 @@ void SILFunction::print(SILPrintContext &PrintCtx) const {
33873387

33883388
switch (isThunk()) {
33893389
case IsNotThunk: break;
3390-
case IsBackDeployedThunk: // FIXME: Give this a distinct label
3390+
case IsBackDeployedThunk:
3391+
OS << "[back_deployed_thunk] ";
3392+
break;
33913393
case IsThunk: OS << "[thunk] "; break;
33923394
case IsSignatureOptimizedThunk:
33933395
OS << "[signature_optimized_thunk] ";

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,8 @@ static bool parseDeclSILOptional(
729729
*isThunk = IsSignatureOptimizedThunk;
730730
else if (isThunk && SP.P.Tok.getText() == "reabstraction_thunk")
731731
*isThunk = IsReabstractionThunk;
732+
else if (isThunk && SP.P.Tok.getText() == "back_deployed_thunk")
733+
*isThunk = IsBackDeployedThunk;
732734
else if (isWithoutActuallyEscapingThunk
733735
&& SP.P.Tok.getText() == "without_actually_escaping")
734736
*isWithoutActuallyEscapingThunk = true;

test/SILGen/back_deployed_attr.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// REQUIRES: OS=macosx
88

99
// CHECK: sil non_abi [serialized] [ossa] @$s11back_deploy8someFuncyyFTwB
10-
// CHECK: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy8someFuncyyFTwb
10+
// CHECK: sil non_abi [serialized] [back_deployed_thunk] [ossa] @$s11back_deploy8someFuncyyFTwb
1111
// CHECK: sil [available 10.52] [ossa] @$s11back_deploy8someFuncyyF
1212
@backDeployed(before: macOS 10.52)
1313
public func someFunc() {}

test/SILGen/back_deployed_attr_accessor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public struct TopLevelStruct {
1111
// CHECK: return [[SELF]] : $TopLevelStruct
1212

1313
// -- Back deployment thunk for TopLevelStruct.property.getter
14-
// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy14TopLevelStructV8propertyACvgTwb : $@convention(method) (TopLevelStruct) -> TopLevelStruct
14+
// CHECK-LABEL: sil non_abi [serialized] [back_deployed_thunk] [ossa] @$s11back_deploy14TopLevelStructV8propertyACvgTwb : $@convention(method) (TopLevelStruct) -> TopLevelStruct
1515
// CHECK: bb0([[BB0_ARG:%.*]] : $TopLevelStruct):
1616
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 52
1717
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 1

test/SILGen/back_deployed_attr_accessor_coroutine.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public struct TopLevelStruct {
1818
// CHECK: unwind
1919

2020
// -- Back deployment thunk for TopLevelStruct.property.read
21-
// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy14TopLevelStructV8propertyACvrTwb : $@yield_once @convention(method) (TopLevelStruct) -> @yields TopLevelStruct
21+
// CHECK-LABEL: sil non_abi [serialized] [back_deployed_thunk] [ossa] @$s11back_deploy14TopLevelStructV8propertyACvrTwb : $@yield_once @convention(method) (TopLevelStruct) -> @yields TopLevelStruct
2222
// CHECK: bb0([[BB0_ARG:%.*]] : $TopLevelStruct):
2323
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 52
2424
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 1

test/SILGen/back_deployed_attr_async_func.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// CHECK: return [[RESULT]] : $()
1818

1919
// -- Back deployment thunk for trivialFunc()
20-
// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy9asyncFuncyyYaFTwb : $@convention(thin) @async () -> ()
20+
// CHECK-LABEL: sil non_abi [serialized] [back_deployed_thunk] [ossa] @$s11back_deploy9asyncFuncyyYaFTwb : $@convention(thin) @async () -> ()
2121
// CHECK: bb0:
2222
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 52
2323
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 1

test/SILGen/back_deployed_attr_func.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// CHECK: return [[RESULT]] : $()
1212

1313
// -- Back deployment thunk for trivialFunc()
14-
// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy11trivialFuncyyFTwb : $@convention(thin) () -> ()
14+
// CHECK-LABEL: sil non_abi [serialized] [back_deployed_thunk] [ossa] @$s11back_deploy11trivialFuncyyFTwb : $@convention(thin) () -> ()
1515
// CHECK: bb0:
1616
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 52
1717
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 1
@@ -46,7 +46,7 @@ public func trivialFunc() {}
4646
// CHECK: return {{%.*}} : $Bool
4747

4848
// -- Back deployment thunk for isNumber(_:)
49-
// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy8isNumberySbSiFTwb : $@convention(thin) (Int) -> Bool
49+
// CHECK-LABEL: sil non_abi [serialized] [back_deployed_thunk] [ossa] @$s11back_deploy8isNumberySbSiFTwb : $@convention(thin) (Int) -> Bool
5050
// CHECK: bb0([[ARG_X:%.*]] : $Int):
5151
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 52
5252
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 1

test/SILGen/back_deployed_attr_generic_func.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// CHECK: return [[RESULT]] : $()
1313

1414
// -- Back deployment thunk for genericFunc(_:)
15-
// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy11genericFuncyxxlFTwb : $@convention(thin) <T> (@in_guaranteed T) -> @out T
15+
// CHECK-LABEL: sil non_abi [serialized] [back_deployed_thunk] [ossa] @$s11back_deploy11genericFuncyxxlFTwb : $@convention(thin) <T> (@in_guaranteed T) -> @out T
1616
// CHECK: bb0([[OUT_ARG:%.*]] : $*T, [[IN_ARG:%.*]] : $*T):
1717
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 52
1818
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 1
@@ -50,7 +50,7 @@ public func genericFunc<T>(_ t: T) -> T {
5050
// CHECK: return [[RESULT]] : $()
5151

5252
// -- Back deployment thunk for genericFuncWithOwnedParam(_:)
53-
// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy25genericFuncWithOwnedParamyyxnlFTwb : $@convention(thin) <T> (@in T) -> ()
53+
// CHECK-LABEL: sil non_abi [serialized] [back_deployed_thunk] [ossa] @$s11back_deploy25genericFuncWithOwnedParamyyxnlFTwb : $@convention(thin) <T> (@in T) -> ()
5454
// CHECK: bb0([[IN_ARG:%.*]] : $*T):
5555
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 52
5656
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 1

test/SILGen/back_deployed_attr_maccatalyst_zippered.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// CHECK: return [[RESULT]] : $()
1111

1212
// -- Back deployment thunk for trivialFunc_iOS()
13-
// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy15trivialFunc_iOSyyFTwb : $@convention(thin) () -> ()
13+
// CHECK-LABEL: sil non_abi [serialized] [back_deployed_thunk] [ossa] @$s11back_deploy15trivialFunc_iOSyyFTwb : $@convention(thin) () -> ()
1414
// CHECK: bb0:
1515
// CHECK: [[IOS_MAJOR:%.*]] = integer_literal $Builtin.Word, 51
1616
// CHECK: [[IOS_MINOR:%.*]] = integer_literal $Builtin.Word, 1
@@ -45,7 +45,7 @@ public func trivialFunc_iOS() {}
4545
// CHECK: return [[RESULT]] : $()
4646

4747
// -- Back deployment thunk for trivialFunc_macOS()
48-
// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy17trivialFunc_macOSyyFTwb : $@convention(thin) () -> ()
48+
// CHECK-LABEL: sil non_abi [serialized] [back_deployed_thunk] [ossa] @$s11back_deploy17trivialFunc_macOSyyFTwb : $@convention(thin) () -> ()
4949
// CHECK: bb0:
5050
// CHECK: [[MACOS_MAJOR:%.*]] = integer_literal $Builtin.Word, 10
5151
// CHECK: [[MACOS_MINOR:%.*]] = integer_literal $Builtin.Word, 53
@@ -80,7 +80,7 @@ public func trivialFunc_macOS() {}
8080
// CHECK: return [[RESULT]] : $()
8181

8282
// -- Back deployment thunk for trivialFunc_iOS_macOS()
83-
// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy019trivialFunc_iOS_macE0yyFTwb : $@convention(thin) () -> ()
83+
// CHECK-LABEL: sil non_abi [serialized] [back_deployed_thunk] [ossa] @$s11back_deploy019trivialFunc_iOS_macE0yyFTwb : $@convention(thin) () -> ()
8484
// CHECK: bb0:
8585
// CHECK: [[MACOS_MAJOR:%.*]] = integer_literal $Builtin.Word, 10
8686
// CHECK: [[MACOS_MINOR:%.*]] = integer_literal $Builtin.Word, 53

test/SILGen/back_deployed_attr_struct_init.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public struct TopLevelStruct<T> {
3030
// CHECK: return [[RESULT]] : $()
3131

3232
// -- Back deployment thunk for TopLevelStruct.init(_:)
33-
// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy14TopLevelStructVyACyxGxcfCTwb : $@convention(method) <T> (@in T, @thin TopLevelStruct<T>.Type) -> @out TopLevelStruct<T>
33+
// CHECK-LABEL: sil non_abi [serialized] [back_deployed_thunk] [ossa] @$s11back_deploy14TopLevelStructVyACyxGxcfCTwb : $@convention(method) <T> (@in T, @thin TopLevelStruct<T>.Type) -> @out TopLevelStruct<T>
3434
// CHECK: bb0([[SELF_OUT:%.*]] : $*TopLevelStruct<T>, [[T_ARG:%.*]] : $*T, [[METATYPE_ARG:%.*]] : $@thin TopLevelStruct<T>.Type):
3535
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 52
3636
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 1

test/SILGen/back_deployed_attr_struct_method.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public struct TopLevelStruct {
1212
// CHECK: return [[RESULT]] : $()
1313

1414
// -- Back deployment thunk for TopLevelStruct.trivialMethod()
15-
// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy14TopLevelStructV13trivialMethodyyFTwb : $@convention(method) (TopLevelStruct) -> ()
15+
// CHECK-LABEL: sil non_abi [serialized] [back_deployed_thunk] [ossa] @$s11back_deploy14TopLevelStructV13trivialMethodyyFTwb : $@convention(method) (TopLevelStruct) -> ()
1616
// CHECK: bb0([[BB0_ARG:%.*]] : $TopLevelStruct):
1717
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 52
1818
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 1

test/SILGen/back_deployed_attr_throwing_func.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// CHECK: return [[RESULT]] : $()
1212

1313
// -- Back deployment thunk for throwingFunc()
14-
// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy12throwingFuncyyKFTwb : $@convention(thin) () -> @error any Error
14+
// CHECK-LABEL: sil non_abi [serialized] [back_deployed_thunk] [ossa] @$s11back_deploy12throwingFuncyyKFTwb : $@convention(thin) () -> @error any Error
1515
// CHECK: bb0:
1616
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 52
1717
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 1

0 commit comments

Comments
 (0)