Use the range variant of find/find_if 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: 278469
This commit is contained in:
David Majnemer 2016-08-12 03:55:06 +00:00
parent e7746af20b
commit 319d420e44
32 changed files with 88 additions and 127 deletions

View File

@ -288,8 +288,7 @@ void LoopBase<BlockT, LoopT>::verifyLoop() const {
// Check the parent loop pointer.
if (ParentLoop) {
assert(std::find(ParentLoop->begin(), ParentLoop->end(), this) !=
ParentLoop->end() &&
assert(is_contained(*ParentLoop, this) &&
"Loop is not a subloop of its parent!");
}
#endif

View File

@ -904,7 +904,7 @@ public:
void replaceElements(DINodeArray Elements) {
#ifndef NDEBUG
for (DINode *Op : getElements())
assert(std::find(Elements->op_begin(), Elements->op_end(), Op) &&
assert(is_contained(Elements->operands(), Op) &&
"Lost a member during member list replacement");
#endif
replaceOperandWith(4, Elements.get());
@ -2433,7 +2433,7 @@ public:
void replaceElements(DIMacroNodeArray Elements) {
#ifndef NDEBUG
for (DIMacroNode *Op : getElements())
assert(std::find(Elements->op_begin(), Elements->op_end(), Op) &&
assert(is_contained(Elements->operands(), Op) &&
"Lost a macro node during macro node list replacement");
#endif
replaceOperandWith(1, Elements.get());

View File

@ -635,10 +635,9 @@ void LazyCallGraph::RefSCC::switchInternalEdgeToRef(Node &SourceN,
// root DFS number.
auto SCCNodes = make_range(
PendingSCCStack.rbegin(),
std::find_if(PendingSCCStack.rbegin(), PendingSCCStack.rend(),
[RootDFSNumber](Node *N) {
return N->DFSNumber < RootDFSNumber;
}));
find_if(reverse(PendingSCCStack), [RootDFSNumber](const Node *N) {
return N->DFSNumber < RootDFSNumber;
}));
// Form a new SCC out of these nodes and then clear them off our pending
// stack.
@ -1120,10 +1119,9 @@ LazyCallGraph::RefSCC::removeInternalRefEdge(Node &SourceN, Node &TargetN) {
// root DFS number.
auto RefSCCNodes = make_range(
PendingRefSCCStack.rbegin(),
std::find_if(PendingRefSCCStack.rbegin(), PendingRefSCCStack.rend(),
[RootDFSNumber](Node *N) {
return N->DFSNumber < RootDFSNumber;
}));
find_if(reverse(PendingRefSCCStack), [RootDFSNumber](const Node *N) {
return N->DFSNumber < RootDFSNumber;
}));
// Mark the postorder number for these nodes and clear them off the
// stack. We'll use the postorder number to pull them into RefSCCs at the
@ -1177,11 +1175,11 @@ LazyCallGraph::RefSCC::removeInternalRefEdge(Node &SourceN, Node &TargetN) {
G->connectRefSCC(*RC);
// Now erase all but the root's SCCs.
SCCs.erase(std::remove_if(SCCs.begin(), SCCs.end(),
[&](SCC *C) {
return PostOrderMapping.lookup(&*C->begin()) !=
RootPostOrderNumber;
}),
SCCs.erase(remove_if(SCCs,
[&](SCC *C) {
return PostOrderMapping.lookup(&*C->begin()) !=
RootPostOrderNumber;
}),
SCCs.end());
#ifndef NDEBUG
@ -1370,10 +1368,9 @@ void LazyCallGraph::buildSCCs(RefSCC &RC, node_stack_range Nodes) {
// root DFS number.
auto SCCNodes = make_range(
PendingSCCStack.rbegin(),
std::find_if(PendingSCCStack.rbegin(), PendingSCCStack.rend(),
[RootDFSNumber](Node *N) {
return N->DFSNumber < RootDFSNumber;
}));
find_if(reverse(PendingSCCStack), [RootDFSNumber](const Node *N) {
return N->DFSNumber < RootDFSNumber;
}));
// Form a new SCC out of these nodes and then clear them off our pending
// stack.
RC.SCCs.push_back(createSCC(RC, SCCNodes));
@ -1492,9 +1489,9 @@ LazyCallGraph::RefSCC *LazyCallGraph::getNextRefSCCInPostOrder() {
// root DFS number.
auto RefSCCNodes = node_stack_range(
PendingRefSCCStack.rbegin(),
std::find_if(
PendingRefSCCStack.rbegin(), PendingRefSCCStack.rend(),
[RootDFSNumber](Node *N) { return N->DFSNumber < RootDFSNumber; }));
find_if(reverse(PendingRefSCCStack), [RootDFSNumber](const Node *N) {
return N->DFSNumber < RootDFSNumber;
}));
// Form a new RefSCC out of these nodes and then clear them off our pending
// stack.
RefSCC *NewRC = createRefSCC(*this);

View File

@ -1583,8 +1583,7 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI, IfcvtKind Kind) {
// Prob(BBI.BB, CvtBBI->BB) * Prob(CvtBBI->BB, CvtBBI->FalseBB)
auto NewTrueBB = getNextBlock(BBI.BB);
auto NewNext = BBNext + BBCvt * CvtNext;
auto NewTrueBBIter =
std::find(BBI.BB->succ_begin(), BBI.BB->succ_end(), NewTrueBB);
auto NewTrueBBIter = find(BBI.BB->successors(), NewTrueBB);
if (NewTrueBBIter != BBI.BB->succ_end())
BBI.BB->setSuccProbability(NewTrueBBIter, NewNext);
@ -2114,9 +2113,8 @@ void IfConverter::MergeBlocks(BBInfo &ToBBI, BBInfo &FromBBI, bool AddEdges) {
// Set the edge probability from ToBBI.BB to FromBBI.BB to zero to avoid the
// edge probability being merged to other edges when this edge is removed
// later.
ToBBI.BB->setSuccProbability(
std::find(ToBBI.BB->succ_begin(), ToBBI.BB->succ_end(), FromBBI.BB),
BranchProbability::getZero());
ToBBI.BB->setSuccProbability(find(ToBBI.BB->successors(), FromBBI.BB),
BranchProbability::getZero());
}
for (unsigned i = 0, e = FromSuccs.size(); i != e; ++i) {
@ -2169,7 +2167,7 @@ void IfConverter::MergeBlocks(BBInfo &ToBBI, BBInfo &FromBBI, bool AddEdges) {
//
if (ToBBI.BB->isSuccessor(Succ))
ToBBI.BB->setSuccProbability(
std::find(ToBBI.BB->succ_begin(), ToBBI.BB->succ_end(), Succ),
find(ToBBI.BB->successors(), Succ),
MBPI->getEdgeProbability(ToBBI.BB, Succ) + NewProb);
else
ToBBI.BB->addSuccessor(Succ, NewProb);

View File

@ -185,10 +185,7 @@ private:
bool isSnippet(const LiveInterval &SnipLI);
void collectRegsToSpill();
bool isRegToSpill(unsigned Reg) {
return std::find(RegsToSpill.begin(),
RegsToSpill.end(), Reg) != RegsToSpill.end();
}
bool isRegToSpill(unsigned Reg) { return is_contained(RegsToSpill, Reg); }
bool isSibling(unsigned Reg);
bool hoistSpillInsideBB(LiveInterval &SpillLI, MachineInstr &CopyMI);

View File

@ -323,9 +323,8 @@ void MachineBasicBlock::printAsOperand(raw_ostream &OS,
}
void MachineBasicBlock::removeLiveIn(MCPhysReg Reg, LaneBitmask LaneMask) {
LiveInVector::iterator I = std::find_if(
LiveIns.begin(), LiveIns.end(),
[Reg] (const RegisterMaskPair &LI) { return LI.PhysReg == Reg; });
LiveInVector::iterator I = find_if(
LiveIns, [Reg](const RegisterMaskPair &LI) { return LI.PhysReg == Reg; });
if (I == LiveIns.end())
return;
@ -335,9 +334,8 @@ void MachineBasicBlock::removeLiveIn(MCPhysReg Reg, LaneBitmask LaneMask) {
}
bool MachineBasicBlock::isLiveIn(MCPhysReg Reg, LaneBitmask LaneMask) const {
livein_iterator I = std::find_if(
LiveIns.begin(), LiveIns.end(),
[Reg] (const RegisterMaskPair &LI) { return LI.PhysReg == Reg; });
livein_iterator I = find_if(
LiveIns, [Reg](const RegisterMaskPair &LI) { return LI.PhysReg == Reg; });
return I != livein_end() && (I->LaneMask & LaneMask) != 0;
}
@ -661,11 +659,11 @@ MachineBasicBlock::transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB) {
}
bool MachineBasicBlock::isPredecessor(const MachineBasicBlock *MBB) const {
return std::find(pred_begin(), pred_end(), MBB) != pred_end();
return is_contained(predecessors(), MBB);
}
bool MachineBasicBlock::isSuccessor(const MachineBasicBlock *MBB) const {
return std::find(succ_begin(), succ_end(), MBB) != succ_end();
return is_contained(successors(), MBB);
}
bool MachineBasicBlock::isLayoutSuccessor(const MachineBasicBlock *MBB) const {

View File

@ -50,8 +50,7 @@ BranchProbability MachineBranchProbabilityInfo::getEdgeProbability(
const MachineBasicBlock *Src, const MachineBasicBlock *Dst) const {
// This is a linear search. Try to use the const_succ_iterator version when
// possible.
return getEdgeProbability(Src,
std::find(Src->succ_begin(), Src->succ_end(), Dst));
return getEdgeProbability(Src, find(Src->successors(), Dst));
}
bool MachineBranchProbabilityInfo::isEdgeHot(

View File

@ -769,10 +769,9 @@ void RegPressureTracker::recede(const RegisterOperands &RegOpers,
if (!TrackLaneMasks) {
addRegLanes(*LiveUses, RegisterMaskPair(Reg, NewMask));
} else {
auto I = std::find_if(LiveUses->begin(), LiveUses->end(),
[Reg](const RegisterMaskPair Other) {
return Other.RegUnit == Reg;
});
auto I = find_if(*LiveUses, [Reg](const RegisterMaskPair Other) {
return Other.RegUnit == Reg;
});
bool IsRedef = I != LiveUses->end();
if (IsRedef) {
// ignore re-defs here...

View File

@ -139,8 +139,7 @@ void SUnit::removePred(const SDep &D) {
SDep P = D;
P.setSUnit(this);
SUnit *N = D.getSUnit();
SmallVectorImpl<SDep>::iterator Succ = std::find(N->Succs.begin(),
N->Succs.end(), P);
SmallVectorImpl<SDep>::iterator Succ = find(N->Succs, P);
assert(Succ != N->Succs.end() && "Mismatching preds / succs lists!");
N->Succs.erase(Succ);
Preds.erase(I);

View File

@ -625,7 +625,7 @@ void MCJIT::UnregisterJITEventListener(JITEventListener *L) {
if (!L)
return;
MutexGuard locked(lock);
auto I = std::find(EventListeners.rbegin(), EventListeners.rend(), L);
auto I = find(reverse(EventListeners), L);
if (I != EventListeners.rend()) {
std::swap(*I, EventListeners.back());
EventListeners.pop_back();

View File

@ -48,9 +48,8 @@ TargetMachine *EngineBuilder::selectTarget(const Triple &TargetTriple,
// Adjust the triple to match what the user requested.
const Target *TheTarget = nullptr;
if (!MArch.empty()) {
auto I = std::find_if(
TargetRegistry::targets().begin(), TargetRegistry::targets().end(),
[&](const Target &T) { return MArch == T.getName(); });
auto I = find_if(TargetRegistry::targets(),
[&](const Target &T) { return MArch == T.getName(); });
if (I == TargetRegistry::targets().end()) {
if (ErrorStr)

View File

@ -878,7 +878,7 @@ MDNode *MDNode::intersect(MDNode *A, MDNode *B) {
SmallVector<Metadata *, 4> MDs;
for (Metadata *MD : A->operands())
if (std::find(B->op_begin(), B->op_end(), MD) != B->op_end())
if (is_contained(B->operands(), MD))
MDs.push_back(MD);
// FIXME: This preserves long-standing behaviour, but is it really the right
@ -892,7 +892,7 @@ MDNode *MDNode::getMostGenericAliasScope(MDNode *A, MDNode *B) {
SmallVector<Metadata *, 4> MDs(B->op_begin(), B->op_end());
for (Metadata *MD : A->operands())
if (std::find(B->op_begin(), B->op_end(), MD) == B->op_end())
if (!is_contained(B->operands(), MD))
MDs.push_back(MD);
// FIXME: This preserves long-standing behaviour, but is it really the right

View File

@ -124,10 +124,10 @@ bool Value::isUsedInBasicBlock(const BasicBlock *BB) const {
const_user_iterator UI = user_begin(), UE = user_end();
for (; BI != BE && UI != UE; ++BI, ++UI) {
// Scan basic block: Check if this Value is used by the instruction at BI.
if (std::find(BI->op_begin(), BI->op_end(), this) != BI->op_end())
if (is_contained(BI->operands(), this))
return true;
// Scan use list: Check if the use at UI is in BB.
const Instruction *User = dyn_cast<Instruction>(*UI);
const auto *User = dyn_cast<Instruction>(*UI);
if (User && User->getParent() == BB)
return true;
}

View File

@ -284,7 +284,7 @@ bool llvm::sys::RemoveFileOnSignal(StringRef Filename,
void llvm::sys::DontRemoveFileOnSignal(StringRef Filename) {
sys::SmartScopedLock<true> Guard(*SignalsMutex);
std::vector<std::string>::reverse_iterator RI =
std::find(FilesToRemove->rbegin(), FilesToRemove->rend(), Filename);
find(reverse(*FilesToRemove), Filename);
std::vector<std::string>::iterator I = FilesToRemove->end();
if (RI != FilesToRemove->rend())
I = FilesToRemove->erase(RI.base()-1);

View File

@ -470,7 +470,7 @@ void sys::DontRemoveFileOnSignal(StringRef Filename) {
RegisterHandler();
std::vector<std::string>::reverse_iterator I =
std::find(FilesToRemove->rbegin(), FilesToRemove->rend(), Filename);
find(reverse(*FilesToRemove), Filename);
if (I != FilesToRemove->rend())
FilesToRemove->erase(I.base()-1);

View File

@ -582,7 +582,7 @@ bool ARMConstantIslands::BBHasFallthrough(MachineBasicBlock *MBB) {
return false;
MachineBasicBlock *NextBB = &*std::next(MBBI);
if (std::find(MBB->succ_begin(), MBB->succ_end(), NextBB) == MBB->succ_end())
if (!MBB->isSuccessor(NextBB))
return false;
// Try to analyze the end of the block. A potential fallthrough may already

View File

@ -73,7 +73,7 @@ void HexagonBlockRanges::IndexRange::merge(const IndexRange &A) {
void HexagonBlockRanges::RangeList::include(const RangeList &RL) {
for (auto &R : RL)
if (std::find(begin(), end(), R) == end())
if (!is_contained(*this, R))
push_back(R);
}

View File

@ -59,9 +59,8 @@ LLVMTargetRef LLVMGetNextTarget(LLVMTargetRef T) {
LLVMTargetRef LLVMGetTargetFromName(const char *Name) {
StringRef NameRef = Name;
auto I = std::find_if(
TargetRegistry::targets().begin(), TargetRegistry::targets().end(),
[&](const Target &T) { return T.getName() == NameRef; });
auto I = find_if(TargetRegistry::targets(),
[&](const Target &T) { return T.getName() == NameRef; });
return I != TargetRegistry::targets().end() ? wrap(&*I) : nullptr;
}

View File

@ -9731,9 +9731,8 @@ static SDValue lowerV8I16GeneralSingleInputVectorShuffle(
// by inputs being moved and *staying* in that half.
if (IncomingInputs.size() == 1) {
if (isWordClobbered(SourceHalfMask, IncomingInputs[0] - SourceOffset)) {
int InputFixed = std::find(std::begin(SourceHalfMask),
std::end(SourceHalfMask), -1) -
std::begin(SourceHalfMask) + SourceOffset;
int InputFixed = find(SourceHalfMask, -1) - std::begin(SourceHalfMask) +
SourceOffset;
SourceHalfMask[InputFixed - SourceOffset] =
IncomingInputs[0] - SourceOffset;
std::replace(HalfMask.begin(), HalfMask.end(), IncomingInputs[0],

View File

@ -835,8 +835,8 @@ Instruction *InstCombiner::SliceUpIllegalIntegerPHI(PHINode &FirstPhi) {
// needed piece.
if (PHINode *OldInVal = dyn_cast<PHINode>(PN->getIncomingValue(i)))
if (PHIsInspected.count(OldInVal)) {
unsigned RefPHIId = std::find(PHIsToSlice.begin(),PHIsToSlice.end(),
OldInVal)-PHIsToSlice.begin();
unsigned RefPHIId =
find(PHIsToSlice, OldInVal) - PHIsToSlice.begin();
PHIUsers.push_back(PHIUsageRecord(RefPHIId, Offset,
cast<Instruction>(Res)));
++UserE;

View File

@ -2799,8 +2799,7 @@ void LSRInstance::FinalizeChain(IVChain &Chain) {
for (const IVInc &Inc : Chain) {
DEBUG(dbgs() << " Inc: " << Inc.UserInst << "\n");
auto UseI = std::find(Inc.UserInst->op_begin(), Inc.UserInst->op_end(),
Inc.IVOperand);
auto UseI = find(Inc.UserInst->operands(), Inc.IVOperand);
assert(UseI != Inc.UserInst->op_end() && "cannot find IV operand");
IVIncSet.insert(UseI);
}
@ -2933,8 +2932,8 @@ void LSRInstance::CollectFixupsAndInitialFormulae() {
for (const IVStrideUse &U : IU) {
Instruction *UserInst = U.getUser();
// Skip IV users that are part of profitable IV Chains.
User::op_iterator UseI = std::find(UserInst->op_begin(), UserInst->op_end(),
U.getOperandValToReplace());
User::op_iterator UseI =
find(UserInst->operands(), U.getOperandValToReplace());
assert(UseI != UserInst->op_end() && "cannot find IV operand");
if (IVIncSet.count(UseI))
continue;

View File

@ -347,7 +347,7 @@ static bool canMoveAboveCall(Instruction *I, CallInst *CI) {
// return value of the call, it must only use things that are defined before
// the call, or movable instructions between the call and the instruction
// itself.
return std::find(I->op_begin(), I->op_end(), CI) == I->op_end();
return !is_contained(I->operands(), CI);
}
/// Return true if the specified value is the same when the return would exit

View File

@ -307,7 +307,7 @@ bool RecurrenceDescriptor::AddReductionVar(PHINode *Phi, RecurrenceKind Kind,
// The instruction used by an outside user must be the last instruction
// before we feed back to the reduction phi. Otherwise, we loose VF-1
// operations on the value.
if (std::find(Phi->op_begin(), Phi->op_end(), Cur) == Phi->op_end())
if (!is_contained(Phi->operands(), Cur))
return false;
ExitInstruction = Cur;

View File

@ -1614,9 +1614,8 @@ MemoryAccess *MemorySSA::createMemoryAccessInBB(Instruction *I,
auto *Accesses = getOrCreateAccessList(BB);
if (Point == Beginning) {
// It goes after any phi nodes
auto AI = std::find_if(
Accesses->begin(), Accesses->end(),
[](const MemoryAccess &MA) { return !isa<MemoryPhi>(MA); });
auto AI = find_if(
*Accesses, [](const MemoryAccess &MA) { return !isa<MemoryPhi>(MA); });
Accesses->insert(AI, NewAccess);
} else {

View File

@ -4033,8 +4033,7 @@ void InnerLoopVectorizer::predicateStores() {
InnerLoopVectorizer::VectorParts
InnerLoopVectorizer::createEdgeMask(BasicBlock *Src, BasicBlock *Dst) {
assert(std::find(pred_begin(Dst), pred_end(Dst), Src) != pred_end(Dst) &&
"Invalid edge");
assert(is_contained(predecessors(Dst), Src) && "Invalid edge");
// Look for cached value.
std::pair<BasicBlock *, BasicBlock *> Edge(Src, Dst);

View File

@ -2650,8 +2650,7 @@ Value *BoUpSLP::vectorizeTree() {
// Skip users that we already RAUW. This happens when one instruction
// has multiple uses of the same value.
if (std::find(Scalar->user_begin(), Scalar->user_end(), User) ==
Scalar->user_end())
if (!is_contained(Scalar->users(), User))
continue;
assert(ScalarToTreeEntry.count(Scalar) && "Invalid scalar");
@ -3999,8 +3998,7 @@ public:
/// \brief Try to find a reduction tree.
bool matchAssociativeReduction(PHINode *Phi, BinaryOperator *B) {
assert((!Phi ||
std::find(Phi->op_begin(), Phi->op_end(), B) != Phi->op_end()) &&
assert((!Phi || is_contained(Phi->operands(), B)) &&
"Thi phi needs to use the binary operator");
// We could have a initial reductions that is not an add.

View File

@ -862,9 +862,9 @@ static void DumpLiteralPointerSection(MachOObjectFile *O,
}
// First look for an external relocation entry for this literal pointer.
auto Reloc = std::find_if(
Relocs.begin(), Relocs.end(),
[&](const std::pair<uint64_t, SymbolRef> &P) { return P.first == i; });
auto Reloc = find_if(Relocs, [&](const std::pair<uint64_t, SymbolRef> &P) {
return P.first == i;
});
if (Reloc != Relocs.end()) {
symbol_iterator RelocSym = Reloc->second;
Expected<StringRef> SymName = RelocSym->getName();

View File

@ -240,18 +240,17 @@ private:
llvm::object::ObjectFile const &Object;
};
SectionFilter ToolSectionFilter(llvm::object::ObjectFile const &O) {
return SectionFilter([](llvm::object::SectionRef const &S) {
if(FilterSections.empty())
return true;
llvm::StringRef String;
std::error_code error = S.getName(String);
if (error)
return false;
return std::find(FilterSections.begin(),
FilterSections.end(),
String) != FilterSections.end();
},
O);
return SectionFilter(
[](llvm::object::SectionRef const &S) {
if (FilterSections.empty())
return true;
llvm::StringRef String;
std::error_code error = S.getName(String);
if (error)
return false;
return is_contained(FilterSections, String);
},
O);
}
}

View File

@ -157,8 +157,7 @@ FindUniqueOperandCommands(std::vector<std::string> &UniqueOperandCommands,
// Check to see if we already have 'Command' in UniqueOperandCommands.
// If not, add it.
auto I = std::find(UniqueOperandCommands.begin(),
UniqueOperandCommands.end(), Command);
auto I = find(UniqueOperandCommands, Command);
if (I != UniqueOperandCommands.end()) {
size_t idx = I - UniqueOperandCommands.begin();
InstrsForCase[idx] += ", ";
@ -838,9 +837,8 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
Rec->isSubClassOf("Operand")) {
std::string PrintMethod = Rec->getValueAsString("PrintMethod");
if (PrintMethod != "" && PrintMethod != "printOperand") {
PrintMethodIdx = std::find(PrintMethods.begin(),
PrintMethods.end(), PrintMethod) -
PrintMethods.begin();
PrintMethodIdx =
find(PrintMethods, PrintMethod) - PrintMethods.begin();
if (static_cast<unsigned>(PrintMethodIdx) == PrintMethods.size())
PrintMethods.push_back(PrintMethod);
}

View File

@ -1498,9 +1498,7 @@ void CodeGenSchedModels::collectProcResources() {
if (!(*RI)->getValueInit("SchedModel")->isComplete())
continue;
CodeGenProcModel &PM = getProcModel((*RI)->getValueAsDef("SchedModel"));
RecIter I = std::find(PM.ProcResourceDefs.begin(),
PM.ProcResourceDefs.end(), *RI);
if (I == PM.ProcResourceDefs.end())
if (!is_contained(PM.ProcResourceDefs, *RI))
PM.ProcResourceDefs.push_back(*RI);
}
// Finalize each ProcModel by sorting the record arrays.
@ -1716,9 +1714,7 @@ void CodeGenSchedModels::addProcResource(Record *ProcResKind,
Record *ProcResUnits = findProcResUnits(ProcResKind, PM);
// See if this ProcResource is already associated with this processor.
RecIter I = std::find(PM.ProcResourceDefs.begin(),
PM.ProcResourceDefs.end(), ProcResUnits);
if (I != PM.ProcResourceDefs.end())
if (is_contained(PM.ProcResourceDefs, ProcResUnits))
return;
PM.ProcResourceDefs.push_back(ProcResUnits);
@ -1737,8 +1733,7 @@ void CodeGenSchedModels::addWriteRes(Record *ProcWriteResDef, unsigned PIdx) {
assert(PIdx && "don't add resources to an invalid Processor model");
RecVec &WRDefs = ProcModels[PIdx].WriteResDefs;
RecIter WRI = find(WRDefs, ProcWriteResDef);
if (WRI != WRDefs.end())
if (is_contained(WRDefs, ProcWriteResDef))
return;
WRDefs.push_back(ProcWriteResDef);
@ -1754,8 +1749,7 @@ void CodeGenSchedModels::addWriteRes(Record *ProcWriteResDef, unsigned PIdx) {
void CodeGenSchedModels::addReadAdvance(Record *ProcReadAdvanceDef,
unsigned PIdx) {
RecVec &RADefs = ProcModels[PIdx].ReadAdvanceDefs;
RecIter I = find(RADefs, ProcReadAdvanceDef);
if (I != RADefs.end())
if (is_contained(RADefs, ProcReadAdvanceDef))
return;
RADefs.push_back(ProcReadAdvanceDef);
}

View File

@ -1108,9 +1108,7 @@ unsigned FilterChooser::getDecoderIndex(DecoderSet &Decoders,
// Make sure the predicate is in the table.
Decoders.insert(StringRef(Decoder));
// Now figure out the index for when we write out the table.
DecoderSet::const_iterator P = std::find(Decoders.begin(),
Decoders.end(),
Decoder.str());
DecoderSet::const_iterator P = find(Decoders, Decoder.str());
return (unsigned)(P - Decoders.begin());
}
@ -1183,9 +1181,7 @@ unsigned FilterChooser::getPredicateIndex(DecoderTableInfo &TableInfo,
// Make sure the predicate is in the table.
TableInfo.Predicates.insert(Predicate.str());
// Now figure out the index for when we write out the table.
PredicateSet::const_iterator P = std::find(TableInfo.Predicates.begin(),
TableInfo.Predicates.end(),
Predicate.str());
PredicateSet::const_iterator P = find(TableInfo.Predicates, Predicate.str());
return (unsigned)(P - TableInfo.Predicates.begin());
}

View File

@ -826,9 +826,7 @@ void SubtargetEmitter::GenSchedClassTables(const CodeGenProcModel &ProcModel,
HasVariants = true;
break;
}
IdxIter PIPos = std::find(TI->ProcIndices.begin(),
TI->ProcIndices.end(), ProcModel.Index);
if (PIPos != TI->ProcIndices.end()) {
if (is_contained(TI->ProcIndices, ProcModel.Index)) {
HasVariants = true;
break;
}
@ -843,9 +841,7 @@ void SubtargetEmitter::GenSchedClassTables(const CodeGenProcModel &ProcModel,
// If ProcIndices contains 0, this class applies to all processors.
assert(!SC.ProcIndices.empty() && "expect at least one procidx");
if (SC.ProcIndices[0] != 0) {
IdxIter PIPos = std::find(SC.ProcIndices.begin(),
SC.ProcIndices.end(), ProcModel.Index);
if (PIPos == SC.ProcIndices.end())
if (!is_contained(SC.ProcIndices, ProcModel.Index))
continue;
}
IdxVec Writes = SC.Writes;