Skip to content

Commit 22dcc92

Browse files
authored
Merge pull request #2948 from swiftwasm/katei/merge-main-2021-04-08
Merge main 2021-04-08
2 parents 4a48525 + 793b01b commit 22dcc92

File tree

165 files changed

+1993
-2212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+1993
-2212
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

docs/Testing.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ out with ``lit.py -h``. We document some of the more useful ones below:
124124
line, amid a sequence.
125125
* ``-a`` causes a test's commandline and output to always be printed.
126126
* ``--filter=<pattern>`` causes only tests with paths matching the given regular
127-
expression to be run.
127+
expression to be run. Alternately, you can use the `LIT_FILTER='<pattern>'`
128+
environment variable, in case you're invoking `lit.py` through some other
129+
tool such as `build-script`.
128130
* ``-i`` causes tests that have a newer modification date and failing tests to
129131
be run first. This is implemented by updating the mtimes of the tests.
130132
* ``--no-execute`` causes a dry run to be performed. *NOTE* This means that all

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/ASTScope.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ class OpaqueTypeScope final : public GenericTypeScope {
703703
Decl *getDecl() const override { return decl; }
704704
};
705705

706-
/// Since each generic parameter can "see" the preceeding ones,
706+
/// Since each generic parameter can "see" the preceding ones,
707707
/// (e.g. <A, B: A>) -- it's not legal but that's how lookup behaves --
708708
/// Each GenericParamScope scopes just ONE parameter, and we next
709709
/// each one within the previous one.

include/swift/AST/Decl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,9 @@ class alignas(1 << DeclAlignInBits) Decl {
789789
return Attrs;
790790
}
791791

792+
/// Returns the innermost enclosing decl with an availability annotation.
793+
const Decl *getInnermostDeclWithAvailability() const;
794+
792795
/// Returns the introduced OS version in the given platform kind specified
793796
/// by @available attribute.
794797
/// This function won't consider the parent context to get the information.

include/swift/AST/IRGenOptions.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,26 @@ struct PointerAuthOptions : clang::PointerAuthOptions {
142142
/// Resilient class stub initializer callbacks.
143143
PointerAuthSchema ResilientClassStubInitCallbacks;
144144

145+
/// Like SwiftFunctionPointers but for use with AsyncFunctionPointer values.
146+
PointerAuthSchema AsyncSwiftFunctionPointers;
147+
148+
/// Like SwiftClassMethods but for use with AsyncFunctionPointer values.
149+
PointerAuthSchema AsyncSwiftClassMethods;
150+
151+
/// Like ProtocolWitnesses but for use with AsyncFunctionPointer values.
152+
PointerAuthSchema AsyncProtocolWitnesses;
153+
154+
/// Like SwiftClassMethodPointers but for use with AsyncFunctionPointer
155+
/// values.
156+
PointerAuthSchema AsyncSwiftClassMethodPointers;
157+
158+
/// Like SwiftDynamicReplacements but for use with AsyncFunctionPointer
159+
/// values.
160+
PointerAuthSchema AsyncSwiftDynamicReplacements;
161+
162+
/// Like PartialApplyCapture but for use with AsyncFunctionPointer values.
163+
PointerAuthSchema AsyncPartialApplyCapture;
164+
145165
/// The parent async context stored within a child async context.
146166
PointerAuthSchema AsyncContextParent;
147167

include/swift/AST/PrintOptions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,12 @@ struct PrintOptions {
371371
/// Whether to print the extensions from conforming protocols.
372372
bool PrintExtensionFromConformingProtocols = false;
373373

374+
/// Whether to always try and print parameter labels. If present, print the
375+
/// external parameter name. Otherwise try printing the internal name as
376+
/// `_ <internalName>`, if an internal name exists. If neither an external nor
377+
/// an internal name exists, only print the parameter's type.
378+
bool AlwaysTryPrintParameterLabels = false;
379+
374380
std::shared_ptr<ShouldPrintChecker> CurrentPrintabilityChecker =
375381
std::make_shared<ShouldPrintChecker>();
376382

include/swift/AST/Types.h

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,8 +2785,9 @@ class AnyFunctionType : public TypeBase {
27852785
public:
27862786
explicit Param(Type t,
27872787
Identifier l = Identifier(),
2788-
ParameterTypeFlags f = ParameterTypeFlags())
2789-
: Ty(t), Label(l), Flags(f) {
2788+
ParameterTypeFlags f = ParameterTypeFlags(),
2789+
Identifier internalLabel = Identifier())
2790+
: Ty(t), Label(l), InternalLabel(internalLabel), Flags(f) {
27902791
assert(t && "param type must be non-null");
27912792
assert(!t->is<InOutType>() && "set flags instead");
27922793
}
@@ -2796,8 +2797,18 @@ class AnyFunctionType : public TypeBase {
27962797
/// element type.
27972798
Type Ty;
27982799

2799-
// The label associated with the parameter, if any.
2800+
/// The label associated with the parameter, if any.
28002801
Identifier Label;
2802+
2803+
/// The internal label of the parameter, if explicitly specified, otherwise
2804+
/// empty. The internal label is considered syntactic sugar. It is not
2805+
/// considered part of the canonical type and is thus also ignored in \c
2806+
/// operator==.
2807+
/// E.g.
2808+
/// - `name name2: Int` has internal label `name2`
2809+
/// - `_ name2: Int` has internal label `name2`
2810+
/// - `name: Int` has no internal label
2811+
Identifier InternalLabel;
28012812

28022813
/// Parameter specific flags.
28032814
ParameterTypeFlags Flags = {};
@@ -2823,6 +2834,9 @@ class AnyFunctionType : public TypeBase {
28232834

28242835
bool hasLabel() const { return !Label.empty(); }
28252836
Identifier getLabel() const { return Label; }
2837+
2838+
bool hasInternalLabel() const { return !InternalLabel.empty(); }
2839+
Identifier getInternalLabel() const { return InternalLabel; }
28262840

28272841
ParameterTypeFlags getParameterFlags() const { return Flags; }
28282842

@@ -2851,23 +2865,34 @@ class AnyFunctionType : public TypeBase {
28512865
return Flags.getValueOwnership();
28522866
}
28532867

2868+
/// Returns \c true if the two \c Params are equal in their canonicalized
2869+
/// form.
2870+
/// Two \c Params are equal if their external label, flags and
2871+
/// *canonicalized* types match. The internal label and sugar types are
2872+
/// *not* considered for type equality.
28542873
bool operator==(Param const &b) const {
28552874
return (Label == b.Label &&
28562875
getPlainType()->isEqual(b.getPlainType()) &&
28572876
Flags == b.Flags);
28582877
}
28592878
bool operator!=(Param const &b) const { return !(*this == b); }
28602879

2861-
Param getWithoutLabel() const { return Param(Ty, Identifier(), Flags); }
2880+
/// Return the parameter without external and internal labels.
2881+
Param getWithoutLabels() const {
2882+
return Param(Ty, /*Label=*/Identifier(), Flags,
2883+
/*InternalLabel=*/Identifier());
2884+
}
28622885

28632886
Param withLabel(Identifier newLabel) const {
2864-
return Param(Ty, newLabel, Flags);
2887+
return Param(Ty, newLabel, Flags, InternalLabel);
28652888
}
28662889

2867-
Param withType(Type newType) const { return Param(newType, Label, Flags); }
2890+
Param withType(Type newType) const {
2891+
return Param(newType, Label, Flags, InternalLabel);
2892+
}
28682893

28692894
Param withFlags(ParameterTypeFlags flags) const {
2870-
return Param(Ty, Label, flags);
2895+
return Param(Ty, Label, flags, InternalLabel);
28712896
}
28722897
};
28732898

@@ -2988,14 +3013,19 @@ class AnyFunctionType : public TypeBase {
29883013
return composeInput(ctx, params.getOriginalArray(), canonicalVararg);
29893014
}
29903015

2991-
/// Given two arrays of parameters determine if they are equal.
3016+
/// Given two arrays of parameters determine if they are equal in their
3017+
/// canonicalized form. Internal labels and type sugar is *not* taken into
3018+
/// account.
29923019
static bool equalParams(ArrayRef<Param> a, ArrayRef<Param> b);
29933020

2994-
/// Given two arrays of parameters determine if they are equal.
3021+
/// Given two arrays of parameters determine if they are equal in their
3022+
/// canonicalized form. Internal labels and type sugar is *not* taken into
3023+
/// account.
29953024
static bool equalParams(CanParamArrayRef a, CanParamArrayRef b);
29963025

29973026
/// Given an array of parameters and an array of labels of the
29983027
/// same length, update each parameter to have the corresponding label.
3028+
/// The internal parameter labels remain the same.
29993029
static void relabelParams(MutableArrayRef<Param> params,
30003030
ArrayRef<Identifier> labels);
30013031

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

0 commit comments

Comments
 (0)