1 //===-- UnifyMethodExitNodes.h - Ensure methods have one return --*- C++ -*--=//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_XFORMS_UNIFY_METHOD_EXIT_NODES_H
10 #define LLVM_XFORMS_UNIFY_METHOD_EXIT_NODES_H
12 #include "llvm/Pass.h"
13 #include "llvm/Analysis/SimplifyCFG.h" // FIXME!!
15 struct UnifyMethodExitNodes : public MethodPass {
18 static AnalysisID ID; // Pass ID
19 UnifyMethodExitNodes(AnalysisID id) : ExitNode(0) { assert(ID == id); }
21 virtual bool runOnMethod(Method *M) {
22 ExitNode = cfg::UnifyAllExitNodes(M);
24 return true; // FIXME: This should return a correct code!!!
27 BasicBlock *getExitNode() const { return ExitNode; }
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!