Skip to content

Commit 5acc140

Browse files
committed
Revert "[GSB] SE-0157: Reprocess delayed requirements when we need a complete PA."
This reverts commit ded45a6. This seems to slow down type checking of Swift.o by more than 3x.
1 parent ed23eb3 commit 5acc140

File tree

2 files changed

+1
-40
lines changed

2 files changed

+1
-40
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,6 @@ struct GenericSignatureBuilder::Implementation {
9090
/// The set of requirements that have been delayed for some reason.
9191
SmallVector<DelayedRequirement, 4> DelayedRequirements;
9292

93-
/// The generation number, which is incremented whenever we successfully
94-
/// introduce a new constraint.
95-
unsigned Generation = 0;
96-
97-
/// The generation at which we last processed all of the delayed requirements.
98-
unsigned LastProcessedGeneration = 0;
99-
10093
#ifndef NDEBUG
10194
/// Whether we've already finalized the builder.
10295
bool finalized = false;
@@ -1406,9 +1399,6 @@ bool PotentialArchetype::addConformance(ProtocolDecl *proto,
14061399
return false;
14071400
}
14081401

1409-
// Bump the generation.
1410-
++builder.Impl->Generation;
1411-
14121402
// Add the conformance along with this constraint.
14131403
equivClass->conformsTo[proto].push_back({this, proto, source});
14141404
++NumConformanceConstraints;
@@ -1876,12 +1866,6 @@ PotentialArchetype *PotentialArchetype::updateNestedTypeForConformance(
18761866
if (!assocType && !concreteDecl)
18771867
return nullptr;
18781868

1879-
// If we were asked for a complete, well-formed archetype, make sure we
1880-
// process delayed requirements if anything changed.
1881-
SWIFT_DEFER {
1882-
getBuilder()->processDelayedRequirements();
1883-
};
1884-
18851869
Identifier name = assocType ? assocType->getName() : concreteDecl->getName();
18861870
ProtocolDecl *proto =
18871871
assocType ? assocType->getProtocol()
@@ -1916,9 +1900,6 @@ PotentialArchetype *PotentialArchetype::updateNestedTypeForConformance(
19161900
switch (kind) {
19171901
case ArchetypeResolutionKind::CompleteWellFormed:
19181902
case ArchetypeResolutionKind::WellFormed: {
1919-
// Bump the generation count, because we created a new archetype.
1920-
++getBuilder()->Impl->Generation;
1921-
19221903
if (assocType)
19231904
resultPA = new PotentialArchetype(this, assocType);
19241905
else
@@ -2837,9 +2818,6 @@ ConstraintResult GenericSignatureBuilder::addLayoutRequirement(
28372818
return ConstraintResult::Resolved;
28382819
}
28392820

2840-
// Bump the generation.
2841-
++Impl->Generation;
2842-
28432821
auto pa = resolvedSubject->getPotentialArchetype();
28442822
return addLayoutRequirementDirect(pa, layout, source.getSource(pa));
28452823
}
@@ -2924,9 +2902,6 @@ ConstraintResult GenericSignatureBuilder::addSuperclassRequirementDirect(
29242902
.push_back(ConcreteConstraint{T, superclass, source});
29252903
++NumSuperclassConstraints;
29262904

2927-
// Bump the generation.
2928-
++Impl->Generation;
2929-
29302905
// Update the equivalence class with the constraint.
29312906
updateSuperclass(T, superclass, source);
29322907
return ConstraintResult::Resolved;
@@ -3086,9 +3061,6 @@ GenericSignatureBuilder::addSameTypeRequirementBetweenArchetypes(
30863061
if (T1 == T2)
30873062
return ConstraintResult::Resolved;
30883063

3089-
// Bump the generation.
3090-
++Impl->Generation;
3091-
30923064
unsigned nestingDepth1 = T1->getNestingDepth();
30933065
unsigned nestingDepth2 = T2->getNestingDepth();
30943066

@@ -3224,9 +3196,6 @@ ConstraintResult GenericSignatureBuilder::addSameTypeRequirementToConcrete(
32243196
ConcreteConstraint{T, Concrete, Source});
32253197
++NumConcreteTypeConstraints;
32263198

3227-
// Bump the generation.
3228-
++Impl->Generation;
3229-
32303199
// If we've already been bound to a type, match that type.
32313200
if (equivClass->concreteType) {
32323201
return addSameTypeRequirement(equivClass->concreteType, Concrete, Source,
@@ -4009,13 +3978,6 @@ static GenericSignatureBuilder::UnresolvedType asUnresolvedType(
40093978
}
40103979

40113980
void GenericSignatureBuilder::processDelayedRequirements() {
4012-
// If we're already up-to-date, do nothing.
4013-
if (Impl->Generation == Impl->LastProcessedGeneration) return;
4014-
4015-
SWIFT_DEFER {
4016-
Impl->LastProcessedGeneration = Impl->Generation;
4017-
};
4018-
40193981
bool anySolved = !Impl->DelayedRequirements.empty();
40203982
while (anySolved) {
40213983
// Steal the delayed requirements so we can reprocess them.

test/decl/protocol/recursive_requirement_ok.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ protocol P {
99
func testP<T: P>(_ t: T) {
1010
testP(t.assoc)
1111
testP(t.assoc.assoc)
12-
testP(t.assoc.assoc.assoc)
13-
testP(t.assoc.assoc.assoc.assoc.assoc.assoc.assoc)
12+
testP(t.assoc.assoc.assoc) // FIXME: expected-error{{argument type 'T.Assoc.Assoc.Assoc' does not conform to expected type 'P'}}
1413
}

0 commit comments

Comments
 (0)