Skip to content

Commit b12a705

Browse files
committed
SILOptimizer: add some dump() functions to the Existential utility classes.
For better debugging.
1 parent 3f31b49 commit b12a705

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

include/swift/SILOptimizer/Utils/Existential.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ struct OpenedArchetypeInfo {
4949
assert(!OpenedArchetype || (OpenedArchetypeValue && ExistentialValue));
5050
return OpenedArchetype;
5151
}
52+
53+
void dump() const;
5254
};
5355

5456
/// Record conformance and concrete type info derived from an init_existential
@@ -102,6 +104,8 @@ struct ConcreteExistentialInfo {
102104
CanType selfTy = P->getSelfInterfaceType()->getCanonicalType();
103105
return ExistentialSubs.lookupConformance(selfTy, P);
104106
}
107+
108+
void dump() const;
105109

106110
private:
107111
void initializeSubstitutionMap(
@@ -131,6 +135,8 @@ struct ConcreteOpenedExistentialInfo {
131135
assert(CEI->isValid());
132136
return true;
133137
}
138+
139+
void dump() const;
134140
};
135141

136142
} // end namespace swift

lib/SILOptimizer/Utils/Existential.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,40 @@ ConcreteOpenedExistentialInfo::ConcreteOpenedExistentialInfo(
433433
}
434434
CEI->isConcreteValueCopied |= OAI.isOpenedValueCopied;
435435
}
436+
437+
void LLVM_ATTRIBUTE_USED OpenedArchetypeInfo::dump() const {
438+
if (!isValid()) {
439+
llvm::dbgs() << "invalid OpenedArchetypeInfo\n";
440+
return;
441+
}
442+
llvm::dbgs() << "OpendArchetype: ";
443+
OpenedArchetype->dump(llvm::dbgs());
444+
llvm::dbgs() << "OpendArchetypeValue: ";
445+
OpenedArchetypeValue->dump();
446+
llvm::dbgs() << (isOpenedValueCopied ? "copied " : "") << "ExistentialValue: ";
447+
ExistentialValue->dump();
448+
}
449+
450+
void LLVM_ATTRIBUTE_USED ConcreteExistentialInfo::dump() const {
451+
llvm::dbgs() << "ExistentialType: ";
452+
ExistentialType->dump(llvm::dbgs());
453+
llvm::dbgs() << "ConcreteType: ";
454+
ConcreteType->dump(llvm::dbgs());
455+
llvm::dbgs() << (isConcreteValueCopied ? "copied " : "") << "ConcreteValue: ";
456+
ConcreteValue->dump();
457+
if (ConcreteTypeDef) {
458+
llvm::dbgs() << "ConcreteTypeDef: ";
459+
ConcreteTypeDef->dump();
460+
}
461+
ExistentialSubs.dump(llvm::dbgs());
462+
llvm::dbgs() << '\n';
463+
}
464+
465+
void LLVM_ATTRIBUTE_USED ConcreteOpenedExistentialInfo::dump() const {
466+
OAI.dump();
467+
if (CEI) {
468+
CEI->dump();
469+
} else {
470+
llvm::dbgs() << "no ConcreteExistentialInfo\n";
471+
}
472+
}

0 commit comments

Comments
 (0)