|
11 | 11 | //===----------------------------------------------------------------------===// |
12 | 12 |
|
13 | 13 | #include "swift/SIL/BasicBlockUtils.h" |
14 | | -#include "swift/SIL/BasicBlockDatastructures.h" |
15 | 14 | #include "swift/Basic/Defer.h" |
16 | 15 | #include "swift/Basic/STLExtras.h" |
| 16 | +#include "swift/SIL/BasicBlockDatastructures.h" |
17 | 17 | #include "swift/SIL/Dominance.h" |
18 | 18 | #include "swift/SIL/LoopInfo.h" |
19 | 19 | #include "swift/SIL/OwnershipUtils.h" |
|
22 | 22 | #include "swift/SIL/SILBuilder.h" |
23 | 23 | #include "swift/SIL/SILFunction.h" |
24 | 24 | #include "swift/SIL/TerminatorUtils.h" |
| 25 | +#include "swift/SIL/Test.h" |
25 | 26 | #include "llvm/ADT/STLExtras.h" |
26 | 27 |
|
27 | 28 | using namespace swift; |
@@ -420,6 +421,27 @@ bool DeadEndBlocks::triviallyEndsInUnreachable(SILBasicBlock *block) { |
420 | 421 | return isa<UnreachableInst>(block->getTerminator()); |
421 | 422 | } |
422 | 423 |
|
| 424 | +namespace swift::test { |
| 425 | +// Arguments: |
| 426 | +// - none |
| 427 | +// Dumps: |
| 428 | +// - the function |
| 429 | +// - the blocks which are dead-end blocks |
| 430 | +static FunctionTest DeadEndBlocksTest("dead_end_blocks", [](auto &function, |
| 431 | + auto &arguments, |
| 432 | + auto &test) { |
| 433 | + std::unique_ptr<DeadEndBlocks> DeadEnds; |
| 434 | + DeadEnds.reset(new DeadEndBlocks(&function)); |
| 435 | + function.print(llvm::outs()); |
| 436 | +#ifndef NDEBUG |
| 437 | + for (auto &block : function) { |
| 438 | + if (DeadEnds->isDeadEnd(&block)) |
| 439 | + block.printID(llvm::outs(), true); |
| 440 | + } |
| 441 | +#endif |
| 442 | +}); |
| 443 | +} // end namespace swift::test |
| 444 | + |
423 | 445 | //===----------------------------------------------------------------------===// |
424 | 446 | // Post Dominance Set Completion Utilities |
425 | 447 | //===----------------------------------------------------------------------===// |
|
0 commit comments