Skip to content

Commit 253099a

Browse files
Merge pull request swiftlang#35103 from nate-chandler/concurrency/irgen/rdar72336407
[IRGen] Corrected mangling of AsyncFunctionPointers.
2 parents fb4583f + 73cfca8 commit 253099a

File tree

39 files changed

+55
-35
lines changed

39 files changed

+55
-35
lines changed

docs/ABI/Mangling.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ types where the metadata itself has unknown layout.)
207207
global ::= global 'TD' // dynamic dispatch thunk
208208
global ::= global 'Td' // direct method reference thunk
209209
global ::= global 'TI' // implementation of a dynamic_replaceable function
210+
global :== global 'Tu' // async function pointer of a function
210211
global ::= global 'TX' // function pointer of a dynamic_replaceable function
211212
global ::= entity entity 'TV' // vtable override thunk, derived followed by base
212213
global ::= type label-list? 'D' // type mangling for the debugger with label list for function types.

include/swift/Demangling/DemangleNodes.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,5 +306,8 @@ NODE(GlobalVariableOnceToken)
306306
NODE(GlobalVariableOnceDeclList)
307307
NODE(CanonicalPrespecializedGenericTypeCachingOnceToken)
308308

309+
// Added in Swift 5.5
310+
NODE(AsyncFunctionPointer)
311+
309312
#undef CONTEXT_NODE
310313
#undef NODE

lib/Demangling/Demangler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ bool swift::Demangle::isFunctionAttr(Node::Kind kind) {
122122
case Node::Kind::DynamicallyReplaceableFunctionImpl:
123123
case Node::Kind::DynamicallyReplaceableFunctionKey:
124124
case Node::Kind::DynamicallyReplaceableFunctionVar:
125+
case Node::Kind::AsyncFunctionPointer:
125126
return true;
126127
default:
127128
return false;
@@ -2477,6 +2478,7 @@ NodePointer Demangler::popProtocolConformance() {
24772478
return nullptr;
24782479
return createNode(Node::Kind::OutlinedBridgedMethod, Params);
24792480
}
2481+
case 'u': return createNode(Node::Kind::AsyncFunctionPointer);
24802482
default:
24812483
return nullptr;
24822484
}

lib/Demangling/NodePrinter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ class NodePrinter {
564564
case Node::Kind::GlobalVariableOnceFunction:
565565
case Node::Kind::GlobalVariableOnceToken:
566566
case Node::Kind::CanonicalPrespecializedGenericTypeCachingOnceToken:
567+
case Node::Kind::AsyncFunctionPointer:
567568
return false;
568569
}
569570
printer_unreachable("bad node kind");
@@ -2552,6 +2553,9 @@ NodePointer NodePrinter::print(NodePointer Node, bool asPrefixContext) {
25522553
"metadata for ";
25532554
print(Node->getChild(0));
25542555
return nullptr;
2556+
case Node::Kind::AsyncFunctionPointer:
2557+
Printer << "async function pointer to ";
2558+
return nullptr;
25552559
}
25562560
printer_unreachable("bad node kind!");
25572561
}

lib/Demangling/OldRemangler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,10 @@ void Remangler::mangleDefaultArgumentInitializer(Node *node,
816816
mangleNamedEntity(node, 'I', "A", ctx);
817817
}
818818

819+
void Remangler::mangleAsyncFunctionPointer(Node *node) {
820+
Buffer << "Tu";
821+
}
822+
819823
void Remangler::mangleDeallocator(Node *node, EntityContext &ctx) {
820824
mangleSimpleEntity(node, 'F', "D", ctx);
821825
}

lib/Demangling/Remangler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,10 @@ void Remangler::mangleDefaultArgumentInitializer(Node *node) {
837837
mangleChildNode(node, 1);
838838
}
839839

840+
void Remangler::mangleAsyncFunctionPointer(Node *node) {
841+
Buffer << "Tu";
842+
}
843+
840844
void Remangler::mangleDependentAssociatedTypeRef(Node *node) {
841845
mangleIdentifier(node->getFirstChild());
842846
if (node->getNumChildren() > 1)
@@ -1384,6 +1388,7 @@ void Remangler::mangleGlobal(Node *node) {
13841388
case Node::Kind::DynamicallyReplaceableFunctionKey:
13851389
case Node::Kind::DynamicallyReplaceableFunctionImpl:
13861390
case Node::Kind::DynamicallyReplaceableFunctionVar:
1391+
case Node::Kind::AsyncFunctionPointer:
13871392
mangleInReverseOrder = true;
13881393
break;
13891394
default:

lib/IRGen/Linking.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,13 @@ std::string LinkEntity::mangleAsString() const {
432432
getSILDifferentiabilityWitness()->getConfig()});
433433
case Kind::AsyncFunctionPointer: {
434434
std::string Result(getSILFunction()->getName());
435-
Result.append("AD");
435+
Result.append("Tu");
436436
return Result;
437437
}
438438
case Kind::AsyncFunctionPointerAST: {
439439
std::string Result;
440440
Result = mangler.mangleEntity(getDecl());
441-
Result.append("AD");
441+
Result.append("Tu");
442442
return Result;
443443
}
444444
}

test/Demangle/Inputs/manglings.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,4 @@ $s7example1fyyYF -> example.f() async -> ()
371371
$s7example1fyyYKF -> example.f() async throws -> ()
372372
$s4main20receiveInstantiationyySo34__CxxTemplateInst12MagicWrapperIiEVzF ---> main.receiveInstantiation(inout __C.__CxxTemplateInst12MagicWrapperIiE) -> ()
373373
$s4main19returnInstantiationSo34__CxxTemplateInst12MagicWrapperIiEVyF ---> main.returnInstantiation() -> __C.__CxxTemplateInst12MagicWrapperIiE
374+
$s4main6testityyYFTu ---> async function pointer to main.testit() async -> ()

test/IRGen/async/run-call-classinstance-int64-to-void.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class S {
2929
init()
3030
}
3131

32-
// CHECK-LL: @classinstanceSInt64ToVoidAD =
32+
// CHECK-LL: @classinstanceSInt64ToVoidTu =
3333
// CHECK-LL: define hidden swiftcc void @classinstanceSInt64ToVoid(%swift.task* {{%[0-9]+}}, %swift.executor* {{%[0-9]+}}, %swift.context* {{%[0-9]+}}) {{#[0-9]+}} {
3434
sil hidden @classinstanceSInt64ToVoid : $@async @convention(method) (Int64, @guaranteed S) -> () {
3535
bb0(%int : $Int64, %instance : $S):

test/IRGen/async/run-call-classinstance-void-to-void.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class S {
2929
init()
3030
}
3131

32-
// CHECK-LL: @classinstanceSVoidToVoidAD =
32+
// CHECK-LL: @classinstanceSVoidToVoidTu =
3333
// CHECK-LL: define hidden swiftcc void @classinstanceSVoidToVoid(%swift.task* {{%[0-9]+}}, %swift.executor* {{%[0-9]+}}, %swift.context* {{%[0-9]+}}) {{#[0-9]*}} {
3434
sil hidden @classinstanceSVoidToVoid : $@async @convention(method) (@guaranteed S) -> () {
3535
bb0(%instance : $S):

0 commit comments

Comments
 (0)