@@ -894,6 +894,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
894
894
llvm::SmallVector<SILValue, 8 > values;
895
895
llvm::copy (inst->getResults (), std::back_inserter (values));
896
896
printUserList (values, inst);
897
+ printBranchTargets (inst);
897
898
}
898
899
899
900
void printUserList (ArrayRef<SILValue> values, SILNodePointer node) {
@@ -937,6 +938,31 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
937
938
[&] { *this << " , " ; });
938
939
}
939
940
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
+ } else if (auto termInst = dyn_cast<TermInst>(inst)) {
954
+ // Otherwise, we just print the successors in order without pretty printing
955
+ for (unsigned i = 0 , numSuccessors = termInst->getSuccessors ().size ();
956
+ i != numSuccessors; ++i) {
957
+ auto &successor = termInst->getSuccessors ()[i];
958
+ if (successor.getBB ()->getDebugName ().hasValue ()) {
959
+ *this << " , #" << i
960
+ << " ->" << successor.getBB ()->getDebugName ().getValue ();
961
+ }
962
+ }
963
+ }
964
+ }
965
+
940
966
void printConformances (ArrayRef<ProtocolConformanceRef> conformances) {
941
967
// FIXME: conformances should always be printed and parsed!
942
968
if (!Ctx.printVerbose ()) {
0 commit comments