Skip to content

Commit 206a6c2

Browse files
committed
IRGen: Move isResilientConformance() and isDependentConformance() to IRGenModule
1 parent 1745316 commit 206a6c2

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

lib/IRGen/GenProto.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,8 @@ namespace {
947947

948948
/// Return true if the witness table requires runtime instantiation to
949949
/// handle resiliently-added requirements with default implementations.
950-
static bool isResilientConformance(const NormalProtocolConformance *conformance) {
950+
bool IRGenModule::isResilientConformance(
951+
const NormalProtocolConformance *conformance) {
951952
// If the protocol is not resilient, the conformance is not resilient
952953
// either.
953954
if (!conformance->getProtocol()->isResilient())
@@ -963,7 +964,7 @@ static bool isResilientConformance(const NormalProtocolConformance *conformance)
963964
return true;
964965
}
965966

966-
static bool isResilientConformance(const RootProtocolConformance *root) {
967+
bool IRGenModule::isResilientConformance(const RootProtocolConformance *root) {
967968
if (auto normal = dyn_cast<NormalProtocolConformance>(root))
968969
return isResilientConformance(normal);
969970
// Self-conformances never require this.
@@ -996,6 +997,7 @@ static bool hasDependentTypeWitness(
996997
}
997998

998999
static bool isDependentConformance(
1000+
IRGenModule &IGM,
9991001
const RootProtocolConformance *rootConformance,
10001002
bool considerResilience,
10011003
llvm::SmallPtrSet<const NormalProtocolConformance *, 4> &visited){
@@ -1010,7 +1012,7 @@ static bool isDependentConformance(
10101012
return false;
10111013

10121014
// If the conformance is resilient, this is always true.
1013-
if (considerResilience && isResilientConformance(conformance))
1015+
if (considerResilience && IGM.isResilientConformance(conformance))
10141016
return true;
10151017

10161018
// Check whether any of the conformances are dependent.
@@ -1026,7 +1028,8 @@ static bool isDependentConformance(
10261028
auto assocConformance =
10271029
conformance->getAssociatedConformance(req.getFirstType(), assocProtocol);
10281030
if (assocConformance.isAbstract() ||
1029-
isDependentConformance(assocConformance.getConcrete()
1031+
isDependentConformance(IGM,
1032+
assocConformance.getConcrete()
10301033
->getRootConformance(),
10311034
considerResilience,
10321035
visited))
@@ -1044,10 +1047,12 @@ static bool isDependentConformance(
10441047

10451048
/// Is there anything about the given conformance that requires witness
10461049
/// tables to be dependently-generated?
1047-
static bool isDependentConformance(const RootProtocolConformance *conformance,
1048-
bool considerResilience) {
1050+
bool IRGenModule::isDependentConformance(
1051+
const RootProtocolConformance *conformance,
1052+
bool considerResilience) {
10491053
llvm::SmallPtrSet<const NormalProtocolConformance *, 4> visited;
1050-
return ::isDependentConformance(conformance, considerResilience, visited);
1054+
return ::isDependentConformance(*this, conformance, considerResilience,
1055+
visited);
10511056
}
10521057

10531058
static bool isSynthesizedNonUnique(const RootProtocolConformance *conformance) {
@@ -1285,7 +1290,7 @@ class AccessorConformanceInfo : public ConformanceInfo {
12851290
Conformance.getDeclContext())),
12861291
SILEntries(SILWT->getEntries()),
12871292
SILConditionalConformances(SILWT->getConditionalConformances()),
1288-
ResilientConformance(isResilientConformance(&Conformance)),
1293+
ResilientConformance(IGM.isResilientConformance(&Conformance)),
12891294
PI(IGM.getProtocolInfo(SILWT->getConformance()->getProtocol(),
12901295
(ResilientConformance
12911296
? ProtocolInfoKind::RequirementSignature

lib/IRGen/IRGenModule.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,11 @@ class IRGenModule {
793793
ResilienceExpansion getResilienceExpansionForLayout(NominalTypeDecl *decl);
794794
ResilienceExpansion getResilienceExpansionForLayout(SILGlobalVariable *var);
795795

796+
bool isResilientConformance(const NormalProtocolConformance *conformance);
797+
bool isResilientConformance(const RootProtocolConformance *root);
798+
bool isDependentConformance(const RootProtocolConformance *conformance,
799+
bool considerResilience);
800+
796801
Alignment getCappedAlignment(Alignment alignment);
797802

798803
SpareBitVector getSpareBitsForType(llvm::Type *scalarTy, Size size);

0 commit comments

Comments
 (0)