Skip to content

Commit d413806

Browse files
committed
SIL: Simplify SILLinkerVisitor::visitProtocolConformance()
Now that SILModule::lookUpWitnessTable() can create a declaration if needed, we don't have to call it twice.
1 parent ee82b00 commit d413806

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

lib/SIL/Linker.cpp

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static bool mustDeserializeProtocolConformance(SILModule &M,
200200

201201
void SILLinkerVisitor::visitProtocolConformance(
202202
ProtocolConformanceRef ref, const Optional<SILDeclRef> &Member) {
203-
// If an abstract protocol conformance was passed in, just return false.
203+
// If an abstract protocol conformance was passed in, do nothing.
204204
if (ref.isAbstract())
205205
return;
206206

@@ -211,29 +211,16 @@ void SILLinkerVisitor::visitProtocolConformance(
211211

212212
if (!VisitedConformances.insert(C).second)
213213
return;
214-
215-
SILWitnessTable *WT = Mod.lookUpWitnessTable(C, /*deserializeLazily=*/false);
216-
217-
// If we don't find any witness table for the conformance, bail and return
218-
// false.
219-
if (!WT) {
220-
Mod.createWitnessTableDeclaration(C);
221-
222-
// Adding the declaration may allow us to now deserialize the body.
223-
// Force the body if we must deserialize this witness table.
224-
if (mustDeserialize) {
225-
WT = Mod.lookUpWitnessTable(C, /*deserializeLazily=*/true);
226-
assert(WT && WT->isDefinition()
227-
&& "unable to deserialize witness table when we must?!");
228-
} else {
229-
return;
230-
}
231-
}
214+
215+
auto *WT = Mod.lookUpWitnessTable(C, mustDeserialize);
232216

233217
// If the looked up witness table is a declaration, there is nothing we can
234-
// do here. Just bail and return false.
235-
if (WT->isDeclaration())
218+
// do here.
219+
if (WT == nullptr || WT->isDeclaration()) {
220+
assert(!mustDeserialize &&
221+
"unable to deserialize witness table when we must?!");
236222
return;
223+
}
237224

238225
auto maybeVisitRelatedConformance = [&](ProtocolConformanceRef c) {
239226
// Formally all conformances referenced by a used conformance are used.

0 commit comments

Comments
 (0)