24 std::vector<BasicBlock *> UnreachableBlocks;
27 if (isa<UnreachableInst>(
I.getTerminator()))
28 UnreachableBlocks.push_back(&
I);
30 if (UnreachableBlocks.size() <= 1)
38 BB->back().eraseFromParent();
46 std::vector<BasicBlock *> ReturningBlocks;
49 if (isa<ReturnInst>(
I.getTerminator()))
50 ReturningBlocks.push_back(&
I);
52 if (ReturningBlocks.size() <= 1)
59 "UnifiedReturnBlock", &
F);
62 if (
F.getReturnType()->isVoidTy()) {
78 PN->
addIncoming(BB->getTerminator()->getOperand(0), BB);
80 BB->back().eraseFromParent();
91 Changed |= unifyUnreachableBlocks(
F);
92 Changed |= unifyReturnBlocks(
F);
A container for analyses that lazily runs them and caches their results.
LLVM Basic Block Representation.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
static BranchInst * Create(BasicBlock *IfTrue, InsertPosition InsertBefore=nullptr)
InstListType::iterator insertInto(BasicBlock *ParentBB, InstListType::iterator It)
Inserts an unlinked instruction into ParentBB at position It and returns the iterator of the inserted...
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, InsertPosition InsertBefore=nullptr)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
This function has undefined behavior.
This is an optimization pass for GlobalISel generic memory operations.