diff --git a/include/swift/SIL/SILBasicBlock.h b/include/swift/SIL/SILBasicBlock.h index 916fde5d161..5973b89486a 100644 --- a/include/swift/SIL/SILBasicBlock.h +++ b/include/swift/SIL/SILBasicBlock.h @@ -211,18 +211,18 @@ public: const_succ_iterator succ_begin() const { return getSuccessors().begin(); } const_succ_iterator succ_end() const { return getSuccessors().end(); } - SILBasicBlock *getSingleSuccessor() { + SILBasicBlock *getSingleSuccessorBlock() { if (succ_empty() || std::next(succ_begin()) != succ_end()) return nullptr; return *succ_begin(); } - const SILBasicBlock *getSingleSuccessor() const { - return const_cast(this)->getSingleSuccessor(); + const SILBasicBlock *getSingleSuccessorBlock() const { + return const_cast(this)->getSingleSuccessorBlock(); } /// \brief Returns true if \p BB is a successor of this block. - bool isSuccessor(SILBasicBlock *BB) const { + bool isSuccessorBlock(SILBasicBlock *BB) const { auto Range = getSuccessorBlocks(); return any_of(Range, [&BB](const SILBasicBlock *SuccBB) -> bool { return BB == SuccBB; @@ -256,26 +256,30 @@ public: pred_iterator pred_begin() const { return pred_iterator(PredList); } pred_iterator pred_end() const { return pred_iterator(); } - iterator_range getPreds() const { - return {pred_begin(), pred_end() }; + iterator_range getPredecessorBlocks() const { + return {pred_begin(), pred_end()}; } - bool isPredecessor(SILBasicBlock *BB) const { - return any_of(getPreds(), [&BB](const SILBasicBlock *PredBB) -> bool { - return BB == PredBB; - }); + bool isPredecessorBlock(SILBasicBlock *BB) const { + return any_of( + getPredecessorBlocks(), + [&BB](const SILBasicBlock *PredBB) -> bool { return BB == PredBB; }); } - SILBasicBlock *getSinglePredecessor() { + SILBasicBlock *getSinglePredecessorBlock() { if (pred_empty() || std::next(pred_begin()) != pred_end()) return nullptr; return *pred_begin(); } - const SILBasicBlock *getSinglePredecessor() const { - return const_cast(this)->getSinglePredecessor(); + const SILBasicBlock *getSinglePredecessorBlock() const { + return const_cast(this)->getSinglePredecessorBlock(); } + //===--------------------------------------------------------------------===// + // Debugging + //===--------------------------------------------------------------------===// + /// Pretty-print the SILBasicBlock. void dump() const; diff --git a/include/swift/SILOptimizer/Utils/SCCVisitor.h b/include/swift/SILOptimizer/Utils/SCCVisitor.h index c2c66efc9d7..1fc684380a1 100644 --- a/include/swift/SILOptimizer/Utils/SCCVisitor.h +++ b/include/swift/SILOptimizer/Utils/SCCVisitor.h @@ -154,7 +154,7 @@ private: auto *BB = A->getParent(); auto Index = A->getIndex(); - for (auto *Pred : BB->getPreds()) + for (auto *Pred : BB->getPredecessorBlocks()) getArgsForTerminator(Pred->getTerminator(), BB, Index, Operands); return; } diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp index 87ce929ddbe..668202a164d 100644 --- a/lib/IRGen/IRGenSIL.cpp +++ b/lib/IRGen/IRGenSIL.cpp @@ -2041,7 +2041,7 @@ void IRGenSILFunction::visitFullApplySite(FullApplySite site) { // Zero the error slot to maintain the invariant that it always // contains null. This will frequently become a dead store. auto nullError = llvm::Constant::getNullValue(errorValue->getType()); - if (!tryApplyInst->getErrorBB()->getSinglePredecessor()) { + if (!tryApplyInst->getErrorBB()->getSinglePredecessorBlock()) { // Only do that here if we can't move the store to the error block. // See below. Builder.CreateStore(nullError, errorSlot); @@ -2059,8 +2059,8 @@ void IRGenSILFunction::visitFullApplySite(FullApplySite site) { // Set up the PHI nodes on the error edge. assert(errorDest.phis.size() == 1); errorDest.phis[0]->addIncoming(errorValue, Builder.GetInsertBlock()); - - if (tryApplyInst->getErrorBB()->getSinglePredecessor()) { + + if (tryApplyInst->getErrorBB()->getSinglePredecessorBlock()) { // Zeroing out the error slot only in the error block increases the chance // that it will become a dead store. auto origBB = Builder.GetInsertBlock(); diff --git a/lib/SIL/InstructionUtils.cpp b/lib/SIL/InstructionUtils.cpp index 6f92f929166..18b532b4e4a 100644 --- a/lib/SIL/InstructionUtils.cpp +++ b/lib/SIL/InstructionUtils.cpp @@ -86,7 +86,7 @@ SILValue swift::stripSinglePredecessorArgs(SILValue V) { // First try and grab the single predecessor of our parent BB. If we don't // have one, bail. - SILBasicBlock *Pred = BB->getSinglePredecessor(); + SILBasicBlock *Pred = BB->getSinglePredecessorBlock(); if (!Pred) return V; diff --git a/lib/SIL/SILArgument.cpp b/lib/SIL/SILArgument.cpp index c3349b2f390..5e55407f003 100644 --- a/lib/SIL/SILArgument.cpp +++ b/lib/SIL/SILArgument.cpp @@ -86,7 +86,7 @@ static SILValue getIncomingValueForPred(const SILBasicBlock *BB, SILValue SILArgument::getSingleIncomingValue() const { const SILBasicBlock *Parent = getParent(); - const SILBasicBlock *PredBB = Parent->getSinglePredecessor(); + const SILBasicBlock *PredBB = Parent->getSinglePredecessorBlock(); if (!PredBB) return SILValue(); return getIncomingValueForPred(Parent, PredBB, getIndex()); @@ -99,7 +99,7 @@ bool SILArgument::getIncomingValues(llvm::SmallVectorImpl &OutArray) { return false; unsigned Index = getIndex(); - for (SILBasicBlock *Pred : getParent()->getPreds()) { + for (SILBasicBlock *Pred : getParent()->getPredecessorBlocks()) { SILValue Value = getIncomingValueForPred(Parent, Pred, Index); if (!Value) return false; @@ -117,7 +117,7 @@ bool SILArgument::getIncomingValues( return false; unsigned Index = getIndex(); - for (SILBasicBlock *Pred : getParent()->getPreds()) { + for (SILBasicBlock *Pred : getParent()->getPredecessorBlocks()) { SILValue Value = getIncomingValueForPred(Parent, Pred, Index); if (!Value) return false; @@ -142,7 +142,7 @@ SILValue SILArgument::getIncomingValue(unsigned BBIndex) { // We use this funky loop since predecessors are stored in a linked list but // we want array like semantics. unsigned BBCount = 0; - for (SILBasicBlock *Pred : Parent->getPreds()) { + for (SILBasicBlock *Pred : Parent->getPredecessorBlocks()) { // If BBCount is not BBIndex, continue. if (BBCount < BBIndex) { BBCount++; diff --git a/lib/SIL/SILPrinter.cpp b/lib/SIL/SILPrinter.cpp index 7a048d1dc05..823bde699f8 100644 --- a/lib/SIL/SILPrinter.cpp +++ b/lib/SIL/SILPrinter.cpp @@ -523,7 +523,7 @@ public: *this << "// Preds:"; llvm::SmallVector PredIDs; - for (auto *BBI : BB->getPreds()) + for (auto *BBI : BB->getPredecessorBlocks()) PredIDs.push_back(getID(BBI)); // Display the pred ids sorted to give a stable use order in the printer's diff --git a/lib/SIL/SILVerifier.cpp b/lib/SIL/SILVerifier.cpp index e19e6b18b90..7ef023e8956 100644 --- a/lib/SIL/SILVerifier.cpp +++ b/lib/SIL/SILVerifier.cpp @@ -3397,7 +3397,7 @@ public: // And its destination block has more than one predecessor. SILBasicBlock *DestBB = SrcSuccs[EdgeIdx]; assert(!DestBB->pred_empty() && "There should be a predecessor"); - if (DestBB->getSinglePredecessor()) + if (DestBB->getSinglePredecessorBlock()) return false; return true; @@ -3437,16 +3437,16 @@ public: // have this basic block in its predecessor/successor list. for (const auto *SuccBB : BB->getSuccessorBlocks()) { bool FoundSelfInSuccessor = false; - if (SuccBB->isPredecessor(BB)) { + if (SuccBB->isPredecessorBlock(BB)) { FoundSelfInSuccessor = true; break; } require(FoundSelfInSuccessor, "Must be a predecessor of each successor."); } - for (const SILBasicBlock *PredBB : BB->getPreds()) { + for (const SILBasicBlock *PredBB : BB->getPredecessorBlocks()) { bool FoundSelfInPredecessor = false; - if (PredBB->isSuccessor(BB)) { + if (PredBB->isSuccessorBlock(BB)) { FoundSelfInPredecessor = true; break; } diff --git a/lib/SILGen/SILGenPattern.cpp b/lib/SILGen/SILGenPattern.cpp index 9887f21866e..e84d0f3bc44 100644 --- a/lib/SILGen/SILGenPattern.cpp +++ b/lib/SILGen/SILGenPattern.cpp @@ -1989,7 +1989,7 @@ void PatternMatchEmission::emitSharedCaseBlocks() { // predecessor. We rely on the SIL CFG here, because unemitted shared case // blocks might fallthrough into this one. if (!hasFallthroughTo && caseBlock->getCaseLabelItems().size() == 1) { - SILBasicBlock *predBB = caseBB->getSinglePredecessor(); + SILBasicBlock *predBB = caseBB->getSinglePredecessorBlock(); assert(predBB && "Should only have 1 predecessor because it isn't shared"); assert(isa(predBB->getTerminator()) && "Should have uncond branch to shared block"); diff --git a/lib/SILOptimizer/ARC/GlobalARCSequenceDataflow.cpp b/lib/SILOptimizer/ARC/GlobalARCSequenceDataflow.cpp index e397d07984d..53e4a829b8a 100644 --- a/lib/SILOptimizer/ARC/GlobalARCSequenceDataflow.cpp +++ b/lib/SILOptimizer/ARC/GlobalARCSequenceDataflow.cpp @@ -123,7 +123,7 @@ void ARCSequenceDataflowEvaluator::mergePredecessors( ARCBBState &BBState = DataHandle.getState(); // For each successor of BB... - for (SILBasicBlock *PredBB : BB->getPreds()) { + for (SILBasicBlock *PredBB : BB->getPredecessorBlocks()) { // Try to look up the data handle for it. If we don't have any such state, // then the predecessor must be unreachable from the entrance and thus is @@ -295,7 +295,7 @@ bool ARCSequenceDataflowEvaluator::processBBBottomUp( // that this block could not have multiple predecessors since otherwise, the // edge would be broken. llvm::TinyPtrVector PredTerminators; - for (SILBasicBlock *PredBB : BB.getPreds()) { + for (SILBasicBlock *PredBB : BB.getPredecessorBlocks()) { auto *TermInst = PredBB->getTerminator(); if (!isARCSignificantTerminator(TermInst)) continue; diff --git a/lib/SILOptimizer/Analysis/ARCAnalysis.cpp b/lib/SILOptimizer/Analysis/ARCAnalysis.cpp index e878a4a6d7d..cfe7c4b8272 100644 --- a/lib/SILOptimizer/Analysis/ARCAnalysis.cpp +++ b/lib/SILOptimizer/Analysis/ARCAnalysis.cpp @@ -622,7 +622,8 @@ findMatchingRetains(SILBasicBlock *BB) { // Did not find a retain in this block, try to go to its predecessors. if (Kind.first == FindRetainKind::None) { // We can not find a retain in a block with no predecessors. - if (R.first->getPreds().begin() == R.first->getPreds().end()) { + if (R.first->getPredecessorBlocks().begin() == + R.first->getPredecessorBlocks().end()) { EpilogueRetainInsts.clear(); return; } @@ -636,7 +637,7 @@ findMatchingRetains(SILBasicBlock *BB) { if (SA && SA->getParent() != R.first) SA = nullptr; - for (auto X : R.first->getPreds()) { + for (auto X : R.first->getPredecessorBlocks()) { if (HandledBBs.find(X) != HandledBBs.end()) continue; // Try to use the predecessor edge-value. @@ -875,7 +876,7 @@ static void propagateLiveness(llvm::SmallPtrSetImpl &LiveIn, // First populate a worklist of predecessors. llvm::SmallVector Worklist; for (auto *BB : LiveIn) - for (auto Pred : BB->getPreds()) + for (auto Pred : BB->getPredecessorBlocks()) Worklist.push_back(Pred); // Now propagate liveness backwards until we hit the alloc_box. @@ -887,7 +888,7 @@ static void propagateLiveness(llvm::SmallPtrSetImpl &LiveIn, if (BB == DefBB || !LiveIn.insert(BB).second) continue; - for (auto Pred : BB->getPreds()) + for (auto Pred : BB->getPredecessorBlocks()) Worklist.push_back(Pred); } } diff --git a/lib/SILOptimizer/Analysis/EpilogueARCAnalysis.cpp b/lib/SILOptimizer/Analysis/EpilogueARCAnalysis.cpp index d198c59ddbe..3148a4a6dbd 100644 --- a/lib/SILOptimizer/Analysis/EpilogueARCAnalysis.cpp +++ b/lib/SILOptimizer/Analysis/EpilogueARCAnalysis.cpp @@ -46,7 +46,7 @@ void EpilogueARCContext::initializeDataflow() { SILArgument *A = dyn_cast(CArg); if (A && !A->isFunctionArg()) { // Find predecessor and break the SILArgument to predecessors. - for (auto X : A->getParent()->getPreds()) { + for (auto X : A->getParent()->getPredecessorBlocks()) { // Try to find the predecessor edge-value. SILValue IA = A->getIncomingValue(X); EpilogueARCBlockStates[X]->LocalArg = IA; diff --git a/lib/SILOptimizer/Analysis/EscapeAnalysis.cpp b/lib/SILOptimizer/Analysis/EscapeAnalysis.cpp index ac11c6e13d0..8a7b77af588 100644 --- a/lib/SILOptimizer/Analysis/EscapeAnalysis.cpp +++ b/lib/SILOptimizer/Analysis/EscapeAnalysis.cpp @@ -989,7 +989,7 @@ static bool linkBBArgs(SILBasicBlock *BB) { return false; // We don't need to link to the try_apply's normal result argument, because // we handle it separately in setAllEscaping() and mergeCalleeGraph(). - if (SILBasicBlock *SinglePred = BB->getSinglePredecessor()) { + if (SILBasicBlock *SinglePred = BB->getSinglePredecessorBlock()) { auto *TAI = dyn_cast(SinglePred->getTerminator()); if (TAI && BB == TAI->getNormalBB()) return false; diff --git a/lib/SILOptimizer/Analysis/LoopRegionAnalysis.cpp b/lib/SILOptimizer/Analysis/LoopRegionAnalysis.cpp index 7c1cf019bf5..3f66fb25aa6 100644 --- a/lib/SILOptimizer/Analysis/LoopRegionAnalysis.cpp +++ b/lib/SILOptimizer/Analysis/LoopRegionAnalysis.cpp @@ -204,7 +204,7 @@ void LoopRegionFunctionInfo::verify() { // If R and OtherR are blocks, then OtherR should be a successor of the // real block. if (R->isBlock() && OtherR->isBlock()) - assert(R->getBlock()->isSuccessor(OtherR->getBlock()) && + assert(R->getBlock()->isSuccessorBlock(OtherR->getBlock()) && "Expected either R was not a block or OtherR was a CFG level " "successor of R."); } @@ -298,7 +298,7 @@ void LoopRegionFunctionInfo::initializeBlockRegionSuccessors( void LoopRegionFunctionInfo::markIrreducibleLoopPredecessorsOfNonLoopHeader( BlockTy *NonHeaderBB, RegionTy *NonHeaderBBRegion, PostOrderFunctionInfo *PI) { - for (BlockTy *Pred : NonHeaderBB->getPreds()) { + for (BlockTy *Pred : NonHeaderBB->getPredecessorBlocks()) { // If we do not have an RPO number for a predecessor, it is because the // predecessor is unreachable and a pass did not clean up after // itself. Just ignore it, it will be cleaned up by simplify-cfg. diff --git a/lib/SILOptimizer/Analysis/RCIdentityAnalysis.cpp b/lib/SILOptimizer/Analysis/RCIdentityAnalysis.cpp index 62e4dea7438..26c01729861 100644 --- a/lib/SILOptimizer/Analysis/RCIdentityAnalysis.cpp +++ b/lib/SILOptimizer/Analysis/RCIdentityAnalysis.cpp @@ -166,7 +166,7 @@ static llvm::Optional proveNonPayloadedEnumCase(SILBasicBlock *BB, SILValue RCIdentity) { // Then see if BB has one predecessor... if it does not, return None so we // keep searching up the domtree. - SILBasicBlock *SinglePred = BB->getSinglePredecessor(); + SILBasicBlock *SinglePred = BB->getSinglePredecessorBlock(); if (!SinglePred) return None; diff --git a/lib/SILOptimizer/Analysis/SimplifyInstruction.cpp b/lib/SILOptimizer/Analysis/SimplifyInstruction.cpp index 68a9b2b0384..4aca53d46c5 100644 --- a/lib/SILOptimizer/Analysis/SimplifyInstruction.cpp +++ b/lib/SILOptimizer/Analysis/SimplifyInstruction.cpp @@ -230,8 +230,8 @@ SILValue InstSimplifier::visitEnumInst(EnumInst *EI) { SILBasicBlock *EnumBlock = EI->getParent(); if (EnumArg->getParent() != EnumBlock) return SILValue(); - - auto *Pred = EnumBlock->getSinglePredecessor(); + + auto *Pred = EnumBlock->getSinglePredecessorBlock(); if (!Pred) return SILValue(); @@ -257,7 +257,7 @@ SILValue InstSimplifier::visitEnumInst(EnumInst *EI) { // // we'll return %0 auto *BB = EI->getParent(); - auto *Pred = BB->getSinglePredecessor(); + auto *Pred = BB->getSinglePredecessorBlock(); if (!Pred) return SILValue(); diff --git a/lib/SILOptimizer/IPO/GlobalPropertyOpt.cpp b/lib/SILOptimizer/IPO/GlobalPropertyOpt.cpp index ee9c540ecab..7cbca3aad45 100644 --- a/lib/SILOptimizer/IPO/GlobalPropertyOpt.cpp +++ b/lib/SILOptimizer/IPO/GlobalPropertyOpt.cpp @@ -400,7 +400,7 @@ void GlobalPropertyOpt::scanInstructions() { bool hasPreds = false; SILType Type = BBArg->getType(); if (isArrayType(Type) || isTupleWithArray(Type.getSwiftRValueType())) { - for (auto *Pred : BB.getPreds()) { + for (auto *Pred : BB.getPredecessorBlocks()) { hasPreds = true; auto *Term = Pred->getTerminator(); SILValue PredArg; diff --git a/lib/SILOptimizer/LoopTransforms/ArrayBoundsCheckOpts.cpp b/lib/SILOptimizer/LoopTransforms/ArrayBoundsCheckOpts.cpp index 2238c4a9ccb..dac7ff06a92 100644 --- a/lib/SILOptimizer/LoopTransforms/ArrayBoundsCheckOpts.cpp +++ b/lib/SILOptimizer/LoopTransforms/ArrayBoundsCheckOpts.cpp @@ -668,7 +668,7 @@ static bool isRangeChecked(SILValue Start, SILValue End, return true; // Look for a branch on EQ around the Preheader. - auto *PreheaderPred = Preheader->getSinglePredecessor(); + auto *PreheaderPred = Preheader->getSinglePredecessorBlock(); if (!PreheaderPred) return false; auto *CondBr = dyn_cast(PreheaderPred->getTerminator()); @@ -1182,9 +1182,9 @@ static bool hoistBoundsChecks(SILLoop *Loop, DominanceInfo *DT, SILLoopInfo *LI, return Changed; // Look back a split edge. - if (!Loop->isLoopExiting(Latch) && Latch->getSinglePredecessor() && - Loop->isLoopExiting(Latch->getSinglePredecessor())) - Latch = Latch->getSinglePredecessor(); + if (!Loop->isLoopExiting(Latch) && Latch->getSinglePredecessorBlock() && + Loop->isLoopExiting(Latch->getSinglePredecessorBlock())) + Latch = Latch->getSinglePredecessorBlock(); if (Loop->isLoopExiting(Latch) && Latch->getSuccessors().size() == 2) { ExitingBlk = Latch; ExitBlk = Loop->contains(Latch->getSuccessors()[0]) diff --git a/lib/SILOptimizer/LoopTransforms/COWArrayOpt.cpp b/lib/SILOptimizer/LoopTransforms/COWArrayOpt.cpp index 5307128668b..790ac2d210b 100644 --- a/lib/SILOptimizer/LoopTransforms/COWArrayOpt.cpp +++ b/lib/SILOptimizer/LoopTransforms/COWArrayOpt.cpp @@ -1965,7 +1965,7 @@ public: // inside the cloned region. The SSAUpdater can't handle critical non // cond_br edges. for (auto *BB : OutsideBBs) { - SmallVector Preds(BB->getPreds()); + SmallVector Preds(BB->getPredecessorBlocks()); for (auto *Pred : Preds) if (!isa(Pred->getTerminator()) && !isa(Pred->getTerminator())) @@ -2120,7 +2120,8 @@ public: SILLoop *getLoop() { auto *LoopInfo = LoopAnalysis->get(HoistableLoopPreheader->getParent()); - return LoopInfo->getLoopFor(HoistableLoopPreheader->getSingleSuccessor()); + return LoopInfo->getLoopFor( + HoistableLoopPreheader->getSingleSuccessorBlock()); } protected: @@ -2234,7 +2235,7 @@ void ArrayPropertiesSpecializer::specializeLoopNest() { HoistableLoopPreheader->getTerminator(), DomTree, nullptr); // Get the exit blocks of the original loop. - auto *Header = CheckBlock->getSingleSuccessor(); + auto *Header = CheckBlock->getSingleSuccessorBlock(); assert(Header); // Our loop info is not really completely valid anymore since the cloner does diff --git a/lib/SILOptimizer/LoopTransforms/LoopRotate.cpp b/lib/SILOptimizer/LoopTransforms/LoopRotate.cpp index e64cb0fa8e1..98a03a147e6 100644 --- a/lib/SILOptimizer/LoopTransforms/LoopRotate.cpp +++ b/lib/SILOptimizer/LoopTransforms/LoopRotate.cpp @@ -233,10 +233,11 @@ static bool isSingleBlockLoop(SILLoop *L) { if (BackEdge == Header) BackEdge = Blocks[0]; - if (!BackEdge->getSingleSuccessor()) + if (!BackEdge->getSingleSuccessorBlock()) return false; - assert(BackEdge->getSingleSuccessor() == Header && "Loop not well formed"); + assert(BackEdge->getSingleSuccessorBlock() == Header && + "Loop not well formed"); // Check whether the back-edge block is just a split-edge. return ++BackEdge->begin() == BackEdge->end(); @@ -315,7 +316,7 @@ bool swift::rotateLoop(SILLoop *L, DominanceInfo *DT, SILLoopInfo *LI, // We don't want to rotate such that we merge two headers of separate loops // into one. This can be turned into an assert again once we have guaranteed // preheader insertions. - if (!NewHeader->getSinglePredecessor() && Header != Latch) + if (!NewHeader->getSinglePredecessorBlock() && Header != Latch) return false; // Now that we know we can perform the rotation - move the instructions that diff --git a/lib/SILOptimizer/LoopTransforms/LoopUnroll.cpp b/lib/SILOptimizer/LoopTransforms/LoopUnroll.cpp index 4312e22aa32..cc50f41c31b 100644 --- a/lib/SILOptimizer/LoopTransforms/LoopUnroll.cpp +++ b/lib/SILOptimizer/LoopTransforms/LoopUnroll.cpp @@ -110,7 +110,8 @@ static Optional getMaxLoopTripCount(SILLoop *Loop, // Skip a split backedge. SILBasicBlock *OrigLatch = Latch; - if (!Loop->isLoopExiting(Latch) && !(Latch = Latch->getSinglePredecessor())) + if (!Loop->isLoopExiting(Latch) && + !(Latch = Latch->getSinglePredecessorBlock())) return None; if (!Loop->isLoopExiting(Latch)) return None; @@ -215,8 +216,8 @@ static void redirectTerminator(SILBasicBlock *Latch, unsigned CurLoopIter, // On the last iteration change the conditional exit to an unconditional // one. if (CurLoopIter == LastLoopIter) { - auto *CondBr = - cast(Latch->getSinglePredecessor()->getTerminator()); + auto *CondBr = cast( + Latch->getSinglePredecessorBlock()->getTerminator()); if (CondBr->getTrueBB() != Latch) SILBuilder(CondBr).createBranch(CondBr->getLoc(), CondBr->getTrueBB(), CondBr->getTrueArgs()); diff --git a/lib/SILOptimizer/Mandatory/DIMemoryUseCollector.cpp b/lib/SILOptimizer/Mandatory/DIMemoryUseCollector.cpp index dbe6b0e2fbf..bd9333d0e20 100644 --- a/lib/SILOptimizer/Mandatory/DIMemoryUseCollector.cpp +++ b/lib/SILOptimizer/Mandatory/DIMemoryUseCollector.cpp @@ -1144,7 +1144,7 @@ static bool isSelfInitUse(SILArgument *Arg) { // predecessor to the block, and the predecessor instruction is a try_apply // of a throwing delegated init. auto *BB = Arg->getParent(); - auto *Pred = BB->getSinglePredecessor(); + auto *Pred = BB->getSinglePredecessorBlock(); // The two interesting cases are where self.init throws, in which case // the argument came from a try_apply, or if self.init is failable, diff --git a/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp b/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp index fcf0558d161..e44951fc87b 100644 --- a/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp +++ b/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp @@ -1458,7 +1458,7 @@ void LifetimeChecker::handleLoadUseFailure(const DIMemoryUse &Use, // Otherwise, there are multiple paths to the epilog block, scan its // predecessors to see if there are any where the value is unavailable. // If so, we can use its location information for more precision. - for (auto pred : LI->getParent()->getPreds()) { + for (auto pred : LI->getParent()->getPredecessorBlocks()) { auto *TI = pred->getTerminator(); // Check if this is an early return with uninitialized members. if (TI->getLoc().getKind() == SILLocation::ReturnKind && @@ -2335,13 +2335,13 @@ computePredsLiveOut(SILBasicBlock *BB) { // Collect blocks for which we have to calculate the out-availability. // These are the paths from blocks with known out-availability to the BB. WorkListType WorkList; - for (auto Pred : BB->getPreds()) { + for (auto Pred : BB->getPredecessorBlocks()) { putIntoWorkList(Pred, WorkList); } size_t idx = 0; while (idx < WorkList.size()) { SILBasicBlock *WorkBB = WorkList[idx++]; - for (auto Pred : WorkBB->getPreds()) { + for (auto Pred : WorkBB->getPredecessorBlocks()) { putIntoWorkList(Pred, WorkList); } } @@ -2365,7 +2365,7 @@ computePredsLiveOut(SILBasicBlock *BB) { LiveOutBlockState &BBState = getBlockInfo(WorkBB); // Merge from the predecessor blocks. - for (auto Pred : WorkBB->getPreds()) { + for (auto Pred : WorkBB->getPredecessorBlocks()) { changed |= BBState.mergeFromPred(getBlockInfo(Pred)); } DEBUG(llvm::dbgs() << " Block " << WorkBB->getDebugID() << " out: " @@ -2382,8 +2382,8 @@ computePredsLiveOut(SILBasicBlock *BB) { void LifetimeChecker:: getOutAvailability(SILBasicBlock *BB, AvailabilitySet &Result) { computePredsLiveOut(BB); - - for (auto Pred : BB->getPreds()) { + + for (auto *Pred : BB->getPredecessorBlocks()) { // If self was consumed in a predecessor P, don't look at availability // at all, because there's no point in making things more conditional // than they are. If we enter the current block through P, the self value @@ -2401,8 +2401,8 @@ getOutAvailability(SILBasicBlock *BB, AvailabilitySet &Result) { void LifetimeChecker:: getOutSelfConsumed(SILBasicBlock *BB, Optional &Result) { computePredsLiveOut(BB); - - for (auto Pred : BB->getPreds()) + + for (auto *Pred : BB->getPredecessorBlocks()) Result = mergeKinds(Result, getBlockInfo(Pred).OutSelfConsumed); } diff --git a/lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp b/lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp index 7e2aaf1b391..43054771e64 100644 --- a/lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp +++ b/lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp @@ -879,7 +879,7 @@ SILCombiner::visitInjectEnumAddrInst(InjectEnumAddrInst *IEAI) { } // Go to predecessors and do all that again - for (SILBasicBlock *Pred : CurrBB->getPreds()) { + for (SILBasicBlock *Pred : CurrBB->getPredecessorBlocks()) { // If it's already in the set, then we've already queued and/or // processed the predecessors. if (Preds.insert(Pred).second) { @@ -1081,10 +1081,10 @@ SILInstruction *SILCombiner::visitCondBranchInst(CondBranchInst *CBI) { // the transformation, as SIL in canonical form may // only have critical edges that are originating from cond_br // instructions. - if (!CBI->getTrueBB()->getSinglePredecessor()) + if (!CBI->getTrueBB()->getSinglePredecessorBlock()) return nullptr; - if (!CBI->getFalseBB()->getSinglePredecessor()) + if (!CBI->getFalseBB()->getSinglePredecessorBlock()) return nullptr; SILBasicBlock *DefaultBB = nullptr; @@ -1278,7 +1278,7 @@ visitAllocRefDynamicInst(AllocRefDynamicInst *ARDI) { // alloc_ref_dynamic %T : $X.Type, $X // -> // alloc_ref $X - auto *PredBB = ARDI->getParent()->getSinglePredecessor(); + auto *PredBB = ARDI->getParent()->getSinglePredecessorBlock(); if (!PredBB) return nullptr; auto *CCBI = dyn_cast(PredBB->getTerminator()); diff --git a/lib/SILOptimizer/Transforms/ARCCodeMotion.cpp b/lib/SILOptimizer/Transforms/ARCCodeMotion.cpp index af3e61a1f12..c74981ddd87 100644 --- a/lib/SILOptimizer/Transforms/ARCCodeMotion.cpp +++ b/lib/SILOptimizer/Transforms/ARCCodeMotion.cpp @@ -375,7 +375,7 @@ bool RetainCodeMotionContext::requireIteration() { // genset and killset. llvm::SmallPtrSet PBBs; for (SILBasicBlock *B : PO->getReversePostOrder()) { - for (auto X : B->getPreds()) { + for (auto X : B->getPredecessorBlocks()) { if (!PBBs.count(X)) return true; } @@ -563,7 +563,7 @@ void RetainCodeMotionContext::computeCodeMotionInsertPoints() { for (unsigned i = 0; i < RCRootVault.size(); ++i) { if (S->BBSetIn[i]) continue; - for (auto Pred : BB->getPreds()) { + for (auto Pred : BB->getPredecessorBlocks()) { BlockState *PBB = BlockStates[Pred]; if (!PBB->BBSetOut[i]) continue; @@ -906,7 +906,7 @@ void ReleaseCodeMotionContext::convergeCodeMotionDataFlow() { SILBasicBlock *BB = WorkList.pop_back_val(); HandledBBs.erase(BB); if (processBBWithGenKillSet(BB)) { - for (auto X : BB->getPreds()) { + for (auto X : BB->getPredecessorBlocks()) { // We do not push basic block into the worklist if its already // in the worklist. if (HandledBBs.count(X)) diff --git a/lib/SILOptimizer/Transforms/AllocBoxToStack.cpp b/lib/SILOptimizer/Transforms/AllocBoxToStack.cpp index 499ce7e12e0..cc15c5ab3de 100644 --- a/lib/SILOptimizer/Transforms/AllocBoxToStack.cpp +++ b/lib/SILOptimizer/Transforms/AllocBoxToStack.cpp @@ -53,7 +53,7 @@ static void propagateLiveness(llvm::SmallPtrSetImpl &LiveIn, // First populate a worklist of predecessors. llvm::SmallVector Worklist; for (auto *BB : LiveIn) - for (auto Pred : BB->getPreds()) + for (auto Pred : BB->getPredecessorBlocks()) Worklist.push_back(Pred); // Now propagate liveness backwards until we hit the alloc_box. @@ -65,7 +65,7 @@ static void propagateLiveness(llvm::SmallPtrSetImpl &LiveIn, if (BB == DefBB || !LiveIn.insert(BB).second) continue; - for (auto Pred : BB->getPreds()) + for (auto Pred : BB->getPredecessorBlocks()) Worklist.push_back(Pred); } } diff --git a/lib/SILOptimizer/Transforms/ConditionForwarding.cpp b/lib/SILOptimizer/Transforms/ConditionForwarding.cpp index a5066f9311c..11ab4fd1c72 100644 --- a/lib/SILOptimizer/Transforms/ConditionForwarding.cpp +++ b/lib/SILOptimizer/Transforms/ConditionForwarding.cpp @@ -164,7 +164,7 @@ bool ConditionForwarding::tryOptimize(SwitchEnumInst *SEI) { if (isDebugInst(ArgUser)) continue; - if (ArgUser->getParent()->getSinglePredecessor() == SEI->getParent()) { + if (ArgUser->getParent()->getSinglePredecessorBlock() == SEI->getParent()) { continue; } return false; @@ -181,8 +181,8 @@ bool ConditionForwarding::tryOptimize(SwitchEnumInst *SEI) { // Check if all predecessors of the merging block pass an Enum to its argument // and have a single predecessor - the block of the condition. SILBasicBlock *CommonBranchBlock = nullptr; - for (SILBasicBlock *Pred : BB->getPreds()) { - SILBasicBlock *PredPred = Pred->getSinglePredecessor(); + for (SILBasicBlock *Pred : BB->getPredecessorBlocks()) { + SILBasicBlock *PredPred = Pred->getSinglePredecessorBlock(); if (!PredPred) return false; @@ -234,7 +234,7 @@ bool ConditionForwarding::tryOptimize(SwitchEnumInst *SEI) { continue; } SILBasicBlock *UseBlock = ArgUser->getParent(); - if (UseBlock->getSinglePredecessor() == SEI->getParent()) { + if (UseBlock->getSinglePredecessorBlock() == SEI->getParent()) { // The Arg is used in a successor block of the switch_enum. To keep things // simple, we just create a new block argument and later (see below) we // pass the corresponding enum to the block. This argument will be deleted diff --git a/lib/SILOptimizer/Transforms/DeadCodeElimination.cpp b/lib/SILOptimizer/Transforms/DeadCodeElimination.cpp index 617f19dc1d8..6abcc751082 100644 --- a/lib/SILOptimizer/Transforms/DeadCodeElimination.cpp +++ b/lib/SILOptimizer/Transforms/DeadCodeElimination.cpp @@ -351,7 +351,7 @@ void DCE::propagateLiveBlockArgument(SILArgument *Arg) { auto *Block = Arg->getParent(); auto ArgIndex = Arg->getIndex(); - for (auto Pred : Block->getPreds()) + for (auto Pred : Block->getPredecessorBlocks()) markTerminatorArgsLive(Pred, Block, ArgIndex); } @@ -582,7 +582,7 @@ void DCE::computePredecessorDependence(SILFunction &F) { assert(ControllingInfoMap.find(&BB) != ControllingInfoMap.end() && "Expected to already have a map entry for block!"); - for (auto Pred : BB.getPreds()) + for (auto Pred : BB.getPredecessorBlocks()) if (!PDT->properlyDominates(&BB, Pred)) { assert(ControllingInfoMap.find(Pred) != ControllingInfoMap.end() && "Expected to already have a map entry for block!"); diff --git a/lib/SILOptimizer/Transforms/DeadStoreElimination.cpp b/lib/SILOptimizer/Transforms/DeadStoreElimination.cpp index 6c710d7e550..0df9c34576d 100644 --- a/lib/SILOptimizer/Transforms/DeadStoreElimination.cpp +++ b/lib/SILOptimizer/Transforms/DeadStoreElimination.cpp @@ -1115,7 +1115,7 @@ void DSEContext::runIterativeDSE() { SILBasicBlock *BB = WorkList.pop_back_val(); HandledBBs.erase(BB); if (processBasicBlockWithGenKillSet(BB)) { - for (auto X : BB->getPreds()) { + for (auto X : BB->getPredecessorBlocks()) { // We do not push basic block into the worklist if its already // in the worklist. if (HandledBBs.find(X) != HandledBBs.end()) diff --git a/lib/SILOptimizer/Transforms/PerformanceInliner.cpp b/lib/SILOptimizer/Transforms/PerformanceInliner.cpp index 55d92d020f9..8b11019b75d 100644 --- a/lib/SILOptimizer/Transforms/PerformanceInliner.cpp +++ b/lib/SILOptimizer/Transforms/PerformanceInliner.cpp @@ -325,8 +325,9 @@ bool SILPerformanceInliner::isProfitableToInline(FullApplySite AI, SILBasicBlock *takenBlock = constTracker.getTakenBlock(block->getTerminator()); if (takenBlock) { BlockW.updateBenefit(Benefit, RemovedTerminatorBenefit); - domOrder.pushChildrenIf(block, [=] (SILBasicBlock *child) { - return child->getSinglePredecessor() != block || child == takenBlock; + domOrder.pushChildrenIf(block, [=](SILBasicBlock *child) { + return child->getSinglePredecessorBlock() != block || + child == takenBlock; }); } else { domOrder.pushChildren(block); diff --git a/lib/SILOptimizer/Transforms/RedundantLoadElimination.cpp b/lib/SILOptimizer/Transforms/RedundantLoadElimination.cpp index 1db338ab70b..38ed6a34edc 100644 --- a/lib/SILOptimizer/Transforms/RedundantLoadElimination.cpp +++ b/lib/SILOptimizer/Transforms/RedundantLoadElimination.cpp @@ -585,7 +585,7 @@ void BlockState::mergePredecessorsAvailSetMax(RLEContext &Ctx) { void BlockState::mergePredecessorAvailSet(RLEContext &Ctx) { // Clear the state if the basic block has no predecessor. - if (BB->getPreds().begin() == BB->getPreds().end()) { + if (BB->getPredecessorBlocks().begin() == BB->getPredecessorBlocks().end()) { ForwardSetIn.reset(); return; } @@ -600,7 +600,7 @@ void BlockState::mergePredecessorAvailSet(RLEContext &Ctx) { void BlockState::mergePredecessorAvailSetAndValue(RLEContext &Ctx) { // Clear the state if the basic block has no predecessor. - if (BB->getPreds().begin() == BB->getPreds().end()) { + if (BB->getPredecessorBlocks().begin() == BB->getPredecessorBlocks().end()) { ForwardSetIn.reset(); ForwardValIn.clear(); return; @@ -1096,7 +1096,7 @@ getProcessFunctionKind(unsigned LoadCount, unsigned StoreCount) { llvm::DenseSet HandledBBs; for (SILBasicBlock *B : PO->getReversePostOrder()) { ++BBCount; - for (auto X : B->getPreds()) { + for (auto X : B->getPredecessorBlocks()) { if (HandledBBs.find(X) == HandledBBs.end()) { RunOneIteration = false; break; @@ -1199,7 +1199,7 @@ SILValue RLEContext::computePredecessorLocationValue(SILBasicBlock *BB, llvm::SmallVector WorkList; // Push in all the predecessors to get started. - for (auto Pred : BB->getPreds()) { + for (auto Pred : BB->getPredecessorBlocks()) { WorkList.push_back(Pred); } @@ -1230,7 +1230,7 @@ SILValue RLEContext::computePredecessorLocationValue(SILBasicBlock *BB, // This BlockState does not contain concrete value for any of the expanded // locations, collect in this block's predecessors. if (Forwarder.isCoverValues(*this, L)) { - for (auto Pred : CurBB->getPreds()) { + for (auto Pred : CurBB->getPredecessorBlocks()) { if (HandledBBs.find(Pred) != HandledBBs.end()) continue; WorkList.push_back(Pred); diff --git a/lib/SILOptimizer/Transforms/RedundantOverflowCheckRemoval.cpp b/lib/SILOptimizer/Transforms/RedundantOverflowCheckRemoval.cpp index de13b529ef1..a406e949727 100644 --- a/lib/SILOptimizer/Transforms/RedundantOverflowCheckRemoval.cpp +++ b/lib/SILOptimizer/Transforms/RedundantOverflowCheckRemoval.cpp @@ -578,8 +578,10 @@ public: // \ | // \ v // [use(x)] - if (!TrueBB->getSinglePredecessor()) TrueBB = nullptr; - if (!FalseBB->getSinglePredecessor()) FalseBB = nullptr; + if (!TrueBB->getSinglePredecessorBlock()) + TrueBB = nullptr; + if (!FalseBB->getSinglePredecessorBlock()) + FalseBB = nullptr; // The relationship expressed in the builtin. ValueRelation Rel; diff --git a/lib/SILOptimizer/Transforms/SILCodeMotion.cpp b/lib/SILOptimizer/Transforms/SILCodeMotion.cpp index 774939130a3..14051225d1b 100644 --- a/lib/SILOptimizer/Transforms/SILCodeMotion.cpp +++ b/lib/SILOptimizer/Transforms/SILCodeMotion.cpp @@ -127,7 +127,7 @@ static bool hoistSILArgumentReleaseInst(SILBasicBlock *BB) { // Make sure the release will not be blocked by the terminator instructions // Make sure the terminator does not block, nor is a branch with multiple targets. - for (auto P : BB->getPreds()) { + for (auto P : BB->getPredecessorBlocks()) { if (!isa(P->getTerminator())) return false; } @@ -139,7 +139,7 @@ static bool hoistSILArgumentReleaseInst(SILBasicBlock *BB) { // Ok, we can get all the incoming values and create releases for them. unsigned indices = 0; - for (auto P : BB->getPreds()) { + for (auto P : BB->getPredecessorBlocks()) { createDecrementBefore(PredValues[indices++], P->getTerminator()); } // Erase the old instruction. @@ -203,7 +203,7 @@ static SILValue findValueShallowRoot(const SILValue &In) { // then we know exactly which value is passed to the argument. if (SILArgument *Arg = dyn_cast(In)) { SILBasicBlock *Parent = Arg->getParent(); - SILBasicBlock *Pred = Parent->getSinglePredecessor(); + SILBasicBlock *Pred = Parent->getSinglePredecessorBlock(); if (!Pred) return In; // If the terminator is a cast instruction then use the pre-cast value. @@ -380,7 +380,7 @@ static bool sinkLiteralArguments(SILBasicBlock *BB, unsigned ArgNum) { return false; // Check if the Nth argument in all predecessors is identical. - for (auto P : BB->getPreds()) { + for (auto P : BB->getPredecessorBlocks()) { if (P == FirstPred) continue; @@ -430,7 +430,7 @@ static bool sinkArgument(SILBasicBlock *BB, unsigned ArgNum) { llvm::Optional DifferentOperandIndex; // Check if the Nth argument in all predecessors is identical. - for (auto P : BB->getPreds()) { + for (auto P : BB->getPredecessorBlocks()) { if (P == FirstPred) continue; @@ -487,7 +487,7 @@ static bool sinkArgument(SILBasicBlock *BB, unsigned ArgNum) { // Update all branch instructions in the predecessors to pass the new // argument to this BB. auto CloneIt = Clones.begin(); - for (auto P : BB->getPreds()) { + for (auto P : BB->getPredecessorBlocks()) { // Only handle branch or conditional branch instructions. TermInst *TI = P->getTerminator(); assert((isa(TI) || isa(TI)) && @@ -532,7 +532,7 @@ static bool sinkArgument(SILBasicBlock *BB, unsigned ArgNum) { /// Notice that unlike other sinking methods in this file we do allow sinking /// of literals from blocks with multiple successors. static bool sinkLiteralsFromPredecessors(SILBasicBlock *BB) { - if (BB->pred_empty() || BB->getSinglePredecessor()) + if (BB->pred_empty() || BB->getSinglePredecessorBlock()) return false; // Try to sink values from each of the arguments to the basic block. @@ -545,12 +545,12 @@ static bool sinkLiteralsFromPredecessors(SILBasicBlock *BB) { /// Try to sink identical arguments coming from multiple predecessors. static bool sinkArgumentsFromPredecessors(SILBasicBlock *BB) { - if (BB->pred_empty() || BB->getSinglePredecessor()) + if (BB->pred_empty() || BB->getSinglePredecessorBlock()) return false; // This block must be the only successor of all the predecessors. - for (auto P : BB->getPreds()) - if (P->getSingleSuccessor() != BB) + for (auto P : BB->getPredecessorBlocks()) + if (P->getSingleSuccessorBlock() != BB) return false; // Try to sink values from each of the arguments to the basic block. @@ -591,8 +591,8 @@ static bool sinkCodeFromPredecessors(SILBasicBlock *BB) { return Changed; // This block must be the only successor of all the predecessors. - for (auto P : BB->getPreds()) - if (P->getSingleSuccessor() != BB) + for (auto P : BB->getPredecessorBlocks()) + if (P->getSingleSuccessorBlock() != BB) return Changed; SILBasicBlock *FirstPred = *BB->pred_begin(); @@ -612,7 +612,7 @@ static bool sinkCodeFromPredecessors(SILBasicBlock *BB) { // bb3(%x, %y): // ... ValueToBBArgIdxMap valueToArgIdxMap; - for (auto P : BB->getPreds()) { + for (auto P : BB->getPredecessorBlocks()) { if (auto *BI = dyn_cast(P->getTerminator())) { auto Args = BI->getArgs(); for (size_t idx = 0, size = Args.size(); idx < size; idx++) { @@ -637,7 +637,7 @@ static bool sinkCodeFromPredecessors(SILBasicBlock *BB) { OperandRelation opRelation = NotDeterminedYet; // For all preds: - for (auto P : BB->getPreds()) { + for (auto P : BB->getPredecessorBlocks()) { if (P == FirstPred) continue; @@ -887,7 +887,7 @@ static bool sinkIncrementsIntoSwitchRegions(SILBasicBlock *BB, AliasAnalysis *AA bool CanSinkToSuccessor = std::none_of(BB->succ_begin(), BB->succ_end(), [](const SILSuccessor &S) -> bool { SILBasicBlock *SuccBB = S.getBB(); - return !SuccBB || !SuccBB->getSinglePredecessor(); + return !SuccBB || !SuccBB->getSinglePredecessorBlock(); }); SILInstruction *S = BB->getTerminator(); @@ -1142,7 +1142,7 @@ initWithFirstPred(BBToDataflowStateMap &BBToStateMap, // are tracking with it. // // TODO: I am writing this too fast. Clean this up later. - if (FirstPredBB->getSingleSuccessor()) { + if (FirstPredBB->getSingleSuccessorBlock()) { for (auto P : ValueToCaseMap.getItems()) { if (!P.hasValue()) continue; @@ -1266,7 +1266,7 @@ mergePredecessorStates(BBToDataflowStateMap &BBToStateMap) { // Check if out predecessor has any other successors. If that is true we // clear all the state since we cannot hoist safely. - if (!PredBB->getSingleSuccessor()) { + if (!PredBB->getSingleSuccessorBlock()) { EnumToEnumBBCaseListMap.clear(); DEBUG(llvm::dbgs() << " Predecessor has other " "successors. Clearing BB cast list map.\n"); @@ -1418,7 +1418,7 @@ BBEnumTagDataflowState::hoistDecrementsIntoSwitchRegions(AliasAnalysis *AA) { // Otherwise create the release_value before the terminator of the // predecessor. - assert(P.first->getSingleSuccessor() && + assert(P.first->getSingleSuccessorBlock() && "Cannot hoist release into BB that has multiple successors"); SILBuilderWithScope Builder(P.first->getTerminator(), RVI); createRefCountOpForPayload(Builder, RVI, P.second); @@ -1577,8 +1577,9 @@ static bool processFunction(SILFunction *F, AliasAnalysis *AA, BBEnumTagDataflowState &State = BBToStateMap.getRPOState(RPOIdx); DEBUG(llvm::dbgs() << " Predecessors (empty if no predecessors):\n"); - DEBUG(for (SILBasicBlock *Pred : State.getBB()->getPreds()) { - llvm::dbgs() << " BB#" << RPOIdx << "; Ptr: " << Pred << "\n"; + DEBUG(for (SILBasicBlock *Pred + : State.getBB()->getPredecessorBlocks()) { + llvm::dbgs() << " BB#" << RPOIdx << "; Ptr: " << Pred << "\n"; }); DEBUG(llvm::dbgs() << " State Addr: " << &State << "\n"); diff --git a/lib/SILOptimizer/Transforms/SILMem2Reg.cpp b/lib/SILOptimizer/Transforms/SILMem2Reg.cpp index e9fa00f572e..7a73b363e72 100644 --- a/lib/SILOptimizer/Transforms/SILMem2Reg.cpp +++ b/lib/SILOptimizer/Transforms/SILMem2Reg.cpp @@ -642,8 +642,9 @@ void StackAllocationPromoter::fixBranchesAndUses(BlockSet &PhiBlocks) { // For each Block with a new Phi argument: for (auto Block : PhiBlocks) { // Fix all predecessors. - for (auto PBBI = Block->getPreds().begin(), E = Block->getPreds().end(); - PBBI != E;) { + for (auto PBBI = Block->getPredecessorBlocks().begin(), + E = Block->getPredecessorBlocks().end(); + PBBI != E;) { auto *PBB = *PBBI; ++PBBI; assert(PBB && "Invalid block!"); diff --git a/lib/SILOptimizer/Transforms/SimplifyCFG.cpp b/lib/SILOptimizer/Transforms/SimplifyCFG.cpp index 348d88e6257..ff48f68a6ea 100644 --- a/lib/SILOptimizer/Transforms/SimplifyCFG.cpp +++ b/lib/SILOptimizer/Transforms/SimplifyCFG.cpp @@ -381,12 +381,12 @@ static bool isKnownEdgeValue(TermInst *Term, SILBasicBlock *SuccBB, if (auto *SEI = dyn_cast(Term)) { if (auto Case = SEI->getUniqueCaseForDestination(SuccBB)) { EnumCase = Case.get(); - return SuccBB->getSinglePredecessor() != nullptr; + return SuccBB->getSinglePredecessorBlock() != nullptr; } return false; } - return SuccBB->getSinglePredecessor() != nullptr; + return SuccBB->getSinglePredecessorBlock() != nullptr; } /// Create an enum element by extracting the operand of a switch_enum. @@ -530,7 +530,7 @@ static bool tryDominatorBasedSimplifications( // If the use is a conditional branch/switch then look for an incoming // edge that is dominated by DominatingSuccBB. if (IsThreadable) { - auto Preds = DestBB->getPreds(); + auto Preds = DestBB->getPredecessorBlocks(); for (SILBasicBlock *PredBB : Preds) { if (!isa(PredBB->getTerminator())) @@ -742,7 +742,7 @@ bool SimplifyCFG::simplifyAfterDroppingPredecessor(SILBasicBlock *BB) { // Make sure that DestBB is in the worklist, as well as its remaining // predecessors, since they may not be able to be simplified. addToWorklist(BB); - for (auto *P : BB->getPreds()) + for (auto *P : BB->getPredecessorBlocks()) addToWorklist(P); return false; @@ -766,7 +766,7 @@ static NullablePtr getEnumCase(SILValue Val, // switch_enum %val, case A: bb1, case B: bb2 // bb1: // use %val // We know that %val has case A - SILBasicBlock *Pred = UsedInBB->getSinglePredecessor(); + SILBasicBlock *Pred = UsedInBB->getSinglePredecessorBlock(); int Limit = 3; // A very simple dominator check: just walk up the single predecessor chain. // The limit is just there to not run into an infinite loop in case of an @@ -777,7 +777,7 @@ static NullablePtr getEnumCase(SILValue Val, return PredSEI->getUniqueCaseForDestination(UsedInBB); } UsedInBB = Pred; - Pred = UsedInBB->getSinglePredecessor(); + Pred = UsedInBB->getSinglePredecessorBlock(); } // In case of a block argument, recursively check the enum cases of all @@ -1111,7 +1111,7 @@ bool SimplifyCFG::simplifyBranchBlock(BranchInst *BI) { // If this block branches to a block with a single predecessor, then // merge the DestBB into this BB. - if (BB != DestBB && DestBB->getSinglePredecessor()) { + if (BB != DestBB && DestBB->getSinglePredecessorBlock()) { DEBUG(llvm::dbgs() << "merge bb" << BB->getDebugID() << " with bb" << DestBB->getDebugID() << '\n'); @@ -1192,7 +1192,7 @@ static bool wouldIntroduceCriticalEdge(TermInst *T, SILBasicBlock *DestBB) { return false; assert(!DestBB->pred_empty() && "There should be a predecessor"); - if (DestBB->getSinglePredecessor()) + if (DestBB->getSinglePredecessorBlock()) return false; return true; @@ -1775,7 +1775,7 @@ bool SimplifyCFG::simplifyUnreachableBlock(UnreachableInst *UI) { Dead->eraseFromParent(); if (isOnlyUnreachable(BB)) - for (auto *P : BB->getPreds()) + for (auto *P : BB->getPredecessorBlocks()) addToWorklist(P); } @@ -2116,11 +2116,11 @@ static bool tryMoveCondFailToPreds(SILBasicBlock *BB) { // Check if some of the predecessor blocks provide a constant for the // cond_fail condition. So that the optimization has a positive effect. bool somePredsAreConst = false; - for (auto *Pred : BB->getPreds()) { - + for (auto *Pred : BB->getPredecessorBlocks()) { + // The cond_fail must post-dominate the predecessor block. We may not // execute the cond_fail speculatively. - if (!Pred->getSingleSuccessor()) + if (!Pred->getSingleSuccessorBlock()) return false; // If we already found a constant pred, we do not need to check the incoming @@ -2139,7 +2139,7 @@ static bool tryMoveCondFailToPreds(SILBasicBlock *BB) { DEBUG(llvm::dbgs() << "move to predecessors: " << *CFI); // Move the cond_fail to the predecessor blocks. - for (auto *Pred : BB->getPreds()) { + for (auto *Pred : BB->getPredecessorBlocks()) { SILValue incoming = condArg->getIncomingValue(Pred); SILBuilderWithScope Builder(Pred->getTerminator()); @@ -2291,7 +2291,7 @@ static bool shouldTailDuplicate(SILBasicBlock &Block) { if (isa(Block.getTerminator())) return false; - if (Block.getSinglePredecessor()) + if (Block.getSinglePredecessorBlock()) return false; for (auto &Inst : Block) { @@ -2419,7 +2419,7 @@ static void removeArgument(SILBasicBlock *BB, unsigned i) { // two edges to this block (e.g. a conditional branch where both // sides reach this block). llvm::SmallPtrSet PredBBs; - for (auto *Pred : BB->getPreds()) + for (auto *Pred : BB->getPredecessorBlocks()) PredBBs.insert(Pred); for (auto *Pred : PredBBs) @@ -2834,7 +2834,7 @@ getSwitchEnumPred(SILBasicBlock *BB, SILBasicBlock *PostBB, // Check if BB is reachable from a single enum case, which means that the // immediate predecessor of BB is the switch_enum itself. - if (SILBasicBlock *PredBB = BB->getSinglePredecessor()) { + if (SILBasicBlock *PredBB = BB->getSinglePredecessorBlock()) { // Check if a predecessor BB terminates with a switch_enum instruction if (auto *SEI = dyn_cast(PredBB->getTerminator())) { Blocks.push_back(BB); @@ -2845,12 +2845,12 @@ getSwitchEnumPred(SILBasicBlock *BB, SILBasicBlock *PostBB, // Check if BB is reachable from multiple enum cases. This means that there is // a single-branch block for each enum case which branch to BB. SILBasicBlock *CommonPredPredBB = nullptr; - for (auto PredBB : BB->getPreds()) { + for (auto PredBB : BB->getPredecessorBlocks()) { TermInst *PredTerm = PredBB->getTerminator(); if (!isa(PredTerm) || PredTerm != &*PredBB->begin()) return nullptr; - auto *PredPredBB = PredBB->getSinglePredecessor(); + auto *PredPredBB = PredBB->getSinglePredecessorBlock(); if (!PredPredBB) return nullptr; @@ -2911,7 +2911,7 @@ static bool simplifySwitchEnumToSelectEnum(SILBasicBlock *BB, unsigned ArgNum, // only produces an integer value and does not have any side-effects. // Predecessors which do not satisfy these conditions are not included in the // BBToValue map (but we don't bail in this case). - for (auto P : BB->getPreds()) { + for (auto P : BB->getPredecessorBlocks()) { // Only handle branch instructions. auto *TI = P->getTerminator(); if (!isa(TI)) @@ -3087,7 +3087,7 @@ CaseInfo getCaseInfo(SILValue &Input, SILBasicBlock *Pred, unsigned ArgNum) { // Check if we come to the Pred block by comparing the input value to a // constant. - SILBasicBlock *CmpBlock = Pred->getSinglePredecessor(); + SILBasicBlock *CmpBlock = Pred->getSinglePredecessorBlock(); if (!CmpBlock) return CaseInfo; @@ -3181,7 +3181,7 @@ bool simplifyToSelectValue(SILBasicBlock *MergeBlock, unsigned ArgNum, SmallPtrSet FoundCmpBlocks; SmallVector CaseInfos; SILValue Input; - for (auto *Pred : MergeBlock->getPreds()) { + for (auto *Pred : MergeBlock->getPredecessorBlocks()) { CaseInfo CaseInfo = getCaseInfo(Input, Pred, ArgNum); if (!CaseInfo.Result) return false; @@ -3221,7 +3221,7 @@ bool simplifyToSelectValue(SILBasicBlock *MergeBlock, unsigned ArgNum, return false; } } - SILBasicBlock *Pred = CaseInfo.CmpOrDefault->getSinglePredecessor(); + SILBasicBlock *Pred = CaseInfo.CmpOrDefault->getSinglePredecessorBlock(); if (!Pred || FoundCmpBlocks.count(Pred) == 0) { // There may be only a single block whose predecessor we didn't see. And // this is the entry block to the CFG pattern. @@ -3303,7 +3303,7 @@ bool SimplifyCFG::simplifyArgument(SILBasicBlock *BB, unsigned i) { // For now, just handle the case where all predecessors are // unconditional branches. - for (auto *Pred : BB->getPreds()) { + for (auto *Pred : BB->getPredecessorBlocks()) { if (!isa(Pred->getTerminator())) return false; auto *Branch = cast(Pred->getTerminator()); @@ -3327,7 +3327,7 @@ bool SimplifyCFG::simplifyArgument(SILBasicBlock *BB, unsigned i) { User->replaceAllUsesWith(NewArg); // Rewrite the branch operand for each incoming branch. - for (auto *Pred : BB->getPreds()) { + for (auto *Pred : BB->getPredecessorBlocks()) { if (auto *Branch = cast(Pred->getTerminator())) { auto V = getInsertedValue(cast(Branch->getArg(i)), User); @@ -3376,7 +3376,7 @@ bool SimplifyCFG::simplifyArgs(SILBasicBlock *BB) { return false; // Ignore blocks that are successors of terminators with mandatory args. - for (SILBasicBlock *pred : BB->getPreds()) { + for (SILBasicBlock *pred : BB->getPredecessorBlocks()) { if (hasMandatoryArgument(pred->getTerminator())) return false; } diff --git a/lib/SILOptimizer/Transforms/StackPromotion.cpp b/lib/SILOptimizer/Transforms/StackPromotion.cpp index b44625174d2..f985968e281 100644 --- a/lib/SILOptimizer/Transforms/StackPromotion.cpp +++ b/lib/SILOptimizer/Transforms/StackPromotion.cpp @@ -194,7 +194,7 @@ bool StackPromoter::promote() { unsigned Idx = 0; while (Idx < ReachableBlocks.size()) { SILBasicBlock *BB = ReachableBlocks[Idx++]; - for (SILBasicBlock *Pred : BB->getPreds()) + for (SILBasicBlock *Pred : BB->getPredecessorBlocks()) ReachableBlocks.insert(Pred); } @@ -529,7 +529,7 @@ SILBasicBlock *StackPromoter::updateEndBlock(SILBasicBlock *CurrentBB, // handled blocks. while (!PredsToHandle.empty()) { SILBasicBlock *BB = PredsToHandle.pop_back_val(); - for (SILBasicBlock *Pred : BB->getPreds()) { + for (SILBasicBlock *Pred : BB->getPredecessorBlocks()) { // Make sure that the EndBlock post-dominates all blocks we are visiting. while (!strictlyPostDominates(EndBlock, Pred)) { EndBlock = getImmediatePostDom(EndBlock); diff --git a/lib/SILOptimizer/Utils/CFG.cpp b/lib/SILOptimizer/Utils/CFG.cpp index 5f163b4d3a7..a8976a60aa2 100644 --- a/lib/SILOptimizer/Utils/CFG.cpp +++ b/lib/SILOptimizer/Utils/CFG.cpp @@ -450,7 +450,7 @@ bool swift::isCriticalEdge(TermInst *T, unsigned EdgeIdx) { SILBasicBlock *DestBB = SrcSuccs[EdgeIdx]; assert(!DestBB->pred_empty() && "There should be a predecessor"); - if (DestBB->getSinglePredecessor()) + if (DestBB->getSinglePredecessorBlock()) return false; return true; @@ -741,7 +741,7 @@ bool swift::mergeBasicBlockWithSuccessor(SILBasicBlock *BB, DominanceInfo *DT, return false; auto *SuccBB = Branch->getDestBB(); - if (BB == SuccBB || !SuccBB->getSinglePredecessor()) + if (BB == SuccBB || !SuccBB->getSinglePredecessorBlock()) return false; // If there are any BB arguments in the destination, replace them with the diff --git a/lib/SILOptimizer/Utils/CheckedCastBrJumpThreading.cpp b/lib/SILOptimizer/Utils/CheckedCastBrJumpThreading.cpp index 6886df9bf20..937e60cd3f7 100644 --- a/lib/SILOptimizer/Utils/CheckedCastBrJumpThreading.cpp +++ b/lib/SILOptimizer/Utils/CheckedCastBrJumpThreading.cpp @@ -320,19 +320,23 @@ modifyCFGForSuccessPreds(Optional &Cloner) { /// Handle a special case, where ArgBB is the entry block. bool CheckedCastBrJumpThreading::handleArgBBIsEntryBlock(SILBasicBlock *ArgBB, CheckedCastBranchInst *DomCCBI) { - if (ArgBB->getPreds().begin() == ArgBB->getPreds().end()) { - // It must be the entry block - // See if it is reached over Success or Failure path. - bool SuccessDominates = DomCCBI->getSuccessBB() == BB; - bool FailureDominates = DomCCBI->getFailureBB() == BB; + if (!ArgBB->pred_empty()) + return false; - if (BlocksToEdit.count(ArgBB) != 0) - return false; + // It must be the entry block + // + // TODO: Is this a correct assumption? Do we know that at this point that + // ArgBB can not be unreachable? + // + // See if it is reached over Success or Failure path. + bool SuccessDominates = DomCCBI->getSuccessBB() == BB; + bool FailureDominates = DomCCBI->getFailureBB() == BB; - classifyPredecessor(ArgBB, SuccessDominates, FailureDominates); - return true; - } - return false; + if (BlocksToEdit.count(ArgBB) != 0) + return false; + + classifyPredecessor(ArgBB, SuccessDominates, FailureDominates); + return true; } // Returns false if cloning required by jump threading cannot @@ -393,7 +397,7 @@ areEquivalentConditionsAlongSomePaths(CheckedCastBranchInst *DomCCBI, if (!handleArgBBIsEntryBlock(ArgBB, DomCCBI)) { // ArgBB is not the entry block and has predecessors. unsigned idx = 0; - for (auto *PredBB : ArgBB->getPreds()) { + for (auto *PredBB : ArgBB->getPredecessorBlocks()) { // We must avoid that we are going to change a block twice. if (BlocksToEdit.count(PredBB) != 0) @@ -456,7 +460,7 @@ areEquivalentConditionsAlongPaths(CheckedCastBranchInst *DomCCBI) { // Figure out for each predecessor which branch of // the dominating checked_cast_br is used to reach it. - for (auto *PredBB : BB->getPreds()) { + for (auto *PredBB : BB->getPredecessorBlocks()) { // All predecessors should either unconditionally branch // to the current BB or be another checked_cast_br instruction. if (!isa(PredBB->getTerminator()) && @@ -469,7 +473,8 @@ areEquivalentConditionsAlongPaths(CheckedCastBranchInst *DomCCBI) { // Don't allow critical edges from PredBB to BB. This ensures that // splitAllCriticalEdges() will not invalidate our predecessor lists. - if (!BB->getSinglePredecessor() && !PredBB->getSingleSuccessor()) + if (!BB->getSinglePredecessorBlock() && + !PredBB->getSingleSuccessorBlock()) return false; SILBasicBlock *DomSuccessBB = DomCCBI->getSuccessBB(); @@ -610,10 +615,9 @@ bool CheckedCastBrJumpThreading::trySimplify(CheckedCastBranchInst *CCBI) { // We have to generate new dedicated BBs as landing BBs for all // FailurePreds and all SuccessPreds. - // Since we are going to change the BB, - // add its successors and predecessors + // Since we are going to change the BB, add its successors and predecessors // for re-processing. - for (auto *B : BB->getPreds()) { + for (auto *B : BB->getPredecessorBlocks()) { BlocksForWorklist.push_back(B); } for (auto *B : BB->getSuccessorBlocks()) { diff --git a/lib/SILOptimizer/Utils/Devirtualize.cpp b/lib/SILOptimizer/Utils/Devirtualize.cpp index 8598783286d..61722588753 100644 --- a/lib/SILOptimizer/Utils/Devirtualize.cpp +++ b/lib/SILOptimizer/Utils/Devirtualize.cpp @@ -238,7 +238,7 @@ SILValue swift::getInstanceWithExactDynamicType(SILValue S, SILModule &M, if (!Arg) break; - auto *SinglePred = Arg->getParent()->getSinglePredecessor(); + auto *SinglePred = Arg->getParent()->getSinglePredecessorBlock(); if (!SinglePred) { if (!Arg->isFunctionArg()) break; @@ -366,7 +366,7 @@ SILType swift::getExactDynamicType(SILValue S, SILModule &M, continue; } - auto *SinglePred = Arg->getParent()->getSinglePredecessor(); + auto *SinglePred = Arg->getParent()->getSinglePredecessorBlock(); if (SinglePred) { // If it is a BB argument received on a success branch // of a checked_cast_br, then we know its exact type. @@ -664,7 +664,7 @@ DevirtualizationResult swift::devirtualizeClassMethod(FullApplySite AI, // - re-using a BB would create a critical edge // - or, the result of the new apply would be of different // type than the argument of the original normal BB. - if (TAI->getNormalBB()->getSinglePredecessor()) + if (TAI->getNormalBB()->getSinglePredecessorBlock()) ResultBB = TAI->getNormalBB(); else { ResultBB = B.getFunction().createBasicBlock(); @@ -674,7 +674,7 @@ DevirtualizationResult swift::devirtualizeClassMethod(FullApplySite AI, NormalBB = TAI->getNormalBB(); SILBasicBlock *ErrorBB = nullptr; - if (TAI->getErrorBB()->getSinglePredecessor()) + if (TAI->getErrorBB()->getSinglePredecessorBlock()) ErrorBB = TAI->getErrorBB(); else { ErrorBB = B.getFunction().createBasicBlock(); diff --git a/lib/SILOptimizer/Utils/Generics.cpp b/lib/SILOptimizer/Utils/Generics.cpp index 9737cbb1883..f77e6f3e223 100644 --- a/lib/SILOptimizer/Utils/Generics.cpp +++ b/lib/SILOptimizer/Utils/Generics.cpp @@ -283,7 +283,7 @@ static ApplySite replaceWithSpecializedCallee(ApplySite AI, if (auto *TAI = dyn_cast(AI)) { SILBasicBlock *ResultBB = TAI->getNormalBB(); - assert(ResultBB->getSinglePredecessor() == TAI->getParent()); + assert(ResultBB->getSinglePredecessorBlock() == TAI->getParent()); auto *NewTAI = Builder.createTryApply(Loc, Callee, Callee->getType(), {}, Arguments, ResultBB, TAI->getErrorBB()); diff --git a/lib/SILOptimizer/Utils/Local.cpp b/lib/SILOptimizer/Utils/Local.cpp index 8daced52ebf..cf650760dfc 100644 --- a/lib/SILOptimizer/Utils/Local.cpp +++ b/lib/SILOptimizer/Utils/Local.cpp @@ -1180,7 +1180,7 @@ void ValueLifetimeAnalysis::propagateLiveness() { if (BB == DefBB) continue; - for (SILBasicBlock *Pred : BB->getPreds()) { + for (SILBasicBlock *Pred : BB->getPredecessorBlocks()) { // If it's already in the set, then we've already queued and/or // processed the predecessors. if (LiveBlocks.insert(Pred)) @@ -1252,7 +1252,7 @@ bool ValueLifetimeAnalysis::computeFrontier(Frontier &Fr, Mode mode) { bool needSplit = false; // If the value is live only in part of the predecessor blocks we have to // split those predecessor edges. - for (SILBasicBlock *Pred : FrontierBB->getPreds()) { + for (SILBasicBlock *Pred : FrontierBB->getPredecessorBlocks()) { if (!LiveOutBlocks.count(Pred)) { needSplit = true; break; @@ -2136,9 +2136,9 @@ optimizeCheckedCastAddrBranchInst(CheckedCastAddrBranchInst *Inst) { MI = dyn_cast(Src); if (MI) { - if (SuccessBB->getSinglePredecessor() - && canUseScalarCheckedCastInstructions(Inst->getModule(), - MI->getType().getSwiftRValueType(), + if (SuccessBB->getSinglePredecessorBlock() && + canUseScalarCheckedCastInstructions( + Inst->getModule(), MI->getType().getSwiftRValueType(), Dest->getType().getObjectType().getSwiftRValueType())) { SILBuilderWithScope B(Inst); auto NewI = B.createCheckedCastBranch( diff --git a/lib/SILOptimizer/Utils/LoopUtils.cpp b/lib/SILOptimizer/Utils/LoopUtils.cpp index 7f51da40fdf..82b0eda08f6 100644 --- a/lib/SILOptimizer/Utils/LoopUtils.cpp +++ b/lib/SILOptimizer/Utils/LoopUtils.cpp @@ -48,7 +48,7 @@ static SILBasicBlock *insertPreheader(SILLoop *L, DominanceInfo *DT, // Before we create the preheader, gather all of the original preds of header. llvm::SmallVector Preds; - for (auto *Pred : Header->getPreds()) { + for (auto *Pred : Header->getPredecessorBlocks()) { if (!L->contains(Pred)) { Preds.push_back(Pred); } @@ -104,7 +104,7 @@ static SILBasicBlock *insertBackedgeBlock(SILLoop *L, DominanceInfo *DT, // Figure out which basic blocks contain back-edges to the loop header. SmallVector BackedgeBlocks; - for (auto *Pred : Header->getPreds()) { + for (auto *Pred : Header->getPredecessorBlocks()) { if (Pred == Preheader) continue; // Branches can be handled trivially and CondBranch edges can be split. diff --git a/lib/SILOptimizer/Utils/PerformanceInlinerUtils.cpp b/lib/SILOptimizer/Utils/PerformanceInlinerUtils.cpp index 3f51e0ae27b..56da6687607 100644 --- a/lib/SILOptimizer/Utils/PerformanceInlinerUtils.cpp +++ b/lib/SILOptimizer/Utils/PerformanceInlinerUtils.cpp @@ -315,7 +315,7 @@ SILBasicBlock *ConstantTracker::getTakenBlock(TermInst *term) { int ShortestPathAnalysis::getEntryDistFromPreds(const SILBasicBlock *BB, int LoopDepth) { int MinDist = InitialDist; - for (SILBasicBlock *Pred : BB->getPreds()) { + for (SILBasicBlock *Pred : BB->getPredecessorBlocks()) { BlockInfo *PredInfo = getBlockInfo(Pred); Distances &PDists = PredInfo->getDistances(LoopDepth); int DistFromEntry = PDists.DistFromEntry + PredInfo->Length + @@ -351,7 +351,7 @@ static SILBasicBlock *detectLoopBypassPreheader(SILLoop *Loop) { if (!Pred) return nullptr; - SILBasicBlock *PredPred = Pred->getSinglePredecessor(); + SILBasicBlock *PredPred = Pred->getSinglePredecessorBlock(); if (!PredPred) return nullptr; @@ -362,8 +362,8 @@ static SILBasicBlock *detectLoopBypassPreheader(SILLoop *Loop) { SILBasicBlock *Succ = (CBR->getTrueBB() == Pred ? CBR->getFalseBB() : CBR->getTrueBB()); - for (SILBasicBlock *PredOfSucc : Succ->getPreds()) { - SILBasicBlock *Exiting = PredOfSucc->getSinglePredecessor(); + for (SILBasicBlock *PredOfSucc : Succ->getPredecessorBlocks()) { + SILBasicBlock *Exiting = PredOfSucc->getSinglePredecessorBlock(); if (!Exiting) Exiting = PredOfSucc; if (Loop->contains(Exiting)) diff --git a/lib/SILOptimizer/Utils/SILSSAUpdater.cpp b/lib/SILOptimizer/Utils/SILSSAUpdater.cpp index 13a404f14dd..6e7addb3bdc 100644 --- a/lib/SILOptimizer/Utils/SILSSAUpdater.cpp +++ b/lib/SILOptimizer/Utils/SILSSAUpdater.cpp @@ -152,7 +152,7 @@ isEquivalentPHI(SILArgument *PHI, llvm::SmallDenseMap &ValueMap) { SILBasicBlock *PhiBB = PHI->getParent(); size_t Idx = PHI->getIndex(); - for (auto *PredBB : PhiBB->getPreds()) { + for (auto *PredBB : PhiBB->getPredecessorBlocks()) { auto DesiredVal = ValueMap[PredBB]; OperandValueArrayRef EdgeValues = getEdgeValuesForTerminator(PredBB->getTerminator(), PhiBB); @@ -177,7 +177,7 @@ SILValue SILSSAUpdater::GetValueInMiddleOfBlock(SILBasicBlock *BB) { // SSAUpdater can modify TerminatorInst and therefore invalidate the // predecessor iterator. Find all the predecessors before the SSA update. SmallVector Preds; - for (auto *PredBB: BB->getPreds()) { + for (auto *PredBB : BB->getPredecessorBlocks()) { Preds.push_back(PredBB); } @@ -357,7 +357,7 @@ public: size_t PhiIdx = PHI->getIndex(); // If all predecessor edges are 'not set' this is a new phi. - for (auto *PredBB : PhiBB->getPreds()) { + for (auto *PredBB : PhiBB->getPredecessorBlocks()) { OperandValueArrayRef Edges = getEdgeValuesForTerminator(PredBB->getTerminator(), PhiBB); @@ -493,7 +493,7 @@ static StructInst *replaceBBArgWithStruct( for (unsigned ArgIdx : indices(PhiBB->getArguments())) { SmallVectorImpl::const_iterator AVIter = ArgValues.begin(); bool TryNextArgIdx = false; - for (SILBasicBlock *PredBB : PhiBB->getPreds()) { + for (SILBasicBlock *PredBB : PhiBB->getPredecessorBlocks()) { // All argument values must be StructInst. auto *PredSI = dyn_cast(*AVIter++); if (!PredSI)