2002-04-27 06:56:12 +00:00
|
|
|
//===-- UnifyFunctionExitNodes.h - Ensure fn's have one return ---*- C++ -*--=//
|
2002-01-30 23:29:35 +00:00
|
|
|
//
|
2002-04-27 06:56:12 +00:00
|
|
|
// This pass is used to ensure that functions have at most one return
|
2002-05-07 18:51:44 +00:00
|
|
|
// instruction in them. Additionally, it keeps track of which node is the new
|
|
|
|
// exit node of the CFG. If there are no exit nodes in the CFG, the getExitNode
|
|
|
|
// method will return a null pointer.
|
2002-01-30 23:29:35 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2003-03-31 17:29:18 +00:00
|
|
|
#ifndef LLVM_TRANSFORMS_UNIFYFUNCTIONEXITNODES_H
|
|
|
|
#define LLVM_TRANSFORMS_UNIFYFUNCTIONEXITNODES_H
|
2002-01-30 23:29:35 +00:00
|
|
|
|
|
|
|
#include "llvm/Pass.h"
|
|
|
|
|
2002-04-27 06:59:56 +00:00
|
|
|
struct UnifyFunctionExitNodes : public FunctionPass {
|
2002-01-30 23:29:35 +00:00
|
|
|
BasicBlock *ExitNode;
|
|
|
|
public:
|
2002-08-21 17:09:45 +00:00
|
|
|
UnifyFunctionExitNodes() : ExitNode(0) {}
|
2002-01-30 23:29:35 +00:00
|
|
|
|
2003-03-31 17:29:18 +00:00
|
|
|
// We can preserve non-critical-edgeness when we unify function exit nodes
|
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
|
|
|
|
|
2002-05-07 18:51:44 +00:00
|
|
|
// getExitNode - Return the new single (or nonexistant) exit node of the CFG.
|
2002-01-31 01:12:06 +00:00
|
|
|
//
|
2002-01-30 23:29:35 +00:00
|
|
|
BasicBlock *getExitNode() const { return ExitNode; }
|
|
|
|
|
2002-06-25 16:12:52 +00:00
|
|
|
virtual bool runOnFunction(Function &F);
|
2002-01-30 23:29:35 +00:00
|
|
|
};
|
|
|
|
|
2002-04-27 06:59:56 +00:00
|
|
|
static inline Pass *createUnifyFunctionExitNodesPass() {
|
|
|
|
return new UnifyFunctionExitNodes();
|
2002-02-26 21:46:54 +00:00
|
|
|
}
|
|
|
|
|
2002-01-30 23:29:35 +00:00
|
|
|
#endif
|