Skip to content

Commit f19f9b0

Browse files
committed
move the endsInUnreachable utility function into DeadEndBlocks
1 parent d33ea9f commit f19f9b0

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

include/swift/SIL/BasicBlockUtils.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ class DeadEndBlocks {
8888
bool isComputed() const { return didComputeValue; }
8989

9090
const SILFunction *getFunction() const { return f; }
91+
92+
/// Performs a simple check if \p block (or its single successor) ends in an
93+
/// "unreachable".
94+
///
95+
/// This handles the common case of failure-handling blocks, which e.g.
96+
/// contain a call to fatalError().
97+
static bool triviallyEndsInUnreachable(SILBasicBlock *block);
9198
};
9299

93100
/// Compute joint-postdominating set for \p dominatingBlock and \p

lib/SIL/Utils/BasicBlockUtils.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,18 +386,18 @@ void DeadEndBlocks::compute() {
386386
}
387387
}
388388

389-
//===----------------------------------------------------------------------===//
390-
// Post Dominance Set Completion Utilities
391-
//===----------------------------------------------------------------------===//
392-
393-
static bool endsInUnreachable(SILBasicBlock *block) {
389+
bool DeadEndBlocks::triviallyEndsInUnreachable(SILBasicBlock *block) {
394390
// Handle the case where a single "unreachable" block (e.g. containing a call
395391
// to fatalError()), is jumped to from multiple source blocks.
396392
if (SILBasicBlock *singleSucc = block->getSingleSuccessorBlock())
397393
block = singleSucc;
398394
return isa<UnreachableInst>(block->getTerminator());
399395
}
400396

397+
//===----------------------------------------------------------------------===//
398+
// Post Dominance Set Completion Utilities
399+
//===----------------------------------------------------------------------===//
400+
401401
void swift::findJointPostDominatingSet(
402402
SILBasicBlock *dominatingBlock, ArrayRef<SILBasicBlock *> dominatedBlockSet,
403403
function_ref<void(SILBasicBlock *)> inputBlocksFoundDuringWalk,
@@ -482,7 +482,7 @@ void swift::findJointPostDominatingSet(
482482
// Ignore blocks which end in an unreachable. This is a very
483483
// simple check, but covers most of the cases, e.g. block which
484484
// calls fatalError().
485-
!endsInUnreachable(succBlock)) {
485+
!DeadEndBlocks::triviallyEndsInUnreachable(succBlock)) {
486486
assert(succBlock->getSinglePredecessorBlock() == predBlock &&
487487
"CFG must not contain critical edge");
488488
// Note that since there are no critical edges in the CFG, we are

0 commit comments

Comments
 (0)