1 //===-- UnifyFunctionExitNodes.h - Ensure fn's have one return ---*- C++ -*--=//
3 // This pass is used to ensure that functions have at most one return
4 // instruction in them. Additionally, it keeps track of which node is the new
5 // exit node of the CFG. If there are no exit nodes in the CFG, the getExitNode
6 // method will return a null pointer.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_TRANSFORMS_UNIFYFUNCTIONEXITNODES_H
11 #define LLVM_TRANSFORMS_UNIFYFUNCTIONEXITNODES_H
13 #include "llvm/Pass.h"
15 struct UnifyFunctionExitNodes : public FunctionPass {
18 UnifyFunctionExitNodes() : ExitNode(0) {}
20 // We can preserve non-critical-edgeness when we unify function exit nodes
21 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
23 // getExitNode - Return the new single (or nonexistant) exit node of the CFG.
25 BasicBlock *getExitNode() const { return ExitNode; }
27 virtual bool runOnFunction(Function &F);
30 static inline Pass *createUnifyFunctionExitNodesPass() {
31 return new UnifyFunctionExitNodes();