Skip to content

Commit ff5abc4

Browse files
committed
Mangling: Use 'Tw' to mangle back deployment thunks.
1 parent 2120438 commit ff5abc4

File tree

9 files changed

+26
-1
lines changed

9 files changed

+26
-1
lines changed

docs/ABI/Mangling.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ types where the metadata itself has unknown layout.)
223223
global ::= global 'TI' // implementation of a dynamic_replaceable function
224224
global ::= global 'Tu' // async function pointer of a function
225225
global ::= global 'TX' // function pointer of a dynamic_replaceable function
226+
global ::= global 'Tw' // back deployment thunk
226227
global ::= entity entity 'TV' // vtable override thunk, derived followed by base
227228
global ::= type label-list? 'D' // type mangling for the debugger with label list for function types.
228229
global ::= type 'TC' // continuation prototype (not actually used for real symbols)

include/swift/AST/ASTMangler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ class ASTMangler : public Mangler {
105105
ObjCAsSwiftThunk,
106106
DistributedThunk,
107107
DistributedAccessor,
108-
AccessibleFunctionRecord
108+
AccessibleFunctionRecord,
109+
BackDeployedThunk,
109110
};
110111

111112
ASTMangler(bool DWARFMangling = false)

include/swift/Demangling/DemangleNodes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ NODE(CompileTimeConst)
332332

333333
// Added in Swift 5.7
334334
NODE(OpaqueReturnTypeIndexed)
335+
NODE(BackDeployed)
335336

336337
#undef CONTEXT_NODE
337338
#undef NODE

lib/AST/ASTMangler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,9 @@ void ASTMangler::appendSymbolKind(SymbolKind SKind) {
857857
case SymbolKind::DistributedThunk: return appendOperator("TE");
858858
case SymbolKind::DistributedAccessor: return appendOperator("TF");
859859
case SymbolKind::AccessibleFunctionRecord: return appendOperator("HF");
860+
// FIXME(backDeploy): Check whether mangling needs to be extended since
861+
// the available thunk mangling names are almost exhausted.
862+
case SymbolKind::BackDeployedThunk: return appendOperator("Tw");
860863
}
861864
}
862865

lib/Demangling/Demangler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2395,6 +2395,7 @@ NodePointer Demangler::demangleThunkOrSpecialization() {
23952395
case 'X': return createNode(Node::Kind::DynamicallyReplaceableFunctionVar);
23962396
case 'x': return createNode(Node::Kind::DynamicallyReplaceableFunctionKey);
23972397
case 'I': return createNode(Node::Kind::DynamicallyReplaceableFunctionImpl);
2398+
case 'w': return createNode(Node::Kind::BackDeployed);
23982399
case 'Y':
23992400
case 'Q': {
24002401
NodePointer discriminator = demangleIndexAsNode();

lib/Demangling/NodePrinter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ class NodePrinter {
591591
case Node::Kind::AsyncAwaitResumePartialFunction:
592592
case Node::Kind::AsyncSuspendResumePartialFunction:
593593
case Node::Kind::AccessibleFunctionRecord:
594+
case Node::Kind::BackDeployed:
594595
return false;
595596
}
596597
printer_unreachable("bad node kind");
@@ -2050,6 +2051,11 @@ NodePointer NodePrinter::print(NodePointer Node, unsigned depth,
20502051
Printer << "dynamically replaceable variable for ";
20512052
}
20522053
return nullptr;
2054+
case Node::Kind::BackDeployed:
2055+
if (!Options.ShortenThunk) {
2056+
Printer << "back deployment thunk for ";
2057+
}
2058+
return nullptr;
20532059
case Node::Kind::ProtocolSymbolicReference:
20542060
Printer << "protocol symbolic reference 0x";
20552061
Printer.writeHex(Node->getIndex());

lib/Demangling/OldRemangler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,3 +2800,8 @@ ManglingError Remangler::mangleAccessibleFunctionRecord(Node *node,
28002800
Buffer << "HF";
28012801
return ManglingError::Success;
28022802
}
2803+
2804+
ManglingError Remangler::mangleBackDeployed(Node *node, unsigned depth) {
2805+
Buffer << "Tw";
2806+
return ManglingError::Success;
2807+
}

lib/Demangling/Remangler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3407,6 +3407,11 @@ ManglingError Remangler::mangleAccessibleFunctionRecord(Node *node,
34073407
return ManglingError::Success;
34083408
}
34093409

3410+
ManglingError Remangler::mangleBackDeployed(Node *node, unsigned depth) {
3411+
Buffer << "Tw";
3412+
return ManglingError::Success;
3413+
}
3414+
34103415
} // anonymous namespace
34113416

34123417
/// The top-level interface to the remangler.

lib/SIL/IR/SILDeclRef.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,8 @@ std::string SILDeclRef::mangle(ManglingKind MKind) const {
874874
SKind = ASTMangler::SymbolKind::ObjCAsSwiftThunk;
875875
} else if (isDistributedThunk()) {
876876
SKind = ASTMangler::SymbolKind::DistributedThunk;
877+
} else if (isBackDeployedThunk()) {
878+
SKind = ASTMangler::SymbolKind::BackDeployedThunk;
877879
}
878880
break;
879881
case SILDeclRef::ManglingKind::DynamicThunk:

0 commit comments

Comments
 (0)