// 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
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());
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());
// 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.
// 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
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
// 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));
// 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);
// 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);
// 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) {
//
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);
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);
}
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;
}
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;
}
}
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 {
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(
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...
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);
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();
// 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)
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
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
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;
}
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);
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);
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
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);
}
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;
}
// 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],
// 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;
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);
}
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;
// 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
// 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;
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 {
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);
// 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");
/// \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.
}
// 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();
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);
}
}
// 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] += ", ";
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);
}
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.
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);
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);
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);
}
// 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());
}
// 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());
}
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;
}
// 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;