25 std::vector<BasicBlock *> UnreachableBlocks;
28 if (isa<UnreachableInst>(
I.getTerminator()))
29 UnreachableBlocks.push_back(&
I);
31 if (UnreachableBlocks.size() <= 1)
39 BB->back().eraseFromParent();
47 std::vector<BasicBlock *> ReturningBlocks;
50 if (isa<ReturnInst>(
I.getTerminator()))
51 ReturningBlocks.push_back(&
I);
53 if (ReturningBlocks.size() <= 1)
60 "UnifiedReturnBlock", &
F);
63 if (
F.getReturnType()->isVoidTy()) {
79 PN->
addIncoming(BB->getTerminator()->getOperand(0), BB);
81 BB->back().eraseFromParent();
92 Changed |= unifyUnreachableBlocks(
F);
93 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.