Lines Matching full:bb

66   for (auto *BB : BBs) {  in detachDeadBlocks()  local
70 for (BasicBlock *Succ : successors(BB)) { in detachDeadBlocks()
71 Succ->removePredecessor(BB, KeepOneInputPHIs); in detachDeadBlocks()
73 Updates->push_back({DominatorTree::Delete, BB, Succ}); in detachDeadBlocks()
77 while (!BB->empty()) { in detachDeadBlocks()
78 Instruction &I = BB->back(); in detachDeadBlocks()
86 BB->back().eraseFromParent(); in detachDeadBlocks()
88 new UnreachableInst(BB->getContext(), BB); in detachDeadBlocks()
89 assert(BB->size() == 1 && in detachDeadBlocks()
90 isa<UnreachableInst>(BB->getTerminator()) && in detachDeadBlocks()
91 "The successor list of BB isn't empty before " in detachDeadBlocks()
96 void llvm::DeleteDeadBlock(BasicBlock *BB, DomTreeUpdater *DTU, in DeleteDeadBlock() argument
98 DeleteDeadBlocks({BB}, DTU, KeepOneInputPHIs); in DeleteDeadBlock()
107 for (auto *BB : Dead) in DeleteDeadBlocks() local
108 for (BasicBlock *Pred : predecessors(BB)) in DeleteDeadBlocks()
118 for (BasicBlock *BB : BBs) in DeleteDeadBlocks()
120 DTU->deleteBB(BB); in DeleteDeadBlocks()
122 BB->eraseFromParent(); in DeleteDeadBlocks()
130 for (BasicBlock *BB : depth_first_ext(&F, Reachable)) in EliminateUnreachableBlocks()
131 (void)BB/* Mark all reachable blocks */; in EliminateUnreachableBlocks()
135 for (BasicBlock &BB : F) in EliminateUnreachableBlocks()
136 if (!Reachable.count(&BB)) in EliminateUnreachableBlocks()
137 DeadBlocks.push_back(&BB); in EliminateUnreachableBlocks()
145 bool llvm::FoldSingleEntryPHINodes(BasicBlock *BB, in FoldSingleEntryPHINodes() argument
147 if (!isa<PHINode>(BB->begin())) in FoldSingleEntryPHINodes()
150 while (PHINode *PN = dyn_cast<PHINode>(BB->begin())) { in FoldSingleEntryPHINodes()
164 bool llvm::DeleteDeadPHIs(BasicBlock *BB, const TargetLibraryInfo *TLI, in DeleteDeadPHIs() argument
169 for (PHINode &PN : BB->phis()) in DeleteDeadPHIs()
180 bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU, in MergeBlockIntoPredecessor() argument
185 if (BB->hasAddressTaken()) in MergeBlockIntoPredecessor()
189 BasicBlock *PredBB = BB->getUniquePredecessor(); in MergeBlockIntoPredecessor()
193 if (PredBB == BB) return false; in MergeBlockIntoPredecessor()
201 if (!PredecessorWithTwoSuccessors && PredBB->getUniqueSuccessor() != BB) in MergeBlockIntoPredecessor()
204 // Currently only allow PredBB to have two predecessors, one being BB. in MergeBlockIntoPredecessor()
205 // Update BI to branch to BB's only successor instead of BB. in MergeBlockIntoPredecessor()
212 BranchInst *BB_JmpI = dyn_cast<BranchInst>(BB->getTerminator()); in MergeBlockIntoPredecessor()
216 FallThruPath = PredBB_BI->getSuccessor(0) == BB ? 0 : 1; in MergeBlockIntoPredecessor()
220 for (PHINode &PN : BB->phis()) in MergeBlockIntoPredecessor()
224 LLVM_DEBUG(dbgs() << "Merging: " << BB->getName() << " into " in MergeBlockIntoPredecessor()
229 if (isa<PHINode>(BB->front())) { in MergeBlockIntoPredecessor()
230 for (PHINode &PN : BB->phis()) in MergeBlockIntoPredecessor()
232 cast<PHINode>(PN.getIncomingValue(0))->getParent() != BB) in MergeBlockIntoPredecessor()
234 FoldSingleEntryPHINodes(BB, MemDep); in MergeBlockIntoPredecessor()
240 DomTreeNode *BBNode = DT->getNode(BB); in MergeBlockIntoPredecessor()
247 // DTU update: Collect all the edges that exit BB. in MergeBlockIntoPredecessor()
256 Updates.reserve(Updates.size() + 2 * succ_size(BB) + 1); in MergeBlockIntoPredecessor()
263 for (BasicBlock *SuccOfBB : successors(BB)) in MergeBlockIntoPredecessor()
264 // This successor of BB may already be a PredBB's successor. in MergeBlockIntoPredecessor()
269 for (BasicBlock *SuccOfBB : successors(BB)) in MergeBlockIntoPredecessor()
271 Updates.push_back({DominatorTree::Delete, BB, SuccOfBB}); in MergeBlockIntoPredecessor()
272 Updates.push_back({DominatorTree::Delete, PredBB, BB}); in MergeBlockIntoPredecessor()
275 Instruction *STI = BB->getTerminator(); in MergeBlockIntoPredecessor()
276 Instruction *Start = &*BB->begin(); in MergeBlockIntoPredecessor()
283 PredBB->splice(PTI->getIterator(), BB, BB->begin(), STI->getIterator()); in MergeBlockIntoPredecessor()
286 MSSAU->moveAllAfterMergeBlocks(BB, PredBB, Start); in MergeBlockIntoPredecessor()
288 // Make all PHI nodes that referred to BB now refer to Pred as their in MergeBlockIntoPredecessor()
290 BB->replaceAllUsesWith(PredBB); in MergeBlockIntoPredecessor()
293 // Delete the unconditional branch from BB. in MergeBlockIntoPredecessor()
294 BB->back().eraseFromParent(); in MergeBlockIntoPredecessor()
303 BB->back().moveBeforePreserving(*PredBB, PredBB->end()); in MergeBlockIntoPredecessor()
311 // Add unreachable to now empty BB. in MergeBlockIntoPredecessor()
312 new UnreachableInst(BB->getContext(), BB); in MergeBlockIntoPredecessor()
316 PredBB->takeName(BB); in MergeBlockIntoPredecessor()
319 LI->removeBlock(BB); in MergeBlockIntoPredecessor()
328 assert(succ_empty(BB) && in MergeBlockIntoPredecessor()
330 DT->eraseNode(BB); in MergeBlockIntoPredecessor()
334 DeleteDeadBlock(BB, DTU); in MergeBlockIntoPredecessor()
346 BasicBlock *BB = *MergeBlocks.begin(); in MergeBlockSuccessorsIntoGivenBlocks() local
347 BasicBlock *Dest = BB->getSingleSuccessor(); in MergeBlockSuccessorsIntoGivenBlocks()
352 assert(Fold == BB && in MergeBlockSuccessorsIntoGivenBlocks()
353 "Expecting BB to be unique predecessor of the Dest block"); in MergeBlockSuccessorsIntoGivenBlocks()
357 MergeBlocks.erase(BB); in MergeBlockSuccessorsIntoGivenBlocks()
359 MergeBlocks.erase(BB); in MergeBlockSuccessorsIntoGivenBlocks()
386 DbgVariableRecordsRemoveRedundantDbgInstrsUsingBackwardScan(BasicBlock *BB) { in DbgVariableRecordsRemoveRedundantDbgInstrsUsingBackwardScan() argument
389 for (auto &I : reverse(*BB)) { in DbgVariableRecordsRemoveRedundantDbgInstrsUsingBackwardScan()
442 static bool removeRedundantDbgInstrsUsingBackwardScan(BasicBlock *BB) { in removeRedundantDbgInstrsUsingBackwardScan() argument
443 if (BB->IsNewDbgInfoFormat) in removeRedundantDbgInstrsUsingBackwardScan()
444 return DbgVariableRecordsRemoveRedundantDbgInstrsUsingBackwardScan(BB); in removeRedundantDbgInstrsUsingBackwardScan()
448 for (auto &I : reverse(*BB)) { in removeRedundantDbgInstrsUsingBackwardScan()
504 DbgVariableRecordsRemoveRedundantDbgInstrsUsingForwardScan(BasicBlock *BB) { in DbgVariableRecordsRemoveRedundantDbgInstrsUsingForwardScan() argument
508 for (auto &I : *BB) { in DbgVariableRecordsRemoveRedundantDbgInstrsUsingForwardScan()
546 DbgVariableRecordsRemoveUndefDbgAssignsFromEntryBlock(BasicBlock *BB) { in DbgVariableRecordsRemoveUndefDbgAssignsFromEntryBlock() argument
547 assert(BB->isEntryBlock() && "expected entry block"); in DbgVariableRecordsRemoveUndefDbgAssignsFromEntryBlock()
558 for (auto &I : *BB) { in DbgVariableRecordsRemoveUndefDbgAssignsFromEntryBlock()
582 static bool removeRedundantDbgInstrsUsingForwardScan(BasicBlock *BB) { in removeRedundantDbgInstrsUsingForwardScan() argument
583 if (BB->IsNewDbgInfoFormat) in removeRedundantDbgInstrsUsingForwardScan()
584 return DbgVariableRecordsRemoveRedundantDbgInstrsUsingForwardScan(BB); in removeRedundantDbgInstrsUsingForwardScan()
589 for (auto &I : *BB) { in removeRedundantDbgInstrsUsingForwardScan()
646 static bool removeUndefDbgAssignsFromEntryBlock(BasicBlock *BB) { in removeUndefDbgAssignsFromEntryBlock() argument
647 if (BB->IsNewDbgInfoFormat) in removeUndefDbgAssignsFromEntryBlock()
648 return DbgVariableRecordsRemoveUndefDbgAssignsFromEntryBlock(BB); in removeUndefDbgAssignsFromEntryBlock()
650 assert(BB->isEntryBlock() && "expected entry block"); in removeUndefDbgAssignsFromEntryBlock()
661 for (auto &I : *BB) { in removeUndefDbgAssignsFromEntryBlock()
684 bool llvm::RemoveRedundantDbgInstrs(BasicBlock *BB) { in RemoveRedundantDbgInstrs() argument
697 MadeChanges |= removeRedundantDbgInstrsUsingBackwardScan(BB); in RemoveRedundantDbgInstrs()
698 if (BB->isEntryBlock() && in RemoveRedundantDbgInstrs()
699 isAssignmentTrackingEnabled(*BB->getParent()->getParent())) in RemoveRedundantDbgInstrs()
700 MadeChanges |= removeUndefDbgAssignsFromEntryBlock(BB); in RemoveRedundantDbgInstrs()
701 MadeChanges |= removeRedundantDbgInstrsUsingForwardScan(BB); in RemoveRedundantDbgInstrs()
705 << BB->getName() << "\n"); in RemoveRedundantDbgInstrs()
722 void llvm::ReplaceInstWithInst(BasicBlock *BB, BasicBlock::iterator &BI, in ReplaceInstWithInst() argument
733 BasicBlock::iterator New = I->insertInto(BB, BI); in ReplaceInstWithInst()
742 bool llvm::IsBlockFollowedByDeoptOrUnreachable(const BasicBlock *BB) { in IsBlockFollowedByDeoptOrUnreachable() argument
746 while (BB && Depth++ < MaxDeoptOrUnreachableSuccessorCheckDepth && in IsBlockFollowedByDeoptOrUnreachable()
747 VisitedBlocks.insert(BB).second) { in IsBlockFollowedByDeoptOrUnreachable()
748 if (isa<UnreachableInst>(BB->getTerminator()) || in IsBlockFollowedByDeoptOrUnreachable()
749 BB->getTerminatingDeoptimizeCall()) in IsBlockFollowedByDeoptOrUnreachable()
751 BB = BB->getUniqueSuccessor(); in IsBlockFollowedByDeoptOrUnreachable()
761 BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock *Succ, DominatorTree *DT, in SplitEdge() argument
764 unsigned SuccNum = GetSuccessorNumber(BB, Succ); in SplitEdge()
766 Instruction *LatchTerm = BB->getTerminator(); in SplitEdge()
775 return ehAwareSplitEdge(BB, Succ, nullptr, nullptr, Options, BBName); in SplitEdge()
781 // If the edge isn't critical, then BB has a single successor or Succ has a in SplitEdge()
786 assert(SP == BB && "CFG broken"); in SplitEdge()
792 // Otherwise, if BB has a single successor, split it at the bottom of the in SplitEdge()
794 assert(BB->getTerminator()->getNumSuccessors() == 1 && in SplitEdge()
796 return SplitBlock(BB, BB->getTerminator(), DT, LI, MSSAU, BBName); in SplitEdge()
822 // happens because the BB list of PHI nodes are usually in the same in updatePhiNodes()
832 BasicBlock *llvm::ehAwareSplitEdge(BasicBlock *BB, BasicBlock *Succ, in ehAwareSplitEdge() argument
840 return SplitEdge(BB, Succ, Options.DT, Options.LI, Options.MSSAU, BBName); in ehAwareSplitEdge()
848 if (Loop *BBLoop = LI->getLoopFor(BB)) { in ehAwareSplitEdge()
860 if (P == BB) in ehAwareSplitEdge()
881 BasicBlock::Create(BB->getContext(), BBName, BB->getParent(), Succ); in ehAwareSplitEdge()
882 setUnwindEdgeTo(BB->getTerminator(), NewBB); in ehAwareSplitEdge()
883 updatePhiNodes(Succ, BB, NewBB, LandingPadReplacement); in ehAwareSplitEdge()
916 Updates.push_back({DominatorTree::Insert, BB, NewBB}); in ehAwareSplitEdge()
918 Updates.push_back({DominatorTree::Delete, BB, Succ}); in ehAwareSplitEdge()
931 if (Loop *BBLoop = LI->getLoopFor(BB)) { in ehAwareSplitEdge()
956 // If BB is in a loop and Succ is outside of that loop, we may need to in ehAwareSplitEdge()
964 createPHIsForSplitLoopExit(BB, NewBB, Succ); in ehAwareSplitEdge()
1005 for (BasicBlock *BB : Preds) in createPHIsForSplitLoopExit()
1006 NewPN->addIncoming(V, BB); in createPHIsForSplitLoopExit()
1017 for (BasicBlock &BB : F) { in SplitAllCriticalEdges()
1018 Instruction *TI = BB.getTerminator(); in SplitAllCriticalEdges()
1153 // the Entry BB is replaced. in UpdateAnalysisInformation()
1329 SplitBlockPredecessorsImpl(BasicBlock *BB, ArrayRef<BasicBlock *> Preds, in SplitBlockPredecessorsImpl() argument
1334 if (!BB->canSplitPredecessors()) in SplitBlockPredecessorsImpl()
1339 if (BB->isLandingPad()) { in SplitBlockPredecessorsImpl()
1343 SplitLandingPadPredecessorsImpl(BB, Preds, Suffix, NewName.c_str(), NewBBs, in SplitBlockPredecessorsImpl()
1350 BB->getContext(), BB->getName() + Suffix, BB->getParent(), BB); in SplitBlockPredecessorsImpl()
1353 BranchInst *BI = BranchInst::Create(BB, NewBB); in SplitBlockPredecessorsImpl()
1358 if (LI && LI->isLoopHeader(BB)) { in SplitBlockPredecessorsImpl()
1359 L = LI->getLoopFor(BB); in SplitBlockPredecessorsImpl()
1364 // If BB is the header of the Loop, it is possible that the loop is in SplitBlockPredecessorsImpl()
1370 BI->setDebugLoc(BB->getFirstNonPHIOrDbg()->getDebugLoc()); in SplitBlockPredecessorsImpl()
1372 // Move the edges from Preds to point to NewBB instead of BB. in SplitBlockPredecessorsImpl()
1375 // is that there be no more than one indirectbr branching to BB. And in SplitBlockPredecessorsImpl()
1379 Pred->getTerminator()->replaceSuccessorWith(BB, NewBB); in SplitBlockPredecessorsImpl()
1382 // Insert a new PHI node into NewBB for every PHI node in BB and that new PHI in SplitBlockPredecessorsImpl()
1383 // node becomes an incoming value for BB's phi node. However, if the Preds in SplitBlockPredecessorsImpl()
1384 // list is empty, we need to insert dummy entries into the PHI nodes in BB to in SplitBlockPredecessorsImpl()
1388 for (BasicBlock::iterator I = BB->begin(); isa<PHINode>(I); ++I) in SplitBlockPredecessorsImpl()
1394 UpdateAnalysisInformation(BB, NewBB, Preds, DTU, DT, LI, MSSAU, PreserveLCSSA, in SplitBlockPredecessorsImpl()
1398 // Update the PHI nodes in BB with the values coming from NewBB. in SplitBlockPredecessorsImpl()
1399 UpdatePHINodes(BB, NewBB, Preds, BI, HasLoopExit); in SplitBlockPredecessorsImpl()
1418 BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB, in SplitBlockPredecessors() argument
1423 return SplitBlockPredecessorsImpl(BB, Preds, Suffix, /*DTU=*/nullptr, DT, LI, in SplitBlockPredecessors()
1426 BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB, in SplitBlockPredecessors() argument
1432 return SplitBlockPredecessorsImpl(BB, Preds, Suffix, DTU, in SplitBlockPredecessors()
1457 // is that there be no more than one indirectbr branching to BB. And in SplitLandingPadPredecessorsImpl()
1550 ReturnInst *llvm::FoldReturnIntoUncondBranch(ReturnInst *RI, BasicBlock *BB, in FoldReturnIntoUncondBranch() argument
1559 // PHI node in "BB", propagate the right value into the return. in FoldReturnIntoUncondBranch()
1586 if (PN->getParent() == BB) { in FoldReturnIntoUncondBranch()
1599 BB->removePredecessor(Pred); in FoldReturnIntoUncondBranch()
1603 DTU->applyUpdates({{DominatorTree::Delete, Pred, BB}}); in FoldReturnIntoUncondBranch()
1674 auto handleBlock = [&](BasicBlock **PBB, bool Unreachable, BasicBlock *&BB, in SplitBlockAndInsertIfThenElse()
1680 BB = *PBB; // Caller supplied block, use it. in SplitBlockAndInsertIfThenElse()
1683 BB = BasicBlock::Create(C, "", Head->getParent(), Tail); in SplitBlockAndInsertIfThenElse()
1685 (void)new UnreachableInst(C, BB); in SplitBlockAndInsertIfThenElse()
1687 (void)BranchInst::Create(Tail, BB); in SplitBlockAndInsertIfThenElse()
1690 BB->getTerminator()->setDebugLoc(SplitBefore->getDebugLoc()); in SplitBlockAndInsertIfThenElse()
1692 *PBB = BB; in SplitBlockAndInsertIfThenElse()
1802 BranchInst *llvm::GetIfCondition(BasicBlock *BB, BasicBlock *&IfTrue, in GetIfCondition() argument
1804 PHINode *SomePHI = dyn_cast<PHINode>(BB->begin()); in GetIfCondition()
1814 pred_iterator PI = pred_begin(BB), PE = pred_end(BB); in GetIfCondition()
1849 // doesn't dominate BB. in GetIfCondition()
1854 // to BB and Pred2Br. If it doesn't, this isn't an "if statement". in GetIfCondition()
1855 if (Pred1Br->getSuccessor(0) == BB && in GetIfCondition()
1860 Pred1Br->getSuccessor(1) == BB) { in GetIfCondition()
1864 // We know that one arm of the conditional goes to BB, so the other must in GetIfCondition()
1873 // BB. Don't panic! If both blocks only have a single (identical) in GetIfCondition()
1946 redirectToHub(BasicBlock *BB, BasicBlock *FirstGuardBlock, in redirectToHub() argument
1948 assert(isa<BranchInst>(BB->getTerminator()) && in redirectToHub()
1950 auto Branch = cast<BranchInst>(BB->getTerminator()); in redirectToHub()
1970 BranchInst::Create(FirstGuardBlock, BB); in redirectToHub()
2012 "merged.bb.idx", FirstGuardBlock); in calcPredicateUsingInteger()
2029 IncomingId = SelectInst::Create(Condition, Id0, Id1, "target.bb.idx", in calcPredicateUsingInteger()
2216 for (auto &BB : F) { in hasOnlySimpleTerminator() local
2217 auto *Term = BB.getTerminator(); in hasOnlySimpleTerminator()