forked from OSchip/llvm-project
Use llvm::is_contained where appropriate (NFC)
Summary: This patch replaces std::find with llvm::is_contained where appropriate. Reviewers: efriedma, nhaehnle Reviewed By: nhaehnle Subscribers: arsenm, jvesely, nhaehnle, hiraditya, rogfer01, kerbowa, llvm-commits, vkmr Tags: #llvm Differential Revision: https://reviews.llvm.org/D84489
This commit is contained in:
parent
df880b7730
commit
902cbcd59e
|
@ -175,7 +175,7 @@ void AssumptionCache::transferAffectedValuesInCache(Value *OV, Value *NV) {
|
|||
return;
|
||||
|
||||
for (auto &A : AVI->second)
|
||||
if (std::find(NAVV.begin(), NAVV.end(), A) == NAVV.end())
|
||||
if (!llvm::is_contained(NAVV, A))
|
||||
NAVV.push_back(A);
|
||||
AffectedValues.erase(OV);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ LegalityPredicates::typeInSet(unsigned TypeIdx,
|
|||
std::initializer_list<LLT> TypesInit) {
|
||||
SmallVector<LLT, 4> Types = TypesInit;
|
||||
return [=](const LegalityQuery &Query) {
|
||||
return std::find(Types.begin(), Types.end(), Query.Types[TypeIdx]) != Types.end();
|
||||
return llvm::is_contained(Types, Query.Types[TypeIdx]);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ LegalityPredicate LegalityPredicates::typePairInSet(
|
|||
SmallVector<std::pair<LLT, LLT>, 4> Types = TypesInit;
|
||||
return [=](const LegalityQuery &Query) {
|
||||
std::pair<LLT, LLT> Match = {Query.Types[TypeIdx0], Query.Types[TypeIdx1]};
|
||||
return std::find(Types.begin(), Types.end(), Match) != Types.end();
|
||||
return llvm::is_contained(Types, Match);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -495,8 +495,7 @@ bool AMDGPULibCalls::isUnsafeMath(const CallInst *CI) const {
|
|||
}
|
||||
|
||||
bool AMDGPULibCalls::useNativeFunc(const StringRef F) const {
|
||||
return AllNative ||
|
||||
std::find(UseNative.begin(), UseNative.end(), F) != UseNative.end();
|
||||
return AllNative || llvm::is_contained(UseNative, F);
|
||||
}
|
||||
|
||||
void AMDGPULibCalls::initNativeFuncs() {
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace {
|
|||
SmallVector<Metadata *, 4> All;
|
||||
for (auto MD : NamedMD->operands())
|
||||
for (const auto &Op : MD->operands())
|
||||
if (std::find(All.begin(), All.end(), Op.get()) == All.end())
|
||||
if (!llvm::is_contained(All, Op.get()))
|
||||
All.push_back(Op.get());
|
||||
|
||||
NamedMD->eraseFromParent();
|
||||
|
|
|
@ -143,12 +143,10 @@ static bool hasLiveDefs(const MachineInstr &MI, const TargetRegisterInfo *TRI) {
|
|||
return true;
|
||||
|
||||
// Otherwise, return true if any aliased SuperReg of GPR32 is not dead.
|
||||
std::vector<unsigned>::iterator search_begin = GPR64DeadDefs.begin();
|
||||
std::vector<unsigned>::iterator search_end = GPR64DeadDefs.end();
|
||||
for (auto I : GPR32LiveDefs)
|
||||
for (MCSuperRegIterator SR(I, TRI); SR.isValid(); ++SR)
|
||||
if (std::find(search_begin, search_end, *SR) == search_end)
|
||||
return true;
|
||||
if (!llvm::is_contained(GPR64DeadDefs, *SR))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2221,8 +2221,7 @@ isValidCandidateForColdCC(Function &F,
|
|||
BlockFrequencyInfo &CallerBFI = GetBFI(*CallerFunc);
|
||||
if (!isColdCallSite(CB, CallerBFI))
|
||||
return false;
|
||||
auto It = std::find(AllCallsCold.begin(), AllCallsCold.end(), CallerFunc);
|
||||
if (It == AllCallsCold.end())
|
||||
if (!llvm::is_contained(AllCallsCold, CallerFunc))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -1181,8 +1181,7 @@ PartialInlinerImpl::FunctionCloner::doSingleRegionFunctionOutlining() {
|
|||
// (i.e. not to be extracted to the out of line function)
|
||||
auto ToBeInlined = [&, this](BasicBlock *BB) {
|
||||
return BB == ClonedOI->ReturnBlock ||
|
||||
(std::find(ClonedOI->Entries.begin(), ClonedOI->Entries.end(), BB) !=
|
||||
ClonedOI->Entries.end());
|
||||
llvm::is_contained(ClonedOI->Entries, BB);
|
||||
};
|
||||
|
||||
assert(ClonedOI && "Expecting OutlineInfo for single region outline");
|
||||
|
|
|
@ -158,8 +158,7 @@ public:
|
|||
|
||||
void restrictToBlocks(SmallSetVector<BasicBlock *, 4> &Blocks) {
|
||||
for (auto II = Insts.begin(); II != Insts.end();) {
|
||||
if (std::find(Blocks.begin(), Blocks.end(), (*II)->getParent()) ==
|
||||
Blocks.end()) {
|
||||
if (!llvm::is_contained(Blocks, (*II)->getParent())) {
|
||||
ActiveBlocks.remove((*II)->getParent());
|
||||
II = Insts.erase(II);
|
||||
} else {
|
||||
|
@ -277,8 +276,7 @@ public:
|
|||
auto VI = Values.begin();
|
||||
while (BI != Blocks.end()) {
|
||||
assert(VI != Values.end());
|
||||
if (std::find(NewBlocks.begin(), NewBlocks.end(), *BI) ==
|
||||
NewBlocks.end()) {
|
||||
if (!llvm::is_contained(NewBlocks, *BI)) {
|
||||
BI = Blocks.erase(BI);
|
||||
VI = Values.erase(VI);
|
||||
} else {
|
||||
|
|
|
@ -124,7 +124,7 @@ bool VPlanSlp::areVectorizable(ArrayRef<VPValue *> Operands) const {
|
|||
for (auto &I : *Parent) {
|
||||
auto *VPI = cast<VPInstruction>(&I);
|
||||
if (VPI->getOpcode() == Instruction::Load &&
|
||||
std::find(Operands.begin(), Operands.end(), VPI) != Operands.end())
|
||||
llvm::is_contained(Operands, VPI))
|
||||
LoadsSeen++;
|
||||
|
||||
if (LoadsSeen == Operands.size())
|
||||
|
|
|
@ -65,9 +65,7 @@ static void verifyBlocksInRegion(const VPRegionBlock *Region) {
|
|||
for (const VPBlockBase *Succ : Successors) {
|
||||
// There must be a bi-directional link between block and successor.
|
||||
const auto &SuccPreds = Succ->getPredecessors();
|
||||
assert(std::find(SuccPreds.begin(), SuccPreds.end(), VPB) !=
|
||||
SuccPreds.end() &&
|
||||
"Missing predecessor link.");
|
||||
assert(llvm::is_contained(SuccPreds, VPB) && "Missing predecessor link.");
|
||||
(void)SuccPreds;
|
||||
}
|
||||
|
||||
|
@ -86,9 +84,7 @@ static void verifyBlocksInRegion(const VPRegionBlock *Region) {
|
|||
|
||||
// There must be a bi-directional link between block and predecessor.
|
||||
const auto &PredSuccs = Pred->getSuccessors();
|
||||
assert(std::find(PredSuccs.begin(), PredSuccs.end(), VPB) !=
|
||||
PredSuccs.end() &&
|
||||
"Missing successor link.");
|
||||
assert(llvm::is_contained(PredSuccs, VPB) && "Missing successor link.");
|
||||
(void)PredSuccs;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -386,7 +386,7 @@ BugDriver::extractMappedBlocksFromModule(const std::vector<BasicBlock *> &BBs,
|
|||
for (Function &F : *M)
|
||||
for (BasicBlock &BB : F)
|
||||
// Check if this block is going to be extracted.
|
||||
if (std::find(BBs.begin(), BBs.end(), &BB) == BBs.end())
|
||||
if (!llvm::is_contained(BBs, &BB))
|
||||
BlocksToExtract.push_back(&BB);
|
||||
|
||||
raw_fd_ostream OS(Temp->FD, /*shouldClose*/ false);
|
||||
|
|
|
@ -28,7 +28,7 @@ enum EscapeTag { kEscapeCsv, kEscapeHtml, kEscapeHtmlString };
|
|||
template <EscapeTag Tag> void writeEscaped(raw_ostream &OS, const StringRef S);
|
||||
|
||||
template <> void writeEscaped<kEscapeCsv>(raw_ostream &OS, const StringRef S) {
|
||||
if (std::find(S.begin(), S.end(), kCsvSep) == S.end()) {
|
||||
if (!llvm::is_contained(S, kCsvSep)) {
|
||||
OS << S;
|
||||
} else {
|
||||
// Needs escaping.
|
||||
|
|
Loading…
Reference in New Issue