Skip to content

Commit 9458310

Browse files
committed
[SILGen] Eliminate SILGen-specific handling of imported, synthesized conformances
Now that Sema communicates its "used" conformances to SILGen, there is no reason for SILGen to separately look for "used" conformances. NFC
1 parent dfc8d5a commit 9458310

File tree

4 files changed

+0
-32
lines changed

4 files changed

+0
-32
lines changed

lib/SILGen/SILGenExpr.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,6 @@ ManagedValue SILGenFunction::getManagedValue(SILLocation loc,
14501450

14511451
RValue RValueEmitter::visitForcedCheckedCastExpr(ForcedCheckedCastExpr *E,
14521452
SGFContext C) {
1453-
SGF.checkForImportedUsedConformances(E);
14541453
return emitUnconditionalCheckedCast(SGF, E, E->getSubExpr(), E->getType(),
14551454
E->getCastKind(), C);
14561455
}
@@ -1459,14 +1458,12 @@ RValue RValueEmitter::visitForcedCheckedCastExpr(ForcedCheckedCastExpr *E,
14591458
RValue RValueEmitter::
14601459
visitConditionalCheckedCastExpr(ConditionalCheckedCastExpr *E,
14611460
SGFContext C) {
1462-
SGF.checkForImportedUsedConformances(E);
14631461
ManagedValue operand = SGF.emitRValueAsSingleValue(E->getSubExpr());
14641462
return emitConditionalCheckedCast(SGF, E, operand, E->getSubExpr()->getType(),
14651463
E->getType(), E->getCastKind(), C);
14661464
}
14671465

14681466
RValue RValueEmitter::visitIsExpr(IsExpr *E, SGFContext C) {
1469-
SGF.checkForImportedUsedConformances(E);
14701467
SILValue isa = emitIsa(SGF, E, E->getSubExpr(),
14711468
E->getCastTypeLoc().getType(), E->getCastKind());
14721469

@@ -1480,7 +1477,6 @@ RValue RValueEmitter::visitIsExpr(IsExpr *E, SGFContext C) {
14801477
}
14811478

14821479
RValue RValueEmitter::visitCoerceExpr(CoerceExpr *E, SGFContext C) {
1483-
SGF.checkForImportedUsedConformances(E);
14841480
return visit(E->getSubExpr(), C);
14851481
}
14861482

lib/SILGen/SILGenFunction.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ SILGenFunction::SILGenFunction(SILGenModule &SGM, SILFunction &F)
3939
Cleanups(*this)
4040
{
4141
B.setCurrentDebugScope(F.getDebugScope());
42-
checkForImportedUsedConformances(F.getLoweredType().getSwiftType());
4342
}
4443

4544
/// SILGenFunction destructor - called after the entire function's AST has been
@@ -945,18 +944,3 @@ SILGenBuilder::createAllocExistentialBox(SILLocation Loc,
945944
ConcreteType,
946945
Conformances);
947946
}
948-
949-
void SILGenFunction::checkForImportedUsedConformances(Type type) {
950-
// Recognize _BridgedNSError, which must pull in its witness table for
951-
// dynamic casts to work
952-
if (auto bridgedNSErrorProtocol =
953-
getASTContext().getProtocol(KnownProtocolKind::BridgedNSError)) {
954-
if (auto nominalDecl = type->getAnyNominal()) {
955-
SmallVector<ProtocolConformance *, 4> conformances;
956-
if (nominalDecl->lookupConformance(
957-
SGM.SwiftModule, bridgedNSErrorProtocol, conformances)) {
958-
SGM.useConformance(ProtocolConformanceRef(conformances.front()));
959-
}
960-
}
961-
}
962-
}

lib/SILGen/SILGenFunction.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,16 +1593,6 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
15931593
/// Produce a substitution for invoking a pointer argument conversion
15941594
/// intrinsic.
15951595
Substitution getPointerSubstitution(Type pointerType);
1596-
1597-
/// Recognize used conformances from an imported type when we must emit the
1598-
/// witness table.
1599-
///
1600-
/// This arises in _BridgedNSError, where we wouldn't otherwise pull in the
1601-
/// witness table, causing dynamic casts to perform incorrectly.
1602-
void checkForImportedUsedConformances(Type type);
1603-
void checkForImportedUsedConformances(ExplicitCastExpr *expr) {
1604-
checkForImportedUsedConformances(expr->getCastTypeLoc().getType());
1605-
}
16061596
};
16071597

16081598

lib/SILGen/SILGenPattern.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,8 +1590,6 @@ void PatternMatchEmission::emitIsDispatch(ArrayRef<RowToSpecialize> rows,
15901590
CanType sourceType = rows[0].Pattern->getType()->getCanonicalType();
15911591
CanType targetType = getTargetType(rows[0]);
15921592

1593-
SGF.checkForImportedUsedConformances(targetType);
1594-
15951593
// Make any abstraction modifications necessary for casting.
15961594
SmallVector<ConsumableManagedValue, 4> borrowedValues;
15971595
ConsumableManagedValue operand =

0 commit comments

Comments
 (0)