Skip to content

Commit 388a2d7

Browse files
committed
SIL: Add some debugging code
1 parent 6263036 commit 388a2d7

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

include/swift/SIL/SILCloner.h

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,24 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
219219
}
220220

221221
SubstitutionMap getOpSubstitutionMap(SubstitutionMap Subs) {
222-
return asImpl().remapSubstitutionMap(Subs)
222+
auto substSubs = asImpl().remapSubstitutionMap(Subs)
223223
.getCanonical(/*canonicalizeSignature*/false);
224+
225+
#ifndef NDEBUG
226+
for (auto substConf : substSubs.getConformances()) {
227+
if (substConf.isInvalid()) {
228+
llvm::errs() << "Invalid conformance in SIL cloner:\n";
229+
if (Functor.SubsMap)
230+
Functor.SubsMap->dump(llvm::errs());
231+
llvm::errs() << "\nsubstitution map:\n";
232+
Subs.dump(llvm::errs());
233+
llvm::errs() << "\n";
234+
abort();
235+
}
236+
}
237+
#endif
238+
239+
return substSubs;
224240
}
225241

226242
SILType getOpType(SILType Ty) {
@@ -335,7 +351,22 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
335351

336352
ProtocolConformanceRef getOpConformance(Type ty,
337353
ProtocolConformanceRef conformance) {
338-
return asImpl().remapConformance(ty, conformance);
354+
auto substConf = asImpl().remapConformance(ty, conformance);
355+
356+
#ifndef NDEBUG
357+
if (substConf.isInvalid()) {
358+
llvm::errs() << "Invalid conformance in SIL cloner:\n";
359+
if (Functor.SubsMap)
360+
Functor.SubsMap->dump(llvm::errs());
361+
llvm::errs() << "\nconformance:\n";
362+
conformance.dump(llvm::errs());
363+
llvm::errs() << "original type:\n";
364+
ty.dump(llvm::errs());
365+
abort();
366+
}
367+
#endif
368+
369+
return substConf;
339370
}
340371

341372
ArrayRef<ProtocolConformanceRef>

include/swift/SIL/TypeSubstCloner.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,17 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
161161
Original(From),
162162
Inlining(Inlining) {
163163
Functor.SubsMap = ApplySubs;
164+
165+
#ifndef NDEBUG
166+
for (auto substConf : ApplySubs.getConformances()) {
167+
if (substConf.isInvalid()) {
168+
llvm::errs() << "Invalid conformance in SIL cloner:\n";
169+
ApplySubs.dump(llvm::errs());
170+
abort();
171+
}
172+
}
173+
#endif
174+
164175
}
165176

166177
protected:

0 commit comments

Comments
 (0)