-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm] Use llvm::is_contained (NFC) #135566
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_is_contained_llvm
Apr 13, 2025
Merged
[llvm] Use llvm::is_contained (NFC) #135566
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_range_is_contained_llvm
Apr 13, 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-spir-v @llvm/pr-subscribers-llvm-transforms Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/135566.diff 6 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
index 6180c53a9a949..ab3eaa92548ca 100644
--- a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
@@ -467,10 +467,7 @@ class TargetRegisterInfo : public MCRegisterInfo {
/// Returns true if Reg contains RegUnit.
bool hasRegUnit(MCRegister Reg, MCRegUnit RegUnit) const {
- for (MCRegUnit Unit : regunits(Reg))
- if (Unit == RegUnit)
- return true;
- return false;
+ return llvm::is_contained(regunits(Reg), RegUnit);
}
/// Returns the original SrcReg unless it is the target of a copy-like
diff --git a/llvm/lib/CodeGen/WindowScheduler.cpp b/llvm/lib/CodeGen/WindowScheduler.cpp
index 95c86a9ac2668..2492dfc3ca553 100644
--- a/llvm/lib/CodeGen/WindowScheduler.cpp
+++ b/llvm/lib/CodeGen/WindowScheduler.cpp
@@ -679,8 +679,7 @@ MachineInstr *WindowScheduler::getOriMI(MachineInstr *NewMI) {
}
unsigned WindowScheduler::getOriStage(MachineInstr *OriMI, unsigned Offset) {
- assert(llvm::find(OriMIs, OriMI) != OriMIs.end() &&
- "Cannot find OriMI in OriMIs!");
+ assert(llvm::is_contained(OriMIs, OriMI) && "Cannot find OriMI in OriMIs!");
// If there is no instruction fold, all MI stages are 0.
if (Offset == SchedPhiNum)
return 0;
diff --git a/llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp b/llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp
index 3bd6c1e5be2cf..d95f2f602fbcd 100644
--- a/llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/Orc/Shared/ObjectFormats.h"
+#include "llvm/ADT/STLExtras.h"
namespace llvm {
namespace orc {
@@ -34,10 +35,7 @@ StringRef ELFThreadBSSSectionName = ".tbss";
StringRef ELFThreadDataSectionName = ".tdata";
bool isMachOInitializerSection(StringRef QualifiedName) {
- for (auto &InitSection : MachOInitSectionNames)
- if (InitSection == QualifiedName)
- return true;
- return false;
+ return llvm::is_contained(MachOInitSectionNames, QualifiedName);
}
bool isELFInitializerSection(StringRef SecName) {
diff --git a/llvm/lib/Target/NVPTX/NVPTXMachineFunctionInfo.h b/llvm/lib/Target/NVPTX/NVPTXMachineFunctionInfo.h
index d9beab7ec42e1..8feae341893aa 100644
--- a/llvm/lib/Target/NVPTX/NVPTXMachineFunctionInfo.h
+++ b/llvm/lib/Target/NVPTX/NVPTXMachineFunctionInfo.h
@@ -50,8 +50,7 @@ class NVPTXMachineFunctionInfo : public MachineFunctionInfo {
/// Check if the symbol has a mapping. Having a mapping means the handle is
/// replaced with a reference
bool checkImageHandleSymbol(StringRef Symbol) const {
- return ImageHandleList.end() !=
- std::find(ImageHandleList.begin(), ImageHandleList.end(), Symbol);
+ return llvm::is_contained(ImageHandleList, Symbol);
}
};
}
diff --git a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
index 53e88aa485568..86702bbe58f09 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
@@ -125,8 +125,7 @@ bool SPIRVExtensionsParser::parse(cl::Option &O, StringRef ArgName,
if (Token.starts_with("+")) {
EnabledExtensions.insert(NameValuePair->second);
} else if (EnabledExtensions.count(NameValuePair->second)) {
- if (std::find(Tokens.begin(), Tokens.end(), "+" + ExtensionName.str()) !=
- Tokens.end())
+ if (llvm::is_contained(Tokens, "+" + ExtensionName.str()))
return O.error(
"Extension cannot be allowed and disallowed at the same time: " +
ExtensionName.str());
diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index df1f6fddeba60..a5e0251277d8f 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -3807,8 +3807,7 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::identifyClones(
// Make sure we don't pick a previously existing caller edge of this
// Node, which would be processed on a different iteration of the
// outer loop over the saved CallerEdges.
- if (std::find(CallerEdges.begin(), CallerEdges.end(), E) !=
- CallerEdges.end())
+ if (llvm::is_contained(CallerEdges, E))
continue;
// The CallerAllocTypeForAlloc and CalleeEdgeAllocTypesForCallerEdge
// are updated further below for all cases where we just invoked
|
kuhar
approved these changes
Apr 13, 2025
var-const
pushed a commit
to ldionne/llvm-project
that referenced
this pull request
Apr 17, 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.