28 "Unify function exit nodes",
false,
false)
51 std::vector<BasicBlock*> ReturningBlocks;
52 std::vector<BasicBlock*> UnreachableBlocks;
54 if (isa<ReturnInst>(
I->getTerminator()))
55 ReturningBlocks.push_back(
I);
56 else if (isa<UnreachableInst>(
I->getTerminator()))
57 UnreachableBlocks.push_back(
I);
60 if (UnreachableBlocks.empty()) {
62 }
else if (UnreachableBlocks.size() == 1) {
66 "UnifiedUnreachableBlock", &
F);
69 for (std::vector<BasicBlock*>::iterator
I = UnreachableBlocks.begin(),
70 E = UnreachableBlocks.end();
I != E; ++
I) {
78 if (ReturningBlocks.empty()) {
81 }
else if (ReturningBlocks.size() == 1) {
91 "UnifiedReturnBlock", &
F);
107 for (std::vector<BasicBlock*>::iterator
I = ReturningBlocks.begin(),
108 E = ReturningBlocks.end();
I != E; ++
I) {
Pass interface - Implemented by all 'passes'.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Type * getReturnType() const
const Instruction & front() const
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *InsertBefore=nullptr)
void push_back(NodeTy *val)
BasicBlock * UnreachableBlock
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
AnalysisUsage & addPreservedID(const void *ID)
Pass * createUnifyFunctionExitNodesPass()
LLVM Basic Block Representation.
char & BreakCriticalEdgesID
UnreachableInst - This function has undefined behavior.
INITIALIZE_PASS(UnifyFunctionExitNodes,"mergereturn","Unify function exit nodes", false, false) Pass *llvm
Represent the analysis usage information of a pass.
const InstListType & getInstList() const
Return the underlying instruction list container.
Value * getOperand(unsigned i) const
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...
bool isVoidTy() const
isVoidTy - Return true if this is 'void'.