Skip to content

SIL: Simplify SILLinkerVisitor::visitApplySubstitutions() #18662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 10 additions & 24 deletions lib/SIL/Linker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,30 +288,16 @@ void SILLinkerVisitor::visitProtocolConformance(
}

void SILLinkerVisitor::visitApplySubstitutions(SubstitutionMap subs) {
for (auto &reqt : subs.getGenericSignature()->getRequirements()) {
switch (reqt.getKind()) {
case RequirementKind::Conformance: {
auto conformance = subs.lookupConformance(
reqt.getFirstType()->getCanonicalType(),
cast<ProtocolDecl>(reqt.getSecondType()->getAnyNominal()))
.getValue();

// Formally all conformances referenced in a function application are
// used. However, eagerly visiting them all at this point leads to a
// large blowup in the amount of SIL we read in, and we aren't very
// systematic about laziness. For optimization purposes we can defer
// reading in most conformances until we need them for devirtualization.
// However, we *must* pull in shared clang-importer-derived conformances
// we potentially use, since we may not otherwise have a local definition.
if (mustDeserializeProtocolConformance(Mod, conformance)) {
visitProtocolConformance(conformance, None);
}
break;
}
case RequirementKind::Layout:
case RequirementKind::SameType:
case RequirementKind::Superclass:
break;
for (auto conformance : subs.getConformances()) {
// Formally all conformances referenced in a function application are
// used. However, eagerly visiting them all at this point leads to a
// large blowup in the amount of SIL we read in, and we aren't very
// systematic about laziness. For optimization purposes we can defer
// reading in most conformances until we need them for devirtualization.
// However, we *must* pull in shared clang-importer-derived conformances
// we potentially use, since we may not otherwise have a local definition.
if (mustDeserializeProtocolConformance(Mod, conformance)) {
visitProtocolConformance(conformance, None);
}
}
}
Expand Down