diff options
32 files changed, 88 insertions, 127 deletions
diff --git a/llvm/include/llvm/Analysis/LoopInfoImpl.h b/llvm/include/llvm/Analysis/LoopInfoImpl.h index 3a3e8679fb2..f4afa38ca81 100644 --- a/llvm/include/llvm/Analysis/LoopInfoImpl.h +++ b/llvm/include/llvm/Analysis/LoopInfoImpl.h @@ -288,8 +288,7 @@ void LoopBase<BlockT, LoopT>::verifyLoop() const { // Check the parent loop pointer. if (ParentLoop) { - assert(std::find(ParentLoop->begin(), ParentLoop->end(), this) != - ParentLoop->end() && + assert(is_contained(*ParentLoop, this) && "Loop is not a subloop of its parent!"); } #endif diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index 853a94afd9d..ca3f1ee7f87 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -904,7 +904,7 @@ public: void replaceElements(DINodeArray Elements) { #ifndef NDEBUG for (DINode *Op : getElements()) - assert(std::find(Elements->op_begin(), Elements->op_end(), Op) && + assert(is_contained(Elements->operands(), Op) && "Lost a member during member list replacement"); #endif replaceOperandWith(4, Elements.get()); @@ -2433,7 +2433,7 @@ public: void replaceElements(DIMacroNodeArray Elements) { #ifndef NDEBUG for (DIMacroNode *Op : getElements()) - assert(std::find(Elements->op_begin(), Elements->op_end(), Op) && + assert(is_contained(Elements->operands(), Op) && "Lost a macro node during macro node list replacement"); #endif replaceOperandWith(1, Elements.get()); diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp index fc6b02b7a70..9df3aee72d3 100644 --- a/llvm/lib/Analysis/LazyCallGraph.cpp +++ b/llvm/lib/Analysis/LazyCallGraph.cpp @@ -635,10 +635,9 @@ void LazyCallGraph::RefSCC::switchInternalEdgeToRef(Node &SourceN, // root DFS number. auto SCCNodes = make_range( PendingSCCStack.rbegin(), - std::find_if(PendingSCCStack.rbegin(), PendingSCCStack.rend(), - [RootDFSNumber](Node *N) { - return N->DFSNumber < RootDFSNumber; - })); + find_if(reverse(PendingSCCStack), [RootDFSNumber](const Node *N) { + return N->DFSNumber < RootDFSNumber; + })); // Form a new SCC out of these nodes and then clear them off our pending // stack. @@ -1120,10 +1119,9 @@ LazyCallGraph::RefSCC::removeInternalRefEdge(Node &SourceN, Node &TargetN) { // root DFS number. auto RefSCCNodes = make_range( PendingRefSCCStack.rbegin(), - std::find_if(PendingRefSCCStack.rbegin(), PendingRefSCCStack.rend(), - [RootDFSNumber](Node *N) { - return N->DFSNumber < RootDFSNumber; - })); + find_if(reverse(PendingRefSCCStack), [RootDFSNumber](const Node *N) { + return N->DFSNumber < RootDFSNumber; + })); // Mark the postorder number for these nodes and clear them off the // stack. We'll use the postorder number to pull them into RefSCCs at the @@ -1177,11 +1175,11 @@ LazyCallGraph::RefSCC::removeInternalRefEdge(Node &SourceN, Node &TargetN) { G->connectRefSCC(*RC); // Now erase all but the root's SCCs. - SCCs.erase(std::remove_if(SCCs.begin(), SCCs.end(), - [&](SCC *C) { - return PostOrderMapping.lookup(&*C->begin()) != - RootPostOrderNumber; - }), + SCCs.erase(remove_if(SCCs, + [&](SCC *C) { + return PostOrderMapping.lookup(&*C->begin()) != + RootPostOrderNumber; + }), SCCs.end()); #ifndef NDEBUG @@ -1370,10 +1368,9 @@ void LazyCallGraph::buildSCCs(RefSCC &RC, node_stack_range Nodes) { // root DFS number. auto SCCNodes = make_range( PendingSCCStack.rbegin(), - std::find_if(PendingSCCStack.rbegin(), PendingSCCStack.rend(), - [RootDFSNumber](Node *N) { - return N->DFSNumber < RootDFSNumber; - })); + find_if(reverse(PendingSCCStack), [RootDFSNumber](const Node *N) { + return N->DFSNumber < RootDFSNumber; + })); // Form a new SCC out of these nodes and then clear them off our pending // stack. RC.SCCs.push_back(createSCC(RC, SCCNodes)); @@ -1492,9 +1489,9 @@ LazyCallGraph::RefSCC *LazyCallGraph::getNextRefSCCInPostOrder() { // root DFS number. auto RefSCCNodes = node_stack_range( PendingRefSCCStack.rbegin(), - std::find_if( - PendingRefSCCStack.rbegin(), PendingRefSCCStack.rend(), - [RootDFSNumber](Node *N) { return N->DFSNumber < RootDFSNumber; })); + find_if(reverse(PendingRefSCCStack), [RootDFSNumber](const Node *N) { + return N->DFSNumber < RootDFSNumber; + })); // Form a new RefSCC out of these nodes and then clear them off our pending // stack. RefSCC *NewRC = createRefSCC(*this); diff --git a/llvm/lib/CodeGen/IfConversion.cpp b/llvm/lib/CodeGen/IfConversion.cpp index 22fe5288d8d..80d170689bf 100644 --- a/llvm/lib/CodeGen/IfConversion.cpp +++ b/llvm/lib/CodeGen/IfConversion.cpp @@ -1583,8 +1583,7 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI, IfcvtKind Kind) { // Prob(BBI.BB, CvtBBI->BB) * Prob(CvtBBI->BB, CvtBBI->FalseBB) auto NewTrueBB = getNextBlock(BBI.BB); auto NewNext = BBNext + BBCvt * CvtNext; - auto NewTrueBBIter = - std::find(BBI.BB->succ_begin(), BBI.BB->succ_end(), NewTrueBB); + auto NewTrueBBIter = find(BBI.BB->successors(), NewTrueBB); if (NewTrueBBIter != BBI.BB->succ_end()) BBI.BB->setSuccProbability(NewTrueBBIter, NewNext); @@ -2114,9 +2113,8 @@ void IfConverter::MergeBlocks(BBInfo &ToBBI, BBInfo &FromBBI, bool AddEdges) { // Set the edge probability from ToBBI.BB to FromBBI.BB to zero to avoid the // edge probability being merged to other edges when this edge is removed // later. - ToBBI.BB->setSuccProbability( - std::find(ToBBI.BB->succ_begin(), ToBBI.BB->succ_end(), FromBBI.BB), - BranchProbability::getZero()); + ToBBI.BB->setSuccProbability(find(ToBBI.BB->successors(), FromBBI.BB), + BranchProbability::getZero()); } for (unsigned i = 0, e = FromSuccs.size(); i != e; ++i) { @@ -2169,7 +2167,7 @@ void IfConverter::MergeBlocks(BBInfo &ToBBI, BBInfo &FromBBI, bool AddEdges) { // if (ToBBI.BB->isSuccessor(Succ)) ToBBI.BB->setSuccProbability( - std::find(ToBBI.BB->succ_begin(), ToBBI.BB->succ_end(), Succ), + find(ToBBI.BB->successors(), Succ), MBPI->getEdgeProbability(ToBBI.BB, Succ) + NewProb); else ToBBI.BB->addSuccessor(Succ, NewProb); diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp index 9aa58af391f..1dd028f4bce 100644 --- a/llvm/lib/CodeGen/InlineSpiller.cpp +++ b/llvm/lib/CodeGen/InlineSpiller.cpp @@ -185,10 +185,7 @@ private: bool isSnippet(const LiveInterval &SnipLI); void collectRegsToSpill(); - bool isRegToSpill(unsigned Reg) { - return std::find(RegsToSpill.begin(), - RegsToSpill.end(), Reg) != RegsToSpill.end(); - } + bool isRegToSpill(unsigned Reg) { return is_contained(RegsToSpill, Reg); } bool isSibling(unsigned Reg); bool hoistSpillInsideBB(LiveInterval &SpillLI, MachineInstr &CopyMI); diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 2c2373f84ea..58f758890d7 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -323,9 +323,8 @@ void MachineBasicBlock::printAsOperand(raw_ostream &OS, } void MachineBasicBlock::removeLiveIn(MCPhysReg Reg, LaneBitmask LaneMask) { - LiveInVector::iterator I = std::find_if( - LiveIns.begin(), LiveIns.end(), - [Reg] (const RegisterMaskPair &LI) { return LI.PhysReg == Reg; }); + LiveInVector::iterator I = find_if( + LiveIns, [Reg](const RegisterMaskPair &LI) { return LI.PhysReg == Reg; }); if (I == LiveIns.end()) return; @@ -335,9 +334,8 @@ void MachineBasicBlock::removeLiveIn(MCPhysReg Reg, LaneBitmask LaneMask) { } bool MachineBasicBlock::isLiveIn(MCPhysReg Reg, LaneBitmask LaneMask) const { - livein_iterator I = std::find_if( - LiveIns.begin(), LiveIns.end(), - [Reg] (const RegisterMaskPair &LI) { return LI.PhysReg == Reg; }); + livein_iterator I = find_if( + LiveIns, [Reg](const RegisterMaskPair &LI) { return LI.PhysReg == Reg; }); return I != livein_end() && (I->LaneMask & LaneMask) != 0; } @@ -661,11 +659,11 @@ MachineBasicBlock::transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB) { } bool MachineBasicBlock::isPredecessor(const MachineBasicBlock *MBB) const { - return std::find(pred_begin(), pred_end(), MBB) != pred_end(); + return is_contained(predecessors(), MBB); } bool MachineBasicBlock::isSuccessor(const MachineBasicBlock *MBB) const { - return std::find(succ_begin(), succ_end(), MBB) != succ_end(); + return is_contained(successors(), MBB); } bool MachineBasicBlock::isLayoutSuccessor(const MachineBasicBlock *MBB) const { diff --git a/llvm/lib/CodeGen/MachineBranchProbabilityInfo.cpp b/llvm/lib/CodeGen/MachineBranchProbabilityInfo.cpp index fe734061837..21eff9dfff9 100644 --- a/llvm/lib/CodeGen/MachineBranchProbabilityInfo.cpp +++ b/llvm/lib/CodeGen/MachineBranchProbabilityInfo.cpp @@ -50,8 +50,7 @@ BranchProbability MachineBranchProbabilityInfo::getEdgeProbability( const MachineBasicBlock *Src, const MachineBasicBlock *Dst) const { // This is a linear search. Try to use the const_succ_iterator version when // possible. - return getEdgeProbability(Src, - std::find(Src->succ_begin(), Src->succ_end(), Dst)); + return getEdgeProbability(Src, find(Src->successors(), Dst)); } bool MachineBranchProbabilityInfo::isEdgeHot( diff --git a/llvm/lib/CodeGen/RegisterPressure.cpp b/llvm/lib/CodeGen/RegisterPressure.cpp index dba8929ef05..45c4aba9cbc 100644 --- a/llvm/lib/CodeGen/RegisterPressure.cpp +++ b/llvm/lib/CodeGen/RegisterPressure.cpp @@ -769,10 +769,9 @@ void RegPressureTracker::recede(const RegisterOperands &RegOpers, if (!TrackLaneMasks) { addRegLanes(*LiveUses, RegisterMaskPair(Reg, NewMask)); } else { - auto I = std::find_if(LiveUses->begin(), LiveUses->end(), - [Reg](const RegisterMaskPair Other) { - return Other.RegUnit == Reg; - }); + auto I = find_if(*LiveUses, [Reg](const RegisterMaskPair Other) { + return Other.RegUnit == Reg; + }); bool IsRedef = I != LiveUses->end(); if (IsRedef) { // ignore re-defs here... diff --git a/llvm/lib/CodeGen/ScheduleDAG.cpp b/llvm/lib/CodeGen/ScheduleDAG.cpp index efde61ece63..6d9235a35aa 100644 --- a/llvm/lib/CodeGen/ScheduleDAG.cpp +++ b/llvm/lib/CodeGen/ScheduleDAG.cpp @@ -139,8 +139,7 @@ void SUnit::removePred(const SDep &D) { SDep P = D; P.setSUnit(this); SUnit *N = D.getSUnit(); - SmallVectorImpl<SDep>::iterator Succ = std::find(N->Succs.begin(), - N->Succs.end(), P); + SmallVectorImpl<SDep>::iterator Succ = find(N->Succs, P); assert(Succ != N->Succs.end() && "Mismatching preds / succs lists!"); N->Succs.erase(Succ); Preds.erase(I); diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp index 1abb754f7cb..71cd7ad0d8e 100644 --- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp +++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp @@ -625,7 +625,7 @@ void MCJIT::UnregisterJITEventListener(JITEventListener *L) { if (!L) return; MutexGuard locked(lock); - auto I = std::find(EventListeners.rbegin(), EventListeners.rend(), L); + auto I = find(reverse(EventListeners), L); if (I != EventListeners.rend()) { std::swap(*I, EventListeners.back()); EventListeners.pop_back(); diff --git a/llvm/lib/ExecutionEngine/TargetSelect.cpp b/llvm/lib/ExecutionEngine/TargetSelect.cpp index b45f0c89de8..6e2973c04e5 100644 --- a/llvm/lib/ExecutionEngine/TargetSelect.cpp +++ b/llvm/lib/ExecutionEngine/TargetSelect.cpp @@ -48,9 +48,8 @@ TargetMachine *EngineBuilder::selectTarget(const Triple &TargetTriple, // Adjust the triple to match what the user requested. const Target *TheTarget = nullptr; if (!MArch.empty()) { - auto I = std::find_if( - TargetRegistry::targets().begin(), TargetRegistry::targets().end(), - [&](const Target &T) { return MArch == T.getName(); }); + auto I = find_if(TargetRegistry::targets(), + [&](const Target &T) { return MArch == T.getName(); }); if (I == TargetRegistry::targets().end()) { if (ErrorStr) diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index cbbd808475b..5e41b9f410e 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/lib/IR/Metadata.cpp @@ -878,7 +878,7 @@ MDNode *MDNode::intersect(MDNode *A, MDNode *B) { SmallVector<Metadata *, 4> MDs; for (Metadata *MD : A->operands()) - if (std::find(B->op_begin(), B->op_end(), MD) != B->op_end()) + if (is_contained(B->operands(), MD)) MDs.push_back(MD); // FIXME: This preserves long-standing behaviour, but is it really the right @@ -892,7 +892,7 @@ MDNode *MDNode::getMostGenericAliasScope(MDNode *A, MDNode *B) { SmallVector<Metadata *, 4> MDs(B->op_begin(), B->op_end()); for (Metadata *MD : A->operands()) - if (std::find(B->op_begin(), B->op_end(), MD) == B->op_end()) + if (!is_contained(B->operands(), MD)) MDs.push_back(MD); // FIXME: This preserves long-standing behaviour, but is it really the right diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index 6ae37fa6f15..b523497b247 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -124,10 +124,10 @@ bool Value::isUsedInBasicBlock(const BasicBlock *BB) const { const_user_iterator UI = user_begin(), UE = user_end(); for (; BI != BE && UI != UE; ++BI, ++UI) { // Scan basic block: Check if this Value is used by the instruction at BI. - if (std::find(BI->op_begin(), BI->op_end(), this) != BI->op_end()) + if (is_contained(BI->operands(), this)) return true; // Scan use list: Check if the use at UI is in BB. - const Instruction *User = dyn_cast<Instruction>(*UI); + const auto *User = dyn_cast<Instruction>(*UI); if (User && User->getParent() == BB) return true; } diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc index 117d4e8bcb5..97b8394f023 100644 --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -284,7 +284,7 @@ bool llvm::sys::RemoveFileOnSignal(StringRef Filename, void llvm::sys::DontRemoveFileOnSignal(StringRef Filename) { sys::SmartScopedLock<true> Guard(*SignalsMutex); std::vector<std::string>::reverse_iterator RI = - std::find(FilesToRemove->rbegin(), FilesToRemove->rend(), Filename); + find(reverse(*FilesToRemove), Filename); std::vector<std::string>::iterator I = FilesToRemove->end(); if (RI != FilesToRemove->rend()) I = FilesToRemove->erase(RI.base()-1); diff --git a/llvm/lib/Support/Windows/Signals.inc b/llvm/lib/Support/Windows/Signals.inc index 1e2fa4210df..d3a70c365a4 100644 --- a/llvm/lib/Support/Windows/Signals.inc +++ b/llvm/lib/Support/Windows/Signals.inc @@ -470,7 +470,7 @@ void sys::DontRemoveFileOnSignal(StringRef Filename) { RegisterHandler(); std::vector<std::string>::reverse_iterator I = - std::find(FilesToRemove->rbegin(), FilesToRemove->rend(), Filename); + find(reverse(*FilesToRemove), Filename); if (I != FilesToRemove->rend()) FilesToRemove->erase(I.base()-1); diff --git a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp index aac6c5bcf5d..7992d029d81 100644 --- a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp +++ b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp @@ -582,7 +582,7 @@ bool ARMConstantIslands::BBHasFallthrough(MachineBasicBlock *MBB) { return false; MachineBasicBlock *NextBB = &*std::next(MBBI); - if (std::find(MBB->succ_begin(), MBB->succ_end(), NextBB) == MBB->succ_end()) + if (!MBB->isSuccessor(NextBB)) return false; // Try to analyze the end of the block. A potential fallthrough may already diff --git a/llvm/lib/Target/Hexagon/HexagonBlockRanges.cpp b/llvm/lib/Target/Hexagon/HexagonBlockRanges.cpp index 5c44029dc6e..c6a5e7a55ea 100644 --- a/llvm/lib/Target/Hexagon/HexagonBlockRanges.cpp +++ b/llvm/lib/Target/Hexagon/HexagonBlockRanges.cpp @@ -73,7 +73,7 @@ void HexagonBlockRanges::IndexRange::merge(const IndexRange &A) { void HexagonBlockRanges::RangeList::include(const RangeList &RL) { for (auto &R : RL) - if (std::find(begin(), end(), R) == end()) + if (!is_contained(*this, R)) push_back(R); } diff --git a/llvm/lib/Target/TargetMachineC.cpp b/llvm/lib/Target/TargetMachineC.cpp index 02836eaf08e..5fb5b022780 100644 --- a/llvm/lib/Target/TargetMachineC.cpp +++ b/llvm/lib/Target/TargetMachineC.cpp @@ -59,9 +59,8 @@ LLVMTargetRef LLVMGetNextTarget(LLVMTargetRef T) { LLVMTargetRef LLVMGetTargetFromName(const char *Name) { StringRef NameRef = Name; - auto I = std::find_if( - TargetRegistry::targets().begin(), TargetRegistry::targets().end(), - [&](const Target &T) { return T.getName() == NameRef; }); + auto I = find_if(TargetRegistry::targets(), + [&](const Target &T) { return T.getName() == NameRef; }); return I != TargetRegistry::targets().end() ? wrap(&*I) : nullptr; } diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index af97864043a..4c913bfd9f5 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -9731,9 +9731,8 @@ static SDValue lowerV8I16GeneralSingleInputVectorShuffle( // by inputs being moved and *staying* in that half. if (IncomingInputs.size() == 1) { if (isWordClobbered(SourceHalfMask, IncomingInputs[0] - SourceOffset)) { - int InputFixed = std::find(std::begin(SourceHalfMask), - std::end(SourceHalfMask), -1) - - std::begin(SourceHalfMask) + SourceOffset; + int InputFixed = find(SourceHalfMask, -1) - std::begin(SourceHalfMask) + + SourceOffset; SourceHalfMask[InputFixed - SourceOffset] = IncomingInputs[0] - SourceOffset; std::replace(HalfMask.begin(), HalfMask.end(), IncomingInputs[0], diff --git a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp index 6f3505b1351..675a5d17ad9 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp @@ -835,8 +835,8 @@ Instruction *InstCombiner::SliceUpIllegalIntegerPHI(PHINode &FirstPhi) { // needed piece. if (PHINode *OldInVal = dyn_cast<PHINode>(PN->getIncomingValue(i))) if (PHIsInspected.count(OldInVal)) { - unsigned RefPHIId = std::find(PHIsToSlice.begin(),PHIsToSlice.end(), - OldInVal)-PHIsToSlice.begin(); + unsigned RefPHIId = + find(PHIsToSlice, OldInVal) - PHIsToSlice.begin(); PHIUsers.push_back(PHIUsageRecord(RefPHIId, Offset, cast<Instruction>(Res))); ++UserE; diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index d9417816a13..d9489bc0a28 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -2799,8 +2799,7 @@ void LSRInstance::FinalizeChain(IVChain &Chain) { for (const IVInc &Inc : Chain) { DEBUG(dbgs() << " Inc: " << Inc.UserInst << "\n"); - auto UseI = std::find(Inc.UserInst->op_begin(), Inc.UserInst->op_end(), - Inc.IVOperand); + auto UseI = find(Inc.UserInst->operands(), Inc.IVOperand); assert(UseI != Inc.UserInst->op_end() && "cannot find IV operand"); IVIncSet.insert(UseI); } @@ -2933,8 +2932,8 @@ void LSRInstance::CollectFixupsAndInitialFormulae() { for (const IVStrideUse &U : IU) { Instruction *UserInst = U.getUser(); // Skip IV users that are part of profitable IV Chains. - User::op_iterator UseI = std::find(UserInst->op_begin(), UserInst->op_end(), - U.getOperandValToReplace()); + User::op_iterator UseI = + find(UserInst->operands(), U.getOperandValToReplace()); assert(UseI != UserInst->op_end() && "cannot find IV operand"); if (IVIncSet.count(UseI)) continue; diff --git a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp index d5ff9975037..16c88270a84 100644 --- a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -347,7 +347,7 @@ static bool canMoveAboveCall(Instruction *I, CallInst *CI) { // return value of the call, it must only use things that are defined before // the call, or movable instructions between the call and the instruction // itself. - return std::find(I->op_begin(), I->op_end(), CI) == I->op_end(); + return !is_contained(I->operands(), CI); } /// Return true if the specified value is the same when the return would exit diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 549fc8c8091..624db3ca7c6 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -307,7 +307,7 @@ bool RecurrenceDescriptor::AddReductionVar(PHINode *Phi, RecurrenceKind Kind, // The instruction used by an outside user must be the last instruction // before we feed back to the reduction phi. Otherwise, we loose VF-1 // operations on the value. - if (std::find(Phi->op_begin(), Phi->op_end(), Cur) == Phi->op_end()) + if (!is_contained(Phi->operands(), Cur)) return false; ExitInstruction = Cur; diff --git a/llvm/lib/Transforms/Utils/MemorySSA.cpp b/llvm/lib/Transforms/Utils/MemorySSA.cpp index 8a4fd93b1a8..a99cfa57a97 100644 --- a/llvm/lib/Transforms/Utils/MemorySSA.cpp +++ b/llvm/lib/Transforms/Utils/MemorySSA.cpp @@ -1614,9 +1614,8 @@ MemoryAccess *MemorySSA::createMemoryAccessInBB(Instruction *I, auto *Accesses = getOrCreateAccessList(BB); if (Point == Beginning) { // It goes after any phi nodes - auto AI = std::find_if( - Accesses->begin(), Accesses->end(), - [](const MemoryAccess &MA) { return !isa<MemoryPhi>(MA); }); + auto AI = find_if( + *Accesses, [](const MemoryAccess &MA) { return !isa<MemoryPhi>(MA); }); Accesses->insert(AI, NewAccess); } else { diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index a5d10c0e5bf..8aa826fe7ab 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -4033,8 +4033,7 @@ void InnerLoopVectorizer::predicateStores() { InnerLoopVectorizer::VectorParts InnerLoopVectorizer::createEdgeMask(BasicBlock *Src, BasicBlock *Dst) { - assert(std::find(pred_begin(Dst), pred_end(Dst), Src) != pred_end(Dst) && - "Invalid edge"); + assert(is_contained(predecessors(Dst), Src) && "Invalid edge"); // Look for cached value. std::pair<BasicBlock *, BasicBlock *> Edge(Src, Dst); diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 44de90b7d8b..83d1aff07fe 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -2650,8 +2650,7 @@ Value *BoUpSLP::vectorizeTree() { // Skip users that we already RAUW. This happens when one instruction // has multiple uses of the same value. - if (std::find(Scalar->user_begin(), Scalar->user_end(), User) == - Scalar->user_end()) + if (!is_contained(Scalar->users(), User)) continue; assert(ScalarToTreeEntry.count(Scalar) && "Invalid scalar"); @@ -3999,8 +3998,7 @@ public: /// \brief Try to find a reduction tree. bool matchAssociativeReduction(PHINode *Phi, BinaryOperator *B) { - assert((!Phi || - std::find(Phi->op_begin(), Phi->op_end(), B) != Phi->op_end()) && + assert((!Phi || is_contained(Phi->operands(), B)) && "Thi phi needs to use the binary operator"); // We could have a initial reductions that is not an add. diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index d0ac915e90a..9782659fb52 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -862,9 +862,9 @@ static void DumpLiteralPointerSection(MachOObjectFile *O, } // First look for an external relocation entry for this literal pointer. - auto Reloc = std::find_if( - Relocs.begin(), Relocs.end(), - [&](const std::pair<uint64_t, SymbolRef> &P) { return P.first == i; }); + auto Reloc = find_if(Relocs, [&](const std::pair<uint64_t, SymbolRef> &P) { + return P.first == i; + }); if (Reloc != Relocs.end()) { symbol_iterator RelocSym = Reloc->second; Expected<StringRef> SymName = RelocSym->getName(); diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 7482965b784..ec03a6ab815 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -240,18 +240,17 @@ private: llvm::object::ObjectFile const &Object; }; SectionFilter ToolSectionFilter(llvm::object::ObjectFile const &O) { - return SectionFilter([](llvm::object::SectionRef const &S) { - if(FilterSections.empty()) - return true; - llvm::StringRef String; - std::error_code error = S.getName(String); - if (error) - return false; - return std::find(FilterSections.begin(), - FilterSections.end(), - String) != FilterSections.end(); - }, - O); + return SectionFilter( + [](llvm::object::SectionRef const &S) { + if (FilterSections.empty()) + return true; + llvm::StringRef String; + std::error_code error = S.getName(String); + if (error) + return false; + return is_contained(FilterSections, String); + }, + O); } } diff --git a/llvm/utils/TableGen/AsmWriterEmitter.cpp b/llvm/utils/TableGen/AsmWriterEmitter.cpp index fc2138f7e8e..e80b0db31c4 100644 --- a/llvm/utils/TableGen/AsmWriterEmitter.cpp +++ b/llvm/utils/TableGen/AsmWriterEmitter.cpp @@ -157,8 +157,7 @@ FindUniqueOperandCommands(std::vector<std::string> &UniqueOperandCommands, // Check to see if we already have 'Command' in UniqueOperandCommands. // If not, add it. - auto I = std::find(UniqueOperandCommands.begin(), - UniqueOperandCommands.end(), Command); + auto I = find(UniqueOperandCommands, Command); if (I != UniqueOperandCommands.end()) { size_t idx = I - UniqueOperandCommands.begin(); InstrsForCase[idx] += ", "; @@ -838,9 +837,8 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) { Rec->isSubClassOf("Operand")) { std::string PrintMethod = Rec->getValueAsString("PrintMethod"); if (PrintMethod != "" && PrintMethod != "printOperand") { - PrintMethodIdx = std::find(PrintMethods.begin(), - PrintMethods.end(), PrintMethod) - - PrintMethods.begin(); + PrintMethodIdx = + find(PrintMethods, PrintMethod) - PrintMethods.begin(); if (static_cast<unsigned>(PrintMethodIdx) == PrintMethods.size()) PrintMethods.push_back(PrintMethod); } diff --git a/llvm/utils/TableGen/CodeGenSchedule.cpp b/llvm/utils/TableGen/CodeGenSchedule.cpp index d6b5e0a90eb..22f48ad3d48 100644 --- a/llvm/utils/TableGen/CodeGenSchedule.cpp +++ b/llvm/utils/TableGen/CodeGenSchedule.cpp @@ -1498,9 +1498,7 @@ void CodeGenSchedModels::collectProcResources() { if (!(*RI)->getValueInit("SchedModel")->isComplete()) continue; CodeGenProcModel &PM = getProcModel((*RI)->getValueAsDef("SchedModel")); - RecIter I = std::find(PM.ProcResourceDefs.begin(), - PM.ProcResourceDefs.end(), *RI); - if (I == PM.ProcResourceDefs.end()) + if (!is_contained(PM.ProcResourceDefs, *RI)) PM.ProcResourceDefs.push_back(*RI); } // Finalize each ProcModel by sorting the record arrays. @@ -1716,9 +1714,7 @@ void CodeGenSchedModels::addProcResource(Record *ProcResKind, Record *ProcResUnits = findProcResUnits(ProcResKind, PM); // See if this ProcResource is already associated with this processor. - RecIter I = std::find(PM.ProcResourceDefs.begin(), - PM.ProcResourceDefs.end(), ProcResUnits); - if (I != PM.ProcResourceDefs.end()) + if (is_contained(PM.ProcResourceDefs, ProcResUnits)) return; PM.ProcResourceDefs.push_back(ProcResUnits); @@ -1737,8 +1733,7 @@ void CodeGenSchedModels::addWriteRes(Record *ProcWriteResDef, unsigned PIdx) { assert(PIdx && "don't add resources to an invalid Processor model"); RecVec &WRDefs = ProcModels[PIdx].WriteResDefs; - RecIter WRI = find(WRDefs, ProcWriteResDef); - if (WRI != WRDefs.end()) + if (is_contained(WRDefs, ProcWriteResDef)) return; WRDefs.push_back(ProcWriteResDef); @@ -1754,8 +1749,7 @@ void CodeGenSchedModels::addWriteRes(Record *ProcWriteResDef, unsigned PIdx) { void CodeGenSchedModels::addReadAdvance(Record *ProcReadAdvanceDef, unsigned PIdx) { RecVec &RADefs = ProcModels[PIdx].ReadAdvanceDefs; - RecIter I = find(RADefs, ProcReadAdvanceDef); - if (I != RADefs.end()) + if (is_contained(RADefs, ProcReadAdvanceDef)) return; RADefs.push_back(ProcReadAdvanceDef); } diff --git a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp index 1200324d6b0..733c7549b2c 100644 --- a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp +++ b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp @@ -1108,9 +1108,7 @@ unsigned FilterChooser::getDecoderIndex(DecoderSet &Decoders, // Make sure the predicate is in the table. Decoders.insert(StringRef(Decoder)); // Now figure out the index for when we write out the table. - DecoderSet::const_iterator P = std::find(Decoders.begin(), - Decoders.end(), - Decoder.str()); + DecoderSet::const_iterator P = find(Decoders, Decoder.str()); return (unsigned)(P - Decoders.begin()); } @@ -1183,9 +1181,7 @@ unsigned FilterChooser::getPredicateIndex(DecoderTableInfo &TableInfo, // Make sure the predicate is in the table. TableInfo.Predicates.insert(Predicate.str()); // Now figure out the index for when we write out the table. - PredicateSet::const_iterator P = std::find(TableInfo.Predicates.begin(), - TableInfo.Predicates.end(), - Predicate.str()); + PredicateSet::const_iterator P = find(TableInfo.Predicates, Predicate.str()); return (unsigned)(P - TableInfo.Predicates.begin()); } diff --git a/llvm/utils/TableGen/SubtargetEmitter.cpp b/llvm/utils/TableGen/SubtargetEmitter.cpp index bc56384d2fa..9719412d8ee 100644 --- a/llvm/utils/TableGen/SubtargetEmitter.cpp +++ b/llvm/utils/TableGen/SubtargetEmitter.cpp @@ -826,9 +826,7 @@ void SubtargetEmitter::GenSchedClassTables(const CodeGenProcModel &ProcModel, HasVariants = true; break; } - IdxIter PIPos = std::find(TI->ProcIndices.begin(), - TI->ProcIndices.end(), ProcModel.Index); - if (PIPos != TI->ProcIndices.end()) { + if (is_contained(TI->ProcIndices, ProcModel.Index)) { HasVariants = true; break; } @@ -843,9 +841,7 @@ void SubtargetEmitter::GenSchedClassTables(const CodeGenProcModel &ProcModel, // If ProcIndices contains 0, this class applies to all processors. assert(!SC.ProcIndices.empty() && "expect at least one procidx"); if (SC.ProcIndices[0] != 0) { - IdxIter PIPos = std::find(SC.ProcIndices.begin(), - SC.ProcIndices.end(), ProcModel.Index); - if (PIPos == SC.ProcIndices.end()) + if (!is_contained(SC.ProcIndices, ProcModel.Index)) continue; } IdxVec Writes = SC.Writes; |