[llvm] 902cbcd - Use llvm::is_contained where appropriate (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 27 10:21:01 PDT 2020
Author: Kazu Hirata
Date: 2020-07-27T10:20:44-07:00
New Revision: 902cbcd59e22ccd853f6b0c22acc772fd955dc46
URL: https://github.com/llvm/llvm-project/commit/902cbcd59e22ccd853f6b0c22acc772fd955dc46
DIFF: https://github.com/llvm/llvm-project/commit/902cbcd59e22ccd853f6b0c22acc772fd955dc46.diff
LOG: 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
Added:
Modified:
llvm/lib/Analysis/AssumptionCache.cpp
llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp
llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
llvm/lib/Target/AMDGPU/AMDGPUUnifyMetadata.cpp
llvm/lib/Target/BPF/BPFMIChecking.cpp
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/lib/Transforms/IPO/PartialInlining.cpp
llvm/lib/Transforms/Scalar/GVNSink.cpp
llvm/lib/Transforms/Vectorize/VPlanSLP.cpp
llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
llvm/tools/bugpoint/ExtractFunction.cpp
llvm/tools/llvm-exegesis/lib/Analysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/AssumptionCache.cpp b/llvm/lib/Analysis/AssumptionCache.cpp
index 16bfd5c75902..bc0cdc4c4c77 100644
--- a/llvm/lib/Analysis/AssumptionCache.cpp
+++ b/llvm/lib/Analysis/AssumptionCache.cpp
@@ -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);
}
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp b/llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp
index a83742f2138f..17bce517814d 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp
@@ -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);
};
}
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
index 4a14259f1bdb..538a22df514f 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
@@ -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() {
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUUnifyMetadata.cpp b/llvm/lib/Target/AMDGPU/AMDGPUUnifyMetadata.cpp
index 281ae6d646e9..f898456203a1 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUUnifyMetadata.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUUnifyMetadata.cpp
@@ -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();
diff --git a/llvm/lib/Target/BPF/BPFMIChecking.cpp b/llvm/lib/Target/BPF/BPFMIChecking.cpp
index f82f166eda4d..ac40b24596a2 100644
--- a/llvm/lib/Target/BPF/BPFMIChecking.cpp
+++ b/llvm/lib/Target/BPF/BPFMIChecking.cpp
@@ -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;
}
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index d9fb820f7cb5..0b650b3b58f4 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -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;
diff --git a/llvm/lib/Transforms/IPO/PartialInlining.cpp b/llvm/lib/Transforms/IPO/PartialInlining.cpp
index 5d863f1330a4..e1dc036ae413 100644
--- a/llvm/lib/Transforms/IPO/PartialInlining.cpp
+++ b/llvm/lib/Transforms/IPO/PartialInlining.cpp
@@ -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");
diff --git a/llvm/lib/Transforms/Scalar/GVNSink.cpp b/llvm/lib/Transforms/Scalar/GVNSink.cpp
index dfb4b7e038ba..5a34ad18158b 100644
--- a/llvm/lib/Transforms/Scalar/GVNSink.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -158,8 +158,7 @@ class LockstepReverseIterator {
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 @@ class ModelledPHI {
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 {
diff --git a/llvm/lib/Transforms/Vectorize/VPlanSLP.cpp b/llvm/lib/Transforms/Vectorize/VPlanSLP.cpp
index 9019ed15ec5f..b072ca9c3920 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanSLP.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanSLP.cpp
@@ -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())
diff --git a/llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp b/llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
index b384c94121e9..6eec8d14de4a 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
@@ -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;
}
}
diff --git a/llvm/tools/bugpoint/ExtractFunction.cpp b/llvm/tools/bugpoint/ExtractFunction.cpp
index d9047acd30e1..7a75cb90edc5 100644
--- a/llvm/tools/bugpoint/ExtractFunction.cpp
+++ b/llvm/tools/bugpoint/ExtractFunction.cpp
@@ -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);
diff --git a/llvm/tools/llvm-exegesis/lib/Analysis.cpp b/llvm/tools/llvm-exegesis/lib/Analysis.cpp
index 5e9023b8127a..077acf9aff6b 100644
--- a/llvm/tools/llvm-exegesis/lib/Analysis.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Analysis.cpp
@@ -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.
More information about the llvm-commits
mailing list