UnreachableBlockElim.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- UnreachableBlockElim.h - Remove unreachable blocks for codegen --===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This pass is an extremely simple version of the SimplifyCFG pass. Its sole
  15. // job is to delete LLVM basic blocks that are not reachable from the entry
  16. // node. To do this, it performs a simple depth first traversal of the CFG,
  17. // then deletes any unvisited nodes.
  18. //
  19. // Note that this pass is really a hack. In particular, the instruction
  20. // selectors for various targets should just not generate code for unreachable
  21. // blocks. Until LLVM has a more systematic way of defining instruction
  22. // selectors, however, we cannot really expect them to handle additional
  23. // complexity.
  24. //
  25. //===----------------------------------------------------------------------===//
  26. #ifndef LLVM_CODEGEN_UNREACHABLEBLOCKELIM_H
  27. #define LLVM_CODEGEN_UNREACHABLEBLOCKELIM_H
  28. #include "llvm/IR/PassManager.h"
  29. namespace llvm {
  30. class UnreachableBlockElimPass
  31. : public PassInfoMixin<UnreachableBlockElimPass> {
  32. public:
  33. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
  34. };
  35. } // end namespace llvm
  36. #endif // LLVM_CODEGEN_UNREACHABLEBLOCKELIM_H
  37. #ifdef __GNUC__
  38. #pragma GCC diagnostic pop
  39. #endif