Skip to content

Commit 3d5903c

Browse files
[llvm] Use llvm::is_contained (NFC) (#145844)
llvm::is_contained is shorter than llvm::all_of plus a lambda.
1 parent 3112244 commit 3d5903c

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

llvm/lib/MC/MCRegisterInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ ArrayRef<MCPhysReg> MCRegisterInfo::getCachedAliasesOf(MCRegister R) const {
9393

9494
sort(Aliases);
9595
Aliases.erase(unique(Aliases), Aliases.end());
96-
assert(none_of(Aliases, [&](auto &Cur) { return R == Cur; }) &&
96+
assert(!llvm::is_contained(Aliases, R) &&
9797
"MCRegAliasIteratorImpl includes Self!");
9898

9999
// Always put "self" at the end, so the iterator can choose to ignore it.

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4855,7 +4855,7 @@ getAppleRuntimeUnrollPreferences(Loop *L, ScalarEvolution &SE,
48554855
auto *Latch = L->getLoopLatch();
48564856
SmallVector<BasicBlock *> Preds(predecessors(Latch));
48574857
if (!Term || !Term->isConditional() || Preds.size() == 1 ||
4858-
none_of(Preds, [Header](BasicBlock *Pred) { return Header == Pred; }) ||
4858+
!llvm::is_contained(Preds, Header) ||
48594859
none_of(Preds, [L](BasicBlock *Pred) { return L->contains(Pred); }))
48604860
return;
48614861

llvm/lib/Transforms/IPO/StripSymbols.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,7 @@ PreservedAnalyses StripDeadCGProfilePass::run(Module &M,
309309
SmallVector<Metadata *, 16> ValidCGEdges;
310310
for (Metadata *Edge : CGProf->operands()) {
311311
if (auto *EdgeAsNode = dyn_cast_or_null<MDNode>(Edge))
312-
if (llvm::all_of(EdgeAsNode->operands(),
313-
[](const Metadata *V) { return V != nullptr; }))
312+
if (!llvm::is_contained(EdgeAsNode->operands(), nullptr))
314313
ValidCGEdges.push_back(Edge);
315314
}
316315
M.setModuleFlag(Module::Append, "CG Profile",

llvm/lib/Transforms/Utils/InlineFunction.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,16 +2336,14 @@ remapIndices(Function &Caller, BasicBlock *StartBB,
23362336
Worklist.push_back(Succ);
23372337
}
23382338

2339-
assert(
2340-
llvm::all_of(CalleeCounterMap, [&](const auto &V) { return V != 0; }) &&
2341-
"Counter index mapping should be either to -1 or to non-zero index, "
2342-
"because the 0 "
2343-
"index corresponds to the entry BB of the caller");
2344-
assert(
2345-
llvm::all_of(CalleeCallsiteMap, [&](const auto &V) { return V != 0; }) &&
2346-
"Callsite index mapping should be either to -1 or to non-zero index, "
2347-
"because there should have been at least a callsite - the inlined one "
2348-
"- which would have had a 0 index.");
2339+
assert(!llvm::is_contained(CalleeCounterMap, 0) &&
2340+
"Counter index mapping should be either to -1 or to non-zero index, "
2341+
"because the 0 "
2342+
"index corresponds to the entry BB of the caller");
2343+
assert(!llvm::is_contained(CalleeCallsiteMap, 0) &&
2344+
"Callsite index mapping should be either to -1 or to non-zero index, "
2345+
"because there should have been at least a callsite - the inlined one "
2346+
"- which would have had a 0 index.");
23492347

23502348
return {std::move(CalleeCounterMap), std::move(CalleeCallsiteMap)};
23512349
}

llvm/utils/TableGen/Common/CodeGenRegisters.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ bool CodeGenRegisterClass::hasType(const ValueTypeByHwMode &VT) const {
881881
if (VT.isSimple()) {
882882
MVT T = VT.getSimple();
883883
for (const ValueTypeByHwMode &OurVT : VTs) {
884-
if (llvm::count_if(OurVT, [T](auto &&P) { return P.second == T; }))
884+
if (llvm::is_contained(llvm::make_second_range(OurVT), T))
885885
return true;
886886
}
887887
}

0 commit comments

Comments
 (0)