From f118370581a7354db1d2a4fd881eca01268f7522 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Tue, 19 Jan 2021 20:19:14 -0800 Subject: [PATCH] [llvm] Use llvm::find (NFC) --- lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 3 +-- lib/MCA/Stages/InstructionTables.cpp | 3 +-- lib/Support/DynamicLibrary.cpp | 4 +--- lib/Target/Hexagon/HexagonSubtarget.cpp | 4 ++-- lib/Target/PowerPC/PPCReduceCRLogicals.cpp | 4 ++-- lib/Transforms/Scalar/GuardWidening.cpp | 5 ++--- lib/Transforms/Vectorize/VPlan.h | 4 ++-- utils/TableGen/GlobalISel/GIMatchTree.cpp | 3 +-- utils/TableGen/SubtargetEmitter.cpp | 12 ++++-------- 9 files changed, 16 insertions(+), 26 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index ef83df8bdd9..1bee1421cac 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -18957,8 +18957,7 @@ SDValue DAGCombiner::reduceBuildVecToShuffle(SDNode *N) { // Have we seen this input vector before? // The vectors are expected to be tiny (usually 1 or 2 elements), so using // a map back from SDValues to numbers isn't worth it. - unsigned Idx = std::distance( - VecIn.begin(), std::find(VecIn.begin(), VecIn.end(), ExtractedFromVec)); + unsigned Idx = std::distance(VecIn.begin(), find(VecIn, ExtractedFromVec)); if (Idx == VecIn.size()) VecIn.push_back(ExtractedFromVec); diff --git a/lib/MCA/Stages/InstructionTables.cpp b/lib/MCA/Stages/InstructionTables.cpp index a0cdfb89c55..93e36812306 100644 --- a/lib/MCA/Stages/InstructionTables.cpp +++ b/lib/MCA/Stages/InstructionTables.cpp @@ -30,8 +30,7 @@ Error InstructionTables::execute(InstRef &IR) { if (!Resource.second.size()) continue; unsigned Cycles = Resource.second.size(); - unsigned Index = std::distance( - Masks.begin(), std::find(Masks.begin(), Masks.end(), Resource.first)); + unsigned Index = std::distance(Masks.begin(), find(Masks, Resource.first)); const MCProcResourceDesc &ProcResource = *SM.getProcResource(Index); unsigned NumUnits = ProcResource.NumUnits; if (!ProcResource.SubUnitsIdxBegin) { diff --git a/lib/Support/DynamicLibrary.cpp b/lib/Support/DynamicLibrary.cpp index d23716016fb..bdf74623670 100644 --- a/lib/Support/DynamicLibrary.cpp +++ b/lib/Support/DynamicLibrary.cpp @@ -39,9 +39,7 @@ public: HandleSet() : Process(nullptr) {} ~HandleSet(); - HandleList::iterator Find(void *Handle) { - return std::find(Handles.begin(), Handles.end(), Handle); - } + HandleList::iterator Find(void *Handle) { return find(Handles, Handle); } bool Contains(void *Handle) { return Handle == Process || Find(Handle) != Handles.end(); diff --git a/lib/Target/Hexagon/HexagonSubtarget.cpp b/lib/Target/Hexagon/HexagonSubtarget.cpp index fed1abb9549..87b1c43961d 100644 --- a/lib/Target/Hexagon/HexagonSubtarget.cpp +++ b/lib/Target/Hexagon/HexagonSubtarget.cpp @@ -527,7 +527,7 @@ void HexagonSubtarget::restoreLatency(SUnit *Src, SUnit *Dst) const { // Update the latency of opposite edge too. T.setSUnit(Src); - auto F = std::find(Dst->Preds.begin(), Dst->Preds.end(), T); + auto F = find(Dst->Preds, T); assert(F != Dst->Preds.end()); F->setLatency(I.getLatency()); } @@ -544,7 +544,7 @@ void HexagonSubtarget::changeLatency(SUnit *Src, SUnit *Dst, unsigned Lat) // Update the latency of opposite edge too. T.setSUnit(Src); - auto F = std::find(Dst->Preds.begin(), Dst->Preds.end(), T); + auto F = find(Dst->Preds, T); assert(F != Dst->Preds.end()); F->setLatency(Lat); } diff --git a/lib/Target/PowerPC/PPCReduceCRLogicals.cpp b/lib/Target/PowerPC/PPCReduceCRLogicals.cpp index 90cc81beb89..5cee00c61fc 100644 --- a/lib/Target/PowerPC/PPCReduceCRLogicals.cpp +++ b/lib/Target/PowerPC/PPCReduceCRLogicals.cpp @@ -206,9 +206,9 @@ static bool splitMBB(BlockSplitInfo &BSI) { NewMBB->splice(NewMBB->end(), ThisMBB, InsertPoint, ThisMBB->end()); NewMBB->transferSuccessors(ThisMBB); if (!ProbOrigTarget.isUnknown()) { - auto MBBI = std::find(NewMBB->succ_begin(), NewMBB->succ_end(), OrigTarget); + auto MBBI = find(NewMBB->successors(), OrigTarget); NewMBB->setSuccProbability(MBBI, ProbOrigTarget); - MBBI = std::find(NewMBB->succ_begin(), NewMBB->succ_end(), OrigFallThrough); + MBBI = find(NewMBB->successors(), OrigFallThrough); NewMBB->setSuccProbability(MBBI, ProbOrigFallThrough); } diff --git a/lib/Transforms/Scalar/GuardWidening.cpp b/lib/Transforms/Scalar/GuardWidening.cpp index 1735266f0e5..6ce79bdb707 100644 --- a/lib/Transforms/Scalar/GuardWidening.cpp +++ b/lib/Transforms/Scalar/GuardWidening.cpp @@ -347,9 +347,8 @@ bool GuardWideningImpl::eliminateInstrViaWidening( const auto &GuardsInCurBB = GuardsInBlock.find(CurBB)->second; auto I = GuardsInCurBB.begin(); - auto E = Instr->getParent() == CurBB - ? std::find(GuardsInCurBB.begin(), GuardsInCurBB.end(), Instr) - : GuardsInCurBB.end(); + auto E = Instr->getParent() == CurBB ? find(GuardsInCurBB, Instr) + : GuardsInCurBB.end(); #ifndef NDEBUG { diff --git a/lib/Transforms/Vectorize/VPlan.h b/lib/Transforms/Vectorize/VPlan.h index 4500e761a6e..8d907dbc857 100644 --- a/lib/Transforms/Vectorize/VPlan.h +++ b/lib/Transforms/Vectorize/VPlan.h @@ -413,14 +413,14 @@ class VPBlockBase { /// Remove \p Predecessor from the predecessors of this block. void removePredecessor(VPBlockBase *Predecessor) { - auto Pos = std::find(Predecessors.begin(), Predecessors.end(), Predecessor); + auto Pos = find(Predecessors, Predecessor); assert(Pos && "Predecessor does not exist"); Predecessors.erase(Pos); } /// Remove \p Successor from the successors of this block. void removeSuccessor(VPBlockBase *Successor) { - auto Pos = std::find(Successors.begin(), Successors.end(), Successor); + auto Pos = find(Successors, Successor); assert(Pos && "Successor does not exist"); Successors.erase(Pos); } diff --git a/utils/TableGen/GlobalISel/GIMatchTree.cpp b/utils/TableGen/GlobalISel/GIMatchTree.cpp index b7155398bd3..a67f1de67ed 100644 --- a/utils/TableGen/GlobalISel/GIMatchTree.cpp +++ b/utils/TableGen/GlobalISel/GIMatchTree.cpp @@ -121,8 +121,7 @@ void GIMatchTreeBuilderLeafInfo::declareInstr(const GIMatchDagInstr *Instr, unsi Info.bindOperandVariable(VarBinding.second, ID, VarBinding.first); // Clear the bit indicating we haven't visited this instr. - const auto &NodeI = std::find(MatchDag.instr_nodes_begin(), - MatchDag.instr_nodes_end(), Instr); + const auto &NodeI = find(MatchDag.instr_nodes(), Instr); assert(NodeI != MatchDag.instr_nodes_end() && "Instr isn't in this DAG"); unsigned InstrIdx = MatchDag.getInstrNodeIdx(NodeI); RemainingInstrNodes.reset(InstrIdx); diff --git a/utils/TableGen/SubtargetEmitter.cpp b/utils/TableGen/SubtargetEmitter.cpp index bd40d0e83de..7d2b4b929df 100644 --- a/utils/TableGen/SubtargetEmitter.cpp +++ b/utils/TableGen/SubtargetEmitter.cpp @@ -730,10 +730,8 @@ void SubtargetEmitter::EmitLoadStoreQueueInfo(const CodeGenProcModel &ProcModel, unsigned QueueID = 0; if (ProcModel.LoadQueue) { const Record *Queue = ProcModel.LoadQueue->getValueAsDef("QueueDescriptor"); - QueueID = - 1 + std::distance(ProcModel.ProcResourceDefs.begin(), - std::find(ProcModel.ProcResourceDefs.begin(), - ProcModel.ProcResourceDefs.end(), Queue)); + QueueID = 1 + std::distance(ProcModel.ProcResourceDefs.begin(), + find(ProcModel.ProcResourceDefs, Queue)); } OS << " " << QueueID << ", // Resource Descriptor for the Load Queue\n"; @@ -741,10 +739,8 @@ void SubtargetEmitter::EmitLoadStoreQueueInfo(const CodeGenProcModel &ProcModel, if (ProcModel.StoreQueue) { const Record *Queue = ProcModel.StoreQueue->getValueAsDef("QueueDescriptor"); - QueueID = - 1 + std::distance(ProcModel.ProcResourceDefs.begin(), - std::find(ProcModel.ProcResourceDefs.begin(), - ProcModel.ProcResourceDefs.end(), Queue)); + QueueID = 1 + std::distance(ProcModel.ProcResourceDefs.begin(), + find(ProcModel.ProcResourceDefs, Queue)); } OS << " " << QueueID << ", // Resource Descriptor for the Store Queue\n"; }