Skip to content

Clean up some NDEBUG code errors #75810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions include/swift/SIL/SILBasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,6 @@ public SwiftObjectHeader {

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

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

Expand All @@ -572,7 +571,6 @@ public SwiftObjectHeader {

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

/// getSublistAccess() - returns pointer to member of instruction list
static InstListType SILBasicBlock::*getSublistAccess() {
Expand Down
14 changes: 12 additions & 2 deletions lib/SIL/IR/SILPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3245,20 +3245,30 @@ void SILBasicBlock::print(SILPrintContext &Ctx) const {
SILPrinter(Ctx).print(this);
}

#ifndef NDEBUG
void SILBasicBlock::dumpID(bool newline) const {
#ifndef NDEBUG
printID(llvm::errs(), newline);
#else
llvm::errs() << "NOASSERTS" << (newline ? "\n" : "");
#endif
}

void SILBasicBlock::printID(llvm::raw_ostream &OS, bool newline) const {
#ifndef NDEBUG
SILPrintContext Ctx(OS);
printID(Ctx, newline);
#else
llvm::errs() << "NOASSERTS" << (newline ? "\n" : "");
#endif
}

void SILBasicBlock::printID(SILPrintContext &Ctx, bool newline) const {
#ifndef NDEBUG
SILPrinter(Ctx).printID(this, newline);
}
#else
llvm::errs() << "NOASSERTS" << (newline ? "\n" : "");
#endif
}

/// Pretty-print the SILFunction to errs.
void SILFunction::dump(bool Verbose) const {
Expand Down
13 changes: 4 additions & 9 deletions lib/SILOptimizer/Analysis/RegionAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2352,7 +2352,7 @@ class PartitionOpTranslator {
REGIONBASEDISOLATION_LOG(
llvm::dbgs() << SEP_STR << "Compiling basic block for function "
<< basicBlock->getFunction()->getName() << ": ";
basicBlock->dumpID(); llvm::dbgs() << SEP_STR;
basicBlock->printID(llvm::dbgs()); llvm::dbgs() << SEP_STR;
basicBlock->print(llvm::dbgs());
llvm::dbgs() << SEP_STR << "Results:\n";);
// Translate each SIL instruction to the PartitionOps that it represents if
Expand Down Expand Up @@ -3345,12 +3345,7 @@ bool BlockPartitionState::recomputeExitFromEntry(
void BlockPartitionState::print(llvm::raw_ostream &os) const {
os << SEP_STR << "BlockPartitionState[needsUpdate=" << needsUpdate
<< "]\nid: ";
#ifndef NDEBUG
auto printID = [&](SILBasicBlock *block) { block->printID(os); };
#else
auto printID = [&](SILBasicBlock *) { os << "NOASSERTS. "; };
#endif
printID(basicBlock);
basicBlock->printID(os);
os << "entry partition: ";
entryPartition.print(os);
os << "exit partition: ";
Expand All @@ -3363,12 +3358,12 @@ void BlockPartitionState::print(llvm::raw_ostream &os) const {
os << "└──────────╼\nSuccs:\n";
for (auto succ : basicBlock->getSuccessorBlocks()) {
os << "→";
printID(succ);
succ->printID(os);
}
os << "Preds:\n";
for (auto pred : basicBlock->getPredecessorBlocks()) {
os << "←";
printID(pred);
pred->printID(os);
}
os << SEP_STR;
}
Expand Down