Skip to content

Commit cfaa12b

Browse files
committed
Fix SILBasicBlock::{dump,print}ID so that they are available in no-asserts but just print out NOASSERTS instead of a debug id.
(cherry picked from commit 2e08d61)
1 parent d630b6d commit cfaa12b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

include/swift/SIL/SILBasicBlock.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,6 @@ public SwiftObjectHeader {
562562

563563
void printAsOperand(raw_ostream &OS, bool PrintType = true);
564564

565-
#ifndef NDEBUG
566565
/// Print the ID of the block, bbN.
567566
void dumpID(bool newline = true) const;
568567

@@ -571,7 +570,6 @@ public SwiftObjectHeader {
571570

572571
/// Print the ID of the block with \p Ctx, bbN.
573572
void printID(SILPrintContext &Ctx, bool newline = true) const;
574-
#endif
575573

576574
/// getSublistAccess() - returns pointer to member of instruction list
577575
static InstListType SILBasicBlock::*getSublistAccess() {

lib/SIL/IR/SILPrinter.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3227,20 +3227,30 @@ void SILBasicBlock::print(SILPrintContext &Ctx) const {
32273227
SILPrinter(Ctx).print(this);
32283228
}
32293229

3230-
#ifndef NDEBUG
32313230
void SILBasicBlock::dumpID(bool newline) const {
3231+
#ifndef NDEBUG
32323232
printID(llvm::errs(), newline);
3233+
#else
3234+
llvm::errs() << "NOASSERTS" << (newline ? "\n" : "");
3235+
#endif
32333236
}
32343237

32353238
void SILBasicBlock::printID(llvm::raw_ostream &OS, bool newline) const {
3239+
#ifndef NDEBUG
32363240
SILPrintContext Ctx(OS);
32373241
printID(Ctx, newline);
3242+
#else
3243+
llvm::errs() << "NOASSERTS" << (newline ? "\n" : "");
3244+
#endif
32383245
}
32393246

32403247
void SILBasicBlock::printID(SILPrintContext &Ctx, bool newline) const {
3248+
#ifndef NDEBUG
32413249
SILPrinter(Ctx).printID(this, newline);
3242-
}
3250+
#else
3251+
llvm::errs() << "NOASSERTS" << (newline ? "\n" : "");
32433252
#endif
3253+
}
32443254

32453255
/// Pretty-print the SILFunction to errs.
32463256
void SILFunction::dump(bool Verbose) const {

0 commit comments

Comments
 (0)