[llvm-branch-commits] [llvm] 89e8eb9 - [llvm] Use llvm::find_if (NFC)

Kazu Hirata via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jan 11 18:53:24 PST 2021


Author: Kazu Hirata
Date: 2021-01-11T18:48:06-08:00
New Revision: 89e8eb946d89f29cc76ba0a03425b7f7679aca5d

URL: https://github.com/llvm/llvm-project/commit/89e8eb946d89f29cc76ba0a03425b7f7679aca5d
DIFF: https://github.com/llvm/llvm-project/commit/89e8eb946d89f29cc76ba0a03425b7f7679aca5d.diff

LOG: [llvm] Use llvm::find_if (NFC)

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/LoopCacheAnalysis.h
    llvm/lib/ExecutionEngine/Orc/Core.cpp
    llvm/lib/IR/LegacyPassManager.cpp
    llvm/lib/MC/MCSectionMachO.cpp
    llvm/tools/llvm-exegesis/lib/Analysis.cpp
    llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp
    llvm/tools/obj2yaml/dwarf2yaml.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
index 832122e8a97a..e8f2205545eb 100644
--- a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
@@ -198,9 +198,9 @@ class CacheCost {
   /// Return the estimated cost of loop \p L if the given loop is part of the
   /// loop nest associated with this object. Return -1 otherwise.
   CacheCostTy getLoopCost(const Loop &L) const {
-    auto IT = std::find_if(
-        LoopCosts.begin(), LoopCosts.end(),
-        [&L](const LoopCacheCostTy &LCC) { return LCC.first == &L; });
+    auto IT = llvm::find_if(LoopCosts, [&L](const LoopCacheCostTy &LCC) {
+      return LCC.first == &L;
+    });
     return (IT != LoopCosts.end()) ? (*IT).second : -1;
   }
 

diff  --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp
index 7d61a7d6eddb..458dfc1ef421 100644
--- a/llvm/lib/ExecutionEngine/Orc/Core.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp
@@ -618,10 +618,10 @@ ResourceTrackerSP JITDylib::createResourceTracker() {
 
 void JITDylib::removeGenerator(DefinitionGenerator &G) {
   std::lock_guard<std::mutex> Lock(GeneratorsMutex);
-  auto I = std::find_if(DefGenerators.begin(), DefGenerators.end(),
-                        [&](const std::shared_ptr<DefinitionGenerator> &H) {
-                          return H.get() == &G;
-                        });
+  auto I = llvm::find_if(DefGenerators,
+                         [&](const std::shared_ptr<DefinitionGenerator> &H) {
+                           return H.get() == &G;
+                         });
   assert(I != DefGenerators.end() && "Generator not found");
   DefGenerators.erase(I);
 }
@@ -1264,10 +1264,10 @@ void JITDylib::replaceInLinkOrder(JITDylib &OldJD, JITDylib &NewJD,
 
 void JITDylib::removeFromLinkOrder(JITDylib &JD) {
   ES.runSessionLocked([&]() {
-    auto I = std::find_if(LinkOrder.begin(), LinkOrder.end(),
-                          [&](const JITDylibSearchOrder::value_type &KV) {
-                            return KV.first == &JD;
-                          });
+    auto I = llvm::find_if(LinkOrder,
+                           [&](const JITDylibSearchOrder::value_type &KV) {
+                             return KV.first == &JD;
+                           });
     if (I != LinkOrder.end())
       LinkOrder.erase(I);
   });
@@ -1388,11 +1388,10 @@ void JITDylib::MaterializingInfo::addQuery(
 void JITDylib::MaterializingInfo::removeQuery(
     const AsynchronousSymbolQuery &Q) {
   // FIXME: Implement 'find_as' for shared_ptr<T>/T*.
-  auto I =
-      std::find_if(PendingQueries.begin(), PendingQueries.end(),
-                   [&Q](const std::shared_ptr<AsynchronousSymbolQuery> &V) {
-                     return V.get() == &Q;
-                   });
+  auto I = llvm::find_if(
+      PendingQueries, [&Q](const std::shared_ptr<AsynchronousSymbolQuery> &V) {
+        return V.get() == &Q;
+      });
   assert(I != PendingQueries.end() &&
          "Query is not attached to this MaterializingInfo");
   PendingQueries.erase(I);

diff  --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp
index f6050d063303..f35c5048ae68 100644
--- a/llvm/lib/IR/LegacyPassManager.cpp
+++ b/llvm/lib/IR/LegacyPassManager.cpp
@@ -137,8 +137,7 @@ void PMDataManager::emitInstrCountChangedRemark(
     // remarks. Since it's possible that the first function in the module
     // doesn't actually contain a basic block, we have to go and find one that's
     // suitable for emitting remarks.
-    auto It = std::find_if(M.begin(), M.end(),
-                          [](const Function &Fn) { return !Fn.empty(); });
+    auto It = llvm::find_if(M, [](const Function &Fn) { return !Fn.empty(); });
 
     // Didn't find a function. Quit.
     if (It == M.end())

diff  --git a/llvm/lib/MC/MCSectionMachO.cpp b/llvm/lib/MC/MCSectionMachO.cpp
index 21a63ce83330..794d2c52d7b1 100644
--- a/llvm/lib/MC/MCSectionMachO.cpp
+++ b/llvm/lib/MC/MCSectionMachO.cpp
@@ -215,11 +215,11 @@ std::string MCSectionMachO::ParseSectionSpecifier(StringRef Spec,        // In.
     return "";
 
   // Figure out which section type it is.
-  auto TypeDescriptor = std::find_if(
-      std::begin(SectionTypeDescriptors), std::end(SectionTypeDescriptors),
-      [&](decltype(*SectionTypeDescriptors) &Descriptor) {
-        return SectionType == Descriptor.AssemblerName;
-      });
+  auto TypeDescriptor =
+      llvm::find_if(SectionTypeDescriptors,
+                    [&](decltype(*SectionTypeDescriptors) &Descriptor) {
+                      return SectionType == Descriptor.AssemblerName;
+                    });
 
   // If we didn't find the section type, reject it.
   if (TypeDescriptor == std::end(SectionTypeDescriptors))
@@ -243,11 +243,11 @@ std::string MCSectionMachO::ParseSectionSpecifier(StringRef Spec,        // In.
   Attrs.split(SectionAttrs, '+', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
 
   for (StringRef &SectionAttr : SectionAttrs) {
-    auto AttrDescriptorI = std::find_if(
-        std::begin(SectionAttrDescriptors), std::end(SectionAttrDescriptors),
-        [&](decltype(*SectionAttrDescriptors) &Descriptor) {
-          return SectionAttr.trim() == Descriptor.AssemblerName;
-        });
+    auto AttrDescriptorI =
+        llvm::find_if(SectionAttrDescriptors,
+                      [&](decltype(*SectionAttrDescriptors) &Descriptor) {
+                        return SectionAttr.trim() == Descriptor.AssemblerName;
+                      });
     if (AttrDescriptorI == std::end(SectionAttrDescriptors))
       return "mach-o section specifier has invalid attribute";
 

diff  --git a/llvm/tools/llvm-exegesis/lib/Analysis.cpp b/llvm/tools/llvm-exegesis/lib/Analysis.cpp
index 077acf9aff6b..ac21de1b9652 100644
--- a/llvm/tools/llvm-exegesis/lib/Analysis.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Analysis.cpp
@@ -555,11 +555,10 @@ Error Analysis::run<Analysis::PrintSchedClassInconsistencies>(
         continue; // Ignore noise and errors. FIXME: take noise into account ?
       if (ClusterId.isUnstable() ^ AnalysisDisplayUnstableOpcodes_)
         continue; // Either display stable or unstable clusters only.
-      auto SchedClassClusterIt =
-          std::find_if(SchedClassClusters.begin(), SchedClassClusters.end(),
-                       [ClusterId](const SchedClassCluster &C) {
-                         return C.id() == ClusterId;
-                       });
+      auto SchedClassClusterIt = llvm::find_if(
+          SchedClassClusters, [ClusterId](const SchedClassCluster &C) {
+            return C.id() == ClusterId;
+          });
       if (SchedClassClusterIt == SchedClassClusters.end()) {
         SchedClassClusters.emplace_back();
         SchedClassClusterIt = std::prev(SchedClassClusters.end());

diff  --git a/llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp b/llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp
index fe0e50ea2660..03386cf2384f 100644
--- a/llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp
+++ b/llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp
@@ -286,11 +286,11 @@ std::vector<BenchmarkMeasure> ResolvedSchedClass::getAsPoint(
       uint16_t ProcResIdx = findProcResIdx(STI, Key);
       if (ProcResIdx > 0) {
         // Find the pressure on ProcResIdx `Key`.
-        const auto ProcResPressureIt = std::find_if(
-            IdealizedProcResPressure.begin(), IdealizedProcResPressure.end(),
-            [ProcResIdx](const std::pair<uint16_t, float> &WPR) {
-              return WPR.first == ProcResIdx;
-            });
+        const auto ProcResPressureIt =
+            llvm::find_if(IdealizedProcResPressure,
+                          [ProcResIdx](const std::pair<uint16_t, float> &WPR) {
+                            return WPR.first == ProcResIdx;
+                          });
         Measure.PerInstructionValue =
             ProcResPressureIt == IdealizedProcResPressure.end()
                 ? 0.0

diff  --git a/llvm/tools/obj2yaml/dwarf2yaml.cpp b/llvm/tools/obj2yaml/dwarf2yaml.cpp
index 5da5ac1f37c9..c8459b502a60 100644
--- a/llvm/tools/obj2yaml/dwarf2yaml.cpp
+++ b/llvm/tools/obj2yaml/dwarf2yaml.cpp
@@ -219,8 +219,8 @@ void dumpDebugInfo(DWARFContext &DCtx, DWARFYAML::Data &Y) {
     const DWARFDebugAbbrev *DebugAbbrev = DCtx.getDebugAbbrev();
     NewUnit.AbbrevTableID = std::distance(
         DebugAbbrev->begin(),
-        std::find_if(
-            DebugAbbrev->begin(), DebugAbbrev->end(),
+        llvm::find_if(
+            *DebugAbbrev,
             [&](const std::pair<uint64_t, DWARFAbbreviationDeclarationSet> &P) {
               return P.first == CU->getAbbreviations()->getOffset();
             }));


        


More information about the llvm-branch-commits mailing list