Skip to content

Commit 17d7af9

Browse files
committed
[IRGen] Mangling for async, non-constant partial_apply thunks.
1 parent f7d8664 commit 17d7af9

File tree

8 files changed

+40
-1
lines changed

8 files changed

+40
-1
lines changed

include/swift/Demangling/DemangleNodes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ NODE(AutoDiffSubsetParametersThunk)
316316
NODE(AutoDiffDerivativeVTableThunk)
317317
NODE(DifferentiabilityWitness)
318318
NODE(IndexSubset)
319+
NODE(AsyncNonconstantPartialApplyThunk)
319320

320321
#undef CONTEXT_NODE
321322
#undef NODE

lib/Demangling/Demangler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ bool swift::Demangle::isFunctionAttr(Node::Kind kind) {
123123
case Node::Kind::DynamicallyReplaceableFunctionKey:
124124
case Node::Kind::DynamicallyReplaceableFunctionVar:
125125
case Node::Kind::AsyncFunctionPointer:
126+
case Node::Kind::AsyncNonconstantPartialApplyThunk:
126127
return true;
127128
default:
128129
return false;
@@ -2520,6 +2521,8 @@ NodePointer Demangler::demangleThunkOrSpecialization() {
25202521
return demangleAutoDiffFunctionOrSimpleThunk(
25212522
Node::Kind::AutoDiffFunction);
25222523
}
2524+
case 'w':
2525+
return createNode(Node::Kind::AsyncNonconstantPartialApplyThunk);
25232526
default:
25242527
return nullptr;
25252528
}

lib/Demangling/NodePrinter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ class NodePrinter {
573573
case Node::Kind::AutoDiffFunctionKind:
574574
case Node::Kind::DifferentiabilityWitness:
575575
case Node::Kind::IndexSubset:
576+
case Node::Kind::AsyncNonconstantPartialApplyThunk:
576577
return false;
577578
}
578579
printer_unreachable("bad node kind");
@@ -2774,6 +2775,9 @@ NodePointer NodePrinter::print(NodePointer Node, bool asPrefixContext) {
27742775
case Node::Kind::AsyncFunctionPointer:
27752776
Printer << "async function pointer to ";
27762777
return nullptr;
2778+
case Node::Kind::AsyncNonconstantPartialApplyThunk:
2779+
Printer << "thunk for non-constant partial apply in ";
2780+
return nullptr;
27772781
}
27782782
printer_unreachable("bad node kind!");
27792783
}

lib/Demangling/OldRemangler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,11 @@ void Remangler::mangleDynamicallyReplaceableFunctionVar(Node *node) {
606606
Buffer << "TX";
607607
}
608608

609+
void Remangler::mangleAsyncNonconstantPartialApplyThunk(Node *node) {
610+
Buffer << "Tw";
611+
mangleSingleChildNode(node); // global
612+
}
613+
609614
void Remangler::mangleDirectness(Node *node) {
610615
auto getChar = [](Directness d) -> char {
611616
switch (d) {

lib/Demangling/Remangler.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,7 @@ void Remangler::mangleGlobal(Node *node) {
13961396
case Node::Kind::DynamicallyReplaceableFunctionImpl:
13971397
case Node::Kind::DynamicallyReplaceableFunctionVar:
13981398
case Node::Kind::AsyncFunctionPointer:
1399+
case Node::Kind::AsyncNonconstantPartialApplyThunk:
13991400
mangleInReverseOrder = true;
14001401
break;
14011402
default:
@@ -1904,6 +1905,11 @@ void Remangler::mangleDynamicallyReplaceableFunctionVar(Node *node) {
19041905
Buffer << "TX";
19051906
}
19061907

1908+
void Remangler::mangleAsyncNonconstantPartialApplyThunk(Node *node) {
1909+
mangleChildNodesReversed(node);
1910+
Buffer << "Tw";
1911+
}
1912+
19071913
void Remangler::manglePostfixOperator(Node *node) {
19081914
mangleIdentifierImpl(node, /*isOperator*/ true);
19091915
Buffer << "oP";

lib/IRGen/IRGenMangler.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,22 @@ std::string IRGenMangler::manglePartialApplyForwarder(StringRef FuncName) {
7979
return finalize();
8080
}
8181

82+
std::string
83+
IRGenMangler::mangleAsyncNonconstantPartialApplyThunk(StringRef FuncName) {
84+
if (FuncName.empty()) {
85+
beginMangling();
86+
} else {
87+
if (FuncName.startswith(MANGLING_PREFIX_STR)) {
88+
Buffer << FuncName;
89+
} else {
90+
beginMangling();
91+
appendIdentifier(FuncName);
92+
}
93+
}
94+
appendOperator("Tw");
95+
return finalize();
96+
}
97+
8298
SymbolicMangling
8399
IRGenMangler::withSymbolicReferences(IRGenModule &IGM,
84100
llvm::function_ref<void ()> body) {

lib/IRGen/IRGenMangler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,8 @@ class IRGenMangler : public Mangle::ASTMangler {
574574
}
575575

576576
std::string manglePartialApplyForwarder(StringRef FuncName);
577-
577+
std::string mangleAsyncNonconstantPartialApplyThunk(StringRef FuncName);
578+
578579
std::string mangleTypeForForeignMetadataUniquing(Type type) {
579580
return mangleTypeWithoutPrefix(type);
580581
}

test/Demangle/Inputs/manglings.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,3 +388,6 @@ $sS2f8mangling3FooV13TangentVectorVIegydd_SfAESfIegydd_TJOp ---> autodiff self-r
388388
$s13test_mangling3fooyS2f_S2ftFWJrSpSr ---> reverse-mode differentiability witness for test_mangling.foo(Swift.Float, Swift.Float, Swift.Float) -> Swift.Float with respect to parameters {0} and results {0}
389389
$s13test_mangling3fooyS2f_xq_t16_Differentiation14DifferentiableR_r0_lFAcDRzAcDR_r0_lWJrUSSpSr ---> reverse-mode differentiability witness for test_mangling.foo<A, B where B: _Differentiation.Differentiable>(Swift.Float, A, B) -> Swift.Float with respect to parameters {1, 2} and results {0} with <A, B where A: _Differentiation.Differentiable, B: _Differentiation.Differentiable>
390390
$s5async1hyyS2iJXEF ---> async.h(@concurrent (Swift.Int) -> Swift.Int) -> ()
391+
$s12create_pa_f2Tw ---> thunk for non-constant partial apply in create_pa_f2
392+
$s0019create_pa_f21_HJEEdTw ---> thunk for non-constant partial apply in create_pa_f2.1
393+
$s4main3fooyySiFyyXEfU_TA.1 ---> {T:} closure #1 () -> () in main.foo(Swift.Int) -> ()partial apply forwarder with unmangled suffix ".1"

0 commit comments

Comments
 (0)