LLVM API Documentation
00001 //===-- UnifyFunctionExitNodes.h - Ensure fn's have one return --*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // 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 static char ID; // Pass identification, replacement for typeid 00029 UnifyFunctionExitNodes() : FunctionPass(&ID), 00030 ReturnBlock(0), UnwindBlock(0) {} 00031 00032 // We can preserve non-critical-edgeness when we unify function exit nodes 00033 virtual void getAnalysisUsage(AnalysisUsage &AU) const; 00034 00035 // getReturn|Unwind|UnreachableBlock - Return the new single (or nonexistant) 00036 // return, unwind, or unreachable basic blocks in the CFG. 00037 // 00038 BasicBlock *getReturnBlock() const { return ReturnBlock; } 00039 BasicBlock *getUnwindBlock() const { return UnwindBlock; } 00040 BasicBlock *getUnreachableBlock() const { return UnreachableBlock; } 00041 00042 virtual bool runOnFunction(Function &F); 00043 }; 00044 00045 Pass *createUnifyFunctionExitNodesPass(); 00046 00047 } // End llvm namespace 00048 00049 #endif
This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.