Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===-- UnreachableBlockElim.h - Remove unreachable blocks for codegen --===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This pass is an extremely simple version of the SimplifyCFG pass. Its sole |
| 11 | // job is to delete LLVM basic blocks that are not reachable from the entry |
| 12 | // node. To do this, it performs a simple depth first traversal of the CFG, |
| 13 | // then deletes any unvisited nodes. |
| 14 | // |
| 15 | // Note that this pass is really a hack. In particular, the instruction |
| 16 | // selectors for various targets should just not generate code for unreachable |
| 17 | // blocks. Until LLVM has a more systematic way of defining instruction |
| 18 | // selectors, however, we cannot really expect them to handle additional |
| 19 | // complexity. |
| 20 | // |
| 21 | //===----------------------------------------------------------------------===// |
| 22 | |
| 23 | #ifndef LLVM_LIB_CODEGEN_UNREACHABLEBLOCKELIM_H |
| 24 | #define LLVM_LIB_CODEGEN_UNREACHABLEBLOCKELIM_H |
| 25 | |
| 26 | #include "llvm/IR/PassManager.h" |
| 27 | |
| 28 | namespace llvm { |
| 29 | |
| 30 | class UnreachableBlockElimPass |
| 31 | : public PassInfoMixin<UnreachableBlockElimPass> { |
| 32 | public: |
| 33 | PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); |
| 34 | }; |
| 35 | } // end namespace llvm |
| 36 | |
| 37 | #endif // LLVM_LIB_CODEGEN_UNREACHABLEBLOCKELIM_H |