Skip to content

Commit f275c27

Browse files
authored
Merge pull request #75810 from gottesmm/pr-48fc81afd13a4e0fdcaaa5badf561845da837f6f
Clean up some NDEBUG code errors
2 parents 9d69f2b + 226e97a commit f275c27

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

include/swift/SIL/SILBasicBlock.h

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

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

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

@@ -572,7 +571,6 @@ public SwiftObjectHeader {
572571

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

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

lib/SIL/IR/SILPrinter.cpp

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

3252-
#ifndef NDEBUG
32533252
void SILBasicBlock::dumpID(bool newline) const {
3253+
#ifndef NDEBUG
32543254
printID(llvm::errs(), newline);
3255+
#else
3256+
llvm::errs() << "NOASSERTS" << (newline ? "\n" : "");
3257+
#endif
32553258
}
32563259

32573260
void SILBasicBlock::printID(llvm::raw_ostream &OS, bool newline) const {
3261+
#ifndef NDEBUG
32583262
SILPrintContext Ctx(OS);
32593263
printID(Ctx, newline);
3264+
#else
3265+
llvm::errs() << "NOASSERTS" << (newline ? "\n" : "");
3266+
#endif
32603267
}
32613268

32623269
void SILBasicBlock::printID(SILPrintContext &Ctx, bool newline) const {
3270+
#ifndef NDEBUG
32633271
SILPrinter(Ctx).printID(this, newline);
3264-
}
3272+
#else
3273+
llvm::errs() << "NOASSERTS" << (newline ? "\n" : "");
32653274
#endif
3275+
}
32663276

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

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2352,7 +2352,7 @@ class PartitionOpTranslator {
23522352
REGIONBASEDISOLATION_LOG(
23532353
llvm::dbgs() << SEP_STR << "Compiling basic block for function "
23542354
<< basicBlock->getFunction()->getName() << ": ";
2355-
basicBlock->dumpID(); llvm::dbgs() << SEP_STR;
2355+
basicBlock->printID(llvm::dbgs()); llvm::dbgs() << SEP_STR;
23562356
basicBlock->print(llvm::dbgs());
23572357
llvm::dbgs() << SEP_STR << "Results:\n";);
23582358
// Translate each SIL instruction to the PartitionOps that it represents if
@@ -3345,12 +3345,7 @@ bool BlockPartitionState::recomputeExitFromEntry(
33453345
void BlockPartitionState::print(llvm::raw_ostream &os) const {
33463346
os << SEP_STR << "BlockPartitionState[needsUpdate=" << needsUpdate
33473347
<< "]\nid: ";
3348-
#ifndef NDEBUG
3349-
auto printID = [&](SILBasicBlock *block) { block->printID(os); };
3350-
#else
3351-
auto printID = [&](SILBasicBlock *) { os << "NOASSERTS. "; };
3352-
#endif
3353-
printID(basicBlock);
3348+
basicBlock->printID(os);
33543349
os << "entry partition: ";
33553350
entryPartition.print(os);
33563351
os << "exit partition: ";
@@ -3363,12 +3358,12 @@ void BlockPartitionState::print(llvm::raw_ostream &os) const {
33633358
os << "└──────────╼\nSuccs:\n";
33643359
for (auto succ : basicBlock->getSuccessorBlocks()) {
33653360
os << "";
3366-
printID(succ);
3361+
succ->printID(os);
33673362
}
33683363
os << "Preds:\n";
33693364
for (auto pred : basicBlock->getPredecessorBlocks()) {
33703365
os << "";
3371-
printID(pred);
3366+
pred->printID(os);
33723367
}
33733368
os << SEP_STR;
33743369
}

0 commit comments

Comments
 (0)