diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-08-11 22:21:41 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-08-11 22:21:41 +0000 |
commit | 0d955d0bf5cbbd50061309ad2c08c0dcf8f62039 (patch) | |
tree | 19991ceb4f16b4e3ce06fe2c39304d27a93b8b7b /llvm/lib | |
parent | 332b3b22109e9c0d84456888150c0a30f378f984 (diff) | |
download | bcm5719-llvm-0d955d0bf5cbbd50061309ad2c08c0dcf8f62039.tar.gz bcm5719-llvm-0d955d0bf5cbbd50061309ad2c08c0dcf8f62039.zip |
Use the range variant of find instead of unpacking begin/end
If the result of the find is only used to compare against end(), just
use is_contained instead.
No functionality change is intended.
llvm-svn: 278433
Diffstat (limited to 'llvm/lib')
55 files changed, 90 insertions, 126 deletions
diff --git a/llvm/lib/Analysis/EHPersonalities.cpp b/llvm/lib/Analysis/EHPersonalities.cpp index 5f951f5112e..8896ef06d0c 100644 --- a/llvm/lib/Analysis/EHPersonalities.cpp +++ b/llvm/lib/Analysis/EHPersonalities.cpp @@ -82,7 +82,7 @@ DenseMap<BasicBlock *, ColorVector> llvm::colorEHFunclets(Function &F) { } // Note that this is a member of the given color. ColorVector &Colors = BlockColors[Visiting]; - if (std::find(Colors.begin(), Colors.end(), Color) == Colors.end()) + if (!is_contained(Colors, Color)) Colors.push_back(Color); else continue; diff --git a/llvm/lib/Analysis/GlobalsModRef.cpp b/llvm/lib/Analysis/GlobalsModRef.cpp index 8289e585d27..0da888d47d1 100644 --- a/llvm/lib/Analysis/GlobalsModRef.cpp +++ b/llvm/lib/Analysis/GlobalsModRef.cpp @@ -521,7 +521,7 @@ void GlobalsAAResult::AnalyzeCallGraph(CallGraph &CG, Module &M) { // Can't say anything about it. However, if it is inside our SCC, // then nothing needs to be done. CallGraphNode *CalleeNode = CG[Callee]; - if (std::find(SCC.begin(), SCC.end(), CalleeNode) == SCC.end()) + if (!is_contained(SCC, CalleeNode)) KnowNothing = true; } } else { diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp index 404b8312546..fc6b02b7a70 100644 --- a/llvm/lib/Analysis/LazyCallGraph.cpp +++ b/llvm/lib/Analysis/LazyCallGraph.cpp @@ -907,8 +907,7 @@ void LazyCallGraph::RefSCC::removeOutgoingEdge(Node &SourceN, Node &TargetN) { RefSCC &TargetRC = *G->lookupRefSCC(TargetN); assert(&TargetRC != this && "The target must not be a member of this RefSCC"); - assert(std::find(G->LeafRefSCCs.begin(), G->LeafRefSCCs.end(), this) == - G->LeafRefSCCs.end() && + assert(!is_contained(G->LeafRefSCCs, this) && "Cannot have a leaf RefSCC source."); // First remove it from the node. diff --git a/llvm/lib/Analysis/PHITransAddr.cpp b/llvm/lib/Analysis/PHITransAddr.cpp index b4aad74d50d..84ecd4ab980 100644 --- a/llvm/lib/Analysis/PHITransAddr.cpp +++ b/llvm/lib/Analysis/PHITransAddr.cpp @@ -62,8 +62,7 @@ static bool VerifySubExpr(Value *Expr, // If it's an instruction, it is either in Tmp or its operands recursively // are. - SmallVectorImpl<Instruction*>::iterator Entry = - std::find(InstInputs.begin(), InstInputs.end(), I); + SmallVectorImpl<Instruction *>::iterator Entry = find(InstInputs, I); if (Entry != InstInputs.end()) { InstInputs.erase(Entry); return true; @@ -126,8 +125,7 @@ static void RemoveInstInputs(Value *V, if (!I) return; // If the instruction is in the InstInputs list, remove it. - SmallVectorImpl<Instruction*>::iterator Entry = - std::find(InstInputs.begin(), InstInputs.end(), I); + SmallVectorImpl<Instruction *>::iterator Entry = find(InstInputs, I); if (Entry != InstInputs.end()) { InstInputs.erase(Entry); return; @@ -150,8 +148,7 @@ Value *PHITransAddr::PHITranslateSubExpr(Value *V, BasicBlock *CurBB, if (!Inst) return V; // Determine whether 'Inst' is an input to our PHI translatable expression. - bool isInput = - std::find(InstInputs.begin(), InstInputs.end(), Inst) != InstInputs.end(); + bool isInput = is_contained(InstInputs, Inst); // Handle inputs instructions if needed. if (isInput) { @@ -165,7 +162,7 @@ Value *PHITransAddr::PHITranslateSubExpr(Value *V, BasicBlock *CurBB, // translated, we need to incorporate the value into the expression or fail. // In either case, the instruction itself isn't an input any longer. - InstInputs.erase(std::find(InstInputs.begin(), InstInputs.end(), Inst)); + InstInputs.erase(find(InstInputs, Inst)); // If this is a PHI, go ahead and translate it. if (PHINode *PN = dyn_cast<PHINode>(Inst)) @@ -272,8 +269,7 @@ Value *PHITransAddr::PHITranslateSubExpr(Value *V, BasicBlock *CurBB, isNSW = isNUW = false; // If the old 'LHS' was an input, add the new 'LHS' as an input. - if (std::find(InstInputs.begin(), InstInputs.end(), BOp) != - InstInputs.end()) { + if (is_contained(InstInputs, BOp)) { RemoveInstInputs(BOp, InstInputs); AddAsInput(LHS); } diff --git a/llvm/lib/CodeGen/AllocationOrder.cpp b/llvm/lib/CodeGen/AllocationOrder.cpp index 40451c0d6c1..d840a2f69ab 100644 --- a/llvm/lib/CodeGen/AllocationOrder.cpp +++ b/llvm/lib/CodeGen/AllocationOrder.cpp @@ -48,7 +48,7 @@ AllocationOrder::AllocationOrder(unsigned VirtReg, }); #ifndef NDEBUG for (unsigned I = 0, E = Hints.size(); I != E; ++I) - assert(std::find(Order.begin(), Order.end(), Hints[I]) != Order.end() && + assert(is_contained(Order, Hints[I]) && "Target hint is outside allocation order."); #endif } diff --git a/llvm/lib/CodeGen/AllocationOrder.h b/llvm/lib/CodeGen/AllocationOrder.h index 2aee3a63a2b..8223a52e333 100644 --- a/llvm/lib/CodeGen/AllocationOrder.h +++ b/llvm/lib/CodeGen/AllocationOrder.h @@ -18,6 +18,7 @@ #define LLVM_LIB_CODEGEN_ALLOCATIONORDER_H #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/MC/MCRegisterInfo.h" namespace llvm { @@ -79,9 +80,7 @@ public: bool isHint() const { return Pos <= 0; } /// Return true if PhysReg is a preferred register. - bool isHint(unsigned PhysReg) const { - return std::find(Hints.begin(), Hints.end(), PhysReg) != Hints.end(); - } + bool isHint(unsigned PhysReg) const { return is_contained(Hints, PhysReg); } }; } // end namespace llvm diff --git a/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp b/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp index 480fca1454f..c64432b8141 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp @@ -83,7 +83,7 @@ static void dropRegDescribedVar(RegDescribedVarsMap &RegVars, unsigned RegNo, const auto &I = RegVars.find(RegNo); assert(RegNo != 0U && I != RegVars.end()); auto &VarSet = I->second; - const auto &VarPos = std::find(VarSet.begin(), VarSet.end(), Var); + const auto &VarPos = find(VarSet, Var); assert(VarPos != VarSet.end()); VarSet.erase(VarPos); // Don't keep empty sets in a map to keep it as small as possible. @@ -96,7 +96,7 @@ static void addRegDescribedVar(RegDescribedVarsMap &RegVars, unsigned RegNo, InlinedVariable Var) { assert(RegNo != 0U); auto &VarSet = RegVars[RegNo]; - assert(std::find(VarSet.begin(), VarSet.end(), Var) == VarSet.end()); + assert(!is_contained(VarSet, Var)); VarSet.push_back(Var); } diff --git a/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp index c09ef6adea6..8baee4db772 100644 --- a/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp @@ -50,7 +50,7 @@ static void EmitCamlGlobal(const Module &M, AsmPrinter &AP, const char *Id) { std::string SymName; SymName += "caml"; size_t Letter = SymName.size(); - SymName.append(MId.begin(), std::find(MId.begin(), MId.end(), '.')); + SymName.append(MId.begin(), find(MId, '.')); SymName += "__"; SymName += Id; diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index ede404149a1..c87f3bc9073 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -3665,8 +3665,7 @@ isProfitableToFoldIntoAddressingMode(Instruction *I, ExtAddrMode &AMBefore, TPT.rollback(LastKnownGood); // If the match didn't cover I, then it won't be shared by it. - if (std::find(MatchedAddrModeInsts.begin(), MatchedAddrModeInsts.end(), - I) == MatchedAddrModeInsts.end()) + if (!is_contained(MatchedAddrModeInsts, I)) return false; MatchedAddrModeInsts.clear(); diff --git a/llvm/lib/CodeGen/LatencyPriorityQueue.cpp b/llvm/lib/CodeGen/LatencyPriorityQueue.cpp index 43218492ed1..86ef898932a 100644 --- a/llvm/lib/CodeGen/LatencyPriorityQueue.cpp +++ b/llvm/lib/CodeGen/LatencyPriorityQueue.cpp @@ -133,7 +133,7 @@ SUnit *LatencyPriorityQueue::pop() { void LatencyPriorityQueue::remove(SUnit *SU) { assert(!Queue.empty() && "Queue is empty!"); - std::vector<SUnit *>::iterator I = std::find(Queue.begin(), Queue.end(), SU); + std::vector<SUnit *>::iterator I = find(Queue, SU); if (I != std::prev(Queue.end())) std::swap(*I, Queue.back()); Queue.pop_back(); diff --git a/llvm/lib/CodeGen/LiveIntervalUnion.cpp b/llvm/lib/CodeGen/LiveIntervalUnion.cpp index 025d99ce788..fc2f233f6d6 100644 --- a/llvm/lib/CodeGen/LiveIntervalUnion.cpp +++ b/llvm/lib/CodeGen/LiveIntervalUnion.cpp @@ -14,6 +14,7 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/LiveIntervalUnion.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SparseBitVector.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" @@ -102,9 +103,7 @@ void LiveIntervalUnion::verify(LiveVirtRegBitSet& VisitedVRegs) { // Scan the vector of interfering virtual registers in this union. Assume it's // quite small. bool LiveIntervalUnion::Query::isSeenInterference(LiveInterval *VirtReg) const { - SmallVectorImpl<LiveInterval*>::const_iterator I = - std::find(InterferingVRegs.begin(), InterferingVRegs.end(), VirtReg); - return I != InterferingVRegs.end(); + return is_contained(InterferingVRegs, VirtReg); } // Collect virtual registers in this union that interfere with this diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 689dd0764ce..2c2373f84ea 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -545,7 +545,7 @@ void MachineBasicBlock::addSuccessorWithoutProb(MachineBasicBlock *Succ) { void MachineBasicBlock::removeSuccessor(MachineBasicBlock *Succ, bool NormalizeSuccProbs) { - succ_iterator I = std::find(Successors.begin(), Successors.end(), Succ); + succ_iterator I = find(Successors, Succ); removeSuccessor(I, NormalizeSuccProbs); } @@ -611,7 +611,7 @@ void MachineBasicBlock::addPredecessor(MachineBasicBlock *Pred) { } void MachineBasicBlock::removePredecessor(MachineBasicBlock *Pred) { - pred_iterator I = std::find(Predecessors.begin(), Predecessors.end(), Pred); + pred_iterator I = find(Predecessors, Pred); assert(I != Predecessors.end() && "Pred is not a predecessor of this block!"); Predecessors.erase(I); } @@ -775,7 +775,7 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, continue; unsigned Reg = OI->getReg(); - if (std::find(UsedRegs.begin(), UsedRegs.end(), Reg) == UsedRegs.end()) + if (!is_contained(UsedRegs, Reg)) UsedRegs.push_back(Reg); } } @@ -802,9 +802,8 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, for (SmallVectorImpl<MachineInstr*>::iterator I = Terminators.begin(), E = Terminators.end(); I != E; ++I) { - if (std::find(NewTerminators.begin(), NewTerminators.end(), *I) == - NewTerminators.end()) - Indexes->removeMachineInstrFromMaps(**I); + if (!is_contained(NewTerminators, *I)) + Indexes->removeMachineInstrFromMaps(**I); } } diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index 27da8498897..d241e377336 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -1166,8 +1166,7 @@ void MachineBlockPlacement::rotateLoop(BlockChain &LoopChain, } } - BlockChain::iterator ExitIt = - std::find(LoopChain.begin(), LoopChain.end(), ExitingBB); + BlockChain::iterator ExitIt = find(LoopChain, ExitingBB); if (ExitIt == LoopChain.end()) return; @@ -1190,7 +1189,7 @@ void MachineBlockPlacement::rotateLoop(BlockChain &LoopChain, void MachineBlockPlacement::rotateLoopWithProfile( BlockChain &LoopChain, MachineLoop &L, const BlockFilterSet &LoopBlockSet) { auto HeaderBB = L.getHeader(); - auto HeaderIter = std::find(LoopChain.begin(), LoopChain.end(), HeaderBB); + auto HeaderIter = find(LoopChain, HeaderBB); auto RotationPos = LoopChain.end(); BlockFrequency SmallestRotationCost = BlockFrequency::getMaxFrequency(); diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp b/llvm/lib/CodeGen/MachineCopyPropagation.cpp index 8fdf39d54bd..bf61ee04f9b 100644 --- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp +++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp @@ -245,7 +245,7 @@ void MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) { // Remember source that's copied to Def. Once it's clobbered, then // it's no longer available for copy propagation. RegList &DestList = SrcMap[Src]; - if (std::find(DestList.begin(), DestList.end(), Def) == DestList.end()) + if (!is_contained(DestList, Def)) DestList.push_back(Def); continue; diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp index 073fa90c76e..1f4acd01305 100644 --- a/llvm/lib/CodeGen/MachineLICM.cpp +++ b/llvm/lib/CodeGen/MachineLICM.cpp @@ -92,8 +92,7 @@ namespace { SmallVector<MachineBasicBlock*, 8> ExitBlocks; bool isExitBlock(const MachineBasicBlock *MBB) const { - return std::find(ExitBlocks.begin(), ExitBlocks.end(), MBB) != - ExitBlocks.end(); + return is_contained(ExitBlocks, MBB); } // Track 'estimated' register pressure. diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp index 6354c7c0872..5d2d88fa971 100644 --- a/llvm/lib/CodeGen/MachineVerifier.cpp +++ b/llvm/lib/CodeGen/MachineVerifier.cpp @@ -1238,7 +1238,7 @@ void MachineVerifier::checkLiveness(const MachineOperand *MO, unsigned MONum) { if (LiveVars && TargetRegisterInfo::isVirtualRegister(Reg) && MO->isKill()) { LiveVariables::VarInfo &VI = LiveVars->getVarInfo(Reg); - if (std::find(VI.Kills.begin(), VI.Kills.end(), MI) == VI.Kills.end()) + if (!is_contained(VI.Kills, MI)) report("Kill missing from LiveVariables", MO, MONum); } diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 8870bcc3ebf..44be069a4d0 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1571,8 +1571,7 @@ SDValue DAGCombiner::visitTokenFactor(SDNode *N) { break; case ISD::TokenFactor: - if (Op.hasOneUse() && - std::find(TFs.begin(), TFs.end(), Op.getNode()) == TFs.end()) { + if (Op.hasOneUse() && !is_contained(TFs, Op.getNode())) { // Queue up for processing. TFs.push_back(Op.getNode()); // Clean up in case the token factor is removed. diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp index ee34f19bab7..87c968a85e9 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp @@ -599,8 +599,7 @@ void llvm::AddLandingPadInfo(const LandingPadInst &I, MachineModuleInfo &MMI, unsigned FunctionLoweringInfo::findSwiftErrorVReg(const MachineBasicBlock *MBB, const Value* Val) const { // Find the index in SwiftErrorVals. - SwiftErrorValues::const_iterator I = - std::find(SwiftErrorVals.begin(), SwiftErrorVals.end(), Val); + SwiftErrorValues::const_iterator I = find(SwiftErrorVals, Val); assert(I != SwiftErrorVals.end() && "Can't find value in SwiftErrorVals"); return SwiftErrorMap.lookup(MBB)[I - SwiftErrorVals.begin()]; } @@ -608,8 +607,7 @@ unsigned FunctionLoweringInfo::findSwiftErrorVReg(const MachineBasicBlock *MBB, void FunctionLoweringInfo::setSwiftErrorVReg(const MachineBasicBlock *MBB, const Value* Val, unsigned VReg) { // Find the index in SwiftErrorVals. - SwiftErrorValues::iterator I = - std::find(SwiftErrorVals.begin(), SwiftErrorVals.end(), Val); + SwiftErrorValues::iterator I = find(SwiftErrorVals, Val); assert(I != SwiftErrorVals.end() && "Can't find value in SwiftErrorVals"); SwiftErrorMap[MBB][I - SwiftErrorVals.begin()] = VReg; } diff --git a/llvm/lib/CodeGen/SelectionDAG/ResourcePriorityQueue.cpp b/llvm/lib/CodeGen/SelectionDAG/ResourcePriorityQueue.cpp index 1e5c4a73693..ded8e68fcbc 100644 --- a/llvm/lib/CodeGen/SelectionDAG/ResourcePriorityQueue.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/ResourcePriorityQueue.cpp @@ -631,7 +631,7 @@ SUnit *ResourcePriorityQueue::pop() { void ResourcePriorityQueue::remove(SUnit *SU) { assert(!Queue.empty() && "Queue is empty!"); - std::vector<SUnit *>::iterator I = std::find(Queue.begin(), Queue.end(), SU); + std::vector<SUnit *>::iterator I = find(Queue, SU); if (I != std::prev(Queue.end())) std::swap(*I, Queue.back()); diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp index 802c459a022..3549ccd9e34 100644 --- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp @@ -1339,7 +1339,7 @@ void ScheduleDAGRRList::releaseInterferences(unsigned Reg) { LRegsMapT::iterator LRegsPos = LRegsMap.find(SU); if (Reg) { SmallVectorImpl<unsigned> &LRegs = LRegsPos->second; - if (std::find(LRegs.begin(), LRegs.end(), Reg) == LRegs.end()) + if (!is_contained(LRegs, Reg)) continue; } SU->isPending = false; @@ -1704,8 +1704,7 @@ public: void remove(SUnit *SU) override { assert(!Queue.empty() && "Queue is empty!"); assert(SU->NodeQueueId != 0 && "Not in queue!"); - std::vector<SUnit *>::iterator I = std::find(Queue.begin(), Queue.end(), - SU); + std::vector<SUnit *>::iterator I = find(Queue, SU); if (I != std::prev(Queue.end())) std::swap(*I, Queue.back()); Queue.pop_back(); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 23b1dc30a0d..642759afd01 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -3388,7 +3388,7 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch, SelectionDAG::DAGNodeDeletedListener NDL(*CurDAG, [&](SDNode *N, SDNode *E) { auto &Chain = ChainNodesMatched; - assert((!E || llvm::find(Chain, N) == Chain.end()) && + assert((!E || !is_contained(Chain, N)) && "Chain node replaced during MorphNode"); Chain.erase(std::remove(Chain.begin(), Chain.end(), N), Chain.end()); }); diff --git a/llvm/lib/CodeGen/TailDuplicator.cpp b/llvm/lib/CodeGen/TailDuplicator.cpp index 029bd138f53..e9a5f14b04f 100644 --- a/llvm/lib/CodeGen/TailDuplicator.cpp +++ b/llvm/lib/CodeGen/TailDuplicator.cpp @@ -900,7 +900,7 @@ bool TailDuplicator::tailDuplicate(MachineFunction &MF, bool IsSimple, PE = Preds.end(); PI != PE; ++PI) { MachineBasicBlock *PredBB = *PI; - if (std::find(TDBBs.begin(), TDBBs.end(), PredBB) != TDBBs.end()) + if (is_contained(TDBBs, PredBB)) continue; // EH edges diff --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp b/llvm/lib/CodeGen/TargetInstrInfo.cpp index 8a3789a347c..78eb567daf8 100644 --- a/llvm/lib/CodeGen/TargetInstrInfo.cpp +++ b/llvm/lib/CodeGen/TargetInstrInfo.cpp @@ -467,7 +467,7 @@ static MachineInstr *foldPatchpoint(MachineFunction &MF, MachineInstr &MI, for (unsigned i = StartIdx; i < MI.getNumOperands(); ++i) { MachineOperand &MO = MI.getOperand(i); - if (std::find(Ops.begin(), Ops.end(), i) != Ops.end()) { + if (is_contained(Ops, i)) { unsigned SpillSize; unsigned SpillOffset; // Compute the spill slot size and offset. diff --git a/llvm/lib/CodeGen/TargetRegisterInfo.cpp b/llvm/lib/CodeGen/TargetRegisterInfo.cpp index 17cd81c72e3..73e79b02163 100644 --- a/llvm/lib/CodeGen/TargetRegisterInfo.cpp +++ b/llvm/lib/CodeGen/TargetRegisterInfo.cpp @@ -354,7 +354,7 @@ TargetRegisterInfo::getRegAllocationHints(unsigned VirtReg, // Check that Phys is in the allocation order. We shouldn't heed hints // from VirtReg's register class if they aren't in the allocation order. The // target probably has a reason for removing the register. - if (std::find(Order.begin(), Order.end(), Phys) == Order.end()) + if (!is_contained(Order, Phys)) return; // All clear, tell the register allocator to prefer this register. diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp index 8f71d822d27..8a4f142cd3b 100644 --- a/llvm/lib/IR/LegacyPassManager.cpp +++ b/llvm/lib/IR/LegacyPassManager.cpp @@ -841,9 +841,7 @@ bool PMDataManager::preserveHigherLevelAnalysis(Pass *P) { E = HigherLevelAnalysis.end(); I != E; ++I) { Pass *P1 = *I; if (P1->getAsImmutablePass() == nullptr && - std::find(PreservedSet.begin(), PreservedSet.end(), - P1->getPassID()) == - PreservedSet.end()) + !is_contained(PreservedSet, P1->getPassID())) return false; } @@ -881,8 +879,7 @@ void PMDataManager::removeNotPreservedAnalysis(Pass *P) { E = AvailableAnalysis.end(); I != E; ) { DenseMap<AnalysisID, Pass*>::iterator Info = I++; if (Info->second->getAsImmutablePass() == nullptr && - std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) == - PreservedSet.end()) { + !is_contained(PreservedSet, Info->first)) { // Remove this analysis if (PassDebugging >= Details) { Pass *S = Info->second; @@ -905,8 +902,7 @@ void PMDataManager::removeNotPreservedAnalysis(Pass *P) { E = InheritedAnalysis[Index]->end(); I != E; ) { DenseMap<AnalysisID, Pass *>::iterator Info = I++; if (Info->second->getAsImmutablePass() == nullptr && - std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) == - PreservedSet.end()) { + !is_contained(PreservedSet, Info->first)) { // Remove this analysis if (PassDebugging >= Details) { Pass *S = Info->second; diff --git a/llvm/lib/IR/PassRegistry.cpp b/llvm/lib/IR/PassRegistry.cpp index 09b17ba308d..584dee2869c 100644 --- a/llvm/lib/IR/PassRegistry.cpp +++ b/llvm/lib/IR/PassRegistry.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/PassRegistry.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/PassSupport.h" #include "llvm/Support/ManagedStatic.h" @@ -121,6 +122,6 @@ void PassRegistry::addRegistrationListener(PassRegistrationListener *L) { void PassRegistry::removeRegistrationListener(PassRegistrationListener *L) { sys::SmartScopedWriter<true> Guard(Lock); - auto I = std::find(Listeners.begin(), Listeners.end(), L); + auto I = find(Listeners, L); Listeners.erase(I); } diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp index 13aa9667b5c..9260d79da92 100644 --- a/llvm/lib/Option/OptTable.cpp +++ b/llvm/lib/Option/OptTable.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Option/OptTable.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/Option/Arg.h" #include "llvm/Option/ArgList.h" #include "llvm/Option/Option.h" @@ -142,8 +143,7 @@ OptTable::OptTable(ArrayRef<Info> OptionInfos, bool IgnoreCase) StringRef Prefix = I->getKey(); for (StringRef::const_iterator C = Prefix.begin(), CE = Prefix.end(); C != CE; ++C) - if (std::find(PrefixChars.begin(), PrefixChars.end(), *C) - == PrefixChars.end()) + if (!is_contained(PrefixChars, *C)) PrefixChars.push_back(*C); } } diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 1b468a0aa9a..102bc909889 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -2101,7 +2101,7 @@ void cl::AddExtraVersionPrinter(void (*func)()) { StringMap<Option *> &cl::getRegisteredOptions(SubCommand &Sub) { auto &Subs = GlobalParser->RegisteredSubCommands; (void)Subs; - assert(std::find(Subs.begin(), Subs.end(), &Sub) != Subs.end()); + assert(is_contained(Subs, &Sub)); return Sub.OptionsMap; } diff --git a/llvm/lib/Support/YAMLParser.cpp b/llvm/lib/Support/YAMLParser.cpp index 620841c2d15..2b71c596cc4 100644 --- a/llvm/lib/Support/YAMLParser.cpp +++ b/llvm/lib/Support/YAMLParser.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/YAMLParser.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" @@ -802,8 +803,7 @@ Token &Scanner::peekNext() { removeStaleSimpleKeyCandidates(); SimpleKey SK; SK.Tok = TokenQueue.begin(); - if (std::find(SimpleKeys.begin(), SimpleKeys.end(), SK) - == SimpleKeys.end()) + if (!is_contained(SimpleKeys, SK)) break; else NeedMore = true; diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 7a4f516ae3e..a11b032e3f8 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -4976,7 +4976,7 @@ SDValue AArch64TargetLowering::ReconstructShuffle(SDValue Op, // Add this element source to the list if it's not already there. SDValue SourceVec = V.getOperand(0); - auto Source = std::find(Sources.begin(), Sources.end(), SourceVec); + auto Source = find(Sources, SourceVec); if (Source == Sources.end()) Source = Sources.insert(Sources.end(), ShuffleSourceInfo(SourceVec)); @@ -5092,7 +5092,7 @@ SDValue AArch64TargetLowering::ReconstructShuffle(SDValue Op, if (Entry.isUndef()) continue; - auto Src = std::find(Sources.begin(), Sources.end(), Entry.getOperand(0)); + auto Src = find(Sources, Entry.getOperand(0)); int EltNo = cast<ConstantSDNode>(Entry.getOperand(1))->getSExtValue(); // EXTRACT_VECTOR_ELT performs an implicit any_ext; BUILD_VECTOR an implicit diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp index bb7fa6bcb0e..e46e263bfa1 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp @@ -535,7 +535,7 @@ bool AMDGPUPromoteAlloca::collectUsesWithPtrTypes( std::vector<Value*> &WorkList) const { for (User *User : Val->users()) { - if (std::find(WorkList.begin(), WorkList.end(), User) != WorkList.end()) + if (is_contained(WorkList, User)) continue; if (CallInst *CI = dyn_cast<CallInst>(User)) { diff --git a/llvm/lib/Target/AMDGPU/R600OptimizeVectorRegisters.cpp b/llvm/lib/Target/AMDGPU/R600OptimizeVectorRegisters.cpp index ecae27d2233..b01bab2e59c 100644 --- a/llvm/lib/Target/AMDGPU/R600OptimizeVectorRegisters.cpp +++ b/llvm/lib/Target/AMDGPU/R600OptimizeVectorRegisters.cpp @@ -200,12 +200,10 @@ MachineInstr *R600VectorRegMerger::RebuildVector( .addReg(SubReg) .addImm(Chan); UpdatedRegToChan[SubReg] = Chan; - std::vector<unsigned>::iterator ChanPos = - std::find(UpdatedUndef.begin(), UpdatedUndef.end(), Chan); + std::vector<unsigned>::iterator ChanPos = find(UpdatedUndef, Chan); if (ChanPos != UpdatedUndef.end()) UpdatedUndef.erase(ChanPos); - assert(std::find(UpdatedUndef.begin(), UpdatedUndef.end(), Chan) == - UpdatedUndef.end() && + assert(!is_contained(UpdatedUndef, Chan) && "UpdatedUndef shouldn't contain Chan more than once!"); DEBUG(dbgs() << " ->"; Tmp->dump();); (void)Tmp; @@ -236,12 +234,12 @@ void R600VectorRegMerger::RemoveMI(MachineInstr *MI) { for (InstructionSetMap::iterator It = PreviousRegSeqByReg.begin(), E = PreviousRegSeqByReg.end(); It != E; ++It) { std::vector<MachineInstr *> &MIs = (*It).second; - MIs.erase(std::find(MIs.begin(), MIs.end(), MI), MIs.end()); + MIs.erase(find(MIs, MI), MIs.end()); } for (InstructionSetMap::iterator It = PreviousRegSeqByUndefCount.begin(), E = PreviousRegSeqByUndefCount.end(); It != E; ++It) { std::vector<MachineInstr *> &MIs = (*It).second; - MIs.erase(std::find(MIs.begin(), MIs.end(), MI), MIs.end()); + MIs.erase(find(MIs, MI), MIs.end()); } } diff --git a/llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp b/llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp index b5729fef6ff..032f4c1f7b6 100644 --- a/llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp +++ b/llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp @@ -363,7 +363,7 @@ void SIAnnotateControlFlow::closeControlFlow(BasicBlock *BB) { std::vector<BasicBlock*> Preds; for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE; ++PI) { - if (std::find(Latches.begin(), Latches.end(), *PI) == Latches.end()) + if (!is_contained(Latches, *PI)) Preds.push_back(*PI); } BB = llvm::SplitBlockPredecessors(BB, Preds, "endcf.split", DT, LI, false); diff --git a/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp b/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp index 24d675118f8..3b1a9d54f44 100644 --- a/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp +++ b/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp @@ -479,8 +479,7 @@ void SIScheduleBlock::releaseSuccessors(SUnit *SU, bool InOrOutBlock) { void SIScheduleBlock::nodeScheduled(SUnit *SU) { // Is in TopReadySUs assert (!SU->NumPredsLeft); - std::vector<SUnit*>::iterator I = - std::find(TopReadySUs.begin(), TopReadySUs.end(), SU); + std::vector<SUnit *>::iterator I = find(TopReadySUs, SU); if (I == TopReadySUs.end()) { dbgs() << "Data Structure Bug in SI Scheduler\n"; llvm_unreachable(nullptr); diff --git a/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp b/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp index 6920873e2e5..d4ff475cbab 100644 --- a/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp +++ b/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp @@ -289,8 +289,7 @@ ARMBaseRegisterInfo::getRegAllocationHints(unsigned VirtReg, } // First prefer the paired physreg. - if (PairedPhys && - std::find(Order.begin(), Order.end(), PairedPhys) != Order.end()) + if (PairedPhys && is_contained(Order, PairedPhys)) Hints.push_back(PairedPhys); // Then prefer even or odd registers. diff --git a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp index 237ba3060b9..e4fefef2683 100644 --- a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp +++ b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp @@ -1432,7 +1432,7 @@ bool ARMConstantIslands::handleConstantPoolUser(unsigned CPUserIndex, // it. Check for this so it will be removed from the WaterList. // Also remove any entry from NewWaterList. MachineBasicBlock *WaterBB = &*--NewMBB->getIterator(); - IP = std::find(WaterList.begin(), WaterList.end(), WaterBB); + IP = find(WaterList, WaterBB); if (IP != WaterList.end()) NewWaterList.erase(WaterBB); diff --git a/llvm/lib/Target/ARM/ARMFrameLowering.cpp b/llvm/lib/Target/ARM/ARMFrameLowering.cpp index b14d1b5f180..9e79faa3abf 100644 --- a/llvm/lib/Target/ARM/ARMFrameLowering.cpp +++ b/llvm/lib/Target/ARM/ARMFrameLowering.cpp @@ -1640,8 +1640,7 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF, SavedRegs.set(ARM::LR); NumGPRSpills++; SmallVectorImpl<unsigned>::iterator LRPos; - LRPos = std::find(UnspilledCS1GPRs.begin(), UnspilledCS1GPRs.end(), - (unsigned)ARM::LR); + LRPos = find(UnspilledCS1GPRs, (unsigned)ARM::LR); if (LRPos != UnspilledCS1GPRs.end()) UnspilledCS1GPRs.erase(LRPos); @@ -1651,8 +1650,7 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF, if (hasFP(MF)) { SavedRegs.set(FramePtr); - auto FPPos = std::find(UnspilledCS1GPRs.begin(), UnspilledCS1GPRs.end(), - FramePtr); + auto FPPos = find(UnspilledCS1GPRs, FramePtr); if (FPPos != UnspilledCS1GPRs.end()) UnspilledCS1GPRs.erase(FPPos); NumGPRSpills++; diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index d741525be73..c341794ab5e 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -5915,7 +5915,7 @@ SDValue ARMTargetLowering::ReconstructShuffle(SDValue Op, // Add this element source to the list if it's not already there. SDValue SourceVec = V.getOperand(0); - auto Source = std::find(Sources.begin(), Sources.end(), SourceVec); + auto Source = find(Sources, SourceVec); if (Source == Sources.end()) Source = Sources.insert(Sources.end(), ShuffleSourceInfo(SourceVec)); @@ -6031,7 +6031,7 @@ SDValue ARMTargetLowering::ReconstructShuffle(SDValue Op, if (Entry.isUndef()) continue; - auto Src = std::find(Sources.begin(), Sources.end(), Entry.getOperand(0)); + auto Src = find(Sources, Entry.getOperand(0)); int EltNo = cast<ConstantSDNode>(Entry.getOperand(1))->getSExtValue(); // EXTRACT_VECTOR_ELT performs an implicit any_ext; BUILD_VECTOR an implicit diff --git a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp index 62d57f3f498..5eb6c8ba301 100644 --- a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp +++ b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp @@ -834,7 +834,7 @@ MachineInstr *ARMLoadStoreOpt::MergeOpsUpdate(const MergeCandidate &Cand) { assert(MO.isImplicit()); unsigned DefReg = MO.getReg(); - if (std::find(ImpDefs.begin(), ImpDefs.end(), DefReg) != ImpDefs.end()) + if (is_contained(ImpDefs, DefReg)) continue; // We can ignore cases where the super-reg is read and written. if (MI->readsRegister(DefReg)) diff --git a/llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp b/llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp index 6de62f13c65..d4b54e3ddd0 100644 --- a/llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp +++ b/llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp @@ -2665,7 +2665,7 @@ bool HexagonLoopRescheduling::processLoop(LoopCand &C) { if (UseI->getOperand(Idx+1).getMBB() != C.LB) BadUse = true; } else { - auto F = std::find(ShufIns.begin(), ShufIns.end(), UseI); + auto F = find(ShufIns, UseI); if (F == ShufIns.end()) BadUse = true; } diff --git a/llvm/lib/Target/Hexagon/HexagonMachineScheduler.h b/llvm/lib/Target/Hexagon/HexagonMachineScheduler.h index 51c84a4cee3..dc10028c042 100644 --- a/llvm/lib/Target/Hexagon/HexagonMachineScheduler.h +++ b/llvm/lib/Target/Hexagon/HexagonMachineScheduler.h @@ -94,9 +94,7 @@ public: void savePacket(); unsigned getTotalPackets() const { return TotalPackets; } - bool isInPacket(SUnit *SU) const { - return std::find(Packet.begin(), Packet.end(), SU) != Packet.end(); - } + bool isInPacket(SUnit *SU) const { return is_contained(Packet, SU); } }; /// Extend the standard ScheduleDAGMI to provide more context and override the diff --git a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp index 32aacae89b7..f4fce99307a 100644 --- a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp +++ b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp @@ -1338,7 +1338,7 @@ bool HexagonPacketizerList::isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) { // However, there is no dependence edge between (1)->(3). This results // in all 3 instructions going in the same packet. We ignore dependce // only once to avoid this situation. - auto Itr = std::find(IgnoreDepMIs.begin(), IgnoreDepMIs.end(), &J); + auto Itr = find(IgnoreDepMIs, &J); if (Itr != IgnoreDepMIs.end()) { Dependence = true; return false; diff --git a/llvm/lib/Target/Mips/MipsConstantIslandPass.cpp b/llvm/lib/Target/Mips/MipsConstantIslandPass.cpp index b25396fff4d..6531b32594f 100644 --- a/llvm/lib/Target/Mips/MipsConstantIslandPass.cpp +++ b/llvm/lib/Target/Mips/MipsConstantIslandPass.cpp @@ -1374,7 +1374,7 @@ bool MipsConstantIslands::handleConstantPoolUser(unsigned CPUserIndex) { // it. Check for this so it will be removed from the WaterList. // Also remove any entry from NewWaterList. MachineBasicBlock *WaterBB = &*--NewMBB->getIterator(); - IP = std::find(WaterList.begin(), WaterList.end(), WaterBB); + IP = find(WaterList, WaterBB); if (IP != WaterList.end()) NewWaterList.erase(WaterBB); diff --git a/llvm/lib/Target/NVPTX/NVPTXUtilities.cpp b/llvm/lib/Target/NVPTX/NVPTXUtilities.cpp index 835e4b44203..8c980a60ebd 100644 --- a/llvm/lib/Target/NVPTX/NVPTXUtilities.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXUtilities.cpp @@ -169,7 +169,7 @@ bool llvm::isSampler(const llvm::Value &val) { if (llvm::findAllNVVMAnnotation( func, llvm::PropertyAnnotationNames[llvm::PROPERTY_ISSAMPLER], annot)) { - if (std::find(annot.begin(), annot.end(), arg->getArgNo()) != annot.end()) + if (is_contained(annot, arg->getArgNo())) return true; } } @@ -184,7 +184,7 @@ bool llvm::isImageReadOnly(const llvm::Value &val) { llvm::PropertyAnnotationNames[ llvm::PROPERTY_ISREADONLY_IMAGE_PARAM], annot)) { - if (std::find(annot.begin(), annot.end(), arg->getArgNo()) != annot.end()) + if (is_contained(annot, arg->getArgNo())) return true; } } @@ -199,7 +199,7 @@ bool llvm::isImageWriteOnly(const llvm::Value &val) { llvm::PropertyAnnotationNames[ llvm::PROPERTY_ISWRITEONLY_IMAGE_PARAM], annot)) { - if (std::find(annot.begin(), annot.end(), arg->getArgNo()) != annot.end()) + if (is_contained(annot, arg->getArgNo())) return true; } } @@ -214,7 +214,7 @@ bool llvm::isImageReadWrite(const llvm::Value &val) { llvm::PropertyAnnotationNames[ llvm::PROPERTY_ISREADWRITE_IMAGE_PARAM], annot)) { - if (std::find(annot.begin(), annot.end(), arg->getArgNo()) != annot.end()) + if (is_contained(annot, arg->getArgNo())) return true; } } diff --git a/llvm/lib/Target/Sparc/LeonPasses.cpp b/llvm/lib/Target/Sparc/LeonPasses.cpp index 5d0920892ff..cc0f299d65d 100755..100644 --- a/llvm/lib/Target/Sparc/LeonPasses.cpp +++ b/llvm/lib/Target/Sparc/LeonPasses.cpp @@ -51,8 +51,7 @@ int LEONMachineFunctionPass::GetRegIndexForOperand(MachineInstr &MI, int LEONMachineFunctionPass::getUnusedFPRegister(MachineRegisterInfo &MRI) { for (int RegisterIndex = SP::F0; RegisterIndex <= SP::F31; ++RegisterIndex) { if (!MRI.isPhysRegUsed(RegisterIndex) && - !(std::find(UsedRegisters.begin(), UsedRegisters.end(), - RegisterIndex) != UsedRegisters.end())) { + !is_contained(UsedRegisters, RegisterIndex)) { return RegisterIndex; } } diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 2e6612127a3..8903c861276 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -9553,18 +9553,15 @@ static SDValue lowerV8I16GeneralSingleInputVectorShuffle( auto FixFlippedInputs = [&V, &DL, &Mask, &DAG](int PinnedIdx, int DWord, ArrayRef<int> Inputs) { int FixIdx = PinnedIdx ^ 1; // The adjacent slot to the pinned slot. - bool IsFixIdxInput = std::find(Inputs.begin(), Inputs.end(), - PinnedIdx ^ 1) != Inputs.end(); + bool IsFixIdxInput = is_contained(Inputs, PinnedIdx ^ 1); // Determine whether the free index is in the flipped dword or the // unflipped dword based on where the pinned index is. We use this bit // in an xor to conditionally select the adjacent dword. int FixFreeIdx = 2 * (DWord ^ (PinnedIdx / 2 == DWord)); - bool IsFixFreeIdxInput = std::find(Inputs.begin(), Inputs.end(), - FixFreeIdx) != Inputs.end(); + bool IsFixFreeIdxInput = is_contained(Inputs, FixFreeIdx); if (IsFixIdxInput == IsFixFreeIdxInput) FixFreeIdx += 1; - IsFixFreeIdxInput = std::find(Inputs.begin(), Inputs.end(), - FixFreeIdx) != Inputs.end(); + IsFixFreeIdxInput = is_contained(Inputs, FixFreeIdx); assert(IsFixIdxInput != IsFixFreeIdxInput && "We need to be changing the number of flipped inputs!"); int PSHUFHalfMask[] = {0, 1, 2, 3}; diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index 77ec5964f9e..080f7d74145 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -1167,8 +1167,7 @@ FindMostPopularDest(BasicBlock *BB, for (unsigned i = 0; ; ++i) { assert(i != TI->getNumSuccessors() && "Didn't find any successor!"); - if (std::find(SamePopularity.begin(), SamePopularity.end(), - TI->getSuccessor(i)) == SamePopularity.end()) + if (!is_contained(SamePopularity, TI->getSuccessor(i))) continue; MostPopularDest = TI->getSuccessor(i); diff --git a/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp b/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp index 550ecab4f57..4e9fdf86344 100644 --- a/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp +++ b/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp @@ -878,7 +878,7 @@ findRootsRecursive(Instruction *I, SmallInstructionSet SubsumedInsts) { for (User *V : I->users()) { Instruction *I = dyn_cast<Instruction>(V); - if (std::find(LoopIncs.begin(), LoopIncs.end(), I) != LoopIncs.end()) + if (is_contained(LoopIncs, I)) continue; if (!I || !isSimpleArithmeticOp(I) || @@ -1088,7 +1088,7 @@ bool LoopReroll::DAGRootTracker::isBaseInst(Instruction *I) { bool LoopReroll::DAGRootTracker::isRootInst(Instruction *I) { for (auto &DRS : RootSets) { - if (std::find(DRS.Roots.begin(), DRS.Roots.end(), I) != DRS.Roots.end()) + if (is_contained(DRS.Roots, I)) return true; } return false; diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 25421933821..d9417816a13 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -448,8 +448,7 @@ void Formula::deleteBaseReg(const SCEV *&S) { /// Test if this formula references the given register. bool Formula::referencesReg(const SCEV *S) const { - return S == ScaledReg || - std::find(BaseRegs.begin(), BaseRegs.end(), S) != BaseRegs.end(); + return S == ScaledReg || is_contained(BaseRegs, S); } /// Test whether this formula uses registers which are used by uses other than @@ -4231,8 +4230,7 @@ void LSRInstance::SolveRecurse(SmallVectorImpl<const Formula *> &Solution, int NumReqRegsToFind = std::min(F.getNumRegs(), ReqRegs.size()); for (const SCEV *Reg : ReqRegs) { if ((F.ScaledReg && F.ScaledReg == Reg) || - std::find(F.BaseRegs.begin(), F.BaseRegs.end(), Reg) != - F.BaseRegs.end()) { + is_contained(F.BaseRegs, Reg)) { --NumReqRegsToFind; if (NumReqRegsToFind == 0) break; diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index ea4002241a6..3631dfab37d 100644 --- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -1154,7 +1154,7 @@ static void CreateGCRelocates(ArrayRef<Value *> LiveVariables, return; auto FindIndex = [](ArrayRef<Value *> LiveVec, Value *Val) { - auto ValIt = std::find(LiveVec.begin(), LiveVec.end(), Val); + auto ValIt = find(LiveVec, Val); assert(ValIt != LiveVec.end() && "Val not found in LiveVec!"); size_t Index = std::distance(LiveVec.begin(), ValIt); assert(Index < LiveVec.size() && "Bug in std::find?"); @@ -1929,8 +1929,7 @@ static void rematerializeLiveValues(CallSite CS, // Assert that cloned instruction does not use any instructions from // this chain other than LastClonedValue for (auto OpValue : ClonedValue->operand_values()) { - assert(std::find(ChainToBase.begin(), ChainToBase.end(), OpValue) == - ChainToBase.end() && + assert(!is_contained(ChainToBase, OpValue) && "incorrect use in rematerialization chain"); } #endif diff --git a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp index e9ac39beae5..f37ee59618f 100644 --- a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp +++ b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp @@ -321,7 +321,7 @@ void StructurizeCFG::orderNodes() { BasicBlock *BB = (*I)->getEntry(); unsigned LoopDepth = LI->getLoopDepth(BB); - if (std::find(Order.begin(), Order.end(), *I) != Order.end()) + if (is_contained(Order, *I)) continue; if (LoopDepth < CurrentLoopDepth) { diff --git a/llvm/lib/Transforms/Utils/Evaluator.cpp b/llvm/lib/Transforms/Utils/Evaluator.cpp index 008ee505b39..4adf1754253 100644 --- a/llvm/lib/Transforms/Utils/Evaluator.cpp +++ b/llvm/lib/Transforms/Utils/Evaluator.cpp @@ -537,7 +537,7 @@ bool Evaluator::EvaluateFunction(Function *F, Constant *&RetVal, const SmallVectorImpl<Constant*> &ActualArgs) { // Check to see if this function is already executing (recursion). If so, // bail out. TODO: we might want to accept limited recursion. - if (std::find(CallStack.begin(), CallStack.end(), F) != CallStack.end()) + if (is_contained(CallStack, F)) return false; CallStack.push_back(F); diff --git a/llvm/lib/Transforms/Utils/LCSSA.cpp b/llvm/lib/Transforms/Utils/LCSSA.cpp index eee4f7f684c..33c18378cdf 100644 --- a/llvm/lib/Transforms/Utils/LCSSA.cpp +++ b/llvm/lib/Transforms/Utils/LCSSA.cpp @@ -54,7 +54,7 @@ STATISTIC(NumLCSSA, "Number of live out of a loop variables"); /// Return true if the specified block is in the list. static bool isExitBlock(BasicBlock *BB, const SmallVectorImpl<BasicBlock *> &ExitBlocks) { - return find(ExitBlocks, BB) != ExitBlocks.end(); + return is_contained(ExitBlocks, BB); } /// For every instruction from the worklist, check to see if it has any uses diff --git a/llvm/lib/Transforms/Utils/SSAUpdater.cpp b/llvm/lib/Transforms/Utils/SSAUpdater.cpp index 88b39dd7f66..8e93ee757a1 100644 --- a/llvm/lib/Transforms/Utils/SSAUpdater.cpp +++ b/llvm/lib/Transforms/Utils/SSAUpdater.cpp @@ -482,5 +482,5 @@ bool LoadAndStorePromoter::isInstInList(Instruction *I, const SmallVectorImpl<Instruction*> &Insts) const { - return std::find(Insts.begin(), Insts.end(), I) != Insts.end(); + return is_contained(Insts, I); } diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index fb023545fb6..44de90b7d8b 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -954,8 +954,7 @@ void BoUpSLP::buildTree(ArrayRef<Value *> Roots, } // Ignore users in the user ignore list. - if (std::find(UserIgnoreList.begin(), UserIgnoreList.end(), UserInst) != - UserIgnoreList.end()) + if (is_contained(UserIgnoreList, UserInst)) continue; DEBUG(dbgs() << "SLP: Need to extract:" << *U << " from lane " << @@ -2726,8 +2725,7 @@ Value *BoUpSLP::vectorizeTree() { assert((ScalarToTreeEntry.count(U) || // It is legal to replace users in the ignorelist by undef. - (std::find(UserIgnoreList.begin(), UserIgnoreList.end(), U) != - UserIgnoreList.end())) && + is_contained(UserIgnoreList, U)) && "Replacing out-of-tree value with undef"); } #endif @@ -2820,7 +2818,7 @@ void BoUpSLP::optimizeGatherSequence() { } } if (In) { - assert(std::find(Visited.begin(), Visited.end(), In) == Visited.end()); + assert(!is_contained(Visited, In)); Visited.push_back(In); } } |