UnifyFunctionExitNodes.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 UnifyFunctionExitNodesLegacyPass : public FunctionPass {
  24. public:
  25. static char ID; // Pass identification, replacement for typeid
  26. UnifyFunctionExitNodesLegacyPass();
  27. // We can preserve non-critical-edgeness when we unify function exit nodes
  28. void getAnalysisUsage(AnalysisUsage &AU) const override;
  29. bool runOnFunction(Function &F) override;
  30. };
  31. Pass *createUnifyFunctionExitNodesPass();
  32. class UnifyFunctionExitNodesPass
  33. : public PassInfoMixin<UnifyFunctionExitNodesPass> {
  34. public:
  35. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
  36. };
  37. } // end namespace llvm
  38. #endif // LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H
  39. #ifdef __GNUC__
  40. #pragma GCC diagnostic pop
  41. #endif