[llvm] [llvm] Use llvm::is_contained (NFC) (PR #135566)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 13 14:41:31 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-nvptx
@llvm/pr-subscribers-llvm-transforms
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/135566.diff
6 Files Affected:
- (modified) llvm/include/llvm/CodeGen/TargetRegisterInfo.h (+1-4)
- (modified) llvm/lib/CodeGen/WindowScheduler.cpp (+1-2)
- (modified) llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp (+2-4)
- (modified) llvm/lib/Target/NVPTX/NVPTXMachineFunctionInfo.h (+1-2)
- (modified) llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp (+1-2)
- (modified) llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp (+1-2)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/135566
More information about the llvm-commits
mailing list