Skip to content

Commit 46981fe

Browse files
authored
Merge pull request #18662 from slavapestov/sil-linker-cleanup
SIL: Simplify SILLinkerVisitor::visitApplySubstitutions()
2 parents 63665cd + 7004f9a commit 46981fe

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

lib/SIL/Linker.cpp

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -288,30 +288,16 @@ void SILLinkerVisitor::visitProtocolConformance(
288288
}
289289

290290
void SILLinkerVisitor::visitApplySubstitutions(SubstitutionMap subs) {
291-
for (auto &reqt : subs.getGenericSignature()->getRequirements()) {
292-
switch (reqt.getKind()) {
293-
case RequirementKind::Conformance: {
294-
auto conformance = subs.lookupConformance(
295-
reqt.getFirstType()->getCanonicalType(),
296-
cast<ProtocolDecl>(reqt.getSecondType()->getAnyNominal()))
297-
.getValue();
298-
299-
// Formally all conformances referenced in a function application are
300-
// used. However, eagerly visiting them all at this point leads to a
301-
// large blowup in the amount of SIL we read in, and we aren't very
302-
// systematic about laziness. For optimization purposes we can defer
303-
// reading in most conformances until we need them for devirtualization.
304-
// However, we *must* pull in shared clang-importer-derived conformances
305-
// we potentially use, since we may not otherwise have a local definition.
306-
if (mustDeserializeProtocolConformance(Mod, conformance)) {
307-
visitProtocolConformance(conformance, None);
308-
}
309-
break;
310-
}
311-
case RequirementKind::Layout:
312-
case RequirementKind::SameType:
313-
case RequirementKind::Superclass:
314-
break;
291+
for (auto conformance : subs.getConformances()) {
292+
// Formally all conformances referenced in a function application are
293+
// used. However, eagerly visiting them all at this point leads to a
294+
// large blowup in the amount of SIL we read in, and we aren't very
295+
// systematic about laziness. For optimization purposes we can defer
296+
// reading in most conformances until we need them for devirtualization.
297+
// However, we *must* pull in shared clang-importer-derived conformances
298+
// we potentially use, since we may not otherwise have a local definition.
299+
if (mustDeserializeProtocolConformance(Mod, conformance)) {
300+
visitProtocolConformance(conformance, None);
315301
}
316302
}
317303
}

0 commit comments

Comments
 (0)