[llvm] ce9f007 - [llvm] Use llvm::find_if (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 28 10:42:04 PDT 2022
Author: Kazu Hirata
Date: 2022-08-28T10:41:48-07:00
New Revision: ce9f007c7ccf845e169c803a81d00a141853d861
URL: https://github.com/llvm/llvm-project/commit/ce9f007c7ccf845e169c803a81d00a141853d861
DIFF: https://github.com/llvm/llvm-project/commit/ce9f007c7ccf845e169c803a81d00a141853d861.diff
LOG: [llvm] Use llvm::find_if (NFC)
Added:
Modified:
llvm/include/llvm/MCA/Instruction.h
llvm/lib/Analysis/LoopAccessAnalysis.cpp
llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp
llvm/tools/llvm-jitlink/llvm-jitlink-coff.cpp
llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp
llvm/tools/llvm-jitlink/llvm-jitlink-macho.cpp
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
llvm/tools/llvm-xray/xray-account.cpp
llvm/utils/TableGen/AsmMatcherEmitter.cpp
llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MCA/Instruction.h b/llvm/include/llvm/MCA/Instruction.h
index 86f2d7ade1617..29b797cee260d 100644
--- a/llvm/include/llvm/MCA/Instruction.h
+++ b/llvm/include/llvm/MCA/Instruction.h
@@ -549,9 +549,9 @@ class InstructionBase {
/// Return the MCAOperand which corresponds to index Idx within the original
/// MCInst.
const MCAOperand *getOperand(const unsigned Idx) const {
- auto It = std::find_if(
- Operands.begin(), Operands.end(),
- [&Idx](const MCAOperand &Op) { return Op.getIndex() == Idx; });
+ auto It = llvm::find_if(Operands, [&Idx](const MCAOperand &Op) {
+ return Op.getIndex() == Idx;
+ });
if (It == Operands.end())
return nullptr;
return &(*It);
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index b6e05298bb78a..dc56d8d019b21 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -2456,11 +2456,10 @@ void LoopAccessInfo::emitUnsafeDependenceRemark() {
auto Deps = getDepChecker().getDependences();
if (!Deps)
return;
- auto Found = std::find_if(
- Deps->begin(), Deps->end(), [](const MemoryDepChecker::Dependence &D) {
- return MemoryDepChecker::Dependence::isSafeForVectorization(D.Type) !=
- MemoryDepChecker::VectorizationSafetyStatus::Safe;
- });
+ auto Found = llvm::find_if(*Deps, [](const MemoryDepChecker::Dependence &D) {
+ return MemoryDepChecker::Dependence::isSafeForVectorization(D.Type) !=
+ MemoryDepChecker::VectorizationSafetyStatus::Safe;
+ });
if (Found == Deps->end())
return;
MemoryDepChecker::Dependence Dep = *Found;
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp b/llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp
index 3128c1a9a3f42..92c1b37758f1b 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp
@@ -323,10 +323,9 @@ void PipelineSolver::reset() {
for (auto &SG : SyncPipeline) {
SmallVector<SUnit *, 32> TempCollection = SG.Collection;
SG.Collection.clear();
- auto SchedBarr = std::find_if(
- TempCollection.begin(), TempCollection.end(), [](SUnit *SU) {
- return SU->getInstr()->getOpcode() == AMDGPU::SCHED_GROUP_BARRIER;
- });
+ auto SchedBarr = llvm::find_if(TempCollection, [](SUnit *SU) {
+ return SU->getInstr()->getOpcode() == AMDGPU::SCHED_GROUP_BARRIER;
+ });
if (SchedBarr != TempCollection.end())
SG.Collection.push_back(*SchedBarr);
}
@@ -428,9 +427,8 @@ void PipelineSolver::removeEdges(
SUnit *Pred = PredSuccPair.first;
SUnit *Succ = PredSuccPair.second;
- auto Match =
- std::find_if(Succ->Preds.begin(), Succ->Preds.end(),
- [&Pred](SDep &P) { return P.getSUnit() == Pred; });
+ auto Match = llvm::find_if(
+ Succ->Preds, [&Pred](SDep &P) { return P.getSUnit() == Pred; });
if (Match != Succ->Preds.end()) {
assert(Match->isArtificial());
Succ->removePred(*Match);
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-coff.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink-coff.cpp
index 2e7b000da775f..06d555aa80741 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink-coff.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink-coff.cpp
@@ -25,8 +25,8 @@ static bool isCOFFGOTSection(Section &S) { return S.getName() == "$__GOT"; }
static bool isCOFFStubsSection(Section &S) { return S.getName() == "$__STUBS"; }
static Expected<Edge &> getFirstRelocationEdge(LinkGraph &G, Block &B) {
- auto EItr = std::find_if(B.edges().begin(), B.edges().end(),
- [](Edge &E) { return E.isRelocation(); });
+ auto EItr =
+ llvm::find_if(B.edges(), [](Edge &E) { return E.isRelocation(); });
if (EItr == B.edges().end())
return make_error<StringError>("GOT entry in " + G.getName() + ", \"" +
B.getSection().getName() +
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp
index d79dbc410e8e9..b810646c28c8d 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp
@@ -25,8 +25,8 @@ static bool isELFGOTSection(Section &S) { return S.getName() == "$__GOT"; }
static bool isELFStubsSection(Section &S) { return S.getName() == "$__STUBS"; }
static Expected<Edge &> getFirstRelocationEdge(LinkGraph &G, Block &B) {
- auto EItr = std::find_if(B.edges().begin(), B.edges().end(),
- [](Edge &E) { return E.isRelocation(); });
+ auto EItr =
+ llvm::find_if(B.edges(), [](Edge &E) { return E.isRelocation(); });
if (EItr == B.edges().end())
return make_error<StringError>("GOT entry in " + G.getName() + ", \"" +
B.getSection().getName() +
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-macho.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink-macho.cpp
index ed7fd1a57a724..bb43e3a476466 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink-macho.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink-macho.cpp
@@ -27,8 +27,8 @@ static bool isMachOStubsSection(Section &S) {
}
static Expected<Edge &> getFirstRelocationEdge(LinkGraph &G, Block &B) {
- auto EItr = std::find_if(B.edges().begin(), B.edges().end(),
- [](Edge &E) { return E.isRelocation(); });
+ auto EItr =
+ llvm::find_if(B.edges(), [](Edge &E) { return E.isRelocation(); });
if (EItr == B.edges().end())
return make_error<StringError>("GOT entry in " + G.getName() + ", \"" +
B.getSection().getName() +
diff --git a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp b/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
index a80ee2973d05e..fd9b1d52e5445 100644
--- a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ b/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -559,8 +559,7 @@ objcopy::parseObjcopyOptions(ArrayRef<const char *> RawArgsArr,
ObjcopyOptTable T;
const char *const *DashDash =
- std::find_if(RawArgsArr.begin(), RawArgsArr.end(),
- [](StringRef Str) { return Str == "--"; });
+ llvm::find_if(RawArgsArr, [](StringRef Str) { return Str == "--"; });
ArrayRef<const char *> ArgsArr = makeArrayRef(RawArgsArr.begin(), DashDash);
if (DashDash != RawArgsArr.end())
DashDash = std::next(DashDash);
@@ -1220,8 +1219,7 @@ Expected<DriverConfig>
objcopy::parseStripOptions(ArrayRef<const char *> RawArgsArr,
function_ref<Error(Error)> ErrorCallback) {
const char *const *DashDash =
- std::find_if(RawArgsArr.begin(), RawArgsArr.end(),
- [](StringRef Str) { return Str == "--"; });
+ llvm::find_if(RawArgsArr, [](StringRef Str) { return Str == "--"; });
ArrayRef<const char *> ArgsArr = makeArrayRef(RawArgsArr.begin(), DashDash);
if (DashDash != RawArgsArr.end())
DashDash = std::next(DashDash);
diff --git a/llvm/tools/llvm-xray/xray-account.cpp b/llvm/tools/llvm-xray/xray-account.cpp
index 111704665c0b7..988b535030c7c 100644
--- a/llvm/tools/llvm-xray/xray-account.cpp
+++ b/llvm/tools/llvm-xray/xray-account.cpp
@@ -201,10 +201,10 @@ bool LatencyAccountant::accountRecord(const XRayRecord &Record) {
// Look for the parent up the stack.
auto Parent =
- std::find_if(ThreadStack.Stack.rbegin(), ThreadStack.Stack.rend(),
- [&](const std::pair<const int32_t, uint64_t> &E) {
- return E.first == Record.FuncId;
- });
+ llvm::find_if(llvm::reverse(ThreadStack.Stack),
+ [&](const std::pair<const int32_t, uint64_t> &E) {
+ return E.first == Record.FuncId;
+ });
if (Parent == ThreadStack.Stack.rend())
return false;
diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
index 1acc2a86d176f..151212c55fad7 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
@@ -595,8 +595,9 @@ struct MatchableInfo {
/// findAsmOperandNamed - Find the first AsmOperand with the specified name.
/// This does not check the suboperand index.
int findAsmOperandNamed(StringRef N, int LastIdx = -1) const {
- auto I = std::find_if(AsmOperands.begin() + LastIdx + 1, AsmOperands.end(),
- [&](const AsmOperand &Op) { return Op.SrcOpName == N; });
+ auto I =
+ llvm::find_if(llvm::drop_begin(AsmOperands, LastIdx + 1),
+ [&](const AsmOperand &Op) { return Op.SrcOpName == N; });
return (I != AsmOperands.end()) ? I - AsmOperands.begin() : -1;
}
diff --git a/llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp b/llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
index ec59fd60c7711..855b3a62c6f49 100644
--- a/llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
+++ b/llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
@@ -97,8 +97,8 @@ class Trie {
Node *N = Root.get();
for (auto Ch : Name) {
std::string Label(1, Ch);
- auto It = std::find_if(N->Children.begin(), N->Children.end(),
- [&](const auto &C) { return C->Name == Label; });
+ auto It = llvm::find_if(N->Children,
+ [&](const auto &C) { return C->Name == Label; });
if (It == N->Children.end()) {
It = N->Children.insert(It, std::make_unique<Node>(Label, N));
}
More information about the llvm-commits
mailing list