mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[GSB] Don't use archetype anchor ordering when merging equivalence classes.
When we merge equivalence classes (by choosing a new representative), we already prefer the potential archetype with the shorter nesting depth. However, barring that, we were preferring the potential archetype that is a better archetype anchor. At one point we depended on this, but now it's an extra cost that has the side effect of building more potential archetypes than we really need at this stage. Eliminate the compareDependentTypes() check when merging equivalence classes. The intent is that we only need to form archetype anchors when enumerating requirements or canonicalizing---not during the normal "solving" path of the GSB.
This commit is contained in:
@@ -1690,8 +1690,6 @@ PotentialArchetype *PotentialArchetype::getArchetypeAnchor(
|
||||
equivClass->archetypeAnchorCache.numMembers
|
||||
== equivClass->members.size()) {
|
||||
++NumArchetypeAnchorCacheHits;
|
||||
assert(equivClass->archetypeAnchorCache.anchor->getNestingDepth()
|
||||
<= rep->getNestingDepth());
|
||||
return equivClass->archetypeAnchorCache.anchor;
|
||||
}
|
||||
|
||||
@@ -1710,8 +1708,6 @@ PotentialArchetype *PotentialArchetype::getArchetypeAnchor(
|
||||
}
|
||||
#endif
|
||||
|
||||
assert(anchor->getNestingDepth() <= rep->getNestingDepth());
|
||||
|
||||
// Record the cache miss and update the cache.
|
||||
++NumArchetypeAnchorCacheMisses;
|
||||
equivClass->archetypeAnchorCache.anchor = anchor;
|
||||
@@ -3331,11 +3327,9 @@ GenericSignatureBuilder::addSameTypeRequirementBetweenArchetypes(
|
||||
unsigned nestingDepth2 = T2->getNestingDepth();
|
||||
|
||||
// Decide which potential archetype is to be considered the representative.
|
||||
// We prefer potential archetypes with lower nesting depths (because it
|
||||
// prevents us from unnecessarily building deeply nested potential archetypes)
|
||||
// and prefer anchors because it's a minor optimization.
|
||||
if (nestingDepth2 < nestingDepth1 ||
|
||||
compareDependentTypes(&T2, &T1) < 0) {
|
||||
// We prefer potential archetypes with lower nesting depths, because it
|
||||
// prevents us from unnecessarily building deeply nested potential archetypes.
|
||||
if (nestingDepth2 < nestingDepth1) {
|
||||
std::swap(T1, T2);
|
||||
std::swap(OrigT1, OrigT2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user