Skip to content
Merged
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
26 changes: 26 additions & 0 deletions lib/SIL/IR/SILPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
llvm::SmallVector<SILValue, 8> values;
llvm::copy(inst->getResults(), std::back_inserter(values));
printUserList(values, inst);
printBranchTargets(inst);
}

void printUserList(ArrayRef<SILValue> values, SILNodePointer node) {
Expand Down Expand Up @@ -937,6 +938,31 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
[&] { *this << ", "; });
}

void printBranchTargets(const SILInstruction *inst) {
if (auto condBr = dyn_cast<CondBranchInst>(inst)) {
if (condBr->getTrueBB()->getDebugName().hasValue()) {
*this << ", true->" << condBr->getTrueBB()->getDebugName().getValue();
}
if (condBr->getFalseBB()->getDebugName().hasValue()) {
*this << ", false->" << condBr->getFalseBB()->getDebugName().getValue();
}
} else if (auto br = dyn_cast<BranchInst>(inst)) {
if (br->getDestBB()->getDebugName().hasValue()) {
*this << ", dest->" << br->getDestBB()->getDebugName().getValue();
}
} else if (auto termInst = dyn_cast<TermInst>(inst)) {
// Otherwise, we just print the successors in order without pretty printing
for (unsigned i = 0, numSuccessors = termInst->getSuccessors().size();
i != numSuccessors; ++i) {
auto &successor = termInst->getSuccessors()[i];
if (successor.getBB()->getDebugName().hasValue()) {
*this << ", #" << i
<< "->" << successor.getBB()->getDebugName().getValue();
}
}
}
}

void printConformances(ArrayRef<ProtocolConformanceRef> conformances) {
// FIXME: conformances should always be printed and parsed!
if (!Ctx.printVerbose()) {
Expand Down