Skip to content

Commit 571a673

Browse files
committed
[NFC] IRGen: Added debugging info.
In debug builds, provide some context when a witness table fails to be found.
1 parent cf619e2 commit 571a673

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lib/IRGen/GenArchetype.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,33 @@ llvm::Value *irgen::emitArchetypeWitnessTableRef(IRGenFunction &IGF,
274274
rootWTable = emitOpaqueTypeWitnessTableRef(IGF, opaqueRoot,
275275
rootProtocol);
276276
}
277+
#ifndef NDEBUG
278+
if (!rootWTable) {
279+
llvm::errs()
280+
<< "Root witness table not bound in function.\n"
281+
<< " The witness table could be missing entirely because it needs "
282+
"to be passed to the function.\n"
283+
<< " Or the witness table is present and not bound in which case "
284+
"setScopedLocalTypeData or similar must be called.\n";
285+
llvm::errs() << "Root archetype for conformance: " << rootArchetype
286+
<< "\n";
287+
rootArchetype->dump(llvm::errs());
288+
llvm::errs() << "Root protocol without wtable: " << rootProtocol << "\n";
289+
rootProtocol->dump(llvm::errs());
290+
llvm::errs() << "Archetype for conformance: " << archetype << "\n";
291+
archetype->dump(llvm::errs());
292+
llvm::errs() << "Protocol for conformance: " << protocol << "\n";
293+
protocol->dump(llvm::errs());
294+
llvm::errs() << "Function:\n";
295+
IGF.CurFn->print(llvm::errs());
296+
if (auto localTypeData = IGF.getLocalTypeData()) {
297+
llvm::errs() << "LocalTypeData:\n";
298+
localTypeData->dump();
299+
} else {
300+
llvm::errs() << "No LocalTypeDataCache for this function!\n";
301+
}
302+
}
303+
#endif
277304
assert(rootWTable && "root witness table not bound in local context!");
278305
}
279306

0 commit comments

Comments
 (0)