Skip to content

Commit 99a2511

Browse files
Merge pull request swiftlang#36708 from nate-chandler/eliminate-pal
[IRGen] Restore previous async non-constant PAF emission.
2 parents 59a218a + 3243def commit 99a2511

29 files changed

+171
-921
lines changed

docs/ABI/Mangling.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ Globals
147147
// TODO check this::
148148
global ::= mangled-name 'TA' // partial application forwarder
149149
global ::= mangled-name 'Ta' // ObjC partial application forwarder
150-
global ::= mangled-name 'Tw' index // async partial apply thunk for a non-constant function
151150
global ::= mangled-name 'TQ' index // Async await continuation partial function
152151
global ::= mangled-name 'TY' index // Async suspend continuation partial function
153152

include/swift/AST/ASTDemangler.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ class ASTBuilder {
5959
using BuiltType = swift::Type;
6060
using BuiltTypeDecl = swift::GenericTypeDecl *; // nominal or type alias
6161
using BuiltProtocolDecl = swift::ProtocolDecl *;
62-
using BuiltSubstitution = std::pair<Type, Type>;
63-
using BuiltRequirement = swift::Requirement;
6462
explicit ASTBuilder(ASTContext &ctx) : Ctx(ctx) {}
6563

6664
ASTContext &getASTContext() { return Ctx; }
@@ -103,14 +101,11 @@ class ASTBuilder {
103101
FunctionMetadataDifferentiabilityKind diffKind);
104102

105103
Type createImplFunctionType(
106-
Demangle::ImplParameterConvention calleeConvention,
107-
BuiltRequirement *witnessMethodConformanceRequirement,
108-
ArrayRef<BuiltType> GenericParameters,
109-
ArrayRef<BuiltRequirement> Requirements,
110-
ArrayRef<Demangle::ImplFunctionParam<Type>> params,
111-
ArrayRef<Demangle::ImplFunctionResult<Type>> results,
112-
Optional<Demangle::ImplFunctionResult<Type>> errorResult,
113-
ImplFunctionTypeFlags flags);
104+
Demangle::ImplParameterConvention calleeConvention,
105+
ArrayRef<Demangle::ImplFunctionParam<Type>> params,
106+
ArrayRef<Demangle::ImplFunctionResult<Type>> results,
107+
Optional<Demangle::ImplFunctionResult<Type>> errorResult,
108+
ImplFunctionTypeFlags flags);
114109

115110
Type createProtocolCompositionType(ArrayRef<ProtocolDecl *> protocols,
116111
Type superclass,
@@ -135,6 +130,8 @@ class ASTBuilder {
135130

136131
Type createSILBoxType(Type base);
137132
using BuiltSILBoxField = llvm::PointerIntPair<Type, 1>;
133+
using BuiltSubstitution = std::pair<Type, Type>;
134+
using BuiltRequirement = swift::Requirement;
138135
using BuiltLayoutConstraint = swift::LayoutConstraint;
139136
Type createSILBoxTypeWithLayout(ArrayRef<BuiltSILBoxField> Fields,
140137
ArrayRef<BuiltSubstitution> Substitutions,

include/swift/AST/IRGenOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ struct PointerAuthOptions : clang::PointerAuthOptions {
159159
/// values.
160160
PointerAuthSchema AsyncSwiftDynamicReplacements;
161161

162+
/// Like PartialApplyCapture but for use with AsyncFunctionPointer values.
163+
PointerAuthSchema AsyncPartialApplyCapture;
164+
162165
/// The parent async context stored within a child async context.
163166
PointerAuthSchema AsyncContextParent;
164167

include/swift/Demangling/DemangleNodes.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ NODE(AutoDiffSubsetParametersThunk)
313313
NODE(AutoDiffDerivativeVTableThunk)
314314
NODE(DifferentiabilityWitness)
315315
NODE(IndexSubset)
316-
NODE(AsyncNonconstantPartialApplyThunk)
317316
NODE(AsyncAwaitResumePartialFunction)
318317
NODE(AsyncSuspendResumePartialFunction)
319318

include/swift/Demangling/TypeDecoder.h

Lines changed: 32 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -814,12 +814,9 @@ class TypeDecoder {
814814
}
815815
case NodeKind::ImplFunctionType: {
816816
auto calleeConvention = ImplParameterConvention::Direct_Unowned;
817-
BuiltRequirement *witnessMethodConformanceRequirement = nullptr;
818817
llvm::SmallVector<ImplFunctionParam<BuiltType>, 8> parameters;
819818
llvm::SmallVector<ImplFunctionResult<BuiltType>, 8> results;
820819
llvm::SmallVector<ImplFunctionResult<BuiltType>, 8> errorResults;
821-
llvm::SmallVector<BuiltType, 4> genericParameters;
822-
llvm::SmallVector<BuiltRequirement, 4> requirements;
823820
ImplFunctionTypeFlags flags;
824821

825822
for (unsigned i = 0; i < Node->getNumChildren(); i++) {
@@ -852,9 +849,6 @@ class TypeDecoder {
852849
} else if (text == "block") {
853850
flags =
854851
flags.withRepresentation(ImplFunctionRepresentation::Block);
855-
} else if (text == "witness_method") {
856-
flags = flags.withRepresentation(
857-
ImplFunctionRepresentation::WitnessMethod);
858852
}
859853
} else if (child->getKind() == NodeKind::ImplFunctionAttribute) {
860854
if (!child->hasText())
@@ -892,27 +886,6 @@ class TypeDecoder {
892886
if (decodeImplFunctionPart(child, errorResults))
893887
return MAKE_NODE_TYPE_ERROR0(child,
894888
"failed to decode function part");
895-
} else if (child->getKind() == NodeKind::DependentGenericSignature) {
896-
llvm::SmallVector<unsigned, 4> genericParamsAtDepth;
897-
898-
if (auto error = decodeDependentGenericSignatureNode(
899-
child, requirements, genericParamsAtDepth))
900-
return *error;
901-
if (flags.getRepresentation() ==
902-
ImplFunctionRepresentation::WitnessMethod) {
903-
// By convention, the first requirement of a witness method is the
904-
// conformance of Self to the protocol.
905-
witnessMethodConformanceRequirement = &requirements[0];
906-
}
907-
908-
for (unsigned long depth = 0, depths = genericParamsAtDepth.size();
909-
depth < depths; ++depth) {
910-
for (unsigned index = 0; index < genericParamsAtDepth[depth];
911-
++index) {
912-
genericParameters.emplace_back(
913-
Builder.createGenericTypeParameterType(depth, index));
914-
}
915-
}
916889
} else {
917890
return MAKE_NODE_TYPE_ERROR0(child, "unexpected kind");
918891
}
@@ -933,11 +906,11 @@ class TypeDecoder {
933906
// TODO: Some cases not handled above, but *probably* they cannot
934907
// appear as the types of values in SIL (yet?):
935908
// - functions with yield returns
909+
// - functions with generic signatures
936910
// - foreign error conventions
937-
return Builder.createImplFunctionType(
938-
calleeConvention, witnessMethodConformanceRequirement,
939-
genericParameters, requirements, parameters, results, errorResult,
940-
flags);
911+
return Builder.createImplFunctionType(calleeConvention,
912+
parameters, results,
913+
errorResult, flags);
941914
}
942915

943916
case NodeKind::ArgumentTuple:
@@ -1108,12 +1081,35 @@ class TypeDecoder {
11081081
return MAKE_NODE_TYPE_ERROR0(substNode, "expected type list");
11091082

11101083
auto *dependentGenericSignatureNode = Node->getChild(1);
1084+
if (dependentGenericSignatureNode->getKind() !=
1085+
NodeKind::DependentGenericSignature)
1086+
return MAKE_NODE_TYPE_ERROR0(dependentGenericSignatureNode,
1087+
"expected dependent generic signature");
1088+
if (dependentGenericSignatureNode->getNumChildren() < 1)
1089+
return MAKE_NODE_TYPE_ERROR(
1090+
dependentGenericSignatureNode,
1091+
"fewer children (%zu) than required (1)",
1092+
dependentGenericSignatureNode->getNumChildren());
1093+
decodeRequirement<BuiltType, BuiltRequirement, BuiltLayoutConstraint,
1094+
BuilderType>(
1095+
dependentGenericSignatureNode, requirements, Builder/*,
1096+
[&](NodePointer Node) -> BuiltType {
1097+
return decodeMangledType(Node).getType();
1098+
},
1099+
[&](LayoutConstraintKind Kind) -> BuiltLayoutConstraint {
1100+
return {}; // Not implemented!
1101+
},
1102+
[&](LayoutConstraintKind Kind, unsigned SizeInBits,
1103+
unsigned Alignment) -> BuiltLayoutConstraint {
1104+
return {}; // Not Implemented!
1105+
}*/);
1106+
// The number of generic parameters at each depth are in a mini
1107+
// state machine and come first.
11111108
llvm::SmallVector<unsigned, 4> genericParamsAtDepth;
1112-
if (auto error = decodeDependentGenericSignatureNode(
1113-
dependentGenericSignatureNode, requirements,
1114-
genericParamsAtDepth))
1115-
return *error;
1116-
1109+
for (auto *reqNode : *dependentGenericSignatureNode)
1110+
if (reqNode->getKind() == NodeKind::DependentGenericParamCount)
1111+
if (reqNode->hasIndex())
1112+
genericParamsAtDepth.push_back(reqNode->getIndex());
11171113
unsigned depth = 0;
11181114
unsigned index = 0;
11191115
for (auto *subst : *substNode) {
@@ -1463,43 +1459,6 @@ class TypeDecoder {
14631459
params.push_back(std::move(param));
14641460
return true;
14651461
}
1466-
1467-
llvm::Optional<TypeLookupError> decodeDependentGenericSignatureNode(
1468-
NodePointer dependentGenericSignatureNode,
1469-
llvm::SmallVectorImpl<BuiltRequirement> &requirements,
1470-
llvm::SmallVectorImpl<unsigned> &genericParamsAtDepth) {
1471-
using NodeKind = Demangle::Node::Kind;
1472-
if (dependentGenericSignatureNode->getKind() !=
1473-
NodeKind::DependentGenericSignature)
1474-
return llvm::Optional<TypeLookupError>(
1475-
MAKE_NODE_TYPE_ERROR0(dependentGenericSignatureNode,
1476-
"expected dependent generic signature"));
1477-
if (dependentGenericSignatureNode->getNumChildren() < 1)
1478-
return llvm::Optional<TypeLookupError>(MAKE_NODE_TYPE_ERROR(
1479-
dependentGenericSignatureNode,
1480-
"fewer children (%zu) than required (1)",
1481-
dependentGenericSignatureNode->getNumChildren()));
1482-
decodeRequirement<BuiltType, BuiltRequirement, BuiltLayoutConstraint,
1483-
BuilderType>(dependentGenericSignatureNode, requirements,
1484-
Builder /*,
1485-
[&](NodePointer Node) -> BuiltType {
1486-
return decodeMangledType(Node).getType();
1487-
},
1488-
[&](LayoutConstraintKind Kind) -> BuiltLayoutConstraint {
1489-
return {}; // Not implemented!
1490-
},
1491-
[&](LayoutConstraintKind Kind, unsigned SizeInBits,
1492-
unsigned Alignment) -> BuiltLayoutConstraint {
1493-
return {}; // Not Implemented!
1494-
}*/);
1495-
// The number of generic parameters at each depth are in a mini
1496-
// state machine and come first.
1497-
for (auto *reqNode : *dependentGenericSignatureNode)
1498-
if (reqNode->getKind() == NodeKind::DependentGenericParamCount)
1499-
if (reqNode->hasIndex())
1500-
genericParamsAtDepth.push_back(reqNode->getIndex());
1501-
return llvm::None;
1502-
}
15031462
};
15041463

15051464
template <typename BuilderType>

include/swift/IRGen/IRGenSILPasses.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ namespace irgen {
1919
/// Create a pass to hoist alloc_stack instructions with non-fixed size.
2020
SILTransform *createAllocStackHoisting();
2121
SILTransform *createLoadableByAddress();
22-
SILTransform *createPartialApplyLowering();
2322

2423
} // end namespace irgen
2524
} // end namespace swift

include/swift/Reflection/TypeRefBuilder.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,14 +418,9 @@ class TypeRefBuilder {
418418
FunctionMetadataDifferentiabilityKind diffKind) {
419419
return FunctionTypeRef::create(*this, params, result, flags, diffKind);
420420
}
421-
using BuiltSubstitution = std::pair<const TypeRef *, const TypeRef *>;
422-
using BuiltRequirement = TypeRefRequirement;
423421

424422
const FunctionTypeRef *createImplFunctionType(
425423
Demangle::ImplParameterConvention calleeConvention,
426-
BuiltRequirement *witnessMethodConformanceRequirement,
427-
const llvm::SmallVectorImpl<BuiltType> &genericParameters,
428-
const llvm::SmallVectorImpl<BuiltRequirement> &requirements,
429424
llvm::ArrayRef<Demangle::ImplFunctionParam<const TypeRef *>> params,
430425
llvm::ArrayRef<Demangle::ImplFunctionResult<const TypeRef *>> results,
431426
llvm::Optional<Demangle::ImplFunctionResult<const TypeRef *>> errorResult,
@@ -545,6 +540,8 @@ class TypeRefBuilder {
545540
}
546541

547542
using BuiltSILBoxField = typename SILBoxTypeWithLayoutTypeRef::Field;
543+
using BuiltSubstitution = std::pair<const TypeRef *, const TypeRef *>;
544+
using BuiltRequirement = TypeRefRequirement;
548545
using BuiltLayoutConstraint = TypeRefLayoutConstraint;
549546
BuiltLayoutConstraint getLayoutConstraint(LayoutConstraintKind kind) {
550547
// FIXME: Implement this.

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,6 @@ IRGEN_PASS(LoadableByAddress, "loadable-address",
298298
"SIL Large Loadable type by-address lowering.")
299299
PASS(MandatorySILLinker, "mandatory-linker",
300300
"Deserialize all referenced SIL functions that are shared or transparent")
301-
IRGEN_PASS(PartialApplyLowering, "partial-apply-lowering",
302-
"Partial Apply Lowering")
303301
PASS(PerformanceSILLinker, "performance-linker",
304302
"Deserialize all referenced SIL functions")
305303
PASS(RawSILInstLowering, "raw-sil-inst-lowering",

lib/AST/ASTDemangler.cpp

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -483,24 +483,11 @@ getResultDifferentiability(ImplResultDifferentiability diffKind) {
483483

484484
Type ASTBuilder::createImplFunctionType(
485485
Demangle::ImplParameterConvention calleeConvention,
486-
BuiltRequirement *witnessMethodConformanceRequirement,
487-
ArrayRef<BuiltType> GenericParameters,
488-
ArrayRef<BuiltRequirement> Requirements,
489486
ArrayRef<Demangle::ImplFunctionParam<Type>> params,
490487
ArrayRef<Demangle::ImplFunctionResult<Type>> results,
491488
Optional<Demangle::ImplFunctionResult<Type>> errorResult,
492489
ImplFunctionTypeFlags flags) {
493490
GenericSignature genericSig;
494-
if (GenericParameters.size() > 0) {
495-
llvm::SmallVector<GenericTypeParamType *, 4> CastGenericParameters;
496-
for (auto Parameter : GenericParameters) {
497-
CastGenericParameters.push_back(
498-
Parameter->castTo<GenericTypeParamType>());
499-
}
500-
genericSig = GenericSignature::get(CastGenericParameters, Requirements);
501-
} else {
502-
assert(Requirements.size() == 0);
503-
}
504491

505492
SILCoroutineKind funcCoroutineKind = SILCoroutineKind::None;
506493
ParameterConvention funcCalleeConvention =
@@ -585,15 +572,11 @@ Type ASTBuilder::createImplFunctionType(
585572
representation, flags.isPseudogeneric(), !flags.isEscaping(),
586573
flags.isSendable(), flags.isAsync(), diffKind, clangFnType)
587574
.build();
588-
auto witnessMethodConformance =
589-
witnessMethodConformanceRequirement
590-
? ProtocolConformanceRef(
591-
witnessMethodConformanceRequirement->getProtocolDecl())
592-
: ProtocolConformanceRef();
593-
return SILFunctionType::get(
594-
genericSig, einfo, funcCoroutineKind, funcCalleeConvention, funcParams,
595-
funcYields, funcResults, funcErrorResult,
596-
SubstitutionMap(), SubstitutionMap(), Ctx, witnessMethodConformance);
575+
576+
return SILFunctionType::get(genericSig, einfo, funcCoroutineKind,
577+
funcCalleeConvention, funcParams, funcYields,
578+
funcResults, funcErrorResult,
579+
SubstitutionMap(), SubstitutionMap(), Ctx);
597580
}
598581

599582
Type ASTBuilder::createProtocolCompositionType(

lib/Demangling/Demangler.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ 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:
127126
case Node::Kind::AsyncAwaitResumePartialFunction:
128127
case Node::Kind::AsyncSuspendResumePartialFunction:
129128
return true;
@@ -2536,11 +2535,6 @@ NodePointer Demangler::demangleThunkOrSpecialization() {
25362535
return demangleAutoDiffFunctionOrSimpleThunk(
25372536
Node::Kind::AutoDiffFunction);
25382537
}
2539-
case 'w': {
2540-
NodePointer discriminator = demangleIndexAsNode();
2541-
return createWithChild(Node::Kind::AsyncNonconstantPartialApplyThunk,
2542-
discriminator);
2543-
}
25442538
default:
25452539
return nullptr;
25462540
}

0 commit comments

Comments
 (0)