Convert xforms over to use new pass structure
[oota-llvm.git] / include / llvm / Transforms / Utils / UnifyFunctionExitNodes.h
1 //===-- UnifyMethodExitNodes.h - Ensure methods have one return --*- C++ -*--=//
2 //
3 // This pass is used to ensure that methods have at most one return instruction
4 // in them.  It also holds onto the return instruction of the last unified
5 // method.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_XFORMS_UNIFY_METHOD_EXIT_NODES_H
10 #define LLVM_XFORMS_UNIFY_METHOD_EXIT_NODES_H
11
12 #include "llvm/Pass.h"
13 #include "llvm/Analysis/SimplifyCFG.h"   // FIXME!!
14
15 struct UnifyMethodExitNodes : public MethodPass {
16   BasicBlock *ExitNode;
17 public:
18   static AnalysisID ID;            // Pass ID
19   UnifyMethodExitNodes(AnalysisID id) : ExitNode(0) { assert(ID == id); }
20
21   virtual bool runOnMethod(Method *M) {
22     ExitNode = cfg::UnifyAllExitNodes(M);
23
24     return true; // FIXME: This should return a correct code!!!
25   }
26
27   BasicBlock *getExitNode() const { return ExitNode; }
28
29   virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required,
30                                     Pass::AnalysisSet &Destroyed,
31                                     Pass::AnalysisSet &Provided) {
32     // FIXME: Should invalidate CFG
33     Provided.push_back(ID);  // Provide self!
34   }
35 };
36
37 #endif