Skip to content

Commit fcd5225

Browse files
committed
Mangling: add mangling for outlined value operations which must not use value witness functions
1 parent 86f23b0 commit fcd5225

File tree

8 files changed

+110
-10
lines changed

8 files changed

+110
-10
lines changed

Diff for: docs/ABI/Mangling.rst

+4
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,13 @@ with a differentiable function used for differentiable programming.
328328
global ::= generic-signature? type 'WOs' // Outlined release
329329
global ::= generic-signature? type 'WOb' // Outlined initializeWithTake
330330
global ::= generic-signature? type 'WOc' // Outlined initializeWithCopy
331+
global ::= generic-signature? type 'WOC' // Outlined initializeWithCopy, not using value witness
331332
global ::= generic-signature? type 'WOd' // Outlined assignWithTake
333+
global ::= generic-signature? type 'WOD' // Outlined assignWithTake, not using value witness
332334
global ::= generic-signature? type 'WOf' // Outlined assignWithCopy
335+
global ::= generic-signature? type 'WOF' // Outlined assignWithCopy, not using value witness
333336
global ::= generic-signature? type 'WOh' // Outlined destroy
337+
global ::= generic-signature? type 'WOH' // Outlined destroy, not using value witness
334338
global ::= generic-signature? type 'WOi` // Outlined store enum tag
335339
global ::= generic-signature? type 'WOj` // Outlined enum destructive project
336340
global ::= generic-signature? type 'WOg` // Outlined enum get tag

Diff for: include/swift/Demangling/DemangleNodes.def

+5
Original file line numberDiff line numberDiff line change
@@ -381,5 +381,10 @@ NODE(AsyncRemoved)
381381
// Added in Swift 5.TBD
382382
NODE(ObjectiveCProtocolSymbolicReference)
383383

384+
NODE(OutlinedInitializeWithCopyNoValueWitness)
385+
NODE(OutlinedAssignWithTakeNoValueWitness)
386+
NODE(OutlinedAssignWithCopyNoValueWitness)
387+
NODE(OutlinedDestroyNoValueWitness)
388+
384389
#undef CONTEXT_NODE
385390
#undef NODE

Diff for: lib/Demangling/Demangler.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -3427,6 +3427,34 @@ NodePointer Demangler::demangleWitness() {
34273427
}
34283428
case 'O': {
34293429
switch (nextChar()) {
3430+
case 'C': {
3431+
if (auto sig = popNode(Node::Kind::DependentGenericSignature))
3432+
return createWithChildren(Node::Kind::OutlinedInitializeWithCopyNoValueWitness,
3433+
popNode(Node::Kind::Type), sig);
3434+
return createWithChild(Node::Kind::OutlinedInitializeWithCopyNoValueWitness,
3435+
popNode(Node::Kind::Type));
3436+
}
3437+
case 'D': {
3438+
if (auto sig = popNode(Node::Kind::DependentGenericSignature))
3439+
return createWithChildren(Node::Kind::OutlinedAssignWithTakeNoValueWitness,
3440+
popNode(Node::Kind::Type), sig);
3441+
return createWithChild(Node::Kind::OutlinedAssignWithTakeNoValueWitness,
3442+
popNode(Node::Kind::Type));
3443+
}
3444+
case 'F': {
3445+
if (auto sig = popNode(Node::Kind::DependentGenericSignature))
3446+
return createWithChildren(Node::Kind::OutlinedAssignWithCopyNoValueWitness,
3447+
popNode(Node::Kind::Type), sig);
3448+
return createWithChild(Node::Kind::OutlinedAssignWithCopyNoValueWitness,
3449+
popNode(Node::Kind::Type));
3450+
}
3451+
case 'H': {
3452+
if (auto sig = popNode(Node::Kind::DependentGenericSignature))
3453+
return createWithChildren(Node::Kind::OutlinedDestroyNoValueWitness,
3454+
popNode(Node::Kind::Type), sig);
3455+
return createWithChild(Node::Kind::OutlinedDestroyNoValueWitness,
3456+
popNode(Node::Kind::Type));
3457+
}
34303458
case 'y': {
34313459
if (auto sig = popNode(Node::Kind::DependentGenericSignature))
34323460
return createWithChildren(Node::Kind::OutlinedCopy,

Diff for: lib/Demangling/NodePrinter.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,10 @@ class NodePrinter {
573573
case Node::Kind::OutlinedAssignWithTake:
574574
case Node::Kind::OutlinedAssignWithCopy:
575575
case Node::Kind::OutlinedDestroy:
576+
case Node::Kind::OutlinedInitializeWithCopyNoValueWitness:
577+
case Node::Kind::OutlinedAssignWithTakeNoValueWitness:
578+
case Node::Kind::OutlinedAssignWithCopyNoValueWitness:
579+
case Node::Kind::OutlinedDestroyNoValueWitness:
576580
case Node::Kind::OutlinedEnumTagStore:
577581
case Node::Kind::OutlinedEnumGetTag:
578582
case Node::Kind::OutlinedEnumProjectDataForLoad:
@@ -1381,18 +1385,22 @@ NodePointer NodePrinter::print(NodePointer Node, unsigned depth,
13811385
print(Node->getChild(0), depth + 1);
13821386
return nullptr;
13831387
case Node::Kind::OutlinedInitializeWithCopy:
1388+
case Node::Kind::OutlinedInitializeWithCopyNoValueWitness:
13841389
Printer << "outlined init with copy of ";
13851390
print(Node->getChild(0), depth + 1);
13861391
return nullptr;
13871392
case Node::Kind::OutlinedAssignWithTake:
1393+
case Node::Kind::OutlinedAssignWithTakeNoValueWitness:
13881394
Printer << "outlined assign with take of ";
13891395
print(Node->getChild(0), depth + 1);
13901396
return nullptr;
13911397
case Node::Kind::OutlinedAssignWithCopy:
1398+
case Node::Kind::OutlinedAssignWithCopyNoValueWitness:
13921399
Printer << "outlined assign with copy of ";
13931400
print(Node->getChild(0), depth + 1);
13941401
return nullptr;
13951402
case Node::Kind::OutlinedDestroy:
1403+
case Node::Kind::OutlinedDestroyNoValueWitness:
13961404
Printer << "outlined destroy of ";
13971405
print(Node->getChild(0), depth + 1);
13981406
return nullptr;

Diff for: lib/Demangling/OldRemangler.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -2549,6 +2549,24 @@ ManglingError Remangler::mangleOutlinedDestroy(Node *node, unsigned depth) {
25492549
Buffer << "Wh";
25502550
return mangleSingleChildNode(node, depth + 1);
25512551
}
2552+
ManglingError Remangler::mangleOutlinedInitializeWithCopyNoValueWitness(Node *node,
2553+
unsigned depth) {
2554+
return MANGLING_ERROR(ManglingError::UnsupportedNodeKind, node);
2555+
}
2556+
2557+
ManglingError Remangler::mangleOutlinedAssignWithTakeNoValueWitness(Node *node,
2558+
unsigned depth) {
2559+
return MANGLING_ERROR(ManglingError::UnsupportedNodeKind, node);
2560+
}
2561+
2562+
ManglingError Remangler::mangleOutlinedAssignWithCopyNoValueWitness(Node *node,
2563+
unsigned depth) {
2564+
return MANGLING_ERROR(ManglingError::UnsupportedNodeKind, node);
2565+
}
2566+
2567+
ManglingError Remangler::mangleOutlinedDestroyNoValueWitness(Node *node, unsigned depth) {
2568+
return MANGLING_ERROR(ManglingError::UnsupportedNodeKind, node);
2569+
}
25522570
ManglingError Remangler::mangleOutlinedEnumTagStore(Node *node, unsigned depth) {
25532571
Buffer << "Wi";
25542572
return mangleSingleChildNode(node, depth + 1);

Diff for: lib/Demangling/Remangler.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -3315,6 +3315,34 @@ ManglingError Remangler::mangleOutlinedDestroy(Node *node, unsigned depth) {
33153315
Buffer << "WOh";
33163316
return ManglingError::Success;
33173317
}
3318+
3319+
ManglingError Remangler::mangleOutlinedInitializeWithCopyNoValueWitness(Node *node,
3320+
unsigned depth) {
3321+
RETURN_IF_ERROR(mangleChildNodes(node, depth + 1));
3322+
Buffer << "WOC";
3323+
return ManglingError::Success;
3324+
}
3325+
3326+
ManglingError Remangler::mangleOutlinedAssignWithTakeNoValueWitness(Node *node,
3327+
unsigned depth) {
3328+
RETURN_IF_ERROR(mangleChildNodes(node, depth + 1));
3329+
Buffer << "WOD";
3330+
return ManglingError::Success;
3331+
}
3332+
3333+
ManglingError Remangler::mangleOutlinedAssignWithCopyNoValueWitness(Node *node,
3334+
unsigned depth) {
3335+
RETURN_IF_ERROR(mangleChildNodes(node, depth + 1));
3336+
Buffer << "WOF";
3337+
return ManglingError::Success;
3338+
}
3339+
3340+
ManglingError Remangler::mangleOutlinedDestroyNoValueWitness(Node *node, unsigned depth) {
3341+
RETURN_IF_ERROR(mangleChildNodes(node, depth + 1));
3342+
Buffer << "WOH";
3343+
return ManglingError::Success;
3344+
}
3345+
33183346
ManglingError Remangler::mangleOutlinedEnumGetTag(Node *node, unsigned depth) {
33193347
RETURN_IF_ERROR(mangleChildNodes(node, depth + 1));
33203348
Buffer << "WOg";

Diff for: lib/IRGen/IRGenMangler.h

+15-10
Original file line numberDiff line numberDiff line change
@@ -552,48 +552,53 @@ class IRGenMangler : public Mangle::ASTMangler {
552552
}
553553

554554
std::string mangleOutlinedInitializeWithTakeFunction(CanType t,
555-
CanGenericSignature sig) {
555+
CanGenericSignature sig,
556+
bool noValueWitness) {
556557
beginMangling();
557558
appendType(t, sig);
558559
if (sig)
559560
appendGenericSignature(sig);
560-
appendOperator("WOb");
561+
appendOperator(noValueWitness ? "WOB" : "WOb");
561562
return finalize();
562563
}
563564
std::string mangleOutlinedInitializeWithCopyFunction(CanType t,
564-
CanGenericSignature sig) {
565+
CanGenericSignature sig,
566+
bool noValueWitness) {
565567
beginMangling();
566568
appendType(t, sig);
567569
if (sig)
568570
appendGenericSignature(sig);
569-
appendOperator("WOc");
571+
appendOperator(noValueWitness ? "WOC" : "WOc");
570572
return finalize();
571573
}
572574
std::string mangleOutlinedAssignWithTakeFunction(CanType t,
573-
CanGenericSignature sig) {
575+
CanGenericSignature sig,
576+
bool noValueWitness) {
574577
beginMangling();
575578
appendType(t, sig);
576579
if (sig)
577580
appendGenericSignature(sig);
578-
appendOperator("WOd");
581+
appendOperator(noValueWitness ? "WOD" : "WOd");
579582
return finalize();
580583
}
581584
std::string mangleOutlinedAssignWithCopyFunction(CanType t,
582-
CanGenericSignature sig) {
585+
CanGenericSignature sig,
586+
bool noValueWitness) {
583587
beginMangling();
584588
appendType(t, sig);
585589
if (sig)
586590
appendGenericSignature(sig);
587-
appendOperator("WOf");
591+
appendOperator(noValueWitness ? "WOF" : "WOf");
588592
return finalize();
589593
}
590594
std::string mangleOutlinedDestroyFunction(CanType t,
591-
CanGenericSignature sig) {
595+
CanGenericSignature sig,
596+
bool noValueWitness) {
592597
beginMangling();
593598
appendType(t, sig);
594599
if (sig)
595600
appendGenericSignature(sig);
596-
appendOperator("WOh");
601+
appendOperator(noValueWitness ? "WOH" : "WOh");
597602
return finalize();
598603
}
599604

Diff for: test/Demangle/Inputs/manglings.txt

+4
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ _T04main4TestCACSi1x_tc6_PRIV_Llfc ---> main.Test.(in _PRIV_).init(x: Swift.Int)
292292
_$S3abc6testityySiFTm ---> merged abc.testit(Swift.Int) -> ()
293293
_$S4main4TestC1xACSi_tc6_PRIV_Llfc ---> main.Test.(in _PRIV_).init(x: Swift.Int) -> main.Test
294294
_T0SqWOy.17 ---> outlined copy of Swift.Optional with unmangled suffix ".17"
295+
_T0SqWOC ---> outlined init with copy of Swift.Optional
296+
_T0SqWOD ---> outlined assign with take of Swift.Optional
297+
_T0SqWOF ---> outlined assign with copy of Swift.Optional
298+
_T0SqWOH ---> outlined destroy of Swift.Optional
295299
_T03nix6testitSaySiGyFTv_ ---> outlined variable #0 of nix.testit() -> [Swift.Int]
296300
_T03nix6testitSaySiGyFTv_r ---> outlined read-only object #0 of nix.testit() -> [Swift.Int]
297301
_T03nix6testitSaySiGyFTv0_ ---> outlined variable #1 of nix.testit() -> [Swift.Int]

0 commit comments

Comments
 (0)