LLVM API Documentation
00001 //===-- UnifyFunctionExitNodes.h - Ensure fn's have one return --*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This pass is used to ensure that functions have at most one return and one 00011 // unwind instruction in them. Additionally, it keeps track of which node is 00012 // the new exit node of the CFG. If there are no return or unwind instructions 00013 // in the function, the getReturnBlock/getUnwindBlock methods will return a null 00014 // pointer. 00015 // 00016 //===----------------------------------------------------------------------===// 00017 00018 #ifndef LLVM_TRANSFORMS_UNIFYFUNCTIONEXITNODES_H 00019 #define LLVM_TRANSFORMS_UNIFYFUNCTIONEXITNODES_H 00020 00021 #include "llvm/Pass.h" 00022 00023 namespace llvm { 00024 00025 struct UnifyFunctionExitNodes : public FunctionPass { 00026 BasicBlock *ReturnBlock, *UnwindBlock, *UnreachableBlock; 00027 public: 00028 UnifyFunctionExitNodes() : ReturnBlock(0), UnwindBlock(0) {} 00029 00030 // We can preserve non-critical-edgeness when we unify function exit nodes 00031 virtual void getAnalysisUsage(AnalysisUsage &AU) const; 00032 00033 // getReturn|Unwind|UnreachableBlock - Return the new single (or nonexistant) 00034 // return, unwind, or unreachable basic blocks in the CFG. 00035 // 00036 BasicBlock *getReturnBlock() const { return ReturnBlock; } 00037 BasicBlock *getUnwindBlock() const { return UnwindBlock; } 00038 BasicBlock *getUnreachableBlock() const { return UnreachableBlock; } 00039 00040 virtual bool runOnFunction(Function &F); 00041 }; 00042 00043 Pass *createUnifyFunctionExitNodesPass(); 00044 00045 } // End llvm namespace 00046 00047 #endif