Lines Matching refs:BB

58   for (auto *BB : BBs) {
62 for (BasicBlock *Succ : successors(BB)) {
63 Succ->removePredecessor(BB, KeepOneInputPHIs);
65 Updates->push_back({DominatorTree::Delete, BB, Succ});
69 while (!BB->empty()) {
70 Instruction &I = BB->back();
78 BB->getInstList().pop_back();
80 new UnreachableInst(BB->getContext(), BB);
81 assert(BB->getInstList().size() == 1 &&
82 isa<UnreachableInst>(BB->getTerminator()) &&
83 "The successor list of BB isn't empty before "
88 void llvm::DeleteDeadBlock(BasicBlock *BB, DomTreeUpdater *DTU,
90 DeleteDeadBlocks({BB}, DTU, KeepOneInputPHIs);
99 for (auto *BB : Dead)
100 for (BasicBlock *Pred : predecessors(BB))
110 for (BasicBlock *BB : BBs)
112 DTU->deleteBB(BB);
114 BB->eraseFromParent();
122 for (BasicBlock *BB : depth_first_ext(&F, Reachable))
123 (void)BB/* Mark all reachable blocks */;
129 BasicBlock *BB = &*I;
130 DeadBlocks.push_back(BB);
139 void llvm::FoldSingleEntryPHINodes(BasicBlock *BB,
141 if (!isa<PHINode>(BB->begin())) return;
143 while (PHINode *PN = dyn_cast<PHINode>(BB->begin())) {
156 bool llvm::DeleteDeadPHIs(BasicBlock *BB, const TargetLibraryInfo *TLI) {
160 for (PHINode &PN : BB->phis())
171 bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU,
175 if (BB->hasAddressTaken())
179 BasicBlock *PredBB = BB->getUniquePredecessor();
183 if (PredBB == BB) return false;
189 if (!PredecessorWithTwoSuccessors && PredBB->getUniqueSuccessor() != BB)
192 // Currently only allow PredBB to have two predecessors, one being BB.
193 // Update BI to branch to BB's only successor instead of BB.
200 BranchInst *BB_JmpI = dyn_cast<BranchInst>(BB->getTerminator());
204 FallThruPath = PredBB_BI->getSuccessor(0) == BB ? 0 : 1;
208 for (PHINode &PN : BB->phis())
213 LLVM_DEBUG(dbgs() << "Merging: " << BB->getName() << " into "
218 if (isa<PHINode>(BB->front())) {
219 for (PHINode &PN : BB->phis())
221 cast<PHINode>(PN.getIncomingValue(0))->getParent() != BB)
223 FoldSingleEntryPHINodes(BB, MemDep);
226 // DTU update: Collect all the edges that exit BB.
230 Updates.reserve(1 + (2 * succ_size(BB)));
237 for (auto I = succ_begin(BB), E = succ_end(BB); I != E; ++I)
238 // This successor of BB may already have PredBB as a predecessor.
241 for (auto I = succ_begin(BB), E = succ_end(BB); I != E; ++I)
242 Updates.push_back({DominatorTree::Delete, BB, *I});
243 Updates.push_back({DominatorTree::Delete, PredBB, BB});
247 Instruction *STI = BB->getTerminator();
248 Instruction *Start = &*BB->begin();
255 PredBB->getInstList().splice(PTI->getIterator(), BB->getInstList(),
256 BB->begin(), STI->getIterator());
259 MSSAU->moveAllAfterMergeBlocks(BB, PredBB, Start);
261 // Make all PHI nodes that referred to BB now refer to Pred as their
263 BB->replaceAllUsesWith(PredBB);
266 // Delete the unconditional branch from BB.
267 BB->getInstList().pop_back();
276 PredBB->getInstList().splice(PredBB->end(), BB->getInstList());
284 // Add unreachable to now empty BB.
285 new UnreachableInst(BB->getContext(), BB);
294 PredBB->takeName(BB);
297 LI->removeBlock(BB);
304 assert(BB->getInstList().size() == 1 &&
305 isa<UnreachableInst>(BB->getTerminator()) &&
306 "The successor list of BB isn't empty before "
309 DTU->deleteBB(BB);
311 BB->eraseFromParent(); // Nuke BB if DTU is nullptr.
338 static bool removeRedundantDbgInstrsUsingBackwardScan(BasicBlock *BB) {
341 for (auto &I : reverse(*BB)) {
385 static bool removeRedundantDbgInstrsUsingForwardScan(BasicBlock *BB) {
388 for (auto &I : *BB) {
413 bool llvm::RemoveRedundantDbgInstrs(BasicBlock *BB) {
426 MadeChanges |= removeRedundantDbgInstrsUsingBackwardScan(BB);
427 MadeChanges |= removeRedundantDbgInstrsUsingForwardScan(BB);
431 << BB->getName() << "\n");
474 BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock *Succ, DominatorTree *DT,
476 unsigned SuccNum = GetSuccessorNumber(BB, Succ);
479 Instruction *LatchTerm = BB->getTerminator();
485 // If the edge isn't critical, then BB has a single successor or Succ has a
490 assert(SP == BB && "CFG broken");
495 // Otherwise, if BB has a single successor, split it at the bottom of the
497 assert(BB->getTerminator()->getNumSuccessors() == 1 &&
499 return SplitBlock(BB, BB->getTerminator(), DT, LI, MSSAU);
506 for (BasicBlock &BB : F) {
507 Instruction *TI = BB.getTerminator();
709 BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB,
715 if (!BB->canSplitPredecessors())
720 if (BB->isLandingPad()) {
724 SplitLandingPadPredecessors(BB, Preds, Suffix, NewName.c_str(), NewBBs, DT,
731 BB->getContext(), BB->getName() + Suffix, BB->getParent(), BB);
734 BranchInst *BI = BranchInst::Create(BB, NewBB);
736 if (LI && LI->isLoopHeader(BB))
739 BI->setDebugLoc(LI->getLoopFor(BB)->getStartLoc());
741 BI->setDebugLoc(BB->getFirstNonPHIOrDbg()->getDebugLoc());
743 // Move the edges from Preds to point to NewBB instead of BB.
746 // is that there be no more than one indirectbr branching to BB. And
752 Preds[i]->getTerminator()->replaceUsesOfWith(BB, NewBB);
755 // Insert a new PHI node into NewBB for every PHI node in BB and that new PHI
756 // node becomes an incoming value for BB's phi node. However, if the Preds
757 // list is empty, we need to insert dummy entries into the PHI nodes in BB to
761 for (BasicBlock::iterator I = BB->begin(); isa<PHINode>(I); ++I)
767 UpdateAnalysisInformation(BB, NewBB, Preds, DT, LI, MSSAU, PreserveLCSSA,
771 // Update the PHI nodes in BB with the values coming from NewBB.
772 UpdatePHINodes(BB, NewBB, Preds, BI, HasLoopExit);
801 // is that there be no more than one indirectbr branching to BB. And
882 ReturnInst *llvm::FoldReturnIntoUncondBranch(ReturnInst *RI, BasicBlock *BB,
891 // PHI node in "BB", propagate the right value into the return.
905 if (PN->getParent() == BB) {
916 BB->removePredecessor(Pred);
920 DTU->applyUpdates({{DominatorTree::Delete, Pred, BB}});
997 Value *llvm::GetIfCondition(BasicBlock *BB, BasicBlock *&IfTrue,
999 PHINode *SomePHI = dyn_cast<PHINode>(BB->begin());
1009 pred_iterator PI = pred_begin(BB), PE = pred_end(BB);
1044 // doesn't dominate BB.
1049 // to BB and Pred2Br. If it doesn't, this isn't an "if statement".
1050 if (Pred1Br->getSuccessor(0) == BB &&
1055 Pred1Br->getSuccessor(1) == BB) {
1059 // We know that one arm of the conditional goes to BB, so the other must
1068 // BB. Don't panic! If both blocks only have a single (identical)