2003-09-10 20:34:51 +00:00
|
|
|
//===-- UnifyFunctionExitNodes.h - Ensure fn's have one return --*- C++ -*-===//
|
2005-04-21 20:59:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 20:59:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-01-30 23:29:35 +00:00
|
|
|
//
|
2003-09-10 20:34:51 +00:00
|
|
|
// This pass is used to ensure that functions have at most one return and one
|
|
|
|
// unwind instruction in them. Additionally, it keeps track of which node is
|
|
|
|
// the new exit node of the CFG. If there are no return or unwind instructions
|
|
|
|
// in the function, the getReturnBlock/getUnwindBlock methods 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"
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2002-04-27 06:59:56 +00:00
|
|
|
struct UnifyFunctionExitNodes : public FunctionPass {
|
2004-10-16 18:06:43 +00:00
|
|
|
BasicBlock *ReturnBlock, *UnwindBlock, *UnreachableBlock;
|
2002-01-30 23:29:35 +00:00
|
|
|
public:
|
2007-05-06 13:37:16 +00:00
|
|
|
static char ID; // Pass identification, replacement for typeid
|
2007-05-01 21:15:47 +00:00
|
|
|
UnifyFunctionExitNodes() : FunctionPass((intptr_t)&ID),
|
|
|
|
ReturnBlock(0), UnwindBlock(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;
|
|
|
|
|
2004-10-16 18:06:43 +00:00
|
|
|
// getReturn|Unwind|UnreachableBlock - Return the new single (or nonexistant)
|
|
|
|
// return, unwind, or unreachable basic blocks in the CFG.
|
2002-01-31 01:12:06 +00:00
|
|
|
//
|
2003-09-10 20:34:51 +00:00
|
|
|
BasicBlock *getReturnBlock() const { return ReturnBlock; }
|
|
|
|
BasicBlock *getUnwindBlock() const { return UnwindBlock; }
|
2004-10-16 18:06:43 +00:00
|
|
|
BasicBlock *getUnreachableBlock() const { return UnreachableBlock; }
|
2002-01-30 23:29:35 +00:00
|
|
|
|
2002-06-25 16:12:52 +00:00
|
|
|
virtual bool runOnFunction(Function &F);
|
2002-01-30 23:29:35 +00:00
|
|
|
};
|
|
|
|
|
2003-09-10 20:34:51 +00:00
|
|
|
Pass *createUnifyFunctionExitNodesPass();
|
2002-02-26 21:46:54 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2002-01-30 23:29:35 +00:00
|
|
|
#endif
|