Skip to content

Make -emit-verbose-sil print conformances for existential insts. #30859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/swift/AST/ProtocolConformanceRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ class ProtocolConformanceRef {
ProtocolDecl *requirement) const;

SWIFT_DEBUG_DUMP;
void dump(llvm::raw_ostream &out, unsigned indent = 0) const;
void dump(llvm::raw_ostream &out, unsigned indent = 0,
bool details = true) const;

bool operator==(ProtocolConformanceRef other) const {
return Union == other.Union;
Expand Down
7 changes: 5 additions & 2 deletions lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3286,9 +3286,12 @@ void ProtocolConformanceRef::dump() const {
llvm::errs() << '\n';
}

void ProtocolConformanceRef::dump(llvm::raw_ostream &out,
unsigned indent) const {
void ProtocolConformanceRef::dump(llvm::raw_ostream &out, unsigned indent,
bool details) const {
llvm::SmallPtrSet<const ProtocolConformance *, 8> visited;
if (!details && isConcrete())
visited.insert(getConcrete());

dumpProtocolConformanceRefRec(*this, out, indent, visited);
}
void ProtocolConformance::dump() const {
Expand Down
20 changes: 18 additions & 2 deletions lib/SIL/IR/SILPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,16 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
return true;
}

void printConformances(ArrayRef<ProtocolConformanceRef> conformances) {
// FIXME: conformances should always be printed and parsed!
if (!Ctx.printVerbose()) {
return;
}
*this << " // ";
for (ProtocolConformanceRef conformance : conformances)
conformance.dump(PrintState.OS, /*indent*/ 0, /*details*/ false);
}

void printDebugLocRef(SILLocation Loc, const SourceManager &SM,
bool PrintComma = true) {
auto DL = Loc.decodeDebugLoc(SM);
Expand Down Expand Up @@ -1797,6 +1807,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
*this << getIDAndType(WMI->getTypeDependentOperands()[0].get());
}
*this << " : " << WMI->getType();
printConformances({WMI->getConformance()});
}
void visitOpenExistentialAddrInst(OpenExistentialAddrInst *OI) {
if (OI->getAccessKind() == OpenedExistentialAccess::Immutable)
Expand All @@ -1823,21 +1834,26 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
void visitInitExistentialAddrInst(InitExistentialAddrInst *AEI) {
*this << getIDAndType(AEI->getOperand()) << ", $"
<< AEI->getFormalConcreteType();
printConformances(AEI->getConformances());
}
void visitInitExistentialValueInst(InitExistentialValueInst *AEI) {
*this << getIDAndType(AEI->getOperand()) << ", $"
<< AEI->getFormalConcreteType() << ", " << AEI->getType();
printConformances(AEI->getConformances());
}
void visitInitExistentialRefInst(InitExistentialRefInst *AEI) {
*this << getIDAndType(AEI->getOperand()) << " : $"
<< AEI->getFormalConcreteType() << ", " << AEI->getType();
printConformances(AEI->getConformances());
}
void visitInitExistentialMetatypeInst(InitExistentialMetatypeInst *AEI) {
*this << getIDAndType(AEI->getOperand()) << ", " << AEI->getType();
void visitInitExistentialMetatypeInst(InitExistentialMetatypeInst *EMI) {
*this << getIDAndType(EMI->getOperand()) << ", " << EMI->getType();
printConformances(EMI->getConformances());
}
void visitAllocExistentialBoxInst(AllocExistentialBoxInst *AEBI) {
*this << AEBI->getExistentialType() << ", $"
<< AEBI->getFormalConcreteType();
printConformances(AEBI->getConformances());
}
void visitDeinitExistentialAddrInst(DeinitExistentialAddrInst *DEI) {
*this << getIDAndType(DEI->getOperand());
Expand Down