From 5f4283b9dc3785cb9c950ad881fde751af291368 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Tue, 1 Apr 2025 22:32:02 -0700 Subject: [PATCH] [llvm] Use llvm::is_contained (NFC) --- llvm/include/llvm/CodeGen/TargetRegisterInfo.h | 5 +---- llvm/lib/CodeGen/WindowScheduler.cpp | 3 +-- llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp | 6 ++---- llvm/lib/Target/NVPTX/NVPTXMachineFunctionInfo.h | 3 +-- llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp | 3 +-- llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp | 3 +-- 6 files changed, 7 insertions(+), 16 deletions(-) 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::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