Home | History | Annotate | Download | only in Utils

Lines Matching refs:BB

35 void llvm::DeleteDeadBlock(BasicBlock *BB) {
36 assert((pred_begin(BB) == pred_end(BB) ||
38 BB->getSinglePredecessor() == BB) && "Block is not dead!");
39 TerminatorInst *BBTerm = BB->getTerminator();
44 BBTerm->getSuccessor(i)->removePredecessor(BB);
47 while (!BB->empty()) {
48 Instruction &I = BB->back();
56 BB->getInstList().pop_back();
60 BB->eraseFromParent();
63 /// FoldSingleEntryPHINodes - We know that BB has one predecessor. If there are
67 void llvm::FoldSingleEntryPHINodes(BasicBlock *BB, Pass *P) {
68 if (!isa<PHINode>(BB->begin())) return;
77 while (PHINode *PN = dyn_cast<PHINode>(BB->begin())) {
97 bool llvm::DeleteDeadPHIs(BasicBlock *BB) {
101 for (BasicBlock::iterator I = BB->begin();
115 bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, Pass *P) {
117 if (BB->hasAddressTaken()) return false;
120 BasicBlock *PredBB = BB->getUniquePredecessor();
124 if (PredBB == BB) return false;
129 BasicBlock *OnlySucc = BB;
140 for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE; ++BI) {
150 if (isa<PHINode>(BB->front()))
151 FoldSingleEntryPHINodes(BB, P);
156 // Make all PHI nodes that referred to BB now refer to Pred as their
158 BB->replaceAllUsesWith(PredBB);
161 PredBB->getInstList().splice(PredBB->end(), BB->getInstList());
165 PredBB->takeName(BB);
170 if (DomTreeNode *DTN = DT->getNode(BB)) {
177 DT->eraseNode(BB);
181 LI->removeBlock(BB);
189 BB->eraseFromParent();
238 /// GetSuccessorNumber - Search for the specified successor of basic block BB
242 unsigned llvm::GetSuccessorNumber(BasicBlock *BB, BasicBlock *Succ) {
243 TerminatorInst *Term = BB->getTerminator();
257 BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock *Succ, Pass *P) {
258 unsigned SuccNum = GetSuccessorNumber(BB, Succ);
261 TerminatorInst *LatchTerm = BB->getTerminator();
265 // If the edge isn't critical, then BB has a single successor or Succ has a
271 assert(SP == BB && "CFG broken");
276 // Otherwise, if BB has a single successor, split it at the bottom of the
278 assert(BB->getTerminator()->getNumSuccessors() == 1 &&
280 return SplitBlock(BB, BB->getTerminator(), P);
444 /// SplitBlockPredecessors - This method transforms BB by introducing a new
445 /// basic block into the function, and moving some of the predecessors of BB to
455 BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB,
460 BasicBlock *NewBB = BasicBlock::Create(BB->getContext(), BB->getName()+Suffix,
461 BB->getParent(), BB);
464 BranchInst *BI = BranchInst::Create(BB, NewBB);
466 // Move the edges from Preds to point to NewBB instead of BB.
469 // is that there be no more than one indirectbr branching to BB. And
473 Preds[i]->getTerminator()->replaceUsesOfWith(BB, NewBB);
476 // Insert a new PHI node into NewBB for every PHI node in BB and that new PHI
477 // node becomes an incoming value for BB's phi node. However, if the Preds
478 // list is empty, we need to insert dummy entries into the PHI nodes in BB to
482 for (BasicBlock::iterator I = BB->begin(); isa<PHINode>(I); ++I)
489 UpdateAnalysisInformation(BB, NewBB, ArrayRef<BasicBlock*>(Preds, NumPreds),
492 // Update the PHI nodes in BB with the values coming from NewBB.
493 UpdatePHINodes(BB, NewBB, ArrayRef<BasicBlock*>(Preds, NumPreds), BI,
531 // is that there be no more than one indirectbr branching to BB. And
612 const BasicBlock *BB = &F.getEntryBlock();
613 if (succ_begin(BB) == succ_end(BB))
620 Visited.insert(BB);
621 VisitStack.push_back(std::make_pair(BB, succ_begin(BB)));
622 InStack.insert(BB);
630 BB = *I++;
631 if (Visited.insert(BB)) {
636 if (InStack.count(BB))
637 Result.push_back(std::make_pair(ParentBB, BB));
642 InStack.insert(BB);
643 VisitStack.push_back(std::make_pair(BB, succ_begin(BB)));
656 ReturnInst *llvm::FoldReturnIntoUncondBranch(ReturnInst *RI, BasicBlock *BB,
664 // PHI node in "BB", propagate the right value into the return.
668 if (PN->getParent() == BB)
673 BB->removePredecessor(Pred);
680 DebugLoc llvm::GetFirstDebugLocInBasicBlock(const BasicBlock *BB) {
681 if (const Instruction *I = BB->getFirstNonPHI())