Skip to content

Commit 1763a2c

Browse files
committed
[GSB] Stop collapsing "structurally equivalent" potential archetypes.
Now that we only record potential archetypes involving the "anchor" archetypes, there is no need to collapse structurally-equivalent potential archetypes. Delete some temporary code.
1 parent eb31b2b commit 1763a2c

File tree

2 files changed

+3
-57
lines changed

2 files changed

+3
-57
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5504,53 +5504,6 @@ static void collapseSameTypeComponentsThroughDelayedRequirements(
55045504
collapsedParents.end());
55055505
}
55065506

5507-
/// Check whether two potential archetypes "structurally" match, e.g.,
5508-
/// the names match up to the root (which must match).
5509-
static bool potentialArchetypesStructurallyMatch(PotentialArchetype *pa1,
5510-
PotentialArchetype *pa2) {
5511-
auto parent1 = pa1->getParent();
5512-
auto parent2 = pa2->getParent();
5513-
if (!parent1 && !parent2)
5514-
return pa1->getGenericParamKey() == pa2->getGenericParamKey();
5515-
5516-
// Check for depth mismatch.
5517-
if (static_cast<bool>(parent1) != static_cast<bool>(parent2))
5518-
return false;
5519-
5520-
// Check names.
5521-
if (pa1->getNestedName() != pa2->getNestedName())
5522-
return false;
5523-
5524-
return potentialArchetypesStructurallyMatch(parent1, parent2);
5525-
}
5526-
5527-
/// Look for structurally-equivalent types within the given equivalence class,
5528-
/// collapsing their components.
5529-
static void collapseStructurallyEquivalentSameTypeComponents(
5530-
EquivalenceClass *equivClass,
5531-
llvm::SmallDenseMap<PotentialArchetype *, unsigned> &componentOf,
5532-
SmallVectorImpl<unsigned> &collapsedParents,
5533-
unsigned &remainingComponents) {
5534-
for (unsigned i : indices(equivClass->members)) {
5535-
auto pa1 = equivClass->members[i];
5536-
auto rep1 = findRepresentative(collapsedParents, componentOf[pa1]);
5537-
for (unsigned j : indices(equivClass->members).slice(i + 1)) {
5538-
auto pa2 = equivClass->members[j];
5539-
auto rep2 = findRepresentative(collapsedParents, componentOf[pa2]);
5540-
if (rep1 == rep2) continue;
5541-
5542-
auto depth = pa1->getNestingDepth();
5543-
if (depth < 2 || depth != pa2->getNestingDepth()) continue;
5544-
5545-
if (potentialArchetypesStructurallyMatch(pa1, pa2) &&
5546-
unionSets(collapsedParents, rep1, rep2)) {
5547-
--remainingComponents;
5548-
rep1 = findRepresentative(collapsedParents, componentOf[pa1]);
5549-
}
5550-
}
5551-
}
5552-
}
5553-
55545507
/// Collapse same-type components within an equivalence class, minimizing the
55555508
/// number of requirements required to express the equivalence class.
55565509
static void collapseSameTypeComponents(
@@ -5611,14 +5564,6 @@ static void collapseSameTypeComponents(
56115564
builder, equivClass, componentOf, collapsedParents, remainingComponents);
56125565
}
56135566

5614-
if (remainingComponents > 1) {
5615-
// Collapse structurally-equivalent components.
5616-
collapseStructurallyEquivalentSameTypeComponents(equivClass,
5617-
componentOf,
5618-
collapsedParents,
5619-
remainingComponents);
5620-
}
5621-
56225567
// If needed, collapse the same-type components merged by a derived
56235568
// nested-type-name-match edge.
56245569
unsigned maxComponents = equivClass->derivedSameTypeComponents.size();

test/IRGen/associated_types.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ protocol FastRuncible {
6666
// information for archetypes from all paths to that archetype, not just
6767
// its parent relationships.
6868

69-
func testFastRuncible<T: Runcible, U: FastRuncible where T.RuncerType == U.RuncerType>(_ t: T, u: U) {
69+
func testFastRuncible<T: Runcible, U: FastRuncible>(_ t: T, u: U)
70+
where T.RuncerType == U.RuncerType {
7071
U.RuncerType.Runcee.accelerate()
7172
}
7273

73-
// CHECK: define hidden swiftcc void @_T016associated_types16testFastRuncibleyx_q_1utAA0E0RzAA0dE0R_10RuncerTypeQy_AFRtzr0_lF(%swift.opaque* noalias nocapture, %swift.opaque* noalias nocapture, %swift.type* %T, %swift.type* %U, i8** %T.Runcible, i8** %U.FastRuncible) #0 {
74+
// CHECK: define hidden swiftcc void @_T016associated_types16testFastRuncibleyx_q_1utAA0E0RzAA0dE0R_10RuncerTypeQy_AFRtzAF_6RunceeAA0F0PQZAF_AiA0dF0PRTzr0_lF(%swift.opaque* noalias nocapture, %swift.opaque* noalias nocapture, %swift.type* %T, %swift.type* %U, i8** %T.Runcible, i8** %U.FastRuncible) #0 {
7475
// 1. Get the type metadata for U.RuncerType.Runcee.
7576
// 1a. Get the type metadata for U.RuncerType.
7677
// Note that we actually look things up in T, which is going to prove unfortunate.

0 commit comments

Comments
 (0)