Skip to content

Commit ee82b00

Browse files
committed
SIL: Create witness table declaration in SILModule::lookUpWitnessTable()
Should be NFC for now, since callers either assume the linker pass has run, or they manually call createWitnessTableDeclaration().
1 parent 0c6ac60 commit ee82b00

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

lib/SIL/SILModule.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ SILModule::lookUpWitnessTable(const ProtocolConformance *C,
173173
bool deserializeLazily) {
174174
assert(C && "null conformance passed to lookUpWitnessTable");
175175

176+
SILWitnessTable *wtable;
177+
176178
auto rootC = C->getRootConformance();
177179
// Attempt to lookup the witness table from the table.
178180
auto found = WitnessTableMap.find(rootC);
@@ -190,16 +192,22 @@ SILModule::lookUpWitnessTable(const ProtocolConformance *C,
190192
"Found witness table that is not"
191193
" in the witness table lookup cache.");
192194
#endif
193-
return nullptr;
194-
}
195195

196-
SILWitnessTable *wtable = found->second;
197-
assert(wtable != nullptr && "Should never map a conformance to a null witness"
198-
" table.");
196+
// If we don't have a witness table and we're not going to try
197+
// deserializing it, do not create a declaration.
198+
if (!deserializeLazily)
199+
return nullptr;
199200

200-
// If we have a definition, return it.
201-
if (wtable->isDefinition())
202-
return wtable;
201+
wtable = createWitnessTableDeclaration(C);
202+
} else {
203+
wtable = found->second;
204+
assert(wtable != nullptr && "Should never map a conformance to a null witness"
205+
" table.");
206+
207+
// If we have a definition, return it.
208+
if (wtable->isDefinition())
209+
return wtable;
210+
}
203211

204212
// If the module is at or past the Lowered stage, then we can't do any
205213
// further deserialization, since pre-IRGen SIL lowering changes the types

0 commit comments

Comments
 (0)