-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm] Use llvm::copy_if (NFC) #137480
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 2 commits into
llvm:main
from
kazutakahirata:cleanup_001_range_llvm_copy_if
Apr 27, 2025
Merged
[llvm] Use llvm::copy_if (NFC) #137480
kazutakahirata
merged 2 commits into
llvm:main
from
kazutakahirata:cleanup_001_range_llvm_copy_if
Apr 27, 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-tablegen @llvm/pr-subscribers-llvm-transforms Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/137480.diff 3 Files Affected:
diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index c0c58237ddfca..f46cddfd8587a 100644
--- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -270,13 +270,12 @@ struct AllocaInfo {
DbgUserVec AllDbgUsers;
SmallVector<DbgVariableRecord *> AllDPUsers;
findDbgUsers(AllDbgUsers, AI, &AllDPUsers);
- std::copy_if(AllDbgUsers.begin(), AllDbgUsers.end(),
- std::back_inserter(DbgUsers), [](DbgVariableIntrinsic *DII) {
- return !isa<DbgAssignIntrinsic>(DII);
- });
- std::copy_if(AllDPUsers.begin(), AllDPUsers.end(),
- std::back_inserter(DPUsers),
- [](DbgVariableRecord *DVR) { return !DVR->isDbgAssign(); });
+ llvm::copy_if(AllDbgUsers, std::back_inserter(DbgUsers),
+ [](DbgVariableIntrinsic *DII) {
+ return !isa<DbgAssignIntrinsic>(DII);
+ });
+ llvm::copy_if(AllDPUsers, std::back_inserter(DPUsers),
+ [](DbgVariableRecord *DVR) { return !DVR->isDbgAssign(); });
AssignmentTracking.init(AI);
}
};
diff --git a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTableExecutorEmitter.cpp b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTableExecutorEmitter.cpp
index b7926e21ca661..ffab2fdedc5a1 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTableExecutorEmitter.cpp
+++ b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTableExecutorEmitter.cpp
@@ -19,17 +19,17 @@ void GlobalISelMatchTableExecutorEmitter::emitSubtargetFeatureBitsetImpl(
// Separate subtarget features by how often they must be recomputed.
SubtargetFeatureInfoMap ModuleFeatures;
- std::copy_if(SubtargetFeatures.begin(), SubtargetFeatures.end(),
- std::inserter(ModuleFeatures, ModuleFeatures.end()),
- [](const SubtargetFeatureInfoMap::value_type &X) {
- return !X.second.mustRecomputePerFunction();
- });
+ llvm::copy_if(SubtargetFeatures,
+ std::inserter(ModuleFeatures, ModuleFeatures.end()),
+ [](const SubtargetFeatureInfoMap::value_type &X) {
+ return !X.second.mustRecomputePerFunction();
+ });
SubtargetFeatureInfoMap FunctionFeatures;
- std::copy_if(SubtargetFeatures.begin(), SubtargetFeatures.end(),
- std::inserter(FunctionFeatures, FunctionFeatures.end()),
- [](const SubtargetFeatureInfoMap::value_type &X) {
- return X.second.mustRecomputePerFunction();
- });
+ llvm::copy_if(SubtargetFeatures,
+ std::inserter(FunctionFeatures, FunctionFeatures.end()),
+ [](const SubtargetFeatureInfoMap::value_type &X) {
+ return X.second.mustRecomputePerFunction();
+ });
SubtargetFeatureInfo::emitComputeAvailableFeatures(
getTarget().getName(), getClassName(), "computeAvailableModuleFeatures",
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index b9561c137ec8b..8d0403ae43068 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -2273,10 +2273,10 @@ void GlobalISelEmitter::emitAdditionalImpl(raw_ostream &OS) {
void GlobalISelEmitter::emitMIPredicateFns(raw_ostream &OS) {
std::vector<const Record *> MatchedRecords;
- std::copy_if(AllPatFrags.begin(), AllPatFrags.end(),
- std::back_inserter(MatchedRecords), [](const Record *R) {
- return !R->getValueAsString("GISelPredicateCode").empty();
- });
+ llvm::copy_if(AllPatFrags, std::back_inserter(MatchedRecords),
+ [](const Record *R) {
+ return !R->getValueAsString("GISelPredicateCode").empty();
+ });
emitMIPredicateFnsImpl<const Record *>(
OS,
" const MachineFunction &MF = *MI.getParent()->getParent();\n"
@@ -2291,13 +2291,13 @@ void GlobalISelEmitter::emitMIPredicateFns(raw_ostream &OS) {
void GlobalISelEmitter::emitI64ImmPredicateFns(raw_ostream &OS) {
std::vector<const Record *> MatchedRecords;
- std::copy_if(AllPatFrags.begin(), AllPatFrags.end(),
- std::back_inserter(MatchedRecords), [](const Record *R) {
- bool Unset;
- return !R->getValueAsString("ImmediateCode").empty() &&
- !R->getValueAsBitOrUnset("IsAPFloat", Unset) &&
- !R->getValueAsBit("IsAPInt");
- });
+ llvm::copy_if(AllPatFrags, std::back_inserter(MatchedRecords),
+ [](const Record *R) {
+ bool Unset;
+ return !R->getValueAsString("ImmediateCode").empty() &&
+ !R->getValueAsBitOrUnset("IsAPFloat", Unset) &&
+ !R->getValueAsBit("IsAPInt");
+ });
emitImmPredicateFnsImpl<const Record *>(
OS, "I64", "int64_t", ArrayRef<const Record *>(MatchedRecords),
&getPatFragPredicateEnumName,
@@ -2307,12 +2307,12 @@ void GlobalISelEmitter::emitI64ImmPredicateFns(raw_ostream &OS) {
void GlobalISelEmitter::emitAPFloatImmPredicateFns(raw_ostream &OS) {
std::vector<const Record *> MatchedRecords;
- std::copy_if(AllPatFrags.begin(), AllPatFrags.end(),
- std::back_inserter(MatchedRecords), [](const Record *R) {
- bool Unset;
- return !R->getValueAsString("ImmediateCode").empty() &&
- R->getValueAsBitOrUnset("IsAPFloat", Unset);
- });
+ llvm::copy_if(AllPatFrags, std::back_inserter(MatchedRecords),
+ [](const Record *R) {
+ bool Unset;
+ return !R->getValueAsString("ImmediateCode").empty() &&
+ R->getValueAsBitOrUnset("IsAPFloat", Unset);
+ });
emitImmPredicateFnsImpl<const Record *>(
OS, "APFloat", "const APFloat &",
ArrayRef<const Record *>(MatchedRecords), &getPatFragPredicateEnumName,
@@ -2322,11 +2322,11 @@ void GlobalISelEmitter::emitAPFloatImmPredicateFns(raw_ostream &OS) {
void GlobalISelEmitter::emitAPIntImmPredicateFns(raw_ostream &OS) {
std::vector<const Record *> MatchedRecords;
- std::copy_if(AllPatFrags.begin(), AllPatFrags.end(),
- std::back_inserter(MatchedRecords), [](const Record *R) {
- return !R->getValueAsString("ImmediateCode").empty() &&
- R->getValueAsBit("IsAPInt");
- });
+ llvm::copy_if(AllPatFrags, std::back_inserter(MatchedRecords),
+ [](const Record *R) {
+ return !R->getValueAsString("ImmediateCode").empty() &&
+ R->getValueAsBit("IsAPInt");
+ });
emitImmPredicateFnsImpl<const Record *>(
OS, "APInt", "const APInt &", ArrayRef<const Record *>(MatchedRecords),
&getPatFragPredicateEnumName,
|
@llvm/pr-subscribers-llvm-globalisel Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/137480.diff 3 Files Affected:
diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index c0c58237ddfca..f46cddfd8587a 100644
--- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -270,13 +270,12 @@ struct AllocaInfo {
DbgUserVec AllDbgUsers;
SmallVector<DbgVariableRecord *> AllDPUsers;
findDbgUsers(AllDbgUsers, AI, &AllDPUsers);
- std::copy_if(AllDbgUsers.begin(), AllDbgUsers.end(),
- std::back_inserter(DbgUsers), [](DbgVariableIntrinsic *DII) {
- return !isa<DbgAssignIntrinsic>(DII);
- });
- std::copy_if(AllDPUsers.begin(), AllDPUsers.end(),
- std::back_inserter(DPUsers),
- [](DbgVariableRecord *DVR) { return !DVR->isDbgAssign(); });
+ llvm::copy_if(AllDbgUsers, std::back_inserter(DbgUsers),
+ [](DbgVariableIntrinsic *DII) {
+ return !isa<DbgAssignIntrinsic>(DII);
+ });
+ llvm::copy_if(AllDPUsers, std::back_inserter(DPUsers),
+ [](DbgVariableRecord *DVR) { return !DVR->isDbgAssign(); });
AssignmentTracking.init(AI);
}
};
diff --git a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTableExecutorEmitter.cpp b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTableExecutorEmitter.cpp
index b7926e21ca661..ffab2fdedc5a1 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTableExecutorEmitter.cpp
+++ b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTableExecutorEmitter.cpp
@@ -19,17 +19,17 @@ void GlobalISelMatchTableExecutorEmitter::emitSubtargetFeatureBitsetImpl(
// Separate subtarget features by how often they must be recomputed.
SubtargetFeatureInfoMap ModuleFeatures;
- std::copy_if(SubtargetFeatures.begin(), SubtargetFeatures.end(),
- std::inserter(ModuleFeatures, ModuleFeatures.end()),
- [](const SubtargetFeatureInfoMap::value_type &X) {
- return !X.second.mustRecomputePerFunction();
- });
+ llvm::copy_if(SubtargetFeatures,
+ std::inserter(ModuleFeatures, ModuleFeatures.end()),
+ [](const SubtargetFeatureInfoMap::value_type &X) {
+ return !X.second.mustRecomputePerFunction();
+ });
SubtargetFeatureInfoMap FunctionFeatures;
- std::copy_if(SubtargetFeatures.begin(), SubtargetFeatures.end(),
- std::inserter(FunctionFeatures, FunctionFeatures.end()),
- [](const SubtargetFeatureInfoMap::value_type &X) {
- return X.second.mustRecomputePerFunction();
- });
+ llvm::copy_if(SubtargetFeatures,
+ std::inserter(FunctionFeatures, FunctionFeatures.end()),
+ [](const SubtargetFeatureInfoMap::value_type &X) {
+ return X.second.mustRecomputePerFunction();
+ });
SubtargetFeatureInfo::emitComputeAvailableFeatures(
getTarget().getName(), getClassName(), "computeAvailableModuleFeatures",
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index b9561c137ec8b..8d0403ae43068 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -2273,10 +2273,10 @@ void GlobalISelEmitter::emitAdditionalImpl(raw_ostream &OS) {
void GlobalISelEmitter::emitMIPredicateFns(raw_ostream &OS) {
std::vector<const Record *> MatchedRecords;
- std::copy_if(AllPatFrags.begin(), AllPatFrags.end(),
- std::back_inserter(MatchedRecords), [](const Record *R) {
- return !R->getValueAsString("GISelPredicateCode").empty();
- });
+ llvm::copy_if(AllPatFrags, std::back_inserter(MatchedRecords),
+ [](const Record *R) {
+ return !R->getValueAsString("GISelPredicateCode").empty();
+ });
emitMIPredicateFnsImpl<const Record *>(
OS,
" const MachineFunction &MF = *MI.getParent()->getParent();\n"
@@ -2291,13 +2291,13 @@ void GlobalISelEmitter::emitMIPredicateFns(raw_ostream &OS) {
void GlobalISelEmitter::emitI64ImmPredicateFns(raw_ostream &OS) {
std::vector<const Record *> MatchedRecords;
- std::copy_if(AllPatFrags.begin(), AllPatFrags.end(),
- std::back_inserter(MatchedRecords), [](const Record *R) {
- bool Unset;
- return !R->getValueAsString("ImmediateCode").empty() &&
- !R->getValueAsBitOrUnset("IsAPFloat", Unset) &&
- !R->getValueAsBit("IsAPInt");
- });
+ llvm::copy_if(AllPatFrags, std::back_inserter(MatchedRecords),
+ [](const Record *R) {
+ bool Unset;
+ return !R->getValueAsString("ImmediateCode").empty() &&
+ !R->getValueAsBitOrUnset("IsAPFloat", Unset) &&
+ !R->getValueAsBit("IsAPInt");
+ });
emitImmPredicateFnsImpl<const Record *>(
OS, "I64", "int64_t", ArrayRef<const Record *>(MatchedRecords),
&getPatFragPredicateEnumName,
@@ -2307,12 +2307,12 @@ void GlobalISelEmitter::emitI64ImmPredicateFns(raw_ostream &OS) {
void GlobalISelEmitter::emitAPFloatImmPredicateFns(raw_ostream &OS) {
std::vector<const Record *> MatchedRecords;
- std::copy_if(AllPatFrags.begin(), AllPatFrags.end(),
- std::back_inserter(MatchedRecords), [](const Record *R) {
- bool Unset;
- return !R->getValueAsString("ImmediateCode").empty() &&
- R->getValueAsBitOrUnset("IsAPFloat", Unset);
- });
+ llvm::copy_if(AllPatFrags, std::back_inserter(MatchedRecords),
+ [](const Record *R) {
+ bool Unset;
+ return !R->getValueAsString("ImmediateCode").empty() &&
+ R->getValueAsBitOrUnset("IsAPFloat", Unset);
+ });
emitImmPredicateFnsImpl<const Record *>(
OS, "APFloat", "const APFloat &",
ArrayRef<const Record *>(MatchedRecords), &getPatFragPredicateEnumName,
@@ -2322,11 +2322,11 @@ void GlobalISelEmitter::emitAPFloatImmPredicateFns(raw_ostream &OS) {
void GlobalISelEmitter::emitAPIntImmPredicateFns(raw_ostream &OS) {
std::vector<const Record *> MatchedRecords;
- std::copy_if(AllPatFrags.begin(), AllPatFrags.end(),
- std::back_inserter(MatchedRecords), [](const Record *R) {
- return !R->getValueAsString("ImmediateCode").empty() &&
- R->getValueAsBit("IsAPInt");
- });
+ llvm::copy_if(AllPatFrags, std::back_inserter(MatchedRecords),
+ [](const Record *R) {
+ return !R->getValueAsString("ImmediateCode").empty() &&
+ R->getValueAsBit("IsAPInt");
+ });
emitImmPredicateFnsImpl<const Record *>(
OS, "APInt", "const APInt &", ArrayRef<const Record *>(MatchedRecords),
&getPatFragPredicateEnumName,
|
shiltian
approved these changes
Apr 26, 2025
kuhar
approved these changes
Apr 26, 2025
jyli0116
pushed a commit
to jyli0116/llvm-project
that referenced
this pull request
Apr 28, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
Ankur-0429
pushed a commit
to Ankur-0429/llvm-project
that referenced
this pull request
May 9, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.