From 7bc76fd0ec40ae20b6d456e2d6e7c328615ed718 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 31 Dec 2020 09:39:11 -0800 Subject: [PATCH] [CodeGen] Construct SmallVector with iterator ranges (NFC) --- llvm/lib/CodeGen/CodeGenPrepare.cpp | 6 +++--- llvm/lib/CodeGen/IfConversion.cpp | 3 +-- llvm/lib/CodeGen/MachineBlockPlacement.cpp | 4 ++-- llvm/lib/CodeGen/MachineSink.cpp | 3 +-- llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp | 2 +- llvm/lib/CodeGen/ReachingDefAnalysis.cpp | 4 +--- llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp | 2 +- llvm/lib/CodeGen/SjLjEHPrepare.cpp | 2 +- llvm/lib/CodeGen/TailDuplicator.cpp | 3 +-- llvm/lib/CodeGen/WasmEHPrepare.cpp | 2 +- 10 files changed, 13 insertions(+), 18 deletions(-) diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 3ea758a..4a82c95 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -562,7 +562,7 @@ bool CodeGenPrepare::runOnFunction(Function &F) { // are removed. SmallSetVector WorkList; for (BasicBlock &BB : F) { - SmallVector Successors(succ_begin(&BB), succ_end(&BB)); + SmallVector Successors(successors(&BB)); MadeChange |= ConstantFoldTerminator(&BB, true); if (!MadeChange) continue; @@ -576,7 +576,7 @@ bool CodeGenPrepare::runOnFunction(Function &F) { MadeChange |= !WorkList.empty(); while (!WorkList.empty()) { BasicBlock *BB = WorkList.pop_back_val(); - SmallVector Successors(succ_begin(BB), succ_end(BB)); + SmallVector Successors(successors(BB)); DeleteDeadBlock(BB); @@ -5328,7 +5328,7 @@ bool CodeGenPrepare::optimizeGatherScatterInst(Instruction *MemoryInst, if (MemoryInst->getParent() != GEP->getParent()) return false; - SmallVector Ops(GEP->op_begin(), GEP->op_end()); + SmallVector Ops(GEP->operands()); bool RewriteGEP = false; diff --git a/llvm/lib/CodeGen/IfConversion.cpp b/llvm/lib/CodeGen/IfConversion.cpp index d149f8c..37be2ea 100644 --- a/llvm/lib/CodeGen/IfConversion.cpp +++ b/llvm/lib/CodeGen/IfConversion.cpp @@ -2264,8 +2264,7 @@ void IfConverter::MergeBlocks(BBInfo &ToBBI, BBInfo &FromBBI, bool AddEdges) { if (ToBBI.IsBrAnalyzable) ToBBI.BB->normalizeSuccProbs(); - SmallVector FromSuccs(FromMBB.succ_begin(), - FromMBB.succ_end()); + SmallVector FromSuccs(FromMBB.successors()); MachineBasicBlock *NBB = getNextBlock(FromMBB); MachineBasicBlock *FallThrough = FromBBI.HasFallThrough ? NBB : nullptr; // The edge probability from ToBBI.BB to FromMBB, which is only needed when diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index 8850dab..048baa4 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -3160,8 +3160,8 @@ void MachineBlockPlacement::findDuplicateCandidates( MachineBasicBlock *Fallthrough = nullptr; BranchProbability DefaultBranchProb = BranchProbability::getZero(); BlockFrequency BBDupThreshold(scaleThreshold(BB)); - SmallVector Preds(BB->pred_begin(), BB->pred_end()); - SmallVector Succs(BB->succ_begin(), BB->succ_end()); + SmallVector Preds(BB->predecessors()); + SmallVector Succs(BB->successors()); // Sort for highest frequency. auto CmpSucc = [&](MachineBasicBlock *A, MachineBasicBlock *B) { diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp index 265ca6d..48ed8b0 100644 --- a/llvm/lib/CodeGen/MachineSink.cpp +++ b/llvm/lib/CodeGen/MachineSink.cpp @@ -745,8 +745,7 @@ MachineSinking::GetAllSortedSuccessors(MachineInstr &MI, MachineBasicBlock *MBB, if (Succs != AllSuccessors.end()) return Succs->second; - SmallVector AllSuccs(MBB->succ_begin(), - MBB->succ_end()); + SmallVector AllSuccs(MBB->successors()); // Handle cases where sinking can happen but where the sink point isn't a // successor. For example: diff --git a/llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp b/llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp index 1be9544..80c38f3 100644 --- a/llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp +++ b/llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp @@ -96,7 +96,7 @@ static bool lowerObjCCall(Function &F, const char *NewFn, ++I; IRBuilder<> Builder(CI->getParent(), CI->getIterator()); - SmallVector Args(CI->arg_begin(), CI->arg_end()); + SmallVector Args(CI->args()); CallInst *NewCI = Builder.CreateCall(FCache, Args); NewCI->setName(CI->getName()); diff --git a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp index 2f0a622..d16e90a 100644 --- a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp +++ b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp @@ -377,9 +377,7 @@ void ReachingDefAnalysis::getGlobalUses(MachineInstr *MI, MCRegister PhysReg, if (LiveOut != MI) return; - SmallVector ToVisit; - ToVisit.insert(ToVisit.begin(), MBB->successors().begin(), - MBB->successors().end()); + SmallVector ToVisit(MBB->successors()); SmallPtrSetVisited; while (!ToVisit.empty()) { MachineBasicBlock *MBB = ToVisit.back(); diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp index e9a8403..debfdda 100644 --- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp @@ -172,7 +172,7 @@ static bool AddGlue(SDNode *N, SDValue Glue, bool AddGlue, SelectionDAG *DAG) { // Don't add glue to something that already has a glue value. if (N->getValueType(N->getNumValues() - 1) == MVT::Glue) return false; - SmallVector VTs(N->value_begin(), N->value_end()); + SmallVector VTs(N->values()); if (AddGlue) VTs.push_back(MVT::Glue); diff --git a/llvm/lib/CodeGen/SjLjEHPrepare.cpp b/llvm/lib/CodeGen/SjLjEHPrepare.cpp index 0683058..d2fd4a6 100644 --- a/llvm/lib/CodeGen/SjLjEHPrepare.cpp +++ b/llvm/lib/CodeGen/SjLjEHPrepare.cpp @@ -142,7 +142,7 @@ static void MarkBlocksLiveIn(BasicBlock *BB, /// instruction with those returned by the personality function. void SjLjEHPrepare::substituteLPadValues(LandingPadInst *LPI, Value *ExnVal, Value *SelVal) { - SmallVector UseWorkList(LPI->user_begin(), LPI->user_end()); + SmallVector UseWorkList(LPI->users()); while (!UseWorkList.empty()) { Value *Val = UseWorkList.pop_back_val(); auto *EVI = dyn_cast(Val); diff --git a/llvm/lib/CodeGen/TailDuplicator.cpp b/llvm/lib/CodeGen/TailDuplicator.cpp index f9773f7..575bf55 100644 --- a/llvm/lib/CodeGen/TailDuplicator.cpp +++ b/llvm/lib/CodeGen/TailDuplicator.cpp @@ -720,8 +720,7 @@ bool TailDuplicator::duplicateSimpleBB( SmallVectorImpl &Copies) { SmallPtrSet Succs(TailBB->succ_begin(), TailBB->succ_end()); - SmallVector Preds(TailBB->pred_begin(), - TailBB->pred_end()); + SmallVector Preds(TailBB->predecessors()); bool Changed = false; for (MachineBasicBlock *PredBB : Preds) { if (PredBB->hasEHPadSuccessor() || PredBB->mayHaveInlineAsmBr()) diff --git a/llvm/lib/CodeGen/WasmEHPrepare.cpp b/llvm/lib/CodeGen/WasmEHPrepare.cpp index 2a0dfff..89d7013 100644 --- a/llvm/lib/CodeGen/WasmEHPrepare.cpp +++ b/llvm/lib/CodeGen/WasmEHPrepare.cpp @@ -204,7 +204,7 @@ bool WasmEHPrepare::prepareThrows(Function &F) { continue; Changed = true; auto *BB = ThrowI->getParent(); - SmallVector Succs(succ_begin(BB), succ_end(BB)); + SmallVector Succs(successors(BB)); auto &InstList = BB->getInstList(); InstList.erase(std::next(BasicBlock::iterator(ThrowI)), InstList.end()); IRB.SetInsertPoint(BB); -- 2.7.4