32 "Unify function exit nodes",
false,
false)
55 std::vector<BasicBlock*> ReturningBlocks;
56 std::vector<BasicBlock*> UnreachableBlocks;
58 if (isa<ReturnInst>(
I.getTerminator()))
59 ReturningBlocks.push_back(&
I);
60 else if (isa<UnreachableInst>(
I.getTerminator()))
61 UnreachableBlocks.push_back(&
I);
64 if (UnreachableBlocks.empty()) {
66 }
else if (UnreachableBlocks.size() == 1) {
70 "UnifiedUnreachableBlock", &
F);
74 BB->getInstList().pop_back();
80 if (ReturningBlocks.empty()) {
83 }
else if (ReturningBlocks.size() == 1) {
93 "UnifiedReturnBlock", &
F);
96 if (F.getReturnType()->isVoidTy()) {
113 PN->addIncoming(BB->getTerminator()->getOperand(0), BB);
115 BB->getInstList().pop_back();
Pass interface - Implemented by all 'passes'.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents lattice values for constants.
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *InsertBefore=nullptr)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
void initializeUnifyFunctionExitNodesPass(PassRegistry &)
AnalysisUsage & addPreservedID(const void *ID)
Pass * createUnifyFunctionExitNodesPass()
LLVM Basic Block Representation.
char & BreakCriticalEdgesID
This function has undefined behavior.
const Instruction & front() const
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
const InstListType & getInstList() const
Return the underlying instruction list container.
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...
void push_back(pointer val)
INITIALIZE_PASS(UnifyFunctionExitNodes, "mergereturn", "Unify function exit nodes", false, false) Pass *llvm
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...
BasicBlock * UnreachableBlock