Skip to content

Commit 18ea8a1

Browse files
committed
IRGen: Move isResilientConformance() and isDependentConformance() to IRGenModule
1 parent 345e988 commit 18ea8a1

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

lib/IRGen/GenProto.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,8 @@ namespace {
948948

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

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

9991000
static bool isDependentConformance(
1001+
IRGenModule &IGM,
10001002
const RootProtocolConformance *rootConformance,
10011003
bool considerResilience,
10021004
llvm::SmallPtrSet<const NormalProtocolConformance *, 4> &visited){
@@ -1011,7 +1013,7 @@ static bool isDependentConformance(
10111013
return false;
10121014

10131015
// If the conformance is resilient, this is always true.
1014-
if (considerResilience && isResilientConformance(conformance))
1016+
if (considerResilience && IGM.isResilientConformance(conformance))
10151017
return true;
10161018

10171019
// Check whether any of the conformances are dependent.
@@ -1027,7 +1029,8 @@ static bool isDependentConformance(
10271029
auto assocConformance =
10281030
conformance->getAssociatedConformance(req.getFirstType(), assocProtocol);
10291031
if (assocConformance.isAbstract() ||
1030-
isDependentConformance(assocConformance.getConcrete()
1032+
isDependentConformance(IGM,
1033+
assocConformance.getConcrete()
10311034
->getRootConformance(),
10321035
considerResilience,
10331036
visited))
@@ -1045,10 +1048,12 @@ static bool isDependentConformance(
10451048

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

10541059
static bool isSynthesizedNonUnique(const RootProtocolConformance *conformance) {
@@ -1286,7 +1291,7 @@ class AccessorConformanceInfo : public ConformanceInfo {
12861291
Conformance.getDeclContext())),
12871292
SILEntries(SILWT->getEntries()),
12881293
SILConditionalConformances(SILWT->getConditionalConformances()),
1289-
ResilientConformance(isResilientConformance(&Conformance)),
1294+
ResilientConformance(IGM.isResilientConformance(&Conformance)),
12901295
PI(IGM.getProtocolInfo(SILWT->getConformance()->getProtocol(),
12911296
(ResilientConformance
12921297
? ProtocolInfoKind::RequirementSignature
@@ -2086,7 +2091,7 @@ void IRGenerator::ensureRelativeSymbolCollocation(SILWitnessTable &wt) {
20862091

20872092
// Only resilient conformances use relative pointers for witness methods.
20882093
if (wt.isDeclaration() || isAvailableExternally(wt.getLinkage()) ||
2089-
!isResilientConformance(wt.getConformance()))
2094+
!CurrentIGM->isResilientConformance(wt.getConformance()))
20902095
return;
20912096

20922097
for (auto &entry : wt.getEntries()) {

lib/IRGen/IRGenModule.h

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

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

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

0 commit comments

Comments
 (0)