Lines Matching refs:BB

149 static void updatePredecessorProfileMetadata(PHINode *PN, BasicBlock *BB) {  in updatePredecessorProfileMetadata()  argument
150 BranchInst *CondBr = dyn_cast<BranchInst>(BB->getTerminator()); in updatePredecessorProfileMetadata()
204 auto PredOutEdge = GetPredOutEdge(PN->getIncomingBlock(i), BB); in updatePredecessorProfileMetadata()
318 for (auto &BB : *F) in runImpl()
319 if (!DT.isReachableFromEntry(&BB)) in runImpl()
320 Unreachable.insert(&BB); in runImpl()
329 for (auto &BB : *F) { in runImpl()
330 if (Unreachable.count(&BB)) in runImpl()
332 while (processBlock(&BB)) // Thread all of the branches we can over BB. in runImpl()
338 RemoveRedundantDbgInstrs(&BB); in runImpl()
343 if (&BB == &F->getEntryBlock() || DTU->isBBPendingDeletion(&BB)) in runImpl()
346 if (pred_empty(&BB)) { in runImpl()
349 LLVM_DEBUG(dbgs() << " JT: Deleting dead block '" << BB.getName() in runImpl()
350 << "' with terminator: " << *BB.getTerminator() in runImpl()
352 LoopHeaders.erase(&BB); in runImpl()
353 LVI->eraseBlock(&BB); in runImpl()
354 DeleteDeadBlock(&BB, DTU.get()); in runImpl()
361 auto *BI = dyn_cast<BranchInst>(BB.getTerminator()); in runImpl()
366 BB.getFirstNonPHIOrDbg(true)->isTerminator() && in runImpl()
369 !LoopHeaders.count(&BB) && !LoopHeaders.count(Succ) && in runImpl()
370 TryToSimplifyUncondBranchFromEmptyBlock(&BB, DTU.get())) { in runImpl()
374 LVI->eraseBlock(&BB); in runImpl()
428 BasicBlock *BB, in getJumpThreadDuplicationCost() argument
431 assert(StopAt->getParent() == BB && "Not an instruction from proper BB?"); in getJumpThreadDuplicationCost()
438 for (Instruction &I : *BB) { in getJumpThreadDuplicationCost()
454 if (BB->getTerminator() == StopAt) { in getJumpThreadDuplicationCost()
481 if (I->getType()->isTokenTy() && I->isUsedOutsideOfBlock(BB)) in getJumpThreadDuplicationCost()
560 Value *V, BasicBlock *BB, PredValueInfo &Result, in computeValueKnownInPredecessorsImpl() argument
563 const DataLayout &DL = BB->getModule()->getDataLayout(); in computeValueKnownInPredecessorsImpl()
574 for (BasicBlock *Pred : predecessors(BB)) in computeValueKnownInPredecessorsImpl()
583 if (!I || I->getParent() != BB) { in computeValueKnownInPredecessorsImpl()
587 for (BasicBlock *P : predecessors(BB)) { in computeValueKnownInPredecessorsImpl()
591 Constant *PredCst = LVI->getConstantOnEdge(V, P, BB, CxtI); in computeValueKnownInPredecessorsImpl()
600 auto Res = LVI->getPredicateOnEdge(Pred, Val, Cst, P, BB, CxtI); in computeValueKnownInPredecessorsImpl()
620 BB, CxtI); in computeValueKnownInPredecessorsImpl()
633 computeValueKnownInPredecessorsImpl(Source, BB, Vals, Preference, in computeValueKnownInPredecessorsImpl()
649 computeValueKnownInPredecessorsImpl(Source, BB, Result, Preference, in computeValueKnownInPredecessorsImpl()
671 computeValueKnownInPredecessorsImpl(Op0, BB, LHSVals, WantInteger, in computeValueKnownInPredecessorsImpl()
673 computeValueKnownInPredecessorsImpl(Op1, BB, RHSVals, WantInteger, in computeValueKnownInPredecessorsImpl()
709 computeValueKnownInPredecessorsImpl(I->getOperand(0), BB, Result, in computeValueKnownInPredecessorsImpl()
727 computeValueKnownInPredecessorsImpl(BO->getOperand(0), BB, LHSVals, in computeValueKnownInPredecessorsImpl()
759 if (PN && PN->getParent() == BB && !LoopHeaders.contains(BB)) { in computeValueKnownInPredecessorsImpl()
768 RHS = CmpRHS->DoPHITranslation(BB, PredBB); in computeValueKnownInPredecessorsImpl()
770 LHS = CmpLHS->DoPHITranslation(BB, PredBB); in computeValueKnownInPredecessorsImpl()
780 if (LHSInst && LHSInst->getParent() == BB) in computeValueKnownInPredecessorsImpl()
785 cast<Constant>(RHS), PredBB, BB, in computeValueKnownInPredecessorsImpl()
805 cast<Instruction>(CmpLHS)->getParent() != BB) { in computeValueKnownInPredecessorsImpl()
806 for (BasicBlock *P : predecessors(BB)) { in computeValueKnownInPredecessorsImpl()
811 CmpConst, P, BB, CxtI ? CxtI : Cmp); in computeValueKnownInPredecessorsImpl()
833 cast<Instruction>(AddLHS)->getParent() != BB) { in computeValueKnownInPredecessorsImpl()
834 for (BasicBlock *P : predecessors(BB)) { in computeValueKnownInPredecessorsImpl()
839 AddLHS, P, BB, CxtI ? CxtI : cast<Instruction>(CmpLHS)); in computeValueKnownInPredecessorsImpl()
866 computeValueKnownInPredecessorsImpl(I->getOperand(0), BB, LHSVals, in computeValueKnownInPredecessorsImpl()
887 computeValueKnownInPredecessorsImpl(SI->getCondition(), BB, Conds, in computeValueKnownInPredecessorsImpl()
915 assert(CxtI->getParent() == BB && "CxtI should be in BB"); in computeValueKnownInPredecessorsImpl()
918 for (BasicBlock *Pred : predecessors(BB)) in computeValueKnownInPredecessorsImpl()
930 static unsigned getBestDestForJumpOnUndef(BasicBlock *BB) { in getBestDestForJumpOnUndef() argument
931 Instruction *BBTerm = BB->getTerminator(); in getBestDestForJumpOnUndef()
948 static bool hasAddressTakenAndUsed(BasicBlock *BB) { in hasAddressTakenAndUsed() argument
949 if (!BB->hasAddressTaken()) return false; in hasAddressTakenAndUsed()
953 BlockAddress *BA = BlockAddress::get(BB); in hasAddressTakenAndUsed()
960 bool JumpThreadingPass::processBlock(BasicBlock *BB) { in processBlock() argument
963 if (DTU->isBBPendingDeletion(BB) || in processBlock()
964 (pred_empty(BB) && BB != &BB->getParent()->getEntryBlock())) in processBlock()
971 if (maybeMergeBasicBlockIntoOnlyPred(BB)) in processBlock()
974 if (tryToUnfoldSelectInCurrBB(BB)) in processBlock()
978 if (HasGuards && processGuards(BB)) in processBlock()
987 Instruction *Terminator = BB->getTerminator(); in processBlock()
1010 ConstantFoldInstruction(I, BB->getModule()->getDataLayout(), TLI); in processBlock()
1025 unsigned BestSucc = getBestDestForJumpOnUndef(BB); in processBlock()
1029 Instruction *BBTerm = BB->getTerminator(); in processBlock()
1034 Succ->removePredecessor(BB, true); in processBlock()
1035 Updates.push_back({DominatorTree::Delete, BB, Succ}); in processBlock()
1038 LLVM_DEBUG(dbgs() << " In block '" << BB->getName() in processBlock()
1053 LLVM_DEBUG(dbgs() << " In block '" << BB->getName() in processBlock()
1054 << "' folding terminator: " << *BB->getTerminator() in processBlock()
1057 ConstantFoldTerminator(BB, true, nullptr, DTU.get()); in processBlock()
1059 BPI->eraseBlock(BB); in processBlock()
1068 if (processThreadableEdges(Condition, BB, Preference, Terminator)) in processBlock()
1085 CondConst, BB->getTerminator(), in processBlock()
1098 if (replaceFoldableUses(CondCmp, CI, BB)) in processBlock()
1104 if (tryToUnfoldSelect(CondCmp, BB)) in processBlock()
1109 if (SwitchInst *SI = dyn_cast<SwitchInst>(BB->getTerminator())) in processBlock()
1110 if (tryToUnfoldSelect(SI, BB)) in processBlock()
1131 if (PN->getParent() == BB && isa<BranchInst>(BB->getTerminator())) in processBlock()
1132 updatePredecessorProfileMetadata(PN, BB); in processBlock()
1137 if (processThreadableEdges(CondInst, BB, Preference, Terminator)) in processBlock()
1143 if (PN && PN->getParent() == BB && isa<BranchInst>(BB->getTerminator())) in processBlock()
1148 CondInst->getParent() == BB && isa<BranchInst>(BB->getTerminator())) in processBlock()
1153 if (processImpliedCondition(BB)) in processBlock()
1159 bool JumpThreadingPass::processImpliedCondition(BasicBlock *BB) { in processImpliedCondition() argument
1160 auto *BI = dyn_cast<BranchInst>(BB->getTerminator()); in processImpliedCondition()
1176 BasicBlock *CurrentBB = BB; in processImpliedCondition()
1177 BasicBlock *CurrentPred = BB->getSinglePredecessor(); in processImpliedCondition()
1180 auto &DL = BB->getModule()->getDataLayout(); in processImpliedCondition()
1204 RemoveSucc->removePredecessor(BB); in processImpliedCondition()
1212 DTU->applyUpdatesPermissive({{DominatorTree::Delete, BB, RemoveSucc}}); in processImpliedCondition()
1214 BPI->eraseBlock(BB); in processImpliedCondition()
1225 static bool isOpDefinedInBlock(Value *Op, BasicBlock *BB) { in isOpDefinedInBlock() argument
1227 if (OpInst->getParent() == BB) in isOpDefinedInBlock()
1480 findMostPopularDest(BasicBlock *BB, in findMostPopularDest() argument
1496 for (auto *SuccBB : successors(BB)) in findMostPopularDest()
1513 Constant *JumpThreadingPass::evaluateOnPredecessorEdge(BasicBlock *BB, in evaluateOnPredecessorEdge() argument
1516 BasicBlock *PredBB = BB->getSinglePredecessor(); in evaluateOnPredecessorEdge()
1525 if (!I || (I->getParent() != BB && I->getParent() != PredBB)) { in evaluateOnPredecessorEdge()
1538 if (CondCmp->getParent() == BB) { in evaluateOnPredecessorEdge()
1540 evaluateOnPredecessorEdge(BB, PredPredBB, CondCmp->getOperand(0)); in evaluateOnPredecessorEdge()
1542 evaluateOnPredecessorEdge(BB, PredPredBB, CondCmp->getOperand(1)); in evaluateOnPredecessorEdge()
1553 bool JumpThreadingPass::processThreadableEdges(Value *Cond, BasicBlock *BB, in processThreadableEdges() argument
1558 if (LoopHeaders.count(BB)) in processThreadableEdges()
1562 if (!computeValueKnownInPredecessors(Cond, BB, PredValues, Preference, in processThreadableEdges()
1566 return maybethreadThroughTwoBasicBlocks(BB, Cond); in processThreadableEdges()
1572 LLVM_DEBUG(dbgs() << "IN BB: " << *BB; in processThreadableEdges()
1574 dbgs() << " BB '" << BB->getName() in processThreadableEdges()
1601 else if (BranchInst *BI = dyn_cast<BranchInst>(BB->getTerminator())) { in processThreadableEdges()
1604 } else if (SwitchInst *SI = dyn_cast<SwitchInst>(BB->getTerminator())) { in processThreadableEdges()
1608 assert(isa<IndirectBrInst>(BB->getTerminator()) in processThreadableEdges()
1643 if (BB->hasNPredecessors(PredToDestList.size())) { in processThreadableEdges()
1646 Updates.reserve(BB->getTerminator()->getNumSuccessors() - 1); in processThreadableEdges()
1647 for (BasicBlock *SuccBB : successors(BB)) { in processThreadableEdges()
1651 SuccBB->removePredecessor(BB, true); // This is unreachable successor. in processThreadableEdges()
1652 Updates.push_back({DominatorTree::Delete, BB, SuccBB}); in processThreadableEdges()
1657 Instruction *Term = BB->getTerminator(); in processThreadableEdges()
1663 BPI->eraseBlock(BB); in processThreadableEdges()
1678 replaceFoldableUses(CondInst, OnlyVal, BB); in processThreadableEdges()
1702 MostPopularDest = findMostPopularDest(BB, PredToDestList); in processThreadableEdges()
1716 if (Succ == BB) in processThreadableEdges()
1723 MostPopularDest = BB->getTerminator()-> in processThreadableEdges()
1724 getSuccessor(getBestDestForJumpOnUndef(BB)); in processThreadableEdges()
1727 return tryThreadEdge(BB, PredsToFactor, MostPopularDest); in processThreadableEdges()
1734 BasicBlock *BB = PN->getParent(); in processBranchOnPHI() local
1754 if (duplicateCondBranchOnPHIIntoPred(BB, PredBBs)) in processBranchOnPHI()
1766 BasicBlock *BB = BO->getParent(); in processBranchOnXOR() local
1776 if (!isa<PHINode>(BB->front())) in processBranchOnXOR()
1780 if (BB->isEHPad()) in processBranchOnXOR()
1803 if (!computeValueKnownInPredecessors(BO->getOperand(0), BB, XorOpValues, in processBranchOnXOR()
1806 if (!computeValueKnownInPredecessors(BO->getOperand(1), BB, XorOpValues, in processBranchOnXOR()
1831 SplitVal = ConstantInt::getTrue(BB->getContext()); in processBranchOnXOR()
1833 SplitVal = ConstantInt::getFalse(BB->getContext()); in processBranchOnXOR()
1848 cast<PHINode>(BB->front()).getNumIncomingValues()) { in processBranchOnXOR()
1873 return duplicateCondBranchOnPHIIntoPred(BB, BlocksToFoldInto); in processBranchOnXOR()
1900 bool JumpThreadingPass::maybeMergeBasicBlockIntoOnlyPred(BasicBlock *BB) { in maybeMergeBasicBlockIntoOnlyPred() argument
1901 BasicBlock *SinglePred = BB->getSinglePredecessor(); in maybeMergeBasicBlockIntoOnlyPred()
1907 SinglePred == BB || hasAddressTakenAndUsed(BB)) in maybeMergeBasicBlockIntoOnlyPred()
1912 LoopHeaders.insert(BB); in maybeMergeBasicBlockIntoOnlyPred()
1915 MergeBasicBlockIntoOnlyPred(BB, DTU.get()); in maybeMergeBasicBlockIntoOnlyPred()
1944 if (!isGuaranteedToTransferExecutionToSuccessor(BB)) in maybeMergeBasicBlockIntoOnlyPred()
1945 LVI->eraseBlock(BB); in maybeMergeBasicBlockIntoOnlyPred()
1952 BasicBlock *BB, BasicBlock *NewBB, in updateSSA() argument
1963 for (Instruction &I : *BB) { in updateSSA()
1969 if (UserPN->getIncomingBlock(U) == BB) in updateSSA()
1971 } else if (User->getParent() == BB) in updateSSA()
1980 return DbgVal->getParent() == BB; in updateSSA()
1983 return DPVal->getParent() == BB; in updateSSA()
1995 SSAUpdate.AddAvailableValue(BB, &I); in updateSSA()
2130 bool JumpThreadingPass::maybethreadThroughTwoBasicBlocks(BasicBlock *BB, in maybethreadThroughTwoBasicBlocks() argument
2149 BranchInst *CondBr = dyn_cast<BranchInst>(BB->getTerminator()); in maybethreadThroughTwoBasicBlocks()
2154 BasicBlock *PredBB = BB->getSinglePredecessor(); in maybethreadThroughTwoBasicBlocks()
2202 evaluateOnPredecessorEdge(BB, P, Cond))) { in maybethreadThroughTwoBasicBlocks()
2226 if (SuccBB == BB) { in maybethreadThroughTwoBasicBlocks()
2227 LLVM_DEBUG(dbgs() << " Not threading across BB '" << BB->getName() in maybethreadThroughTwoBasicBlocks()
2234 if (LoopHeaders.count(BB) || LoopHeaders.count(SuccBB)) { in maybethreadThroughTwoBasicBlocks()
2236 bool BBIsHeader = LoopHeaders.count(BB); in maybethreadThroughTwoBasicBlocks()
2240 << BB->getName() << "' to dest " in maybethreadThroughTwoBasicBlocks()
2250 TTI, BB, BB->getTerminator(), BBDupThreshold); in maybethreadThroughTwoBasicBlocks()
2259 LLVM_DEBUG(dbgs() << " Not threading BB '" << BB->getName() in maybethreadThroughTwoBasicBlocks()
2266 threadThroughTwoBasicBlocks(PredPredBB, PredBB, BB, SuccBB); in maybethreadThroughTwoBasicBlocks()
2272 BasicBlock *BB, in threadThroughTwoBasicBlocks() argument
2275 << BB->getName() << "'\n"); in threadThroughTwoBasicBlocks()
2278 bool HasProfile = doesBlockHaveProfileData(BB); in threadThroughTwoBasicBlocks()
2282 BranchInst *CondBr = cast<BranchInst>(BB->getTerminator()); in threadThroughTwoBasicBlocks()
2338 threadEdge(BB, PredsToFactor, SuccBB); in threadThroughTwoBasicBlocks()
2343 BasicBlock *BB, const SmallVectorImpl<BasicBlock *> &PredBBs, in tryThreadEdge() argument
2346 if (SuccBB == BB) { in tryThreadEdge()
2347 LLVM_DEBUG(dbgs() << " Not threading across BB '" << BB->getName() in tryThreadEdge()
2354 if (LoopHeaders.count(BB) || LoopHeaders.count(SuccBB)) { in tryThreadEdge()
2356 bool BBIsHeader = LoopHeaders.count(BB); in tryThreadEdge()
2359 << (BBIsHeader ? "loop header BB '" : "block BB '") << BB->getName() in tryThreadEdge()
2367 TTI, BB, BB->getTerminator(), BBDupThreshold); in tryThreadEdge()
2369 LLVM_DEBUG(dbgs() << " Not threading BB '" << BB->getName() in tryThreadEdge()
2374 threadEdge(BB, PredBBs, SuccBB); in tryThreadEdge()
2381 void JumpThreadingPass::threadEdge(BasicBlock *BB, in threadEdge() argument
2384 assert(SuccBB != BB && "Don't create an infinite loop"); in threadEdge()
2386 assert(!LoopHeaders.count(BB) && !LoopHeaders.count(SuccBB) && in threadEdge()
2390 bool HasProfile = doesBlockHaveProfileData(BB); in threadEdge()
2401 PredBB = splitBlockPreds(BB, PredBBs, ".thr_comm"); in threadEdge()
2407 << ", across block:\n " << *BB << "\n"); in threadEdge()
2409 LVI->threadEdge(PredBB, BB, SuccBB); in threadEdge()
2411 BasicBlock *NewBB = BasicBlock::Create(BB->getContext(), in threadEdge()
2412 BB->getName()+".thread", in threadEdge()
2413 BB->getParent(), BB); in threadEdge()
2420 BFI->getBlockFreq(PredBB) * BPI->getEdgeProbability(PredBB, BB); in threadEdge()
2426 cloneInstructions(BB->begin(), std::prev(BB->end()), NewBB, PredBB); in threadEdge()
2431 NewBI->setDebugLoc(BB->getTerminator()->getDebugLoc()); in threadEdge()
2435 addPHINodeEntriesForMappedBlock(SuccBB, BB, NewBB, ValueMapping); in threadEdge()
2442 if (PredTerm->getSuccessor(i) == BB) { in threadEdge()
2443 BB->removePredecessor(PredBB, true); in threadEdge()
2450 {DominatorTree::Delete, PredBB, BB}}); in threadEdge()
2452 updateSSA(BB, NewBB, ValueMapping); in threadEdge()
2460 updateBlockFreqAndEdgeWeight(PredBB, BB, NewBB, SuccBB, BFI, BPI, HasProfile); in threadEdge()
2469 BasicBlock *JumpThreadingPass::splitBlockPreds(BasicBlock *BB, in splitBlockPreds() argument
2482 Pred, BFI->getBlockFreq(Pred) * BPI->getEdgeProbability(Pred, BB))); in splitBlockPreds()
2487 if (BB->isLandingPad()) { in splitBlockPreds()
2489 SplitLandingPadPredecessors(BB, Preds, Suffix, NewName.c_str(), NewBBs); in splitBlockPreds()
2491 NewBBs.push_back(SplitBlockPredecessors(BB, Preds, Suffix)); in splitBlockPreds()
2498 Updates.push_back({DominatorTree::Insert, NewBB, BB}); in splitBlockPreds()
2500 Updates.push_back({DominatorTree::Delete, Pred, BB}); in splitBlockPreds()
2513 bool JumpThreadingPass::doesBlockHaveProfileData(BasicBlock *BB) { in doesBlockHaveProfileData() argument
2514 const Instruction *TI = BB->getTerminator(); in doesBlockHaveProfileData()
2525 BasicBlock *BB, in updateBlockFreqAndEdgeWeight() argument
2542 auto BBOrigFreq = BFI->getBlockFreq(BB); in updateBlockFreqAndEdgeWeight()
2544 auto BB2SuccBBFreq = BBOrigFreq * BPI->getEdgeProbability(BB, SuccBB); in updateBlockFreqAndEdgeWeight()
2546 BFI->setBlockFreq(BB, BBNewFreq); in updateBlockFreqAndEdgeWeight()
2551 for (BasicBlock *Succ : successors(BB)) { in updateBlockFreqAndEdgeWeight()
2554 : BBOrigFreq * BPI->getEdgeProbability(BB, Succ); in updateBlockFreqAndEdgeWeight()
2575 BPI->setEdgeProbability(BB, BBSuccProbs); in updateBlockFreqAndEdgeWeight()
2616 auto TI = BB->getTerminator(); in updateBlockFreqAndEdgeWeight()
2627 BasicBlock *BB, const SmallVectorImpl<BasicBlock *> &PredBBs) { in duplicateCondBranchOnPHIIntoPred() argument
2633 if (LoopHeaders.count(BB)) { in duplicateCondBranchOnPHIIntoPred()
2634 LLVM_DEBUG(dbgs() << " Not duplicating loop header '" << BB->getName() in duplicateCondBranchOnPHIIntoPred()
2641 TTI, BB, BB->getTerminator(), BBDupThreshold); in duplicateCondBranchOnPHIIntoPred()
2643 LLVM_DEBUG(dbgs() << " Not duplicating BB '" << BB->getName() in duplicateCondBranchOnPHIIntoPred()
2656 PredBB = splitBlockPreds(BB, PredBBs, ".thr_comm"); in duplicateCondBranchOnPHIIntoPred()
2658 Updates.push_back({DominatorTree::Delete, PredBB, BB}); in duplicateCondBranchOnPHIIntoPred()
2662 LLVM_DEBUG(dbgs() << " Duplicating block '" << BB->getName() in duplicateCondBranchOnPHIIntoPred()
2665 << DuplicationCost << " block is:" << *BB << "\n"); in duplicateCondBranchOnPHIIntoPred()
2673 PredBB = SplitEdge(OldPredBB, BB); in duplicateCondBranchOnPHIIntoPred()
2675 Updates.push_back({DominatorTree::Insert, PredBB, BB}); in duplicateCondBranchOnPHIIntoPred()
2676 Updates.push_back({DominatorTree::Delete, OldPredBB, BB}); in duplicateCondBranchOnPHIIntoPred()
2684 BasicBlock::iterator BI = BB->begin(); in duplicateCondBranchOnPHIIntoPred()
2689 for (; BI != BB->end(); ++BI) { in duplicateCondBranchOnPHIIntoPred()
2706 {BB->getModule()->getDataLayout(), TLI, nullptr, nullptr, New})) { in duplicateCondBranchOnPHIIntoPred()
2732 BranchInst *BBBranch = cast<BranchInst>(BB->getTerminator()); in duplicateCondBranchOnPHIIntoPred()
2733 addPHINodeEntriesForMappedBlock(BBBranch->getSuccessor(0), BB, PredBB, in duplicateCondBranchOnPHIIntoPred()
2735 addPHINodeEntriesForMappedBlock(BBBranch->getSuccessor(1), BB, PredBB, in duplicateCondBranchOnPHIIntoPred()
2738 updateSSA(BB, PredBB, ValueMapping); in duplicateCondBranchOnPHIIntoPred()
2742 BB->removePredecessor(PredBB, true); in duplicateCondBranchOnPHIIntoPred()
2747 BPI->copyEdgeProbabilities(BB, PredBB); in duplicateCondBranchOnPHIIntoPred()
2759 void JumpThreadingPass::unfoldSelectInstr(BasicBlock *Pred, BasicBlock *BB, in unfoldSelectInstr() argument
2772 BasicBlock *NewBB = BasicBlock::Create(BB->getContext(), "select.unfold", in unfoldSelectInstr()
2773 BB->getParent(), BB); in unfoldSelectInstr()
2778 auto *BI = BranchInst::Create(NewBB, BB, SI->getCondition(), Pred); in unfoldSelectInstr()
2812 DTU->applyUpdatesPermissive({{DominatorTree::Insert, NewBB, BB}, in unfoldSelectInstr()
2816 for (BasicBlock::iterator BI = BB->begin(); in unfoldSelectInstr()
2822 bool JumpThreadingPass::tryToUnfoldSelect(SwitchInst *SI, BasicBlock *BB) { in tryToUnfoldSelect() argument
2825 if (!CondPHI || CondPHI->getParent() != BB) in tryToUnfoldSelect()
2842 unfoldSelectInstr(Pred, BB, PredSI, CondPHI, I); in tryToUnfoldSelect()
2860 bool JumpThreadingPass::tryToUnfoldSelect(CmpInst *CondCmp, BasicBlock *BB) { in tryToUnfoldSelect() argument
2861 BranchInst *CondBr = dyn_cast<BranchInst>(BB->getTerminator()); in tryToUnfoldSelect()
2866 CondLHS->getParent() != BB) in tryToUnfoldSelect()
2887 CondRHS, Pred, BB, CondCmp); in tryToUnfoldSelect()
2890 CondRHS, Pred, BB, CondCmp); in tryToUnfoldSelect()
2894 unfoldSelectInstr(Pred, BB, SI, CondLHS, I); in tryToUnfoldSelect()
2921 bool JumpThreadingPass::tryToUnfoldSelectInCurrBB(BasicBlock *BB) { in tryToUnfoldSelectInCurrBB() argument
2924 if (BB->getParent()->hasFnAttribute(Attribute::SanitizeMemory)) in tryToUnfoldSelectInCurrBB()
2929 if (LoopHeaders.count(BB)) in tryToUnfoldSelectInCurrBB()
2932 for (BasicBlock::iterator BI = BB->begin(); in tryToUnfoldSelectInCurrBB()
2939 auto isUnfoldCandidate = [BB](SelectInst *SI, Value *V) { in tryToUnfoldSelectInCurrBB()
2943 if (SI->getParent() != BB) in tryToUnfoldSelectInCurrBB()
2955 if (Cmp->getParent() == BB && Cmp->hasOneUse() && in tryToUnfoldSelectInCurrBB()
2984 NewPN->addIncoming(SI->getFalseValue(), BB); in tryToUnfoldSelectInCurrBB()
2990 Updates.push_back({DominatorTree::Insert, BB, SplitBB}); in tryToUnfoldSelectInCurrBB()
2991 Updates.push_back({DominatorTree::Insert, BB, NewBB}); in tryToUnfoldSelectInCurrBB()
2995 Updates.push_back({DominatorTree::Delete, BB, Succ}); in tryToUnfoldSelectInCurrBB()
3023 bool JumpThreadingPass::processGuards(BasicBlock *BB) { in processGuards() argument
3028 auto PI = pred_begin(BB), PE = pred_end(BB); in processGuards()
3047 for (auto &I : *BB) in processGuards()
3048 if (isGuard(&I) && threadGuard(BB, cast<IntrinsicInst>(&I), BI)) in processGuards()
3057 bool JumpThreadingPass::threadGuard(BasicBlock *BB, IntrinsicInst *Guard, in threadGuard() argument
3066 auto &DL = BB->getModule()->getDataLayout(); in threadGuard()
3090 getJumpThreadDuplicationCost(TTI, BB, AfterGuard, BBDupThreshold); in threadGuard()
3096 BB, PredGuardedBlock, AfterGuard, GuardedMapping, *DTU); in threadGuard()
3102 BB, PredUnguardedBlock, Guard, UnguardedMapping, *DTU); in threadGuard()
3110 for (auto BI = BB->begin(); &*BI != AfterGuard; ++BI) in threadGuard()
3114 BasicBlock::iterator InsertionPoint = BB->getFirstInsertionPt(); in threadGuard()
3115 assert(InsertionPoint != BB->end() && "Empty block?"); in threadGuard()