Skip to content

Commit e72eb0d

Browse files
committed
[SILPrinter] print target branch debug names in SIL dumps
1 parent 98ba11f commit e72eb0d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/SIL/IR/SILPrinter.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
894894
llvm::SmallVector<SILValue, 8> values;
895895
llvm::copy(inst->getResults(), std::back_inserter(values));
896896
printUserList(values, inst);
897+
printBranchTargets(inst);
897898
}
898899

899900
void printUserList(ArrayRef<SILValue> values, SILNodePointer node) {
@@ -937,6 +938,21 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
937938
[&] { *this << ", "; });
938939
}
939940

941+
void printBranchTargets(const SILInstruction *inst) {
942+
if (auto condBr = dyn_cast<CondBranchInst>(inst)) {
943+
if (condBr->getTrueBB()->getDebugName().hasValue()) {
944+
*this << ", true->" << condBr->getTrueBB()->getDebugName().getValue();
945+
}
946+
if (condBr->getFalseBB()->getDebugName().hasValue()) {
947+
*this << ", false->" << condBr->getFalseBB()->getDebugName().getValue();
948+
}
949+
} else if (auto br = dyn_cast<BranchInst>(inst)) {
950+
if (br->getDestBB()->getDebugName().hasValue()) {
951+
*this << ", dest->" << br->getDestBB()->getDebugName().getValue();
952+
}
953+
}
954+
}
955+
940956
void printConformances(ArrayRef<ProtocolConformanceRef> conformances) {
941957
// FIXME: conformances should always be printed and parsed!
942958
if (!Ctx.printVerbose()) {

0 commit comments

Comments
 (0)