Skip to content

Commit 5670cc6

Browse files
committed
IRGen: Remove some dead code from NecessaryBindings.cpp
1 parent 1f78973 commit 5670cc6

File tree

2 files changed

+7
-71
lines changed

2 files changed

+7
-71
lines changed

lib/IRGen/GenProto.cpp

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2920,14 +2920,6 @@ void NecessaryBindings::save(IRGenFunction &IGF, Address buffer) const {
29202920
void NecessaryBindings::addTypeMetadata(CanType type) {
29212921
assert(!isa<InOutType>(type));
29222922

2923-
// If the bindings are for an async function, we will always need the type
2924-
// metadata. The opportunities to reconstruct it available in the context of
2925-
// partial apply forwarders are not available here.
2926-
if (forAsyncFunction()) {
2927-
addRequirement({type, nullptr});
2928-
return;
2929-
}
2930-
29312923
// Bindings are only necessary at all if the type is dependent.
29322924
if (!type->hasArchetype())
29332925
return;
@@ -2995,21 +2987,12 @@ void NecessaryBindings::addProtocolConformance(CanType type,
29952987
dyn_cast<SpecializedProtocolConformance>(concreteConformance);
29962988
// The partial apply forwarder does not have the context to reconstruct
29972989
// abstract conditional conformance requirements.
2998-
if (forPartialApply() && specializedConf) {
2990+
if (specializedConf) {
29992991
addAbstractConditionalRequirements(specializedConf);
3000-
} else if (forAsyncFunction()) {
3001-
ProtocolDecl *protocol = conf.getRequirement();
3002-
GenericRequirement requirement;
3003-
requirement.TypeParameter = type;
3004-
requirement.Protocol = protocol;
3005-
std::pair<GenericRequirement, ProtocolConformanceRef> pair{requirement,
3006-
conf};
3007-
Conformances.insert(pair);
3008-
addRequirement({type, concreteConformance->getProtocol()});
30092992
}
30102993
return;
30112994
}
3012-
assert(isa<ArchetypeType>(type) || forAsyncFunction());
2995+
assert(isa<ArchetypeType>(type));
30132996

30142997
// TODO: pass something about the root conformance necessary to
30152998
// reconstruct this.
@@ -3204,29 +3187,20 @@ void EmitPolymorphicArguments::emit(SubstitutionMap subs,
32043187
}
32053188
}
32063189

3207-
NecessaryBindings NecessaryBindings::forAsyncFunctionInvocation(
3208-
IRGenModule &IGM, CanSILFunctionType origType, SubstitutionMap subs) {
3209-
return computeBindings(IGM, origType, subs,
3210-
false /*forPartialApplyForwarder*/);
3211-
}
3212-
32133190
NecessaryBindings
32143191
NecessaryBindings::forPartialApplyForwarder(IRGenModule &IGM,
32153192
CanSILFunctionType origType,
32163193
SubstitutionMap subs,
32173194
bool considerParameterSources) {
32183195
return computeBindings(IGM, origType, subs,
3219-
true /*forPartialApplyForwarder*/,
32203196
considerParameterSources);
32213197
}
32223198

32233199
NecessaryBindings NecessaryBindings::computeBindings(
32243200
IRGenModule &IGM, CanSILFunctionType origType, SubstitutionMap subs,
3225-
bool forPartialApplyForwarder, bool considerParameterSources) {
3201+
bool considerParameterSources) {
32263202

32273203
NecessaryBindings bindings;
3228-
bindings.kind =
3229-
forPartialApplyForwarder ? Kind::PartialApply : Kind::AsyncFunction;
32303204

32313205
// Bail out early if we don't have polymorphic parameters.
32323206
if (!hasPolymorphicParameters(origType))
@@ -3249,9 +3223,7 @@ NecessaryBindings NecessaryBindings::computeBindings(
32493223
case MetadataSource::Kind::SelfMetadata:
32503224
// Async functions pass the SelfMetadata and SelfWitnessTable parameters
32513225
// along explicitly.
3252-
if (forPartialApplyForwarder) {
3253-
bindings.addTypeMetadata(getSubstSelfType(IGM, origType, subs));
3254-
}
3226+
bindings.addTypeMetadata(getSubstSelfType(IGM, origType, subs));
32553227
continue;
32563228

32573229
case MetadataSource::Kind::SelfWitnessTable:

lib/IRGen/NecessaryBindings.h

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,11 @@ namespace swift {
4242
/// NecessaryBindings - The set of metadata that must be saved in
4343
/// order to perform some set of operations on a type.
4444
class NecessaryBindings {
45-
enum class Kind {
46-
/// Are the bindings to be computed for a partial apply forwarder.
47-
/// In the case this is true we need to store/restore the conformance of a
48-
/// specialized type with conditional conformance because the conditional
49-
/// requirements are not available in the partial apply forwarder.
50-
PartialApply,
51-
AsyncFunction,
52-
};
53-
Kind kind;
5445
llvm::SetVector<GenericRequirement> RequirementsSet;
55-
llvm::SmallVector<GenericRequirement, 2> RequirementsVector;
5646
llvm::DenseMap<GenericRequirement, ProtocolConformanceRef> Conformances;
5747

5848
void addRequirement(GenericRequirement requirement) {
59-
switch (kind) {
60-
case Kind::PartialApply:
61-
RequirementsSet.insert(requirement);
62-
break;
63-
case Kind::AsyncFunction:
64-
RequirementsVector.push_back(requirement);
65-
break;
66-
}
49+
RequirementsSet.insert(requirement);
6750
}
6851

6952
void addAbstractConditionalRequirements(
@@ -74,9 +57,6 @@ class NecessaryBindings {
7457

7558
/// Collect the necessary bindings to invoke a function with the given
7659
/// signature.
77-
static NecessaryBindings
78-
forAsyncFunctionInvocation(IRGenModule &IGM, CanSILFunctionType origType,
79-
SubstitutionMap subs);
8060
static NecessaryBindings forPartialApplyForwarder(IRGenModule &IGM,
8161
CanSILFunctionType origType,
8262
SubstitutionMap subs,
@@ -88,13 +68,7 @@ class NecessaryBindings {
8868

8969
/// Get the requirement from the bindings at index i.
9070
const GenericRequirement &operator[](size_t i) const {
91-
switch (kind) {
92-
case Kind::PartialApply:
93-
return RequirementsSet[i];
94-
case Kind::AsyncFunction:
95-
return RequirementsVector[i];
96-
}
97-
llvm_unreachable("covered switch");
71+
return RequirementsSet[i];
9872
}
9973

10074
ProtocolConformanceRef
@@ -124,23 +98,13 @@ class NecessaryBindings {
12498
void restore(IRGenFunction &IGF, Address buffer, MetadataState state) const;
12599

126100
const llvm::ArrayRef<GenericRequirement> getRequirements() const {
127-
switch (kind) {
128-
case Kind::PartialApply:
129-
return RequirementsSet.getArrayRef();
130-
case Kind::AsyncFunction:
131-
return RequirementsVector;
132-
}
133-
llvm_unreachable("unhandled case");
101+
return RequirementsSet.getArrayRef();
134102
}
135103

136-
bool forPartialApply() const { return kind == Kind::PartialApply; }
137-
bool forAsyncFunction() const { return kind == Kind::AsyncFunction; }
138-
139104
private:
140105
static NecessaryBindings computeBindings(IRGenModule &IGM,
141106
CanSILFunctionType origType,
142107
SubstitutionMap subs,
143-
bool forPartialApplyForwarder,
144108
bool considerParameterSources = true);
145109
};
146110

0 commit comments

Comments
 (0)