[llvm] Use llvm::all_of (NFC)

This commit is contained in:
Kazu Hirata 2021-01-06 18:27:36 -08:00
parent 9b228f107d
commit cfeecdf7b6
11 changed files with 53 additions and 56 deletions

View File

@ -675,10 +675,10 @@ static void compareLoops(const LoopT *L, const LoopT *OtherL,
const SmallPtrSetImpl<const BlockT *> &BlocksSet = L->getBlocksSet(); const SmallPtrSetImpl<const BlockT *> &BlocksSet = L->getBlocksSet();
const SmallPtrSetImpl<const BlockT *> &OtherBlocksSet = L->getBlocksSet(); const SmallPtrSetImpl<const BlockT *> &OtherBlocksSet = L->getBlocksSet();
assert(BlocksSet.size() == OtherBlocksSet.size() && assert(BlocksSet.size() == OtherBlocksSet.size() &&
std::all_of(BlocksSet.begin(), BlocksSet.end(), llvm::all_of(BlocksSet,
[&OtherBlocksSet](const BlockT *BB) { [&OtherBlocksSet](const BlockT *BB) {
return OtherBlocksSet.count(BB); return OtherBlocksSet.count(BB);
}) && }) &&
"Mismatched basic blocks in BlocksSets!"); "Mismatched basic blocks in BlocksSets!");
} }
#endif #endif

View File

@ -279,9 +279,10 @@ void DOTGraphTraits<DOTFuncInfo *>::computeHiddenNodes(const Function *F) {
(HideDeoptimizePaths && Node->getTerminatingDeoptimizeCall()); (HideDeoptimizePaths && Node->getTerminatingDeoptimizeCall());
return; return;
} }
isHiddenBasicBlock[Node] = std::all_of( isHiddenBasicBlock[Node] =
succ_begin(Node), succ_end(Node), llvm::all_of(successors(Node), [this](const BasicBlock *BB) {
[this](const BasicBlock *BB) { return isHiddenBasicBlock[BB]; }); return isHiddenBasicBlock[BB];
});
}; };
/// The post order traversal iteration is done to know the status of /// The post order traversal iteration is done to know the status of
/// isHiddenBasicBlock for all the successors on the current BB. /// isHiddenBasicBlock for all the successors on the current BB.

View File

@ -2230,8 +2230,7 @@ bool CodeGenPrepare::dupRetToEnableTailCallOpts(BasicBlock *BB, bool &ModifiedDT
EVI = dyn_cast<ExtractValueInst>(V); EVI = dyn_cast<ExtractValueInst>(V);
if (EVI) { if (EVI) {
V = EVI->getOperand(0); V = EVI->getOperand(0);
if (!std::all_of(EVI->idx_begin(), EVI->idx_end(), if (!llvm::all_of(EVI->indices(), [](unsigned idx) { return idx == 0; }))
[](unsigned idx) { return idx == 0; }))
return false; return false;
} }

View File

@ -130,7 +130,7 @@ bool CSEMIRBuilder::checkCopyToDefsPossible(ArrayRef<DstOp> DstOps) {
if (DstOps.size() == 1) if (DstOps.size() == 1)
return true; // always possible to emit copy to just 1 vreg. return true; // always possible to emit copy to just 1 vreg.
return std::all_of(DstOps.begin(), DstOps.end(), [](const DstOp &Op) { return llvm::all_of(DstOps, [](const DstOp &Op) {
DstOp::DstType DT = Op.getDstOpKind(); DstOp::DstType DT = Op.getDstOpKind();
return DT == DstOp::DstType::Ty_LLT || DT == DstOp::DstType::Ty_RC; return DT == DstOp::DstType::Ty_LLT || DT == DstOp::DstType::Ty_RC;
}); });

View File

@ -1089,11 +1089,11 @@ MachineInstrBuilder MachineIRBuilder::buildInstr(unsigned Opc,
case TargetOpcode::G_UNMERGE_VALUES: { case TargetOpcode::G_UNMERGE_VALUES: {
assert(!DstOps.empty() && "Invalid trivial sequence"); assert(!DstOps.empty() && "Invalid trivial sequence");
assert(SrcOps.size() == 1 && "Invalid src for Unmerge"); assert(SrcOps.size() == 1 && "Invalid src for Unmerge");
assert(std::all_of(DstOps.begin(), DstOps.end(), assert(llvm::all_of(DstOps,
[&, this](const DstOp &Op) { [&, this](const DstOp &Op) {
return Op.getLLTTy(*getMRI()) == return Op.getLLTTy(*getMRI()) ==
DstOps[0].getLLTTy(*getMRI()); DstOps[0].getLLTTy(*getMRI());
}) && }) &&
"type mismatch in output list"); "type mismatch in output list");
assert(DstOps.size() * DstOps[0].getLLTTy(*getMRI()).getSizeInBits() == assert(DstOps.size() * DstOps[0].getLLTTy(*getMRI()).getSizeInBits() ==
SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() && SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() &&
@ -1103,11 +1103,11 @@ MachineInstrBuilder MachineIRBuilder::buildInstr(unsigned Opc,
case TargetOpcode::G_MERGE_VALUES: { case TargetOpcode::G_MERGE_VALUES: {
assert(!SrcOps.empty() && "invalid trivial sequence"); assert(!SrcOps.empty() && "invalid trivial sequence");
assert(DstOps.size() == 1 && "Invalid Dst"); assert(DstOps.size() == 1 && "Invalid Dst");
assert(std::all_of(SrcOps.begin(), SrcOps.end(), assert(llvm::all_of(SrcOps,
[&, this](const SrcOp &Op) { [&, this](const SrcOp &Op) {
return Op.getLLTTy(*getMRI()) == return Op.getLLTTy(*getMRI()) ==
SrcOps[0].getLLTTy(*getMRI()); SrcOps[0].getLLTTy(*getMRI());
}) && }) &&
"type mismatch in input list"); "type mismatch in input list");
assert(SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() == assert(SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() ==
DstOps[0].getLLTTy(*getMRI()).getSizeInBits() && DstOps[0].getLLTTy(*getMRI()).getSizeInBits() &&
@ -1154,11 +1154,11 @@ MachineInstrBuilder MachineIRBuilder::buildInstr(unsigned Opc,
assert(DstOps.size() == 1 && "Invalid DstOps"); assert(DstOps.size() == 1 && "Invalid DstOps");
assert(DstOps[0].getLLTTy(*getMRI()).isVector() && assert(DstOps[0].getLLTTy(*getMRI()).isVector() &&
"Res type must be a vector"); "Res type must be a vector");
assert(std::all_of(SrcOps.begin(), SrcOps.end(), assert(llvm::all_of(SrcOps,
[&, this](const SrcOp &Op) { [&, this](const SrcOp &Op) {
return Op.getLLTTy(*getMRI()) == return Op.getLLTTy(*getMRI()) ==
SrcOps[0].getLLTTy(*getMRI()); SrcOps[0].getLLTTy(*getMRI());
}) && }) &&
"type mismatch in input list"); "type mismatch in input list");
assert(SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() == assert(SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() ==
DstOps[0].getLLTTy(*getMRI()).getSizeInBits() && DstOps[0].getLLTTy(*getMRI()).getSizeInBits() &&
@ -1171,11 +1171,11 @@ MachineInstrBuilder MachineIRBuilder::buildInstr(unsigned Opc,
assert(DstOps.size() == 1 && "Invalid DstOps"); assert(DstOps.size() == 1 && "Invalid DstOps");
assert(DstOps[0].getLLTTy(*getMRI()).isVector() && assert(DstOps[0].getLLTTy(*getMRI()).isVector() &&
"Res type must be a vector"); "Res type must be a vector");
assert(std::all_of(SrcOps.begin(), SrcOps.end(), assert(llvm::all_of(SrcOps,
[&, this](const SrcOp &Op) { [&, this](const SrcOp &Op) {
return Op.getLLTTy(*getMRI()) == return Op.getLLTTy(*getMRI()) ==
SrcOps[0].getLLTTy(*getMRI()); SrcOps[0].getLLTTy(*getMRI());
}) && }) &&
"type mismatch in input list"); "type mismatch in input list");
if (SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() == if (SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() ==
DstOps[0].getLLTTy(*getMRI()).getElementType().getSizeInBits()) DstOps[0].getLLTTy(*getMRI()).getElementType().getSizeInBits())
@ -1186,12 +1186,12 @@ MachineInstrBuilder MachineIRBuilder::buildInstr(unsigned Opc,
assert(DstOps.size() == 1 && "Invalid DstOps"); assert(DstOps.size() == 1 && "Invalid DstOps");
assert((!SrcOps.empty() || SrcOps.size() < 2) && assert((!SrcOps.empty() || SrcOps.size() < 2) &&
"Must have at least 2 operands"); "Must have at least 2 operands");
assert(std::all_of(SrcOps.begin(), SrcOps.end(), assert(llvm::all_of(SrcOps,
[&, this](const SrcOp &Op) { [&, this](const SrcOp &Op) {
return (Op.getLLTTy(*getMRI()).isVector() && return (Op.getLLTTy(*getMRI()).isVector() &&
Op.getLLTTy(*getMRI()) == Op.getLLTTy(*getMRI()) ==
SrcOps[0].getLLTTy(*getMRI())); SrcOps[0].getLLTTy(*getMRI()));
}) && }) &&
"type mismatch in input list"); "type mismatch in input list");
assert(SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() == assert(SrcOps.size() * SrcOps[0].getLLTTy(*getMRI()).getSizeInBits() ==
DstOps[0].getLLTTy(*getMRI()).getSizeInBits() && DstOps[0].getLLTTy(*getMRI()).getSizeInBits() &&

View File

@ -545,11 +545,10 @@ void MachineOutliner::findCandidates(
// That is, one must either // That is, one must either
// * End before the other starts // * End before the other starts
// * Start after the other ends // * Start after the other ends
if (std::all_of( if (llvm::all_of(CandidatesForRepeatedSeq, [&StartIdx,
CandidatesForRepeatedSeq.begin(), CandidatesForRepeatedSeq.end(), &EndIdx](const Candidate &C) {
[&StartIdx, &EndIdx](const Candidate &C) { return (EndIdx < C.getStartIdx() || StartIdx > C.getEndIdx());
return (EndIdx < C.getStartIdx() || StartIdx > C.getEndIdx()); })) {
})) {
// It doesn't overlap with anything, so we can outline it. // It doesn't overlap with anything, so we can outline it.
// Each sequence is over [StartIt, EndIt]. // Each sequence is over [StartIt, EndIt].
// Save the candidate and its location. // Save the candidate and its location.

View File

@ -1678,7 +1678,7 @@ Constant *Constant::getSplatValue(bool AllowUndefs) const {
ConstantInt *Index = dyn_cast<ConstantInt>(IElt->getOperand(2)); ConstantInt *Index = dyn_cast<ConstantInt>(IElt->getOperand(2));
if (Index && Index->getValue() == 0 && if (Index && Index->getValue() == 0 &&
std::all_of(Mask.begin(), Mask.end(), [](int I) { return I == 0; })) llvm::all_of(Mask, [](int I) { return I == 0; }))
return SplatVal; return SplatVal;
} }
} }

View File

@ -2898,8 +2898,8 @@ static unsigned getHiPELiteral(
// non-meta instructions between MBBI and MBB.end(). // non-meta instructions between MBBI and MBB.end().
static bool blockEndIsUnreachable(const MachineBasicBlock &MBB, static bool blockEndIsUnreachable(const MachineBasicBlock &MBB,
MachineBasicBlock::const_iterator MBBI) { MachineBasicBlock::const_iterator MBBI) {
return std::all_of( return llvm::all_of(
MBB.succ_begin(), MBB.succ_end(), MBB.successors(),
[](const MachineBasicBlock *Succ) { return Succ->isEHPad(); }) && [](const MachineBasicBlock *Succ) { return Succ->isEHPad(); }) &&
std::all_of(MBBI, MBB.end(), [](const MachineInstr &MI) { std::all_of(MBBI, MBB.end(), [](const MachineInstr &MI) {
return MI.isMetaInstruction(); return MI.isMetaInstruction();

View File

@ -1876,8 +1876,8 @@ bool ModuleAddressSanitizer::shouldInstrumentGlobal(GlobalVariable *G) const {
// Do not instrument user-defined sections (with names resembling // Do not instrument user-defined sections (with names resembling
// valid C identifiers) // valid C identifiers)
if (TargetTriple.isOSBinFormatELF()) { if (TargetTriple.isOSBinFormatELF()) {
if (std::all_of(Section.begin(), Section.end(), if (llvm::all_of(Section,
[](char c) { return llvm::isAlnum(c) || c == '_'; })) [](char c) { return llvm::isAlnum(c) || c == '_'; }))
return false; return false;
} }

View File

@ -3384,8 +3384,7 @@ bool BoUpSLP::canReuseExtract(ArrayRef<Value *> VL, Value *OpValue,
} }
bool BoUpSLP::areAllUsersVectorized(Instruction *I) const { bool BoUpSLP::areAllUsersVectorized(Instruction *I) const {
return I->hasOneUse() || return I->hasOneUse() || llvm::all_of(I->users(), [this](User *U) {
std::all_of(I->user_begin(), I->user_end(), [this](User *U) {
return ScalarToTreeEntry.count(U) > 0; return ScalarToTreeEntry.count(U) > 0;
}); });
} }
@ -4168,11 +4167,10 @@ void BoUpSLP::setInsertPointAfterBundle(TreeEntry *E) {
// should be in this block. // should be in this block.
auto *Front = E->getMainOp(); auto *Front = E->getMainOp();
auto *BB = Front->getParent(); auto *BB = Front->getParent();
assert(llvm::all_of(make_range(E->Scalars.begin(), E->Scalars.end()), assert(llvm::all_of(E->Scalars, [=](Value *V) -> bool {
[=](Value *V) -> bool { auto *I = cast<Instruction>(V);
auto *I = cast<Instruction>(V); return !E->isOpcodeOrAlt(I) || I->getParent() == BB;
return !E->isOpcodeOrAlt(I) || I->getParent() == BB; }));
}));
// The last instruction in the bundle in program order. // The last instruction in the bundle in program order.
Instruction *LastInst = nullptr; Instruction *LastInst = nullptr;

View File

@ -2389,9 +2389,9 @@ static void emitMatchClassEnumeration(CodeGenTarget &Target,
static void emitOperandMatchErrorDiagStrings(AsmMatcherInfo &Info, raw_ostream &OS) { static void emitOperandMatchErrorDiagStrings(AsmMatcherInfo &Info, raw_ostream &OS) {
// If the target does not use DiagnosticString for any operands, don't emit // If the target does not use DiagnosticString for any operands, don't emit
// an unused function. // an unused function.
if (std::all_of( if (llvm::all_of(Info.Classes, [](const ClassInfo &CI) {
Info.Classes.begin(), Info.Classes.end(), return CI.DiagnosticString.empty();
[](const ClassInfo &CI) { return CI.DiagnosticString.empty(); })) }))
return; return;
OS << "static const char *getMatchKindDiag(" << Info.Target.getName() OS << "static const char *getMatchKindDiag(" << Info.Target.getName()