-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[llvm] Use llvm::is_contained (NFC) #140742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_range_llvm_is_contained_llvm
May 20, 2025
Merged
[llvm] Use llvm::is_contained (NFC) #140742
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_range_llvm_is_contained_llvm
May 20, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
@llvm/pr-subscribers-backend-amdgpu @llvm/pr-subscribers-flang-openmp Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/140742.diff 4 Files Affected:
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;
|
|
@llvm/pr-subscribers-llvm-support Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/140742.diff 4 Files Affected:
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;
|
arsenm
approved these changes
May 20, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.