From a6e95fbf6b29a88a79f86ffdffc044e8879dca7f Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 10 Jan 2021 09:24:53 -0800 Subject: [PATCH] [CodeGen, DebugInfo] Use llvm::find_if (NFC) --- lib/CodeGen/CodeGenPrepare.cpp | 4 ++-- lib/CodeGen/InterleavedLoadCombinePass.cpp | 6 ++---- lib/CodeGen/MIRCanonicalizerPass.cpp | 6 +++--- lib/CodeGen/RegisterScavenging.cpp | 9 ++++----- lib/CodeGen/SwiftErrorValueTracking.cpp | 4 ++-- lib/DebugInfo/DWARF/DWARFGdbIndex.cpp | 4 ++-- lib/DebugInfo/PDB/Native/SymbolCache.cpp | 7 ++++--- 7 files changed, 19 insertions(+), 21 deletions(-) diff --git a/lib/CodeGen/CodeGenPrepare.cpp b/lib/CodeGen/CodeGenPrepare.cpp index 85371d0d5d3..564a3d7d9bc 100644 --- a/lib/CodeGen/CodeGenPrepare.cpp +++ b/lib/CodeGen/CodeGenPrepare.cpp @@ -633,8 +633,8 @@ void CodeGenPrepare::removeAllAssertingVHReferences(Value *V) { return; auto &GEPVector = VecI->second; - const auto &I = std::find_if(GEPVector.begin(), GEPVector.end(), - [=](auto &Elt) { return Elt.first == GEP; }); + const auto &I = + llvm::find_if(GEPVector, [=](auto &Elt) { return Elt.first == GEP; }); if (I == GEPVector.end()) return; diff --git a/lib/CodeGen/InterleavedLoadCombinePass.cpp b/lib/CodeGen/InterleavedLoadCombinePass.cpp index a068e666995..ff3f93d51ea 100644 --- a/lib/CodeGen/InterleavedLoadCombinePass.cpp +++ b/lib/CodeGen/InterleavedLoadCombinePass.cpp @@ -1104,10 +1104,8 @@ InterleavedLoadCombineImpl::findFirstLoad(const std::set &LIs) { // All LIs are within the same BB. Select the first for a reference. BasicBlock *BB = (*LIs.begin())->getParent(); - BasicBlock::iterator FLI = - std::find_if(BB->begin(), BB->end(), [&LIs](Instruction &I) -> bool { - return is_contained(LIs, &I); - }); + BasicBlock::iterator FLI = llvm::find_if( + *BB, [&LIs](Instruction &I) -> bool { return is_contained(LIs, &I); }); assert(FLI != BB->end()); return cast(FLI); diff --git a/lib/CodeGen/MIRCanonicalizerPass.cpp b/lib/CodeGen/MIRCanonicalizerPass.cpp index f820b6cc3fc..b6fb6731d65 100644 --- a/lib/CodeGen/MIRCanonicalizerPass.cpp +++ b/lib/CodeGen/MIRCanonicalizerPass.cpp @@ -275,9 +275,9 @@ static bool rescheduleCanonically(unsigned &PseudoIdempotentInstCount, // Sort the defs for users of multiple defs lexographically. for (const auto &E : MultiUserLookup) { - auto UseI = - std::find_if(MBB->instr_begin(), MBB->instr_end(), - [&](MachineInstr &MI) -> bool { return &MI == E.second; }); + auto UseI = llvm::find_if(MBB->instrs(), [&](MachineInstr &MI) -> bool { + return &MI == E.second; + }); if (UseI == MBB->instr_end()) continue; diff --git a/lib/CodeGen/RegisterScavenging.cpp b/lib/CodeGen/RegisterScavenging.cpp index ab8f4fd9778..93e8e27d12a 100644 --- a/lib/CodeGen/RegisterScavenging.cpp +++ b/lib/CodeGen/RegisterScavenging.cpp @@ -634,11 +634,10 @@ static Register scavengeVReg(MachineRegisterInfo &MRI, RegScavenger &RS, // we get a single contiguous lifetime. // // Definitions in MRI.def_begin() are unordered, search for the first. - MachineRegisterInfo::def_iterator FirstDef = - std::find_if(MRI.def_begin(VReg), MRI.def_end(), - [VReg, &TRI](const MachineOperand &MO) { - return !MO.getParent()->readsRegister(VReg, &TRI); - }); + MachineRegisterInfo::def_iterator FirstDef = llvm::find_if( + MRI.def_operands(VReg), [VReg, &TRI](const MachineOperand &MO) { + return !MO.getParent()->readsRegister(VReg, &TRI); + }); assert(FirstDef != MRI.def_end() && "Must have one definition that does not redefine vreg"); MachineInstr &DefMI = *FirstDef->getParent(); diff --git a/lib/CodeGen/SwiftErrorValueTracking.cpp b/lib/CodeGen/SwiftErrorValueTracking.cpp index dd0b9d4c2e4..4408011c95c 100644 --- a/lib/CodeGen/SwiftErrorValueTracking.cpp +++ b/lib/CodeGen/SwiftErrorValueTracking.cpp @@ -202,8 +202,8 @@ void SwiftErrorValueTracking::propagateVRegs() { // downward defs. bool needPHI = VRegs.size() >= 1 && - std::find_if( - VRegs.begin(), VRegs.end(), + llvm::find_if( + VRegs, [&](const std::pair &V) -> bool { return V.second != VRegs[0].second; }) != VRegs.end(); diff --git a/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp b/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp index 252b58e5a59..ace7000f07b 100644 --- a/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp +++ b/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp @@ -71,8 +71,8 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const { StringRef Name = ConstantPoolStrings.substr( ConstantPoolOffset - StringPoolOffset + E.NameOffset); - auto CuVector = std::find_if( - ConstantPoolVectors.begin(), ConstantPoolVectors.end(), + auto CuVector = llvm::find_if( + ConstantPoolVectors, [&](const std::pair> &V) { return V.first == E.VecOffset; }); diff --git a/lib/DebugInfo/PDB/Native/SymbolCache.cpp b/lib/DebugInfo/PDB/Native/SymbolCache.cpp index 3e734c39e94..9017c824098 100644 --- a/lib/DebugInfo/PDB/Native/SymbolCache.cpp +++ b/lib/DebugInfo/PDB/Native/SymbolCache.cpp @@ -109,9 +109,10 @@ SymIndexId SymbolCache::createSimpleType(TypeIndex Index, return createSymbol(Index); const auto Kind = Index.getSimpleKind(); - const auto It = std::find_if( - std::begin(BuiltinTypes), std::end(BuiltinTypes), - [Kind](const BuiltinTypeEntry &Builtin) { return Builtin.Kind == Kind; }); + const auto It = + llvm::find_if(BuiltinTypes, [Kind](const BuiltinTypeEntry &Builtin) { + return Builtin.Kind == Kind; + }); if (It == std::end(BuiltinTypes)) return 0; return createSymbol(Mods, It->Type, It->Size);