2003-09-10 22:34:51 +02:00
|
|
|
//===-- UnifyFunctionExitNodes.h - Ensure fn's have one return --*- C++ -*-===//
|
2005-04-21 22:59:05 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:59:42 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 22:59:05 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-01-31 00:29:35 +01:00
|
|
|
//
|
2003-09-10 22:34:51 +02: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-31 00:29:35 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2003-03-31 19:29:18 +02:00
|
|
|
#ifndef LLVM_TRANSFORMS_UNIFYFUNCTIONEXITNODES_H
|
|
|
|
#define LLVM_TRANSFORMS_UNIFYFUNCTIONEXITNODES_H
|
2002-01-31 00:29:35 +01:00
|
|
|
|
|
|
|
#include "llvm/Pass.h"
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
namespace llvm {
|
|
|
|
|
2002-04-27 08:59:56 +02:00
|
|
|
struct UnifyFunctionExitNodes : public FunctionPass {
|
2004-10-16 20:06:43 +02:00
|
|
|
BasicBlock *ReturnBlock, *UnwindBlock, *UnreachableBlock;
|
2002-01-31 00:29:35 +01:00
|
|
|
public:
|
2007-05-06 15:37:16 +02:00
|
|
|
static char ID; // Pass identification, replacement for typeid
|
2010-08-06 20:33:48 +02:00
|
|
|
UnifyFunctionExitNodes() : FunctionPass(ID),
|
2010-10-19 19:21:58 +02:00
|
|
|
ReturnBlock(0), UnwindBlock(0) {
|
|
|
|
initializeUnifyFunctionExitNodesPass(*PassRegistry::getPassRegistry());
|
|
|
|
}
|
2002-01-31 00:29:35 +01:00
|
|
|
|
2003-03-31 19:29:18 +02:00
|
|
|
// We can preserve non-critical-edgeness when we unify function exit nodes
|
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
|
|
|
|
|
2004-10-16 20:06:43 +02:00
|
|
|
// getReturn|Unwind|UnreachableBlock - Return the new single (or nonexistant)
|
|
|
|
// return, unwind, or unreachable basic blocks in the CFG.
|
2002-01-31 02:12:06 +01:00
|
|
|
//
|
2003-09-10 22:34:51 +02:00
|
|
|
BasicBlock *getReturnBlock() const { return ReturnBlock; }
|
|
|
|
BasicBlock *getUnwindBlock() const { return UnwindBlock; }
|
2004-10-16 20:06:43 +02:00
|
|
|
BasicBlock *getUnreachableBlock() const { return UnreachableBlock; }
|
2002-01-31 00:29:35 +01:00
|
|
|
|
2002-06-25 18:12:52 +02:00
|
|
|
virtual bool runOnFunction(Function &F);
|
2002-01-31 00:29:35 +01:00
|
|
|
};
|
|
|
|
|
2003-09-10 22:34:51 +02:00
|
|
|
Pass *createUnifyFunctionExitNodesPass();
|
2002-02-26 22:46:54 +01:00
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2002-01-31 00:29:35 +01:00
|
|
|
#endif
|