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
This commit is contained in:
David Majnemer 2016-08-11 22:21:41 +00:00
parent 332b3b2210
commit 0d955d0bf5
78 changed files with 142 additions and 205 deletions

View File

@ -72,8 +72,7 @@ public:
} }
void removeModule(ModuleHandleT H) { void removeModule(ModuleHandleT H) {
ModuleHandles.erase( ModuleHandles.erase(find(ModuleHandles, H));
std::find(ModuleHandles.begin(), ModuleHandles.end(), H));
CompileLayer.removeModuleSet(H); CompileLayer.removeModuleSet(H);
} }

View File

@ -46,8 +46,7 @@ public:
/// ///
void erase_one(const T &t) { void erase_one(const T &t) {
// Linear-search to find the element. // Linear-search to find the element.
typename Sequence::size_type i = typename Sequence::size_type i = find(this->c, t) - this->c.begin();
std::find(this->c.begin(), this->c.end(), t) - this->c.begin();
// Logarithmic-time heap bubble-up. // Logarithmic-time heap bubble-up.
while (i != 0) { while (i != 0) {

View File

@ -21,6 +21,7 @@
#define LLVM_ADT_SETVECTOR_H #define LLVM_ADT_SETVECTOR_H
#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallSet.h"
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
@ -143,8 +144,7 @@ public:
/// \brief Remove an item from the set vector. /// \brief Remove an item from the set vector.
bool remove(const value_type& X) { bool remove(const value_type& X) {
if (set_.erase(X)) { if (set_.erase(X)) {
typename vector_type::iterator I = typename vector_type::iterator I = find(vector_, X);
std::find(vector_.begin(), vector_.end(), X);
assert(I != vector_.end() && "Corrupted SetVector instances!"); assert(I != vector_.end() && "Corrupted SetVector instances!");
vector_.erase(I); vector_.erase(I);
return true; return true;

View File

@ -329,7 +329,7 @@ public:
/// Blocks as appropriate. This does not update the mapping in the LoopInfo /// Blocks as appropriate. This does not update the mapping in the LoopInfo
/// class. /// class.
void removeBlockFromLoop(BlockT *BB) { void removeBlockFromLoop(BlockT *BB) {
auto I = std::find(Blocks.begin(), Blocks.end(), BB); auto I = find(Blocks, BB);
assert(I != Blocks.end() && "N is not in this list!"); assert(I != Blocks.end() && "N is not in this list!");
Blocks.erase(I); Blocks.erase(I);
@ -594,7 +594,7 @@ public:
/// loop. /// loop.
void changeTopLevelLoop(LoopT *OldLoop, void changeTopLevelLoop(LoopT *OldLoop,
LoopT *NewLoop) { LoopT *NewLoop) {
auto I = std::find(TopLevelLoops.begin(), TopLevelLoops.end(), OldLoop); auto I = find(TopLevelLoops, OldLoop);
assert(I != TopLevelLoops.end() && "Old loop not at top level!"); assert(I != TopLevelLoops.end() && "Old loop not at top level!");
*I = NewLoop; *I = NewLoop;
assert(!NewLoop->ParentLoop && !OldLoop->ParentLoop && assert(!NewLoop->ParentLoop && !OldLoop->ParentLoop &&

View File

@ -211,8 +211,7 @@ void LoopBase<BlockT, LoopT>::
replaceChildLoopWith(LoopT *OldChild, LoopT *NewChild) { replaceChildLoopWith(LoopT *OldChild, LoopT *NewChild) {
assert(OldChild->ParentLoop == this && "This loop is already broken!"); assert(OldChild->ParentLoop == this && "This loop is already broken!");
assert(!NewChild->ParentLoop && "NewChild already has a parent!"); assert(!NewChild->ParentLoop && "NewChild already has a parent!");
typename std::vector<LoopT *>::iterator I = typename std::vector<LoopT *>::iterator I = find(SubLoops, OldChild);
std::find(SubLoops.begin(), SubLoops.end(), OldChild);
assert(I != SubLoops.end() && "OldChild not in loop!"); assert(I != SubLoops.end() && "OldChild not in loop!");
*I = NewChild; *I = NewChild;
OldChild->ParentLoop = nullptr; OldChild->ParentLoop = nullptr;

View File

@ -92,8 +92,7 @@ public:
/// machine instruction. Returns true if there was a kill /// machine instruction. Returns true if there was a kill
/// corresponding to this instruction, false otherwise. /// corresponding to this instruction, false otherwise.
bool removeKill(MachineInstr &MI) { bool removeKill(MachineInstr &MI) {
std::vector<MachineInstr *>::iterator I = std::vector<MachineInstr *>::iterator I = find(Kills, &MI);
std::find(Kills.begin(), Kills.end(), &MI);
if (I == Kills.end()) if (I == Kills.end())
return false; return false;
Kills.erase(I); Kills.erase(I);

View File

@ -518,9 +518,7 @@ public:
ArrayRef<SUnit*> elements() { return Queue; } ArrayRef<SUnit*> elements() { return Queue; }
iterator find(SUnit *SU) { iterator find(SUnit *SU) { return llvm::find(Queue, SU); }
return std::find(Queue.begin(), Queue.end(), SU);
}
void push(SUnit *SU) { void push(SUnit *SU) {
Queue.push_back(SU); Queue.push_back(SU);

View File

@ -262,9 +262,7 @@ namespace PBQP {
private: private:
NodeId findNextInUse(NodeId NId) const { NodeId findNextInUse(NodeId NId) const {
while (NId < EndNId && while (NId < EndNId && is_contained(FreeNodeIds, NId)) {
std::find(FreeNodeIds.begin(), FreeNodeIds.end(), NId) !=
FreeNodeIds.end()) {
++NId; ++NId;
} }
return NId; return NId;
@ -288,9 +286,7 @@ namespace PBQP {
private: private:
EdgeId findNextInUse(EdgeId EId) const { EdgeId findNextInUse(EdgeId EId) const {
while (EId < EndEId && while (EId < EndEId && is_contained(FreeEdgeIds, EId)) {
std::find(FreeEdgeIds.begin(), FreeEdgeIds.end(), EId) !=
FreeEdgeIds.end()) {
++EId; ++EId;
} }
return EId; return EId;

View File

@ -1478,7 +1478,7 @@ public:
bool hasOperandBundlesOtherThan(ArrayRef<uint32_t> IDs) const { bool hasOperandBundlesOtherThan(ArrayRef<uint32_t> IDs) const {
for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i) { for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i) {
uint32_t ID = getOperandBundleAt(i).getTagID(); uint32_t ID = getOperandBundleAt(i).getTagID();
if (std::find(IDs.begin(), IDs.end(), ID) == IDs.end()) if (!is_contained(IDs, ID))
return true; return true;
} }
return false; return false;

View File

@ -10,6 +10,7 @@
#ifndef LLVM_MC_MCASSEMBLER_H #ifndef LLVM_MC_MCASSEMBLER_H
#define LLVM_MC_MCASSEMBLER_H #define LLVM_MC_MCASSEMBLER_H
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/ilist.h" #include "llvm/ADT/ilist.h"
#include "llvm/ADT/ilist_node.h" #include "llvm/ADT/ilist_node.h"
@ -402,8 +403,7 @@ public:
ArrayRef<std::string> getFileNames() { return FileNames; } ArrayRef<std::string> getFileNames() { return FileNames; }
void addFileName(StringRef FileName) { void addFileName(StringRef FileName) {
if (std::find(FileNames.begin(), FileNames.end(), FileName) == if (!is_contained(FileNames, FileName))
FileNames.end())
FileNames.push_back(FileName); FileNames.push_back(FileName);
} }

View File

@ -126,7 +126,7 @@ public:
assert(IDom && "No immediate dominator?"); assert(IDom && "No immediate dominator?");
if (IDom != NewIDom) { if (IDom != NewIDom) {
typename std::vector<DomTreeNodeBase<NodeT> *>::iterator I = typename std::vector<DomTreeNodeBase<NodeT> *>::iterator I =
std::find(IDom->Children.begin(), IDom->Children.end(), this); find(IDom->Children, this);
assert(I != IDom->Children.end() && assert(I != IDom->Children.end() &&
"Not in immediate dominator children set!"); "Not in immediate dominator children set!");
// I am no longer your child... // I am no longer your child...
@ -588,7 +588,7 @@ public:
DomTreeNodeBase<NodeT> *IDom = Node->getIDom(); DomTreeNodeBase<NodeT> *IDom = Node->getIDom();
if (IDom) { if (IDom) {
typename std::vector<DomTreeNodeBase<NodeT> *>::iterator I = typename std::vector<DomTreeNodeBase<NodeT> *>::iterator I =
std::find(IDom->Children.begin(), IDom->Children.end(), Node); find(IDom->Children, Node);
assert(I != IDom->Children.end() && assert(I != IDom->Children.end() &&
"Not in immediate dominator children set!"); "Not in immediate dominator children set!");
// I am no longer your child... // I am no longer your child...

View File

@ -82,7 +82,7 @@ DenseMap<BasicBlock *, ColorVector> llvm::colorEHFunclets(Function &F) {
} }
// Note that this is a member of the given color. // Note that this is a member of the given color.
ColorVector &Colors = BlockColors[Visiting]; ColorVector &Colors = BlockColors[Visiting];
if (std::find(Colors.begin(), Colors.end(), Color) == Colors.end()) if (!is_contained(Colors, Color))
Colors.push_back(Color); Colors.push_back(Color);
else else
continue; continue;

View File

@ -521,7 +521,7 @@ void GlobalsAAResult::AnalyzeCallGraph(CallGraph &CG, Module &M) {
// Can't say anything about it. However, if it is inside our SCC, // Can't say anything about it. However, if it is inside our SCC,
// then nothing needs to be done. // then nothing needs to be done.
CallGraphNode *CalleeNode = CG[Callee]; CallGraphNode *CalleeNode = CG[Callee];
if (std::find(SCC.begin(), SCC.end(), CalleeNode) == SCC.end()) if (!is_contained(SCC, CalleeNode))
KnowNothing = true; KnowNothing = true;
} }
} else { } else {

View File

@ -907,8 +907,7 @@ void LazyCallGraph::RefSCC::removeOutgoingEdge(Node &SourceN, Node &TargetN) {
RefSCC &TargetRC = *G->lookupRefSCC(TargetN); RefSCC &TargetRC = *G->lookupRefSCC(TargetN);
assert(&TargetRC != this && "The target must not be a member of this RefSCC"); assert(&TargetRC != this && "The target must not be a member of this RefSCC");
assert(std::find(G->LeafRefSCCs.begin(), G->LeafRefSCCs.end(), this) == assert(!is_contained(G->LeafRefSCCs, this) &&
G->LeafRefSCCs.end() &&
"Cannot have a leaf RefSCC source."); "Cannot have a leaf RefSCC source.");
// First remove it from the node. // First remove it from the node.

View File

@ -62,8 +62,7 @@ static bool VerifySubExpr(Value *Expr,
// If it's an instruction, it is either in Tmp or its operands recursively // If it's an instruction, it is either in Tmp or its operands recursively
// are. // are.
SmallVectorImpl<Instruction*>::iterator Entry = SmallVectorImpl<Instruction *>::iterator Entry = find(InstInputs, I);
std::find(InstInputs.begin(), InstInputs.end(), I);
if (Entry != InstInputs.end()) { if (Entry != InstInputs.end()) {
InstInputs.erase(Entry); InstInputs.erase(Entry);
return true; return true;
@ -126,8 +125,7 @@ static void RemoveInstInputs(Value *V,
if (!I) return; if (!I) return;
// If the instruction is in the InstInputs list, remove it. // If the instruction is in the InstInputs list, remove it.
SmallVectorImpl<Instruction*>::iterator Entry = SmallVectorImpl<Instruction *>::iterator Entry = find(InstInputs, I);
std::find(InstInputs.begin(), InstInputs.end(), I);
if (Entry != InstInputs.end()) { if (Entry != InstInputs.end()) {
InstInputs.erase(Entry); InstInputs.erase(Entry);
return; return;
@ -150,8 +148,7 @@ Value *PHITransAddr::PHITranslateSubExpr(Value *V, BasicBlock *CurBB,
if (!Inst) return V; if (!Inst) return V;
// Determine whether 'Inst' is an input to our PHI translatable expression. // Determine whether 'Inst' is an input to our PHI translatable expression.
bool isInput = bool isInput = is_contained(InstInputs, Inst);
std::find(InstInputs.begin(), InstInputs.end(), Inst) != InstInputs.end();
// Handle inputs instructions if needed. // Handle inputs instructions if needed.
if (isInput) { 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. // translated, we need to incorporate the value into the expression or fail.
// In either case, the instruction itself isn't an input any longer. // 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 this is a PHI, go ahead and translate it.
if (PHINode *PN = dyn_cast<PHINode>(Inst)) if (PHINode *PN = dyn_cast<PHINode>(Inst))
@ -272,8 +269,7 @@ Value *PHITransAddr::PHITranslateSubExpr(Value *V, BasicBlock *CurBB,
isNSW = isNUW = false; isNSW = isNUW = false;
// If the old 'LHS' was an input, add the new 'LHS' as an input. // If the old 'LHS' was an input, add the new 'LHS' as an input.
if (std::find(InstInputs.begin(), InstInputs.end(), BOp) != if (is_contained(InstInputs, BOp)) {
InstInputs.end()) {
RemoveInstInputs(BOp, InstInputs); RemoveInstInputs(BOp, InstInputs);
AddAsInput(LHS); AddAsInput(LHS);
} }

View File

@ -48,7 +48,7 @@ AllocationOrder::AllocationOrder(unsigned VirtReg,
}); });
#ifndef NDEBUG #ifndef NDEBUG
for (unsigned I = 0, E = Hints.size(); I != E; ++I) 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."); "Target hint is outside allocation order.");
#endif #endif
} }

View File

@ -18,6 +18,7 @@
#define LLVM_LIB_CODEGEN_ALLOCATIONORDER_H #define LLVM_LIB_CODEGEN_ALLOCATIONORDER_H
#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCRegisterInfo.h"
namespace llvm { namespace llvm {
@ -79,9 +80,7 @@ public:
bool isHint() const { return Pos <= 0; } bool isHint() const { return Pos <= 0; }
/// Return true if PhysReg is a preferred register. /// Return true if PhysReg is a preferred register.
bool isHint(unsigned PhysReg) const { bool isHint(unsigned PhysReg) const { return is_contained(Hints, PhysReg); }
return std::find(Hints.begin(), Hints.end(), PhysReg) != Hints.end();
}
}; };
} // end namespace llvm } // end namespace llvm

View File

@ -83,7 +83,7 @@ static void dropRegDescribedVar(RegDescribedVarsMap &RegVars, unsigned RegNo,
const auto &I = RegVars.find(RegNo); const auto &I = RegVars.find(RegNo);
assert(RegNo != 0U && I != RegVars.end()); assert(RegNo != 0U && I != RegVars.end());
auto &VarSet = I->second; auto &VarSet = I->second;
const auto &VarPos = std::find(VarSet.begin(), VarSet.end(), Var); const auto &VarPos = find(VarSet, Var);
assert(VarPos != VarSet.end()); assert(VarPos != VarSet.end());
VarSet.erase(VarPos); VarSet.erase(VarPos);
// Don't keep empty sets in a map to keep it as small as possible. // 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) { InlinedVariable Var) {
assert(RegNo != 0U); assert(RegNo != 0U);
auto &VarSet = RegVars[RegNo]; auto &VarSet = RegVars[RegNo];
assert(std::find(VarSet.begin(), VarSet.end(), Var) == VarSet.end()); assert(!is_contained(VarSet, Var));
VarSet.push_back(Var); VarSet.push_back(Var);
} }

View File

@ -50,7 +50,7 @@ static void EmitCamlGlobal(const Module &M, AsmPrinter &AP, const char *Id) {
std::string SymName; std::string SymName;
SymName += "caml"; SymName += "caml";
size_t Letter = SymName.size(); size_t Letter = SymName.size();
SymName.append(MId.begin(), std::find(MId.begin(), MId.end(), '.')); SymName.append(MId.begin(), find(MId, '.'));
SymName += "__"; SymName += "__";
SymName += Id; SymName += Id;

View File

@ -3665,8 +3665,7 @@ isProfitableToFoldIntoAddressingMode(Instruction *I, ExtAddrMode &AMBefore,
TPT.rollback(LastKnownGood); TPT.rollback(LastKnownGood);
// If the match didn't cover I, then it won't be shared by it. // If the match didn't cover I, then it won't be shared by it.
if (std::find(MatchedAddrModeInsts.begin(), MatchedAddrModeInsts.end(), if (!is_contained(MatchedAddrModeInsts, I))
I) == MatchedAddrModeInsts.end())
return false; return false;
MatchedAddrModeInsts.clear(); MatchedAddrModeInsts.clear();

View File

@ -133,7 +133,7 @@ SUnit *LatencyPriorityQueue::pop() {
void LatencyPriorityQueue::remove(SUnit *SU) { void LatencyPriorityQueue::remove(SUnit *SU) {
assert(!Queue.empty() && "Queue is empty!"); 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())) if (I != std::prev(Queue.end()))
std::swap(*I, Queue.back()); std::swap(*I, Queue.back());
Queue.pop_back(); Queue.pop_back();

View File

@ -14,6 +14,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/CodeGen/LiveIntervalUnion.h" #include "llvm/CodeGen/LiveIntervalUnion.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SparseBitVector.h" #include "llvm/ADT/SparseBitVector.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.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 // Scan the vector of interfering virtual registers in this union. Assume it's
// quite small. // quite small.
bool LiveIntervalUnion::Query::isSeenInterference(LiveInterval *VirtReg) const { bool LiveIntervalUnion::Query::isSeenInterference(LiveInterval *VirtReg) const {
SmallVectorImpl<LiveInterval*>::const_iterator I = return is_contained(InterferingVRegs, VirtReg);
std::find(InterferingVRegs.begin(), InterferingVRegs.end(), VirtReg);
return I != InterferingVRegs.end();
} }
// Collect virtual registers in this union that interfere with this // Collect virtual registers in this union that interfere with this

View File

@ -545,7 +545,7 @@ void MachineBasicBlock::addSuccessorWithoutProb(MachineBasicBlock *Succ) {
void MachineBasicBlock::removeSuccessor(MachineBasicBlock *Succ, void MachineBasicBlock::removeSuccessor(MachineBasicBlock *Succ,
bool NormalizeSuccProbs) { bool NormalizeSuccProbs) {
succ_iterator I = std::find(Successors.begin(), Successors.end(), Succ); succ_iterator I = find(Successors, Succ);
removeSuccessor(I, NormalizeSuccProbs); removeSuccessor(I, NormalizeSuccProbs);
} }
@ -611,7 +611,7 @@ void MachineBasicBlock::addPredecessor(MachineBasicBlock *Pred) {
} }
void MachineBasicBlock::removePredecessor(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!"); assert(I != Predecessors.end() && "Pred is not a predecessor of this block!");
Predecessors.erase(I); Predecessors.erase(I);
} }
@ -775,7 +775,7 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ,
continue; continue;
unsigned Reg = OI->getReg(); unsigned Reg = OI->getReg();
if (std::find(UsedRegs.begin(), UsedRegs.end(), Reg) == UsedRegs.end()) if (!is_contained(UsedRegs, Reg))
UsedRegs.push_back(Reg); UsedRegs.push_back(Reg);
} }
} }
@ -802,9 +802,8 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ,
for (SmallVectorImpl<MachineInstr*>::iterator I = Terminators.begin(), for (SmallVectorImpl<MachineInstr*>::iterator I = Terminators.begin(),
E = Terminators.end(); I != E; ++I) { E = Terminators.end(); I != E; ++I) {
if (std::find(NewTerminators.begin(), NewTerminators.end(), *I) == if (!is_contained(NewTerminators, *I))
NewTerminators.end()) Indexes->removeMachineInstrFromMaps(**I);
Indexes->removeMachineInstrFromMaps(**I);
} }
} }

View File

@ -1166,8 +1166,7 @@ void MachineBlockPlacement::rotateLoop(BlockChain &LoopChain,
} }
} }
BlockChain::iterator ExitIt = BlockChain::iterator ExitIt = find(LoopChain, ExitingBB);
std::find(LoopChain.begin(), LoopChain.end(), ExitingBB);
if (ExitIt == LoopChain.end()) if (ExitIt == LoopChain.end())
return; return;
@ -1190,7 +1189,7 @@ void MachineBlockPlacement::rotateLoop(BlockChain &LoopChain,
void MachineBlockPlacement::rotateLoopWithProfile( void MachineBlockPlacement::rotateLoopWithProfile(
BlockChain &LoopChain, MachineLoop &L, const BlockFilterSet &LoopBlockSet) { BlockChain &LoopChain, MachineLoop &L, const BlockFilterSet &LoopBlockSet) {
auto HeaderBB = L.getHeader(); auto HeaderBB = L.getHeader();
auto HeaderIter = std::find(LoopChain.begin(), LoopChain.end(), HeaderBB); auto HeaderIter = find(LoopChain, HeaderBB);
auto RotationPos = LoopChain.end(); auto RotationPos = LoopChain.end();
BlockFrequency SmallestRotationCost = BlockFrequency::getMaxFrequency(); BlockFrequency SmallestRotationCost = BlockFrequency::getMaxFrequency();

View File

@ -245,7 +245,7 @@ void MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) {
// Remember source that's copied to Def. Once it's clobbered, then // Remember source that's copied to Def. Once it's clobbered, then
// it's no longer available for copy propagation. // it's no longer available for copy propagation.
RegList &DestList = SrcMap[Src]; RegList &DestList = SrcMap[Src];
if (std::find(DestList.begin(), DestList.end(), Def) == DestList.end()) if (!is_contained(DestList, Def))
DestList.push_back(Def); DestList.push_back(Def);
continue; continue;

View File

@ -92,8 +92,7 @@ namespace {
SmallVector<MachineBasicBlock*, 8> ExitBlocks; SmallVector<MachineBasicBlock*, 8> ExitBlocks;
bool isExitBlock(const MachineBasicBlock *MBB) const { bool isExitBlock(const MachineBasicBlock *MBB) const {
return std::find(ExitBlocks.begin(), ExitBlocks.end(), MBB) != return is_contained(ExitBlocks, MBB);
ExitBlocks.end();
} }
// Track 'estimated' register pressure. // Track 'estimated' register pressure.

View File

@ -1238,7 +1238,7 @@ void MachineVerifier::checkLiveness(const MachineOperand *MO, unsigned MONum) {
if (LiveVars && TargetRegisterInfo::isVirtualRegister(Reg) && if (LiveVars && TargetRegisterInfo::isVirtualRegister(Reg) &&
MO->isKill()) { MO->isKill()) {
LiveVariables::VarInfo &VI = LiveVars->getVarInfo(Reg); 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); report("Kill missing from LiveVariables", MO, MONum);
} }

View File

@ -1571,8 +1571,7 @@ SDValue DAGCombiner::visitTokenFactor(SDNode *N) {
break; break;
case ISD::TokenFactor: case ISD::TokenFactor:
if (Op.hasOneUse() && if (Op.hasOneUse() && !is_contained(TFs, Op.getNode())) {
std::find(TFs.begin(), TFs.end(), Op.getNode()) == TFs.end()) {
// Queue up for processing. // Queue up for processing.
TFs.push_back(Op.getNode()); TFs.push_back(Op.getNode());
// Clean up in case the token factor is removed. // Clean up in case the token factor is removed.

View File

@ -599,8 +599,7 @@ void llvm::AddLandingPadInfo(const LandingPadInst &I, MachineModuleInfo &MMI,
unsigned FunctionLoweringInfo::findSwiftErrorVReg(const MachineBasicBlock *MBB, unsigned FunctionLoweringInfo::findSwiftErrorVReg(const MachineBasicBlock *MBB,
const Value* Val) const { const Value* Val) const {
// Find the index in SwiftErrorVals. // Find the index in SwiftErrorVals.
SwiftErrorValues::const_iterator I = SwiftErrorValues::const_iterator I = find(SwiftErrorVals, Val);
std::find(SwiftErrorVals.begin(), SwiftErrorVals.end(), Val);
assert(I != SwiftErrorVals.end() && "Can't find value in SwiftErrorVals"); assert(I != SwiftErrorVals.end() && "Can't find value in SwiftErrorVals");
return SwiftErrorMap.lookup(MBB)[I - SwiftErrorVals.begin()]; return SwiftErrorMap.lookup(MBB)[I - SwiftErrorVals.begin()];
} }
@ -608,8 +607,7 @@ unsigned FunctionLoweringInfo::findSwiftErrorVReg(const MachineBasicBlock *MBB,
void FunctionLoweringInfo::setSwiftErrorVReg(const MachineBasicBlock *MBB, void FunctionLoweringInfo::setSwiftErrorVReg(const MachineBasicBlock *MBB,
const Value* Val, unsigned VReg) { const Value* Val, unsigned VReg) {
// Find the index in SwiftErrorVals. // Find the index in SwiftErrorVals.
SwiftErrorValues::iterator I = SwiftErrorValues::iterator I = find(SwiftErrorVals, Val);
std::find(SwiftErrorVals.begin(), SwiftErrorVals.end(), Val);
assert(I != SwiftErrorVals.end() && "Can't find value in SwiftErrorVals"); assert(I != SwiftErrorVals.end() && "Can't find value in SwiftErrorVals");
SwiftErrorMap[MBB][I - SwiftErrorVals.begin()] = VReg; SwiftErrorMap[MBB][I - SwiftErrorVals.begin()] = VReg;
} }

View File

@ -631,7 +631,7 @@ SUnit *ResourcePriorityQueue::pop() {
void ResourcePriorityQueue::remove(SUnit *SU) { void ResourcePriorityQueue::remove(SUnit *SU) {
assert(!Queue.empty() && "Queue is empty!"); 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())) if (I != std::prev(Queue.end()))
std::swap(*I, Queue.back()); std::swap(*I, Queue.back());

View File

@ -1339,7 +1339,7 @@ void ScheduleDAGRRList::releaseInterferences(unsigned Reg) {
LRegsMapT::iterator LRegsPos = LRegsMap.find(SU); LRegsMapT::iterator LRegsPos = LRegsMap.find(SU);
if (Reg) { if (Reg) {
SmallVectorImpl<unsigned> &LRegs = LRegsPos->second; SmallVectorImpl<unsigned> &LRegs = LRegsPos->second;
if (std::find(LRegs.begin(), LRegs.end(), Reg) == LRegs.end()) if (!is_contained(LRegs, Reg))
continue; continue;
} }
SU->isPending = false; SU->isPending = false;
@ -1704,8 +1704,7 @@ public:
void remove(SUnit *SU) override { void remove(SUnit *SU) override {
assert(!Queue.empty() && "Queue is empty!"); assert(!Queue.empty() && "Queue is empty!");
assert(SU->NodeQueueId != 0 && "Not in queue!"); assert(SU->NodeQueueId != 0 && "Not in queue!");
std::vector<SUnit *>::iterator I = std::find(Queue.begin(), Queue.end(), std::vector<SUnit *>::iterator I = find(Queue, SU);
SU);
if (I != std::prev(Queue.end())) if (I != std::prev(Queue.end()))
std::swap(*I, Queue.back()); std::swap(*I, Queue.back());
Queue.pop_back(); Queue.pop_back();

View File

@ -3388,7 +3388,7 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
SelectionDAG::DAGNodeDeletedListener NDL(*CurDAG, [&](SDNode *N, SelectionDAG::DAGNodeDeletedListener NDL(*CurDAG, [&](SDNode *N,
SDNode *E) { SDNode *E) {
auto &Chain = ChainNodesMatched; auto &Chain = ChainNodesMatched;
assert((!E || llvm::find(Chain, N) == Chain.end()) && assert((!E || !is_contained(Chain, N)) &&
"Chain node replaced during MorphNode"); "Chain node replaced during MorphNode");
Chain.erase(std::remove(Chain.begin(), Chain.end(), N), Chain.end()); Chain.erase(std::remove(Chain.begin(), Chain.end(), N), Chain.end());
}); });

View File

@ -900,7 +900,7 @@ bool TailDuplicator::tailDuplicate(MachineFunction &MF, bool IsSimple,
PE = Preds.end(); PE = Preds.end();
PI != PE; ++PI) { PI != PE; ++PI) {
MachineBasicBlock *PredBB = *PI; MachineBasicBlock *PredBB = *PI;
if (std::find(TDBBs.begin(), TDBBs.end(), PredBB) != TDBBs.end()) if (is_contained(TDBBs, PredBB))
continue; continue;
// EH edges // EH edges

View File

@ -467,7 +467,7 @@ static MachineInstr *foldPatchpoint(MachineFunction &MF, MachineInstr &MI,
for (unsigned i = StartIdx; i < MI.getNumOperands(); ++i) { for (unsigned i = StartIdx; i < MI.getNumOperands(); ++i) {
MachineOperand &MO = MI.getOperand(i); MachineOperand &MO = MI.getOperand(i);
if (std::find(Ops.begin(), Ops.end(), i) != Ops.end()) { if (is_contained(Ops, i)) {
unsigned SpillSize; unsigned SpillSize;
unsigned SpillOffset; unsigned SpillOffset;
// Compute the spill slot size and offset. // Compute the spill slot size and offset.

View File

@ -354,7 +354,7 @@ TargetRegisterInfo::getRegAllocationHints(unsigned VirtReg,
// Check that Phys is in the allocation order. We shouldn't heed hints // 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 // from VirtReg's register class if they aren't in the allocation order. The
// target probably has a reason for removing the register. // 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; return;
// All clear, tell the register allocator to prefer this register. // All clear, tell the register allocator to prefer this register.

View File

@ -841,9 +841,7 @@ bool PMDataManager::preserveHigherLevelAnalysis(Pass *P) {
E = HigherLevelAnalysis.end(); I != E; ++I) { E = HigherLevelAnalysis.end(); I != E; ++I) {
Pass *P1 = *I; Pass *P1 = *I;
if (P1->getAsImmutablePass() == nullptr && if (P1->getAsImmutablePass() == nullptr &&
std::find(PreservedSet.begin(), PreservedSet.end(), !is_contained(PreservedSet, P1->getPassID()))
P1->getPassID()) ==
PreservedSet.end())
return false; return false;
} }
@ -881,8 +879,7 @@ void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
E = AvailableAnalysis.end(); I != E; ) { E = AvailableAnalysis.end(); I != E; ) {
DenseMap<AnalysisID, Pass*>::iterator Info = I++; DenseMap<AnalysisID, Pass*>::iterator Info = I++;
if (Info->second->getAsImmutablePass() == nullptr && if (Info->second->getAsImmutablePass() == nullptr &&
std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) == !is_contained(PreservedSet, Info->first)) {
PreservedSet.end()) {
// Remove this analysis // Remove this analysis
if (PassDebugging >= Details) { if (PassDebugging >= Details) {
Pass *S = Info->second; Pass *S = Info->second;
@ -905,8 +902,7 @@ void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
E = InheritedAnalysis[Index]->end(); I != E; ) { E = InheritedAnalysis[Index]->end(); I != E; ) {
DenseMap<AnalysisID, Pass *>::iterator Info = I++; DenseMap<AnalysisID, Pass *>::iterator Info = I++;
if (Info->second->getAsImmutablePass() == nullptr && if (Info->second->getAsImmutablePass() == nullptr &&
std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) == !is_contained(PreservedSet, Info->first)) {
PreservedSet.end()) {
// Remove this analysis // Remove this analysis
if (PassDebugging >= Details) { if (PassDebugging >= Details) {
Pass *S = Info->second; Pass *S = Info->second;

View File

@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/PassRegistry.h" #include "llvm/PassRegistry.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/PassSupport.h" #include "llvm/PassSupport.h"
#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/ManagedStatic.h"
@ -121,6 +122,6 @@ void PassRegistry::addRegistrationListener(PassRegistrationListener *L) {
void PassRegistry::removeRegistrationListener(PassRegistrationListener *L) { void PassRegistry::removeRegistrationListener(PassRegistrationListener *L) {
sys::SmartScopedWriter<true> Guard(Lock); sys::SmartScopedWriter<true> Guard(Lock);
auto I = std::find(Listeners.begin(), Listeners.end(), L); auto I = find(Listeners, L);
Listeners.erase(I); Listeners.erase(I);
} }

View File

@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/Option/OptTable.h" #include "llvm/Option/OptTable.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Option/Arg.h" #include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h" #include "llvm/Option/ArgList.h"
#include "llvm/Option/Option.h" #include "llvm/Option/Option.h"
@ -142,8 +143,7 @@ OptTable::OptTable(ArrayRef<Info> OptionInfos, bool IgnoreCase)
StringRef Prefix = I->getKey(); StringRef Prefix = I->getKey();
for (StringRef::const_iterator C = Prefix.begin(), CE = Prefix.end(); for (StringRef::const_iterator C = Prefix.begin(), CE = Prefix.end();
C != CE; ++C) C != CE; ++C)
if (std::find(PrefixChars.begin(), PrefixChars.end(), *C) if (!is_contained(PrefixChars, *C))
== PrefixChars.end())
PrefixChars.push_back(*C); PrefixChars.push_back(*C);
} }
} }

View File

@ -2101,7 +2101,7 @@ void cl::AddExtraVersionPrinter(void (*func)()) {
StringMap<Option *> &cl::getRegisteredOptions(SubCommand &Sub) { StringMap<Option *> &cl::getRegisteredOptions(SubCommand &Sub) {
auto &Subs = GlobalParser->RegisteredSubCommands; auto &Subs = GlobalParser->RegisteredSubCommands;
(void)Subs; (void)Subs;
assert(std::find(Subs.begin(), Subs.end(), &Sub) != Subs.end()); assert(is_contained(Subs, &Sub));
return Sub.OptionsMap; return Sub.OptionsMap;
} }

View File

@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/Support/YAMLParser.h" #include "llvm/Support/YAMLParser.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
@ -802,8 +803,7 @@ Token &Scanner::peekNext() {
removeStaleSimpleKeyCandidates(); removeStaleSimpleKeyCandidates();
SimpleKey SK; SimpleKey SK;
SK.Tok = TokenQueue.begin(); SK.Tok = TokenQueue.begin();
if (std::find(SimpleKeys.begin(), SimpleKeys.end(), SK) if (!is_contained(SimpleKeys, SK))
== SimpleKeys.end())
break; break;
else else
NeedMore = true; NeedMore = true;

View File

@ -4976,7 +4976,7 @@ SDValue AArch64TargetLowering::ReconstructShuffle(SDValue Op,
// Add this element source to the list if it's not already there. // Add this element source to the list if it's not already there.
SDValue SourceVec = V.getOperand(0); SDValue SourceVec = V.getOperand(0);
auto Source = std::find(Sources.begin(), Sources.end(), SourceVec); auto Source = find(Sources, SourceVec);
if (Source == Sources.end()) if (Source == Sources.end())
Source = Sources.insert(Sources.end(), ShuffleSourceInfo(SourceVec)); Source = Sources.insert(Sources.end(), ShuffleSourceInfo(SourceVec));
@ -5092,7 +5092,7 @@ SDValue AArch64TargetLowering::ReconstructShuffle(SDValue Op,
if (Entry.isUndef()) if (Entry.isUndef())
continue; 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(); int EltNo = cast<ConstantSDNode>(Entry.getOperand(1))->getSExtValue();
// EXTRACT_VECTOR_ELT performs an implicit any_ext; BUILD_VECTOR an implicit // EXTRACT_VECTOR_ELT performs an implicit any_ext; BUILD_VECTOR an implicit

View File

@ -535,7 +535,7 @@ bool AMDGPUPromoteAlloca::collectUsesWithPtrTypes(
std::vector<Value*> &WorkList) const { std::vector<Value*> &WorkList) const {
for (User *User : Val->users()) { for (User *User : Val->users()) {
if (std::find(WorkList.begin(), WorkList.end(), User) != WorkList.end()) if (is_contained(WorkList, User))
continue; continue;
if (CallInst *CI = dyn_cast<CallInst>(User)) { if (CallInst *CI = dyn_cast<CallInst>(User)) {

View File

@ -200,12 +200,10 @@ MachineInstr *R600VectorRegMerger::RebuildVector(
.addReg(SubReg) .addReg(SubReg)
.addImm(Chan); .addImm(Chan);
UpdatedRegToChan[SubReg] = Chan; UpdatedRegToChan[SubReg] = Chan;
std::vector<unsigned>::iterator ChanPos = std::vector<unsigned>::iterator ChanPos = find(UpdatedUndef, Chan);
std::find(UpdatedUndef.begin(), UpdatedUndef.end(), Chan);
if (ChanPos != UpdatedUndef.end()) if (ChanPos != UpdatedUndef.end())
UpdatedUndef.erase(ChanPos); UpdatedUndef.erase(ChanPos);
assert(std::find(UpdatedUndef.begin(), UpdatedUndef.end(), Chan) == assert(!is_contained(UpdatedUndef, Chan) &&
UpdatedUndef.end() &&
"UpdatedUndef shouldn't contain Chan more than once!"); "UpdatedUndef shouldn't contain Chan more than once!");
DEBUG(dbgs() << " ->"; Tmp->dump();); DEBUG(dbgs() << " ->"; Tmp->dump(););
(void)Tmp; (void)Tmp;
@ -236,12 +234,12 @@ void R600VectorRegMerger::RemoveMI(MachineInstr *MI) {
for (InstructionSetMap::iterator It = PreviousRegSeqByReg.begin(), for (InstructionSetMap::iterator It = PreviousRegSeqByReg.begin(),
E = PreviousRegSeqByReg.end(); It != E; ++It) { E = PreviousRegSeqByReg.end(); It != E; ++It) {
std::vector<MachineInstr *> &MIs = (*It).second; 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(), for (InstructionSetMap::iterator It = PreviousRegSeqByUndefCount.begin(),
E = PreviousRegSeqByUndefCount.end(); It != E; ++It) { E = PreviousRegSeqByUndefCount.end(); It != E; ++It) {
std::vector<MachineInstr *> &MIs = (*It).second; std::vector<MachineInstr *> &MIs = (*It).second;
MIs.erase(std::find(MIs.begin(), MIs.end(), MI), MIs.end()); MIs.erase(find(MIs, MI), MIs.end());
} }
} }

View File

@ -363,7 +363,7 @@ void SIAnnotateControlFlow::closeControlFlow(BasicBlock *BB) {
std::vector<BasicBlock*> Preds; std::vector<BasicBlock*> Preds;
for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE; ++PI) { 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); Preds.push_back(*PI);
} }
BB = llvm::SplitBlockPredecessors(BB, Preds, "endcf.split", DT, LI, false); BB = llvm::SplitBlockPredecessors(BB, Preds, "endcf.split", DT, LI, false);

View File

@ -479,8 +479,7 @@ void SIScheduleBlock::releaseSuccessors(SUnit *SU, bool InOrOutBlock) {
void SIScheduleBlock::nodeScheduled(SUnit *SU) { void SIScheduleBlock::nodeScheduled(SUnit *SU) {
// Is in TopReadySUs // Is in TopReadySUs
assert (!SU->NumPredsLeft); assert (!SU->NumPredsLeft);
std::vector<SUnit*>::iterator I = std::vector<SUnit *>::iterator I = find(TopReadySUs, SU);
std::find(TopReadySUs.begin(), TopReadySUs.end(), SU);
if (I == TopReadySUs.end()) { if (I == TopReadySUs.end()) {
dbgs() << "Data Structure Bug in SI Scheduler\n"; dbgs() << "Data Structure Bug in SI Scheduler\n";
llvm_unreachable(nullptr); llvm_unreachable(nullptr);

View File

@ -289,8 +289,7 @@ ARMBaseRegisterInfo::getRegAllocationHints(unsigned VirtReg,
} }
// First prefer the paired physreg. // First prefer the paired physreg.
if (PairedPhys && if (PairedPhys && is_contained(Order, PairedPhys))
std::find(Order.begin(), Order.end(), PairedPhys) != Order.end())
Hints.push_back(PairedPhys); Hints.push_back(PairedPhys);
// Then prefer even or odd registers. // Then prefer even or odd registers.

View File

@ -1432,7 +1432,7 @@ bool ARMConstantIslands::handleConstantPoolUser(unsigned CPUserIndex,
// it. Check for this so it will be removed from the WaterList. // it. Check for this so it will be removed from the WaterList.
// Also remove any entry from NewWaterList. // Also remove any entry from NewWaterList.
MachineBasicBlock *WaterBB = &*--NewMBB->getIterator(); MachineBasicBlock *WaterBB = &*--NewMBB->getIterator();
IP = std::find(WaterList.begin(), WaterList.end(), WaterBB); IP = find(WaterList, WaterBB);
if (IP != WaterList.end()) if (IP != WaterList.end())
NewWaterList.erase(WaterBB); NewWaterList.erase(WaterBB);

View File

@ -1640,8 +1640,7 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF,
SavedRegs.set(ARM::LR); SavedRegs.set(ARM::LR);
NumGPRSpills++; NumGPRSpills++;
SmallVectorImpl<unsigned>::iterator LRPos; SmallVectorImpl<unsigned>::iterator LRPos;
LRPos = std::find(UnspilledCS1GPRs.begin(), UnspilledCS1GPRs.end(), LRPos = find(UnspilledCS1GPRs, (unsigned)ARM::LR);
(unsigned)ARM::LR);
if (LRPos != UnspilledCS1GPRs.end()) if (LRPos != UnspilledCS1GPRs.end())
UnspilledCS1GPRs.erase(LRPos); UnspilledCS1GPRs.erase(LRPos);
@ -1651,8 +1650,7 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF,
if (hasFP(MF)) { if (hasFP(MF)) {
SavedRegs.set(FramePtr); SavedRegs.set(FramePtr);
auto FPPos = std::find(UnspilledCS1GPRs.begin(), UnspilledCS1GPRs.end(), auto FPPos = find(UnspilledCS1GPRs, FramePtr);
FramePtr);
if (FPPos != UnspilledCS1GPRs.end()) if (FPPos != UnspilledCS1GPRs.end())
UnspilledCS1GPRs.erase(FPPos); UnspilledCS1GPRs.erase(FPPos);
NumGPRSpills++; NumGPRSpills++;

View File

@ -5915,7 +5915,7 @@ SDValue ARMTargetLowering::ReconstructShuffle(SDValue Op,
// Add this element source to the list if it's not already there. // Add this element source to the list if it's not already there.
SDValue SourceVec = V.getOperand(0); SDValue SourceVec = V.getOperand(0);
auto Source = std::find(Sources.begin(), Sources.end(), SourceVec); auto Source = find(Sources, SourceVec);
if (Source == Sources.end()) if (Source == Sources.end())
Source = Sources.insert(Sources.end(), ShuffleSourceInfo(SourceVec)); Source = Sources.insert(Sources.end(), ShuffleSourceInfo(SourceVec));
@ -6031,7 +6031,7 @@ SDValue ARMTargetLowering::ReconstructShuffle(SDValue Op,
if (Entry.isUndef()) if (Entry.isUndef())
continue; 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(); int EltNo = cast<ConstantSDNode>(Entry.getOperand(1))->getSExtValue();
// EXTRACT_VECTOR_ELT performs an implicit any_ext; BUILD_VECTOR an implicit // EXTRACT_VECTOR_ELT performs an implicit any_ext; BUILD_VECTOR an implicit

View File

@ -834,7 +834,7 @@ MachineInstr *ARMLoadStoreOpt::MergeOpsUpdate(const MergeCandidate &Cand) {
assert(MO.isImplicit()); assert(MO.isImplicit());
unsigned DefReg = MO.getReg(); unsigned DefReg = MO.getReg();
if (std::find(ImpDefs.begin(), ImpDefs.end(), DefReg) != ImpDefs.end()) if (is_contained(ImpDefs, DefReg))
continue; continue;
// We can ignore cases where the super-reg is read and written. // We can ignore cases where the super-reg is read and written.
if (MI->readsRegister(DefReg)) if (MI->readsRegister(DefReg))

View File

@ -2665,7 +2665,7 @@ bool HexagonLoopRescheduling::processLoop(LoopCand &C) {
if (UseI->getOperand(Idx+1).getMBB() != C.LB) if (UseI->getOperand(Idx+1).getMBB() != C.LB)
BadUse = true; BadUse = true;
} else { } else {
auto F = std::find(ShufIns.begin(), ShufIns.end(), UseI); auto F = find(ShufIns, UseI);
if (F == ShufIns.end()) if (F == ShufIns.end())
BadUse = true; BadUse = true;
} }

View File

@ -94,9 +94,7 @@ public:
void savePacket(); void savePacket();
unsigned getTotalPackets() const { return TotalPackets; } unsigned getTotalPackets() const { return TotalPackets; }
bool isInPacket(SUnit *SU) const { bool isInPacket(SUnit *SU) const { return is_contained(Packet, SU); }
return std::find(Packet.begin(), Packet.end(), SU) != Packet.end();
}
}; };
/// Extend the standard ScheduleDAGMI to provide more context and override the /// Extend the standard ScheduleDAGMI to provide more context and override the

View File

@ -1338,7 +1338,7 @@ bool HexagonPacketizerList::isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) {
// However, there is no dependence edge between (1)->(3). This results // However, there is no dependence edge between (1)->(3). This results
// in all 3 instructions going in the same packet. We ignore dependce // in all 3 instructions going in the same packet. We ignore dependce
// only once to avoid this situation. // only once to avoid this situation.
auto Itr = std::find(IgnoreDepMIs.begin(), IgnoreDepMIs.end(), &J); auto Itr = find(IgnoreDepMIs, &J);
if (Itr != IgnoreDepMIs.end()) { if (Itr != IgnoreDepMIs.end()) {
Dependence = true; Dependence = true;
return false; return false;

View File

@ -1374,7 +1374,7 @@ bool MipsConstantIslands::handleConstantPoolUser(unsigned CPUserIndex) {
// it. Check for this so it will be removed from the WaterList. // it. Check for this so it will be removed from the WaterList.
// Also remove any entry from NewWaterList. // Also remove any entry from NewWaterList.
MachineBasicBlock *WaterBB = &*--NewMBB->getIterator(); MachineBasicBlock *WaterBB = &*--NewMBB->getIterator();
IP = std::find(WaterList.begin(), WaterList.end(), WaterBB); IP = find(WaterList, WaterBB);
if (IP != WaterList.end()) if (IP != WaterList.end())
NewWaterList.erase(WaterBB); NewWaterList.erase(WaterBB);

View File

@ -169,7 +169,7 @@ bool llvm::isSampler(const llvm::Value &val) {
if (llvm::findAllNVVMAnnotation( if (llvm::findAllNVVMAnnotation(
func, llvm::PropertyAnnotationNames[llvm::PROPERTY_ISSAMPLER], func, llvm::PropertyAnnotationNames[llvm::PROPERTY_ISSAMPLER],
annot)) { annot)) {
if (std::find(annot.begin(), annot.end(), arg->getArgNo()) != annot.end()) if (is_contained(annot, arg->getArgNo()))
return true; return true;
} }
} }
@ -184,7 +184,7 @@ bool llvm::isImageReadOnly(const llvm::Value &val) {
llvm::PropertyAnnotationNames[ llvm::PropertyAnnotationNames[
llvm::PROPERTY_ISREADONLY_IMAGE_PARAM], llvm::PROPERTY_ISREADONLY_IMAGE_PARAM],
annot)) { annot)) {
if (std::find(annot.begin(), annot.end(), arg->getArgNo()) != annot.end()) if (is_contained(annot, arg->getArgNo()))
return true; return true;
} }
} }
@ -199,7 +199,7 @@ bool llvm::isImageWriteOnly(const llvm::Value &val) {
llvm::PropertyAnnotationNames[ llvm::PropertyAnnotationNames[
llvm::PROPERTY_ISWRITEONLY_IMAGE_PARAM], llvm::PROPERTY_ISWRITEONLY_IMAGE_PARAM],
annot)) { annot)) {
if (std::find(annot.begin(), annot.end(), arg->getArgNo()) != annot.end()) if (is_contained(annot, arg->getArgNo()))
return true; return true;
} }
} }
@ -214,7 +214,7 @@ bool llvm::isImageReadWrite(const llvm::Value &val) {
llvm::PropertyAnnotationNames[ llvm::PropertyAnnotationNames[
llvm::PROPERTY_ISREADWRITE_IMAGE_PARAM], llvm::PROPERTY_ISREADWRITE_IMAGE_PARAM],
annot)) { annot)) {
if (std::find(annot.begin(), annot.end(), arg->getArgNo()) != annot.end()) if (is_contained(annot, arg->getArgNo()))
return true; return true;
} }
} }

3
llvm/lib/Target/Sparc/LeonPasses.cpp Executable file → Normal file
View File

@ -51,8 +51,7 @@ int LEONMachineFunctionPass::GetRegIndexForOperand(MachineInstr &MI,
int LEONMachineFunctionPass::getUnusedFPRegister(MachineRegisterInfo &MRI) { int LEONMachineFunctionPass::getUnusedFPRegister(MachineRegisterInfo &MRI) {
for (int RegisterIndex = SP::F0; RegisterIndex <= SP::F31; ++RegisterIndex) { for (int RegisterIndex = SP::F0; RegisterIndex <= SP::F31; ++RegisterIndex) {
if (!MRI.isPhysRegUsed(RegisterIndex) && if (!MRI.isPhysRegUsed(RegisterIndex) &&
!(std::find(UsedRegisters.begin(), UsedRegisters.end(), !is_contained(UsedRegisters, RegisterIndex)) {
RegisterIndex) != UsedRegisters.end())) {
return RegisterIndex; return RegisterIndex;
} }
} }

View File

@ -9553,18 +9553,15 @@ static SDValue lowerV8I16GeneralSingleInputVectorShuffle(
auto FixFlippedInputs = [&V, &DL, &Mask, &DAG](int PinnedIdx, int DWord, auto FixFlippedInputs = [&V, &DL, &Mask, &DAG](int PinnedIdx, int DWord,
ArrayRef<int> Inputs) { ArrayRef<int> Inputs) {
int FixIdx = PinnedIdx ^ 1; // The adjacent slot to the pinned slot. int FixIdx = PinnedIdx ^ 1; // The adjacent slot to the pinned slot.
bool IsFixIdxInput = std::find(Inputs.begin(), Inputs.end(), bool IsFixIdxInput = is_contained(Inputs, PinnedIdx ^ 1);
PinnedIdx ^ 1) != Inputs.end();
// Determine whether the free index is in the flipped dword or the // 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 // unflipped dword based on where the pinned index is. We use this bit
// in an xor to conditionally select the adjacent dword. // in an xor to conditionally select the adjacent dword.
int FixFreeIdx = 2 * (DWord ^ (PinnedIdx / 2 == DWord)); int FixFreeIdx = 2 * (DWord ^ (PinnedIdx / 2 == DWord));
bool IsFixFreeIdxInput = std::find(Inputs.begin(), Inputs.end(), bool IsFixFreeIdxInput = is_contained(Inputs, FixFreeIdx);
FixFreeIdx) != Inputs.end();
if (IsFixIdxInput == IsFixFreeIdxInput) if (IsFixIdxInput == IsFixFreeIdxInput)
FixFreeIdx += 1; FixFreeIdx += 1;
IsFixFreeIdxInput = std::find(Inputs.begin(), Inputs.end(), IsFixFreeIdxInput = is_contained(Inputs, FixFreeIdx);
FixFreeIdx) != Inputs.end();
assert(IsFixIdxInput != IsFixFreeIdxInput && assert(IsFixIdxInput != IsFixFreeIdxInput &&
"We need to be changing the number of flipped inputs!"); "We need to be changing the number of flipped inputs!");
int PSHUFHalfMask[] = {0, 1, 2, 3}; int PSHUFHalfMask[] = {0, 1, 2, 3};

View File

@ -1167,8 +1167,7 @@ FindMostPopularDest(BasicBlock *BB,
for (unsigned i = 0; ; ++i) { for (unsigned i = 0; ; ++i) {
assert(i != TI->getNumSuccessors() && "Didn't find any successor!"); assert(i != TI->getNumSuccessors() && "Didn't find any successor!");
if (std::find(SamePopularity.begin(), SamePopularity.end(), if (!is_contained(SamePopularity, TI->getSuccessor(i)))
TI->getSuccessor(i)) == SamePopularity.end())
continue; continue;
MostPopularDest = TI->getSuccessor(i); MostPopularDest = TI->getSuccessor(i);

View File

@ -878,7 +878,7 @@ findRootsRecursive(Instruction *I, SmallInstructionSet SubsumedInsts) {
for (User *V : I->users()) { for (User *V : I->users()) {
Instruction *I = dyn_cast<Instruction>(V); Instruction *I = dyn_cast<Instruction>(V);
if (std::find(LoopIncs.begin(), LoopIncs.end(), I) != LoopIncs.end()) if (is_contained(LoopIncs, I))
continue; continue;
if (!I || !isSimpleArithmeticOp(I) || if (!I || !isSimpleArithmeticOp(I) ||
@ -1088,7 +1088,7 @@ bool LoopReroll::DAGRootTracker::isBaseInst(Instruction *I) {
bool LoopReroll::DAGRootTracker::isRootInst(Instruction *I) { bool LoopReroll::DAGRootTracker::isRootInst(Instruction *I) {
for (auto &DRS : RootSets) { 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 true;
} }
return false; return false;

View File

@ -448,8 +448,7 @@ void Formula::deleteBaseReg(const SCEV *&S) {
/// Test if this formula references the given register. /// Test if this formula references the given register.
bool Formula::referencesReg(const SCEV *S) const { bool Formula::referencesReg(const SCEV *S) const {
return S == ScaledReg || return S == ScaledReg || is_contained(BaseRegs, S);
std::find(BaseRegs.begin(), BaseRegs.end(), S) != BaseRegs.end();
} }
/// Test whether this formula uses registers which are used by uses other than /// 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()); int NumReqRegsToFind = std::min(F.getNumRegs(), ReqRegs.size());
for (const SCEV *Reg : ReqRegs) { for (const SCEV *Reg : ReqRegs) {
if ((F.ScaledReg && F.ScaledReg == Reg) || if ((F.ScaledReg && F.ScaledReg == Reg) ||
std::find(F.BaseRegs.begin(), F.BaseRegs.end(), Reg) != is_contained(F.BaseRegs, Reg)) {
F.BaseRegs.end()) {
--NumReqRegsToFind; --NumReqRegsToFind;
if (NumReqRegsToFind == 0) if (NumReqRegsToFind == 0)
break; break;

View File

@ -1154,7 +1154,7 @@ static void CreateGCRelocates(ArrayRef<Value *> LiveVariables,
return; return;
auto FindIndex = [](ArrayRef<Value *> LiveVec, Value *Val) { 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!"); assert(ValIt != LiveVec.end() && "Val not found in LiveVec!");
size_t Index = std::distance(LiveVec.begin(), ValIt); size_t Index = std::distance(LiveVec.begin(), ValIt);
assert(Index < LiveVec.size() && "Bug in std::find?"); 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 // Assert that cloned instruction does not use any instructions from
// this chain other than LastClonedValue // this chain other than LastClonedValue
for (auto OpValue : ClonedValue->operand_values()) { for (auto OpValue : ClonedValue->operand_values()) {
assert(std::find(ChainToBase.begin(), ChainToBase.end(), OpValue) == assert(!is_contained(ChainToBase, OpValue) &&
ChainToBase.end() &&
"incorrect use in rematerialization chain"); "incorrect use in rematerialization chain");
} }
#endif #endif

View File

@ -321,7 +321,7 @@ void StructurizeCFG::orderNodes() {
BasicBlock *BB = (*I)->getEntry(); BasicBlock *BB = (*I)->getEntry();
unsigned LoopDepth = LI->getLoopDepth(BB); unsigned LoopDepth = LI->getLoopDepth(BB);
if (std::find(Order.begin(), Order.end(), *I) != Order.end()) if (is_contained(Order, *I))
continue; continue;
if (LoopDepth < CurrentLoopDepth) { if (LoopDepth < CurrentLoopDepth) {

View File

@ -537,7 +537,7 @@ bool Evaluator::EvaluateFunction(Function *F, Constant *&RetVal,
const SmallVectorImpl<Constant*> &ActualArgs) { const SmallVectorImpl<Constant*> &ActualArgs) {
// Check to see if this function is already executing (recursion). If so, // Check to see if this function is already executing (recursion). If so,
// bail out. TODO: we might want to accept limited recursion. // 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; return false;
CallStack.push_back(F); CallStack.push_back(F);

View File

@ -54,7 +54,7 @@ STATISTIC(NumLCSSA, "Number of live out of a loop variables");
/// Return true if the specified block is in the list. /// Return true if the specified block is in the list.
static bool isExitBlock(BasicBlock *BB, static bool isExitBlock(BasicBlock *BB,
const SmallVectorImpl<BasicBlock *> &ExitBlocks) { 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 /// For every instruction from the worklist, check to see if it has any uses

View File

@ -482,5 +482,5 @@ bool
LoadAndStorePromoter::isInstInList(Instruction *I, LoadAndStorePromoter::isInstInList(Instruction *I,
const SmallVectorImpl<Instruction*> &Insts) const SmallVectorImpl<Instruction*> &Insts)
const { const {
return std::find(Insts.begin(), Insts.end(), I) != Insts.end(); return is_contained(Insts, I);
} }

View File

@ -954,8 +954,7 @@ void BoUpSLP::buildTree(ArrayRef<Value *> Roots,
} }
// Ignore users in the user ignore list. // Ignore users in the user ignore list.
if (std::find(UserIgnoreList.begin(), UserIgnoreList.end(), UserInst) != if (is_contained(UserIgnoreList, UserInst))
UserIgnoreList.end())
continue; continue;
DEBUG(dbgs() << "SLP: Need to extract:" << *U << " from lane " << DEBUG(dbgs() << "SLP: Need to extract:" << *U << " from lane " <<
@ -2726,8 +2725,7 @@ Value *BoUpSLP::vectorizeTree() {
assert((ScalarToTreeEntry.count(U) || assert((ScalarToTreeEntry.count(U) ||
// It is legal to replace users in the ignorelist by undef. // It is legal to replace users in the ignorelist by undef.
(std::find(UserIgnoreList.begin(), UserIgnoreList.end(), U) != is_contained(UserIgnoreList, U)) &&
UserIgnoreList.end())) &&
"Replacing out-of-tree value with undef"); "Replacing out-of-tree value with undef");
} }
#endif #endif
@ -2820,7 +2818,7 @@ void BoUpSLP::optimizeGatherSequence() {
} }
} }
if (In) { if (In) {
assert(std::find(Visited.begin(), Visited.end(), In) == Visited.end()); assert(!is_contained(Visited, In));
Visited.push_back(In); Visited.push_back(In);
} }
} }

View File

@ -239,9 +239,7 @@ static void RemoveFunctionReferences(Module *M, const char* Name) {
bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) { bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) {
// If main isn't present, claim there is no problem. // If main isn't present, claim there is no problem.
if (KeepMain && std::find(Funcs.begin(), Funcs.end(), if (KeepMain && !is_contained(Funcs, BD.getProgram()->getFunction("main")))
BD.getProgram()->getFunction("main")) ==
Funcs.end())
return false; return false;
// Clone the program to try hacking it apart... // Clone the program to try hacking it apart...

View File

@ -285,20 +285,17 @@ void MachODebugMapParser::dumpOneBinaryStab(const MachOObjectFile &MainBinary,
} }
static bool shouldLinkArch(SmallVectorImpl<StringRef> &Archs, StringRef Arch) { static bool shouldLinkArch(SmallVectorImpl<StringRef> &Archs, StringRef Arch) {
if (Archs.empty() || if (Archs.empty() || is_contained(Archs, "all") || is_contained(Archs, "*"))
std::find(Archs.begin(), Archs.end(), "all") != Archs.end() ||
std::find(Archs.begin(), Archs.end(), "*") != Archs.end())
return true; return true;
if (Arch.startswith("arm") && Arch != "arm64" && if (Arch.startswith("arm") && Arch != "arm64" && is_contained(Archs, "arm"))
std::find(Archs.begin(), Archs.end(), "arm") != Archs.end())
return true; return true;
SmallString<16> ArchName = Arch; SmallString<16> ArchName = Arch;
if (Arch.startswith("thumb")) if (Arch.startswith("thumb"))
ArchName = ("arm" + Arch.substr(5)).str(); ArchName = ("arm" + Arch.substr(5)).str();
return std::find(Archs.begin(), Archs.end(), ArchName) != Archs.end(); return is_contained(Archs, ArchName);
} }
bool MachODebugMapParser::dumpStab() { bool MachODebugMapParser::dumpStab() {

View File

@ -429,7 +429,7 @@ static void performReadOperation(ArchiveOperation Operation,
StringRef Name = NameOrErr.get(); StringRef Name = NameOrErr.get();
if (Filter) { if (Filter) {
auto I = std::find(Members.begin(), Members.end(), Name); auto I = find(Members, Name);
if (I == Members.end()) if (I == Members.end())
continue; continue;
Members.erase(I); Members.erase(I);

View File

@ -15,6 +15,7 @@
#ifndef LLVM_UNITTESTS_EXECUTIONENGINE_MCJIT_MCJITTESTAPICOMMON_H #ifndef LLVM_UNITTESTS_EXECUTIONENGINE_MCJIT_MCJITTESTAPICOMMON_H
#define LLVM_UNITTESTS_EXECUTIONENGINE_MCJIT_MCJITTESTAPICOMMON_H #define LLVM_UNITTESTS_EXECUTIONENGINE_MCJIT_MCJITTESTAPICOMMON_H
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Triple.h" #include "llvm/ADT/Triple.h"
#include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/LegacyPassManager.h"
@ -56,13 +57,11 @@ protected:
bool ArchSupportsMCJIT() { bool ArchSupportsMCJIT() {
Triple Host(HostTriple); Triple Host(HostTriple);
// If ARCH is not supported, bail // If ARCH is not supported, bail
if (std::find(SupportedArchs.begin(), SupportedArchs.end(), Host.getArch()) if (!is_contained(SupportedArchs, Host.getArch()))
== SupportedArchs.end())
return false; return false;
// If ARCH is supported and has no specific sub-arch support // If ARCH is supported and has no specific sub-arch support
if (std::find(HasSubArchs.begin(), HasSubArchs.end(), Host.getArch()) if (!is_contained(HasSubArchs, Host.getArch()))
== HasSubArchs.end())
return true; return true;
// If ARCH has sub-arch support, find it // If ARCH has sub-arch support, find it
@ -78,12 +77,11 @@ protected:
bool OSSupportsMCJIT() { bool OSSupportsMCJIT() {
Triple Host(HostTriple); Triple Host(HostTriple);
if (std::find(UnsupportedEnvironments.begin(), UnsupportedEnvironments.end(), if (find(UnsupportedEnvironments, Host.getEnvironment()) !=
Host.getEnvironment()) != UnsupportedEnvironments.end()) UnsupportedEnvironments.end())
return false; return false;
if (std::find(UnsupportedOSs.begin(), UnsupportedOSs.end(), Host.getOS()) if (!is_contained(UnsupportedOSs, Host.getOS()))
== UnsupportedOSs.end())
return true; return true;
return false; return false;

View File

@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/Support/Path.h" #include "llvm/Support/Path.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/ConvertUTF.h" #include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/Errc.h" #include "llvm/Support/Errc.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
@ -677,16 +678,15 @@ TEST_F(FileSystemTest, DirectoryIteration) {
i.no_push(); i.no_push();
visited.push_back(path::filename(i->path())); visited.push_back(path::filename(i->path()));
} }
v_t::const_iterator a0 = std::find(visited.begin(), visited.end(), "a0"); v_t::const_iterator a0 = find(visited, "a0");
v_t::const_iterator aa1 = std::find(visited.begin(), visited.end(), "aa1"); v_t::const_iterator aa1 = find(visited, "aa1");
v_t::const_iterator ab1 = std::find(visited.begin(), visited.end(), "ab1"); v_t::const_iterator ab1 = find(visited, "ab1");
v_t::const_iterator dontlookhere = std::find(visited.begin(), visited.end(), v_t::const_iterator dontlookhere = find(visited, "dontlookhere");
"dontlookhere"); v_t::const_iterator da1 = find(visited, "da1");
v_t::const_iterator da1 = std::find(visited.begin(), visited.end(), "da1"); v_t::const_iterator z0 = find(visited, "z0");
v_t::const_iterator z0 = std::find(visited.begin(), visited.end(), "z0"); v_t::const_iterator za1 = find(visited, "za1");
v_t::const_iterator za1 = std::find(visited.begin(), visited.end(), "za1"); v_t::const_iterator pop = find(visited, "pop");
v_t::const_iterator pop = std::find(visited.begin(), visited.end(), "pop"); v_t::const_iterator p1 = find(visited, "p1");
v_t::const_iterator p1 = std::find(visited.begin(), visited.end(), "p1");
// Make sure that each path was visited correctly. // Make sure that each path was visited correctly.
ASSERT_NE(a0, visited.end()); ASSERT_NE(a0, visited.end());

View File

@ -31,16 +31,14 @@ protected:
bool isUnsupportedOSOrEnvironment() { bool isUnsupportedOSOrEnvironment() {
Triple Host(Triple::normalize(sys::getProcessTriple())); Triple Host(Triple::normalize(sys::getProcessTriple()));
if (std::find(UnsupportedEnvironments.begin(), UnsupportedEnvironments.end(), if (find(UnsupportedEnvironments, Host.getEnvironment()) !=
Host.getEnvironment()) != UnsupportedEnvironments.end()) UnsupportedEnvironments.end())
return true; return true;
if (std::find(UnsupportedOSs.begin(), UnsupportedOSs.end(), Host.getOS()) if (is_contained(UnsupportedOSs, Host.getOS()))
!= UnsupportedOSs.end())
return true; return true;
if (std::find(UnsupportedArchs.begin(), UnsupportedArchs.end(), Host.getArch()) if (is_contained(UnsupportedArchs, Host.getArch()))
!= UnsupportedArchs.end())
return true; return true;
return false; return false;

View File

@ -1819,8 +1819,7 @@ static unsigned getConverterOperandID(const std::string &Name,
bool &IsNew) { bool &IsNew) {
IsNew = Table.insert(Name); IsNew = Table.insert(Name);
unsigned ID = IsNew ? Table.size() - 1 : unsigned ID = IsNew ? Table.size() - 1 : find(Table, Name) - Table.begin();
std::find(Table.begin(), Table.end(), Name) - Table.begin();
assert(ID < Table.size()); assert(ID < Table.size());

View File

@ -412,8 +412,7 @@ public:
} }
void addPredicateFn(const TreePredicateFn &Fn) { void addPredicateFn(const TreePredicateFn &Fn) {
assert(!Fn.isAlwaysTrue() && "Empty predicate string!"); assert(!Fn.isAlwaysTrue() && "Empty predicate string!");
if (std::find(PredicateFns.begin(), PredicateFns.end(), Fn) == if (!is_contained(PredicateFns, Fn))
PredicateFns.end())
PredicateFns.push_back(Fn); PredicateFns.push_back(Fn);
} }

View File

@ -1756,8 +1756,7 @@ void CodeGenRegBank::computeRegUnitSets() {
std::vector<unsigned> RUSets; std::vector<unsigned> RUSets;
for (unsigned i = 0, e = RegUnitSets.size(); i != e; ++i) { for (unsigned i = 0, e = RegUnitSets.size(); i != e; ++i) {
RegUnitSet &RUSet = RegUnitSets[i]; RegUnitSet &RUSet = RegUnitSets[i];
if (std::find(RUSet.Units.begin(), RUSet.Units.end(), UnitIdx) if (!is_contained(RUSet.Units, UnitIdx))
== RUSet.Units.end())
continue; continue;
RUSets.push_back(i); RUSets.push_back(i);
} }

View File

@ -356,8 +356,7 @@ bool CodeGenSchedModels::hasReadOfWrite(Record *WriteDef) const {
continue; continue;
RecVec ValidWrites = ReadDef->getValueAsListOfDefs("ValidWrites"); RecVec ValidWrites = ReadDef->getValueAsListOfDefs("ValidWrites");
if (std::find(ValidWrites.begin(), ValidWrites.end(), WriteDef) if (is_contained(ValidWrites, WriteDef)) {
!= ValidWrites.end()) {
return true; return true;
} }
} }
@ -1400,8 +1399,7 @@ bool CodeGenSchedModels::hasSuperGroup(RecVec &SubUnits, CodeGenProcModel &PM) {
PM.ProcResourceDefs[i]->getValueAsListOfDefs("Resources"); PM.ProcResourceDefs[i]->getValueAsListOfDefs("Resources");
RecIter RI = SubUnits.begin(), RE = SubUnits.end(); RecIter RI = SubUnits.begin(), RE = SubUnits.end();
for ( ; RI != RE; ++RI) { for ( ; RI != RE; ++RI) {
if (std::find(SuperUnits.begin(), SuperUnits.end(), *RI) if (!is_contained(SuperUnits, *RI)) {
== SuperUnits.end()) {
break; break;
} }
} }
@ -1741,7 +1739,7 @@ void CodeGenSchedModels::addWriteRes(Record *ProcWriteResDef, unsigned PIdx) {
assert(PIdx && "don't add resources to an invalid Processor model"); assert(PIdx && "don't add resources to an invalid Processor model");
RecVec &WRDefs = ProcModels[PIdx].WriteResDefs; RecVec &WRDefs = ProcModels[PIdx].WriteResDefs;
RecIter WRI = std::find(WRDefs.begin(), WRDefs.end(), ProcWriteResDef); RecIter WRI = find(WRDefs, ProcWriteResDef);
if (WRI != WRDefs.end()) if (WRI != WRDefs.end())
return; return;
WRDefs.push_back(ProcWriteResDef); WRDefs.push_back(ProcWriteResDef);
@ -1758,15 +1756,14 @@ void CodeGenSchedModels::addWriteRes(Record *ProcWriteResDef, unsigned PIdx) {
void CodeGenSchedModels::addReadAdvance(Record *ProcReadAdvanceDef, void CodeGenSchedModels::addReadAdvance(Record *ProcReadAdvanceDef,
unsigned PIdx) { unsigned PIdx) {
RecVec &RADefs = ProcModels[PIdx].ReadAdvanceDefs; RecVec &RADefs = ProcModels[PIdx].ReadAdvanceDefs;
RecIter I = std::find(RADefs.begin(), RADefs.end(), ProcReadAdvanceDef); RecIter I = find(RADefs, ProcReadAdvanceDef);
if (I != RADefs.end()) if (I != RADefs.end())
return; return;
RADefs.push_back(ProcReadAdvanceDef); RADefs.push_back(ProcReadAdvanceDef);
} }
unsigned CodeGenProcModel::getProcResourceIdx(Record *PRDef) const { unsigned CodeGenProcModel::getProcResourceIdx(Record *PRDef) const {
RecIter PRPos = std::find(ProcResourceDefs.begin(), ProcResourceDefs.end(), RecIter PRPos = find(ProcResourceDefs, PRDef);
PRDef);
if (PRPos == ProcResourceDefs.end()) if (PRPos == ProcResourceDefs.end())
PrintFatalError(PRDef->getLoc(), "ProcResource def is not included in " PrintFatalError(PRDef->getLoc(), "ProcResource def is not included in "
"the ProcResources list for " + ModelName); "the ProcResources list for " + ModelName);

View File

@ -139,7 +139,7 @@ public:
/// supported by the target (i.e. there are registers that directly hold it). /// supported by the target (i.e. there are registers that directly hold it).
bool isLegalValueType(MVT::SimpleValueType VT) const { bool isLegalValueType(MVT::SimpleValueType VT) const {
ArrayRef<MVT::SimpleValueType> LegalVTs = getLegalValueTypes(); ArrayRef<MVT::SimpleValueType> LegalVTs = getLegalValueTypes();
return std::find(LegalVTs.begin(), LegalVTs.end(), VT) != LegalVTs.end(); return is_contained(LegalVTs, VT);
} }
CodeGenSchedModels &getSchedModels() const; CodeGenSchedModels &getSchedModels() const;

View File

@ -783,8 +783,7 @@ void SubtargetEmitter::ExpandProcResources(RecVec &PRVec,
RecVec SuperResources = PR->getValueAsListOfDefs("Resources"); RecVec SuperResources = PR->getValueAsListOfDefs("Resources");
RecIter SubI = SubResources.begin(), SubE = SubResources.end(); RecIter SubI = SubResources.begin(), SubE = SubResources.end();
for( ; SubI != SubE; ++SubI) { for( ; SubI != SubE; ++SubI) {
if (std::find(SuperResources.begin(), SuperResources.end(), *SubI) if (!is_contained(SuperResources, *SubI)) {
== SuperResources.end()) {
break; break;
} }
} }
@ -873,8 +872,7 @@ void SubtargetEmitter::GenSchedClassTables(const CodeGenProcModel &ProcModel,
// Check this processor's itinerary class resources. // Check this processor's itinerary class resources.
for (Record *I : ProcModel.ItinRWDefs) { for (Record *I : ProcModel.ItinRWDefs) {
RecVec Matched = I->getValueAsListOfDefs("MatchedItinClasses"); RecVec Matched = I->getValueAsListOfDefs("MatchedItinClasses");
if (std::find(Matched.begin(), Matched.end(), SC.ItinClassDef) if (is_contained(Matched, SC.ItinClassDef)) {
!= Matched.end()) {
SchedModels.findRWs(I->getValueAsListOfDefs("OperandReadWrites"), SchedModels.findRWs(I->getValueAsListOfDefs("OperandReadWrites"),
Writes, Reads); Writes, Reads);
break; break;