UnifyFunctionExitNodes.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- UnifyFunctionExitNodes.h - Ensure fn's have one return --*- C++ -*-===//
  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 used to ensure that functions have at most one return and one
  15. // unreachable instruction in them.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H
  19. #define LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H
  20. #include "llvm/IR/PassManager.h"
  21. #include "llvm/Pass.h"
  22. namespace llvm {
  23. class BasicBlock;
  24. class UnifyFunctionExitNodesLegacyPass : public FunctionPass {
  25. public:
  26. static char ID; // Pass identification, replacement for typeid
  27. UnifyFunctionExitNodesLegacyPass();
  28. // We can preserve non-critical-edgeness when we unify function exit nodes
  29. void getAnalysisUsage(AnalysisUsage &AU) const override;
  30. bool runOnFunction(Function &F) override;
  31. };
  32. Pass *createUnifyFunctionExitNodesPass();
  33. class UnifyFunctionExitNodesPass
  34. : public PassInfoMixin<UnifyFunctionExitNodesPass> {
  35. public:
  36. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
  37. };
  38. } // end namespace llvm
  39. #endif // LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H
  40. #ifdef __GNUC__
  41. #pragma GCC diagnostic pop
  42. #endif