01f055e801f1d11f9f7f995effb53a6693c1a2e2
[oota-llvm.git] / include / llvm / Transforms / Utils / UnifyFunctionExitNodes.h
1 //===-- UnifyFunctionExitNodes.h - Ensure fn's have one return ---*- C++ -*--=//
2 //
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.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_TRANSFORMS_UNIFYFUNCTIONEXITNODES_H
11 #define LLVM_TRANSFORMS_UNIFYFUNCTIONEXITNODES_H
12
13 #include "llvm/Pass.h"
14
15 struct UnifyFunctionExitNodes : public FunctionPass {
16   BasicBlock *ExitNode;
17 public:
18   UnifyFunctionExitNodes() : ExitNode(0) {}
19
20   // We can preserve non-critical-edgeness when we unify function exit nodes
21   virtual void getAnalysisUsage(AnalysisUsage &AU) const;
22
23   // getExitNode - Return the new single (or nonexistant) exit node of the CFG.
24   //
25   BasicBlock *getExitNode() const { return ExitNode; }
26
27   virtual bool runOnFunction(Function &F);
28 };
29
30 static inline Pass *createUnifyFunctionExitNodesPass() {
31   return new UnifyFunctionExitNodes();
32 }
33
34 #endif