1 //===-- UnifyFunctionExitNodes.h - Ensure fn's have one return --*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This pass is used to ensure that functions have at most one return and one
10 // unreachable instruction in them.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H
15 #define LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H
17 #include "llvm/IR/PassManager.h"
18 #include "llvm/Pass.h"
22 class UnifyFunctionExitNodesLegacyPass : public FunctionPass {
24 static char ID; // Pass identification, replacement for typeid
25 UnifyFunctionExitNodesLegacyPass();
27 // We can preserve non-critical-edgeness when we unify function exit nodes
28 void getAnalysisUsage(AnalysisUsage &AU) const override;
30 bool runOnFunction(Function &F) override;
33 Pass *createUnifyFunctionExitNodesPass();
35 class UnifyFunctionExitNodesPass
36 : public PassInfoMixin<UnifyFunctionExitNodesPass> {
38 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
41 } // end namespace llvm
43 #endif // LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H