1 //===-- UnifyFunctionExitNodes.h - Ensure fn's have one return --*- C++ -*-===//
3 // This pass is used to ensure that functions have at most one return and one
4 // unwind instruction in them. Additionally, it keeps track of which node is
5 // the new exit node of the CFG. If there are no return or unwind instructions
6 // in the function, the getReturnBlock/getUnwindBlock methods will return a null
9 //===----------------------------------------------------------------------===//
11 #ifndef LLVM_TRANSFORMS_UNIFYFUNCTIONEXITNODES_H
12 #define LLVM_TRANSFORMS_UNIFYFUNCTIONEXITNODES_H
14 #include "llvm/Pass.h"
16 struct UnifyFunctionExitNodes : public FunctionPass {
17 BasicBlock *ReturnBlock, *UnwindBlock;
19 UnifyFunctionExitNodes() : ReturnBlock(0), UnwindBlock(0) {}
21 // We can preserve non-critical-edgeness when we unify function exit nodes
22 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
24 // getReturn|UnwindBlock - Return the new single (or nonexistant) return or
25 // unwind basic blocks in the CFG.
27 BasicBlock *getReturnBlock() const { return ReturnBlock; }
28 BasicBlock *getUnwindBlock() const { return UnwindBlock; }
30 virtual bool runOnFunction(Function &F);
33 Pass *createUnifyFunctionExitNodesPass();