[llvm] [llvm] Use llvm::is_contained (NFC) (PR #140742)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue May 20 08:01:09 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/140742

None

>From a6cd15230800925e64c522dc366e5ed900b3e9d1 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 20 May 2025 07:42:38 -0700
Subject: [PATCH] [llvm] Use llvm::is_contained (NFC)

---
 llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h  | 3 +--
 llvm/lib/Support/ThreadPool.cpp                              | 3 +--
 llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp         | 5 +----
 llvm/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp | 3 +--
 4 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
index f702b8dba5a79..cdc80c88b7425 100644
--- a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
+++ b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
@@ -1123,8 +1123,7 @@ template <typename C, typename H> bool ConstructDecompositionT<C, H>::split() {
   bool success = true;
 
   auto isImplicit = [this](const ClauseTy *node) {
-    return llvm::any_of(
-        implicit, [node](const ClauseTy &clause) { return &clause == node; });
+    return llvm::is_contained(llvm::make_pointer_range(implicit), node);
   };
 
   for (llvm::omp::Directive leaf :
diff --git a/llvm/lib/Support/ThreadPool.cpp b/llvm/lib/Support/ThreadPool.cpp
index 27e0f220ac4ed..c304f0f45360b 100644
--- a/llvm/lib/Support/ThreadPool.cpp
+++ b/llvm/lib/Support/ThreadPool.cpp
@@ -137,8 +137,7 @@ bool StdThreadPool::workCompletedUnlocked(ThreadPoolTaskGroup *Group) const {
   if (Group == nullptr)
     return !ActiveThreads && Tasks.empty();
   return ActiveGroups.count(Group) == 0 &&
-         !llvm::any_of(Tasks,
-                       [Group](const auto &T) { return T.second == Group; });
+         !llvm::is_contained(llvm::make_second_range(Tasks), Group);
 }
 
 void StdThreadPool::wait() {
diff --git a/llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp b/llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp
index bb68f4a0e70de..e1008439a33a8 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp
@@ -274,10 +274,7 @@ bool AMDGPURewriteOutArguments::runOnFunction(Function &F) {
         Value *ReplVal = Store.second->getValueOperand();
 
         auto &ValVec = Replacements[Store.first];
-        if (llvm::any_of(ValVec,
-                         [OutArg](const std::pair<Argument *, Value *> &Entry) {
-                           return Entry.first == OutArg;
-                         })) {
+        if (llvm::is_contained(llvm::make_first_range(ValVec), OutArg)) {
           LLVM_DEBUG(dbgs()
                      << "Saw multiple out arg stores" << *OutArg << '\n');
           // It is possible to see stores to the same argument multiple times,
diff --git a/llvm/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp b/llvm/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp
index e00240d7427dc..b1f19e9e20891 100644
--- a/llvm/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp
+++ b/llvm/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp
@@ -96,8 +96,7 @@ class TypeIndexIteratorTest : public testing::Test {
       ArrayRef<uint8_t> Loc = RecordData.drop_front(Offset);
       ArrayRef<TypeIndex> Indices(
           reinterpret_cast<const TypeIndex *>(Loc.data()), Ref.Count);
-      if (llvm::any_of(Indices,
-                       [TI](const TypeIndex &Other) { return Other == TI; }))
+      if (llvm::is_contained(Indices, TI))
         return true;
     }
     return false;



More information about the llvm-commits mailing list