Skip to content

Commit 7c1e5ec

Browse files
committed
[SIL] NFC: Added debug printing of block ids.
1 parent 92fd8da commit 7c1e5ec

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

include/swift/SIL/SILBasicBlock.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,17 @@ public SwiftObjectHeader {
516516

517517
void printAsOperand(raw_ostream &OS, bool PrintType = true);
518518

519+
#ifndef NDEBUG
520+
/// Print the ID of the block, bbN.
521+
void dumpID() const;
522+
523+
/// Print the ID of the block with \p OS, bbN.
524+
void printID(llvm::raw_ostream &OS) const;
525+
526+
/// Print the ID of the block with \p Ctx, bbN.
527+
void printID(SILPrintContext &Ctx) const;
528+
#endif
529+
519530
/// getSublistAccess() - returns pointer to member of instruction list
520531
static InstListType SILBasicBlock::*getSublistAccess() {
521532
return &SILBasicBlock::InstList;

lib/SIL/IR/SILPrinter.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,12 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
854854
*this << ')';
855855
}
856856

857+
#ifndef NDEBUG
858+
void printID(const SILBasicBlock *BB) {
859+
*this << Ctx.getID(BB) << "\n";
860+
}
861+
#endif
862+
857863
void print(const SILBasicBlock *BB) {
858864
// Output uses for BB arguments. These are put into place as comments before
859865
// the block header.
@@ -3086,6 +3092,21 @@ void SILBasicBlock::print(SILPrintContext &Ctx) const {
30863092
SILPrinter(Ctx).print(this);
30873093
}
30883094

3095+
#ifndef NDEBUG
3096+
void SILBasicBlock::dumpID() const {
3097+
printID(llvm::errs());
3098+
}
3099+
3100+
void SILBasicBlock::printID(llvm::raw_ostream &OS) const {
3101+
SILPrintContext Ctx(OS);
3102+
printID(Ctx);
3103+
}
3104+
3105+
void SILBasicBlock::printID(SILPrintContext &Ctx) const {
3106+
SILPrinter(Ctx).printID(this);
3107+
}
3108+
#endif
3109+
30893110
/// Pretty-print the SILFunction to errs.
30903111
void SILFunction::dump(bool Verbose) const {
30913112
SILPrintContext Ctx(llvm::errs(), Verbose);

0 commit comments

Comments
 (0)