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_XFORMS_UNIFY_FUNCTION_EXIT_NODES_H
11 #define LLVM_XFORMS_UNIFY_FUNCTION_EXIT_NODES_H
13 #include "llvm/Pass.h"
15 struct UnifyFunctionExitNodes : public FunctionPass {
18 UnifyFunctionExitNodes() : ExitNode(0) {}
20 // getExitNode - Return the new single (or nonexistant) exit node of the CFG.
22 BasicBlock *getExitNode() const { return ExitNode; }
24 virtual bool runOnFunction(Function &F);
27 static inline Pass *createUnifyFunctionExitNodesPass() {
28 return new UnifyFunctionExitNodes();