Don't attribute in file headers anymore. See llvmdev for the
[oota-llvm.git] / include / llvm / Transforms / Utils / UnifyFunctionExitNodes.h
1 //===-- UnifyFunctionExitNodes.h - Ensure fn's have one return --*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This pass is used to ensure that functions have at most one return and one
11 // unwind instruction in them.  Additionally, it keeps track of which node is
12 // the new exit node of the CFG.  If there are no return or unwind instructions
13 // in the function, the getReturnBlock/getUnwindBlock methods will return a null
14 // pointer.
15 //
16 //===----------------------------------------------------------------------===//
17
18 #ifndef LLVM_TRANSFORMS_UNIFYFUNCTIONEXITNODES_H
19 #define LLVM_TRANSFORMS_UNIFYFUNCTIONEXITNODES_H
20
21 #include "llvm/Pass.h"
22
23 namespace llvm {
24
25 struct UnifyFunctionExitNodes : public FunctionPass {
26   BasicBlock *ReturnBlock, *UnwindBlock, *UnreachableBlock;
27 public:
28   static char ID; // Pass identification, replacement for typeid
29   UnifyFunctionExitNodes() : FunctionPass((intptr_t)&ID),
30                              ReturnBlock(0), UnwindBlock(0) {}
31
32   // We can preserve non-critical-edgeness when we unify function exit nodes
33   virtual void getAnalysisUsage(AnalysisUsage &AU) const;
34
35   // getReturn|Unwind|UnreachableBlock - Return the new single (or nonexistant)
36   // return, unwind, or unreachable  basic blocks in the CFG.
37   //
38   BasicBlock *getReturnBlock() const { return ReturnBlock; }
39   BasicBlock *getUnwindBlock() const { return UnwindBlock; }
40   BasicBlock *getUnreachableBlock() const { return UnreachableBlock; }
41
42   virtual bool runOnFunction(Function &F);
43   
44   // Force linking the impl of this class into anything that uses this header.
45   static int stub;
46 };
47
48 Pass *createUnifyFunctionExitNodesPass();
49
50 static IncludeFile
51 UNIFY_FUNCTION_EXIT_NODES_INCLUDE_FILE(&UnifyFunctionExitNodes::stub);
52
53 } // End llvm namespace
54
55 #endif