[llvm] 6043498 - Use llvm::is_contained where appropriate (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 1 21:51:32 PDT 2020
Author: Kazu Hirata
Date: 2020-08-01T21:51:06-07:00
New Revision: 60434989e5cd718e0f84c7601f648aecd1e8e1eb
URL: https://github.com/llvm/llvm-project/commit/60434989e5cd718e0f84c7601f648aecd1e8e1eb
DIFF: https://github.com/llvm/llvm-project/commit/60434989e5cd718e0f84c7601f648aecd1e8e1eb.diff
LOG: Use llvm::is_contained where appropriate (NFC)
Use llvm::is_contained where appropriate (NFC)
Reviewed By: kazu
Differential Revision: https://reviews.llvm.org/D85083
Added:
Modified:
llvm/include/llvm/IR/PassManager.h
llvm/lib/Analysis/BranchProbabilityInfo.cpp
llvm/lib/Analysis/MemorySSAUpdater.cpp
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/lib/Support/FileCheck.cpp
llvm/lib/Support/Unix/Signals.inc
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
llvm/lib/Target/PowerPC/PPCLowerMASSVEntries.cpp
llvm/lib/Transforms/Scalar/LoopInterchange.cpp
llvm/tools/dsymutil/dsymutil.cpp
llvm/unittests/Support/TargetParserTest.cpp
llvm/utils/TableGen/CodeGenSchedule.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h
index c410818c470c..f16696d7c2e3 100644
--- a/llvm/include/llvm/IR/PassManager.h
+++ b/llvm/include/llvm/IR/PassManager.h
@@ -38,6 +38,7 @@
#define LLVM_IR_PASSMANAGER_H
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/TinyPtrVector.h"
@@ -1137,9 +1138,7 @@ class OuterAnalysisManagerProxy
// analyses that all trigger invalidation on the same outer analysis,
// this entire system should be changed to some other deterministic
// data structure such as a `SetVector` of a pair of pointers.
- auto InvalidatedIt = std::find(InvalidatedIDList.begin(),
- InvalidatedIDList.end(), InvalidatedID);
- if (InvalidatedIt == InvalidatedIDList.end())
+ if (!llvm::is_contained(InvalidatedIDList, InvalidatedID))
InvalidatedIDList.push_back(InvalidatedID);
}
diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp
index 7e34f3b6c869..7b24fe9d56c2 100644
--- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp
+++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp
@@ -692,8 +692,7 @@ computeUnlikelySuccessors(const BasicBlock *BB, Loop *L,
// we can constant-evaluate the compare to see if it makes the branch be
// taken or not.
Constant *CmpLHSConst = dyn_cast<Constant>(V);
- if (!CmpLHSConst ||
- std::find(succ_begin(BB), succ_end(BB), B) == succ_end(BB))
+ if (!CmpLHSConst || !llvm::is_contained(successors(BB), B))
continue;
// First collapse InstChain
for (Instruction *I : llvm::reverse(InstChain)) {
diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp
index 21cbdcd67147..81582413a604 100644
--- a/llvm/lib/Analysis/MemorySSAUpdater.cpp
+++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp
@@ -319,8 +319,7 @@ void MemorySSAUpdater::insertDef(MemoryDef *MD, bool RenameUses) {
bool DefBeforeSameBlock = false;
if (DefBefore->getBlock() == MD->getBlock() &&
!(isa<MemoryPhi>(DefBefore) &&
- std::find(InsertedPHIs.begin(), InsertedPHIs.end(), DefBefore) !=
- InsertedPHIs.end()))
+ llvm::is_contained(InsertedPHIs, DefBefore)))
DefBeforeSameBlock = true;
// There is a def before us, which means we can replace any store/phi uses
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 5d52e7fb8092..b388e4344783 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -494,8 +494,7 @@ void CodeViewDebug::recordLocalVariable(LocalVariable &&Var,
static void addLocIfNotPresent(SmallVectorImpl<const DILocation *> &Locs,
const DILocation *Loc) {
- auto B = Locs.begin(), E = Locs.end();
- if (std::find(B, E, Loc) == E)
+ if (!llvm::is_contained(Locs, Loc))
Locs.push_back(Loc);
}
diff --git a/llvm/lib/Support/FileCheck.cpp b/llvm/lib/Support/FileCheck.cpp
index 29a5a1345a58..137eea0a65a6 100644
--- a/llvm/lib/Support/FileCheck.cpp
+++ b/llvm/lib/Support/FileCheck.cpp
@@ -15,6 +15,7 @@
#include "llvm/Support/FileCheck.h"
#include "FileCheckImpl.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/CheckedArithmetic.h"
@@ -1578,9 +1579,7 @@ FindCheckType(const FileCheckRequest &Req, StringRef Buffer, StringRef Prefix) {
StringRef Rest = Buffer.drop_front(Prefix.size() + 1);
// Check for comment.
- if (Req.CommentPrefixes.end() != std::find(Req.CommentPrefixes.begin(),
- Req.CommentPrefixes.end(),
- Prefix)) {
+ if (llvm::is_contained(Req.CommentPrefixes, Prefix)) {
if (NextChar == ':')
return {Check::CheckComment, Rest};
// Ignore a comment prefix if it has a suffix like "-NOT".
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc
index f68374d29f02..ce1fccf0b427 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -382,8 +382,7 @@ static RETSIGTYPE SignalHandler(int Sig) {
OneShotPipeSignalFunction.exchange(nullptr))
return OldOneShotPipeFunction();
- if (std::find(std::begin(IntSigs), std::end(IntSigs), Sig)
- != std::end(IntSigs)) {
+ if (llvm::is_contained(IntSigs, Sig)) {
if (auto OldInterruptFunction = InterruptFunction.exchange(nullptr))
return OldInterruptFunction();
diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index 0ac09c4f96f0..beae2b059bec 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -5089,12 +5089,8 @@ bool AArch64AsmParser::ParseDirective(AsmToken DirectiveID) {
static void ExpandCryptoAEK(AArch64::ArchKind ArchKind,
SmallVector<StringRef, 4> &RequestedExtensions) {
- const bool NoCrypto =
- (std::find(RequestedExtensions.begin(), RequestedExtensions.end(),
- "nocrypto") != std::end(RequestedExtensions));
- const bool Crypto =
- (std::find(RequestedExtensions.begin(), RequestedExtensions.end(),
- "crypto") != std::end(RequestedExtensions));
+ const bool NoCrypto = llvm::is_contained(RequestedExtensions, "nocrypto");
+ const bool Crypto = llvm::is_contained(RequestedExtensions, "crypto");
if (!NoCrypto && Crypto) {
switch (ArchKind) {
diff --git a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
index f45cc06e0a0a..916d515af5da 100644
--- a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
@@ -19,6 +19,7 @@
#include "NVPTXTargetObjectFile.h"
#include "NVPTXUtilities.h"
#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/Analysis.h"
@@ -2438,8 +2439,7 @@ static bool isImageOrSamplerVal(const Value *arg, const Module *context) {
if (!STy || STy->isLiteral())
return false;
- return std::find(std::begin(specialTypes), std::end(specialTypes),
- STy->getName()) != std::end(specialTypes);
+ return llvm::is_contained(specialTypes, STy->getName());
}
SDValue NVPTXTargetLowering::LowerFormalArguments(
diff --git a/llvm/lib/Target/PowerPC/PPCLowerMASSVEntries.cpp b/llvm/lib/Target/PowerPC/PPCLowerMASSVEntries.cpp
index 2b0e604e0ccd..a61e1f83705e 100644
--- a/llvm/lib/Target/PowerPC/PPCLowerMASSVEntries.cpp
+++ b/llvm/lib/Target/PowerPC/PPCLowerMASSVEntries.cpp
@@ -16,6 +16,7 @@
#include "PPC.h"
#include "PPCSubtarget.h"
#include "PPCTargetMachine.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/Instructions.h"
@@ -64,8 +65,7 @@ class PPCLowerMASSVEntries : public ModulePass {
/// Checks if the specified function name represents an entry in the MASSV
/// library.
bool PPCLowerMASSVEntries::isMASSVFunc(StringRef Name) {
- auto Iter = std::find(std::begin(MASSVFuncs), std::end(MASSVFuncs), Name);
- return Iter != std::end(MASSVFuncs);
+ return llvm::is_contained(MASSVFuncs, Name);
}
// FIXME:
diff --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
index 7787c0bccd4c..3cfe1b595571 100644
--- a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
@@ -1521,8 +1521,7 @@ bool LoopInterchangeTransform::adjustLoopBranches() {
InnerLoopPreHeader, DTUpdates, /*MustUpdateOnce=*/false);
// The outer loop header might or might not branch to the outer latch.
// We are guaranteed to branch to the inner loop preheader.
- if (std::find(succ_begin(OuterLoopHeaderBI), succ_end(OuterLoopHeaderBI),
- OuterLoopLatch) != succ_end(OuterLoopHeaderBI))
+ if (llvm::is_contained(OuterLoopHeaderBI->successors(), OuterLoopLatch))
updateSuccessor(OuterLoopHeaderBI, OuterLoopLatch, LoopExit, DTUpdates,
/*MustUpdateOnce=*/false);
updateSuccessor(OuterLoopHeaderBI, InnerLoopPreHeader,
diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp
index 3a32acbec06f..a7d5e7afca03 100644
--- a/llvm/tools/dsymutil/dsymutil.cpp
+++ b/llvm/tools/dsymutil/dsymutil.cpp
@@ -17,6 +17,7 @@
#include "LinkUtils.h"
#include "MachOUtils.h"
#include "Reproducer.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
@@ -157,9 +158,7 @@ static Error verifyOptions(const DsymutilOptions &Options) {
errc::invalid_argument);
}
- if (Options.LinkOpts.Update &&
- std::find(Options.InputFiles.begin(), Options.InputFiles.end(), "-") !=
- Options.InputFiles.end()) {
+ if (Options.LinkOpts.Update && llvm::is_contained(Options.InputFiles, "-")) {
// FIXME: We cannot use stdin for an update because stdin will be
// consumed by the BinaryHolder during the debugmap parsing, and
// then we will want to consume it again in DwarfLinker. If we
diff --git a/llvm/unittests/Support/TargetParserTest.cpp b/llvm/unittests/Support/TargetParserTest.cpp
index 9f923e1358dd..f9392751de4e 100644
--- a/llvm/unittests/Support/TargetParserTest.cpp
+++ b/llvm/unittests/Support/TargetParserTest.cpp
@@ -610,16 +610,13 @@ TEST(TargetParserTest, ARMExtensionFeatures) {
// test +extension
Features.clear();
ARM::getExtensionFeatures(E.first, Features);
- auto Found =
- std::find(std::begin(Features), std::end(Features), E.second.at(0));
- EXPECT_TRUE(Found != std::end(Features));
+ EXPECT_TRUE(llvm::is_contained(Features, E.second.at(0)));
EXPECT_TRUE(Extensions.size() == Features.size());
// test -extension
Features.clear();
ARM::getExtensionFeatures(~E.first, Features);
- Found = std::find(std::begin(Features), std::end(Features), E.second.at(1));
- EXPECT_TRUE(Found != std::end(Features));
+ EXPECT_TRUE(llvm::is_contained(Features, E.second.at(1)));
EXPECT_TRUE(Extensions.size() == Features.size());
}
}
@@ -1227,27 +1224,24 @@ TEST(TargetParserTest, AArch64ExtensionFeatures) {
AArch64::getExtensionFeatures(ExtVal, Features);
EXPECT_TRUE(Extensions.size() == Features.size());
- auto B = std::begin(Features);
- auto E = std::end(Features);
-
- EXPECT_TRUE(std::find(B, E, "+crc") != E);
- EXPECT_TRUE(std::find(B, E, "+crypto") != E);
- EXPECT_TRUE(std::find(B, E, "+fp-armv8") != E);
- EXPECT_TRUE(std::find(B, E, "+neon") != E);
- EXPECT_TRUE(std::find(B, E, "+fullfp16") != E);
- EXPECT_TRUE(std::find(B, E, "+spe") != E);
- EXPECT_TRUE(std::find(B, E, "+ras") != E);
- EXPECT_TRUE(std::find(B, E, "+lse") != E);
- EXPECT_TRUE(std::find(B, E, "+rdm") != E);
- EXPECT_TRUE(std::find(B, E, "+dotprod") != E);
- EXPECT_TRUE(std::find(B, E, "+rcpc") != E);
- EXPECT_TRUE(std::find(B, E, "+fp16fml") != E);
- EXPECT_TRUE(std::find(B, E, "+sve") != E);
- EXPECT_TRUE(std::find(B, E, "+sve2") != E);
- EXPECT_TRUE(std::find(B, E, "+sve2-aes") != E);
- EXPECT_TRUE(std::find(B, E, "+sve2-sm4") != E);
- EXPECT_TRUE(std::find(B, E, "+sve2-sha3") != E);
- EXPECT_TRUE(std::find(B, E, "+sve2-bitperm") != E);
+ EXPECT_TRUE(llvm::is_contained(Features, "+crc"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+crypto"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+fp-armv8"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+neon"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+fullfp16"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+spe"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+ras"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+lse"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+rdm"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+dotprod"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+rcpc"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+fp16fml"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+sve"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+sve2"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+sve2-aes"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+sve2-sm4"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+sve2-sha3"));
+ EXPECT_TRUE(llvm::is_contained(Features, "+sve2-bitperm"));
}
TEST(TargetParserTest, AArch64ArchFeatures) {
diff --git a/llvm/utils/TableGen/CodeGenSchedule.h b/llvm/utils/TableGen/CodeGenSchedule.h
index c487d142d46c..b60a1b4fa242 100644
--- a/llvm/utils/TableGen/CodeGenSchedule.h
+++ b/llvm/utils/TableGen/CodeGenSchedule.h
@@ -16,6 +16,7 @@
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/TableGen/Record.h"
@@ -358,8 +359,7 @@ class OpcodeGroup {
OpcodeGroup(OpcodeGroup &&Other) = default;
void addOpcode(const Record *Opcode) {
- assert(std::find(Opcodes.begin(), Opcodes.end(), Opcode) == Opcodes.end() &&
- "Opcode already in set!");
+ assert(!llvm::is_contained(Opcodes, Opcode) && "Opcode already in set!");
Opcodes.push_back(Opcode);
}
More information about the llvm-commits
mailing list