mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-11 07:18:44 +00:00
[llvm] Use llvm::is_contained (NFC)
This commit is contained in:
parent
955b5e24b3
commit
ff49587cde
@ -260,10 +260,7 @@ public:
|
||||
///
|
||||
/// The width is specified in bits.
|
||||
bool isLegalInteger(uint64_t Width) const {
|
||||
for (unsigned LegalIntWidth : LegalIntWidths)
|
||||
if (LegalIntWidth == Width)
|
||||
return true;
|
||||
return false;
|
||||
return llvm::is_contained(LegalIntWidths, Width);
|
||||
}
|
||||
|
||||
bool isIllegalInteger(uint64_t Width) const { return !isLegalInteger(Width); }
|
||||
|
@ -1568,9 +1568,7 @@ public:
|
||||
void getDirectSuperClasses(SmallVectorImpl<Record *> &Classes) const;
|
||||
|
||||
bool isTemplateArg(Init *Name) const {
|
||||
for (Init *TA : TemplateArgs)
|
||||
if (TA == Name) return true;
|
||||
return false;
|
||||
return llvm::is_contained(TemplateArgs, Name);
|
||||
}
|
||||
|
||||
const RecordVal *getValue(const Init *Name) const {
|
||||
|
@ -157,9 +157,8 @@ llvm::getKnowledgeFromUse(const Use *U,
|
||||
return RetainedKnowledge::none();
|
||||
RetainedKnowledge RK =
|
||||
getKnowledgeFromBundle(*cast<CallInst>(U->getUser()), *Bundle);
|
||||
for (auto Attr : AttrKinds)
|
||||
if (Attr == RK.AttrKind)
|
||||
return RK;
|
||||
if (llvm::is_contained(AttrKinds, RK.AttrKind))
|
||||
return RK;
|
||||
return RetainedKnowledge::none();
|
||||
}
|
||||
|
||||
|
@ -616,15 +616,7 @@ bool Loop::isAnnotatedParallel() const {
|
||||
if (!LoopIdMD)
|
||||
return false;
|
||||
|
||||
bool LoopIdMDFound = false;
|
||||
for (const MDOperand &MDOp : LoopIdMD->operands()) {
|
||||
if (MDOp == DesiredLoopIdMetadata) {
|
||||
LoopIdMDFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!LoopIdMDFound)
|
||||
if (!llvm::is_contained(LoopIdMD->operands(), DesiredLoopIdMetadata))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -222,10 +222,8 @@ MachineModuleInfo::getAddrLabelSymbolToEmit(const BasicBlock *BB) {
|
||||
/// \{
|
||||
|
||||
void MachineModuleInfo::addPersonality(const Function *Personality) {
|
||||
for (unsigned i = 0; i < Personalities.size(); ++i)
|
||||
if (Personalities[i] == Personality)
|
||||
return;
|
||||
Personalities.push_back(Personality);
|
||||
if (!llvm::is_contained(Personalities, Personality))
|
||||
Personalities.push_back(Personality);
|
||||
}
|
||||
|
||||
/// \}
|
||||
|
@ -2181,12 +2181,8 @@ void MachineVerifier::checkLiveness(const MachineOperand *MO, unsigned MONum) {
|
||||
if (!Register::isPhysicalRegister(MOP.getReg()))
|
||||
continue;
|
||||
|
||||
for (const MCPhysReg &SubReg : TRI->subregs(MOP.getReg())) {
|
||||
if (SubReg == Reg) {
|
||||
Bad = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (llvm::is_contained(TRI->subregs(MOP.getReg()), Reg))
|
||||
Bad = false;
|
||||
}
|
||||
}
|
||||
if (Bad)
|
||||
|
@ -204,10 +204,7 @@ static Error optimizeELF_x86_64_GOTAndStubs(LinkGraph &G) {
|
||||
}
|
||||
|
||||
static bool isDwarfSection(StringRef SectionName) {
|
||||
for (auto &DwarfSectionName : DwarfSectionNames)
|
||||
if (SectionName == DwarfSectionName)
|
||||
return true;
|
||||
return false;
|
||||
return llvm::is_contained(DwarfSectionNames, SectionName);
|
||||
}
|
||||
|
||||
namespace llvm {
|
||||
|
@ -247,11 +247,7 @@ Error Builder::addSymbol(const ModuleSymbolTable &Msymtab,
|
||||
|
||||
setStr(Sym.IRName, GV->getName());
|
||||
|
||||
bool IsBuiltinFunc = false;
|
||||
|
||||
for (const char *LibcallName : LibcallRoutineNames)
|
||||
if (GV->getName() == LibcallName)
|
||||
IsBuiltinFunc = true;
|
||||
bool IsBuiltinFunc = llvm::is_contained(LibcallRoutineNames, GV->getName());
|
||||
|
||||
if (Used.count(GV) || IsBuiltinFunc)
|
||||
Sym.Flags |= 1 << storage::Symbol::FB_used;
|
||||
|
@ -782,11 +782,7 @@ bool PrintIRInstrumentation::shouldPrintBeforePass(StringRef PassID) {
|
||||
return true;
|
||||
|
||||
StringRef PassName = PIC->getPassNameForClassName(PassID);
|
||||
for (const auto &P : printBeforePasses()) {
|
||||
if (PassName == P)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return llvm::is_contained(printBeforePasses(), PassName);
|
||||
}
|
||||
|
||||
bool PrintIRInstrumentation::shouldPrintAfterPass(StringRef PassID) {
|
||||
@ -794,11 +790,7 @@ bool PrintIRInstrumentation::shouldPrintAfterPass(StringRef PassID) {
|
||||
return true;
|
||||
|
||||
StringRef PassName = PIC->getPassNameForClassName(PassID);
|
||||
for (const auto &P : printAfterPasses()) {
|
||||
if (PassName == P)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return llvm::is_contained(printAfterPasses(), PassName);
|
||||
}
|
||||
|
||||
void PrintIRInstrumentation::registerCallbacks(
|
||||
|
@ -2715,10 +2715,8 @@ Init *RecordResolver::resolve(Init *VarName) {
|
||||
if (Val)
|
||||
return Val;
|
||||
|
||||
for (Init *S : Stack) {
|
||||
if (S == VarName)
|
||||
return nullptr; // prevent infinite recursion
|
||||
}
|
||||
if (llvm::is_contained(Stack, VarName))
|
||||
return nullptr; // prevent infinite recursion
|
||||
|
||||
if (RecordVal *RV = getCurrentRecord()->getValue(VarName)) {
|
||||
if (!isa<UnsetInit>(RV->getValue())) {
|
||||
|
@ -1419,11 +1419,7 @@ void AMDGPUMachineCFGStructurizer::extractKilledPHIs(MachineBasicBlock *MBB) {
|
||||
|
||||
static bool isPHIRegionIndex(SmallVector<unsigned, 2> PHIRegionIndices,
|
||||
unsigned Index) {
|
||||
for (auto i : PHIRegionIndices) {
|
||||
if (i == Index)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
llvm::is_contained(PHIRegionIndices, Index);
|
||||
}
|
||||
|
||||
bool AMDGPUMachineCFGStructurizer::shrinkPHI(MachineInstr &PHI,
|
||||
|
@ -1370,10 +1370,8 @@ bool HexagonHardwareLoops::isLoopFeeder(MachineLoop *L, MachineBasicBlock *A,
|
||||
LLVM_DEBUG(dbgs() << "\nhw_loop head, "
|
||||
<< printMBBReference(**L->block_begin()));
|
||||
// Ignore all BBs that form Loop.
|
||||
for (MachineBasicBlock *MBB : L->getBlocks()) {
|
||||
if (A == MBB)
|
||||
return false;
|
||||
}
|
||||
if (llvm::is_contained(L->getBlocks(), A))
|
||||
return false;
|
||||
MachineInstr *Def = MRI->getVRegDef(MO->getReg());
|
||||
LoopFeederPhi.insert(std::make_pair(MO->getReg(), Def));
|
||||
return true;
|
||||
|
@ -60,10 +60,7 @@ CheckTy0Ty1MemSizeAlign(const LegalityQuery &Query,
|
||||
|
||||
static bool CheckTyN(unsigned N, const LegalityQuery &Query,
|
||||
std::initializer_list<LLT> SupportedValues) {
|
||||
for (auto &Val : SupportedValues)
|
||||
if (Val == Query.Types[N])
|
||||
return true;
|
||||
return false;
|
||||
return llvm::is_contained(SupportedValues, Query.Types[N]);
|
||||
}
|
||||
|
||||
MipsLegalizerInfo::MipsLegalizerInfo(const MipsSubtarget &ST) {
|
||||
|
@ -41,11 +41,7 @@ bool X86SelectionDAGInfo::isBaseRegConflictPossible(
|
||||
|
||||
const X86RegisterInfo *TRI = static_cast<const X86RegisterInfo *>(
|
||||
DAG.getSubtarget().getRegisterInfo());
|
||||
Register BaseReg = TRI->getBaseRegister();
|
||||
for (unsigned R : ClobberSet)
|
||||
if (BaseReg == R)
|
||||
return true;
|
||||
return false;
|
||||
return llvm::is_contained(ClobberSet, TRI->getBaseRegister());
|
||||
}
|
||||
|
||||
SDValue X86SelectionDAGInfo::EmitTargetCodeForMemset(
|
||||
|
@ -986,13 +986,8 @@ promoteArguments(Function *F, function_ref<AAResults &(Function &F)> AARGetter,
|
||||
// function, we could end up infinitely peeling the function argument.
|
||||
if (isSelfRecursive) {
|
||||
if (StructType *STy = dyn_cast<StructType>(AgTy)) {
|
||||
bool RecursiveType = false;
|
||||
for (const auto *EltTy : STy->elements()) {
|
||||
if (EltTy == PtrArg->getType()) {
|
||||
RecursiveType = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool RecursiveType =
|
||||
llvm::is_contained(STy->elements(), PtrArg->getType());
|
||||
if (RecursiveType)
|
||||
continue;
|
||||
}
|
||||
|
@ -207,9 +207,8 @@ bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU,
|
||||
|
||||
// Can't merge if there is PHI loop.
|
||||
for (PHINode &PN : BB->phis())
|
||||
for (Value *IncValue : PN.incoming_values())
|
||||
if (IncValue == &PN)
|
||||
return false;
|
||||
if (llvm::is_contained(PN.incoming_values(), &PN))
|
||||
return false;
|
||||
|
||||
LLVM_DEBUG(dbgs() << "Merging: " << BB->getName() << " into "
|
||||
<< PredBB->getName() << "\n");
|
||||
|
@ -2675,9 +2675,8 @@ bool isSafeToExpandAt(const SCEV *S, const Instruction *InsertionPoint,
|
||||
if (InsertionPoint->getParent()->getTerminator() == InsertionPoint)
|
||||
return true;
|
||||
if (const SCEVUnknown *U = dyn_cast<SCEVUnknown>(S))
|
||||
for (const Value *V : InsertionPoint->operand_values())
|
||||
if (V == U->getValue())
|
||||
return true;
|
||||
if (llvm::is_contained(InsertionPoint->operand_values(), U->getValue()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -294,10 +294,7 @@ static Twine truncateString(const StringRef &S, size_t n) {
|
||||
}
|
||||
|
||||
template <typename T> static bool containsNullptr(const T &Collection) {
|
||||
for (const auto &E : Collection)
|
||||
if (E == nullptr)
|
||||
return true;
|
||||
return false;
|
||||
return llvm::is_contained(Collection, nullptr);
|
||||
}
|
||||
|
||||
static std::string getLabel(const GraphDiffRenderer::GraphT::EdgeValueType &E,
|
||||
|
@ -484,9 +484,8 @@ static bool shouldPinPassToLegacyPM(StringRef Pass) {
|
||||
"amdgpu-unify-metadata",
|
||||
"amdgpu-printf-runtime-binding",
|
||||
"amdgpu-always-inline"};
|
||||
for (const auto &P : PassNameExactToIgnore)
|
||||
if (Pass == P)
|
||||
return false;
|
||||
if (llvm::is_contained(PassNameExactToIgnore, Pass))
|
||||
return false;
|
||||
|
||||
std::vector<StringRef> PassNamePrefix = {
|
||||
"x86-", "xcore-", "wasm-", "systemz-", "ppc-", "nvvm-", "nvptx-",
|
||||
@ -511,10 +510,7 @@ static bool shouldPinPassToLegacyPM(StringRef Pass) {
|
||||
for (const auto &P : PassNameContain)
|
||||
if (Pass.contains(P))
|
||||
return true;
|
||||
for (const auto &P : PassNameExact)
|
||||
if (Pass == P)
|
||||
return true;
|
||||
return false;
|
||||
return llvm::is_contained(PassNameExact, Pass);
|
||||
}
|
||||
|
||||
// For use in NPM transition.
|
||||
|
Loading…
x
Reference in New Issue
Block a user