LLVM  5.0.0
UnifyFunctionExitNodes.h
Go to the documentation of this file.
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_UTILS_UNIFYFUNCTIONEXITNODES_H
19 #define LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H
20 
21 #include "llvm/Pass.h"
22 #include "llvm/PassRegistry.h"
23 
24 namespace llvm {
25 
27  BasicBlock *ReturnBlock = nullptr;
28  BasicBlock *UnwindBlock = nullptr;
30 
31 public:
32  static char ID; // Pass identification, replacement for typeid
35  }
36 
37  // We can preserve non-critical-edgeness when we unify function exit nodes
38  void getAnalysisUsage(AnalysisUsage &AU) const override;
39 
40  // getReturn|Unwind|UnreachableBlock - Return the new single (or nonexistent)
41  // return, unwind, or unreachable basic blocks in the CFG.
42  //
43  BasicBlock *getReturnBlock() const { return ReturnBlock; }
44  BasicBlock *getUnwindBlock() const { return UnwindBlock; }
46 
47  bool runOnFunction(Function &F) override;
48 };
49 
51 
52 } // end namespace llvm
53 
54 #endif // LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
#define F(x, y, z)
Definition: MD5.cpp:55
void initializeUnifyFunctionExitNodesPass(PassRegistry &)
Pass * createUnifyFunctionExitNodesPass()
LLVM Basic Block Representation.
Definition: BasicBlock.h:59
BasicBlock * getReturnBlock() const
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:298
BasicBlock * getUnwindBlock() const
print lazy value Lazy Value Info Printer Pass
BasicBlock * getUnreachableBlock() const
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...