[llvm] Use isa instead of dyn_cast (NFC)

This commit is contained in:
Kazu Hirata 2021-11-14 19:40:46 -08:00
parent a84a401f7e
commit d243cbf8ea
11 changed files with 14 additions and 19 deletions

View File

@ -817,7 +817,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
if (BranchInst *BI = dyn_cast<BranchInst>(&I)) {
// Count a conditional branch as savings if it becomes unconditional.
if (BI->isConditional() &&
dyn_cast_or_null<ConstantInt>(
isa_and_nonnull<ConstantInt>(
SimplifiedValues.lookup(BI->getCondition()))) {
CurrentSavings += InlineConstants::InstrCost;
}
@ -2225,7 +2225,7 @@ bool CallAnalyzer::visitBranchInst(BranchInst &BI) {
// inliner more regular and predictable. Interestingly, conditional branches
// which will fold away are also free.
return BI.isUnconditional() || isa<ConstantInt>(BI.getCondition()) ||
dyn_cast_or_null<ConstantInt>(
isa_and_nonnull<ConstantInt>(
SimplifiedValues.lookup(BI.getCondition()));
}

View File

@ -1527,7 +1527,7 @@ static void computeKnownBitsFromOperator(const Operator *I,
// taking conservative care to avoid excessive recursion.
if (Depth < MaxAnalysisRecursionDepth - 1 && !Known.Zero && !Known.One) {
// Skip if every incoming value references to ourself.
if (dyn_cast_or_null<UndefValue>(P->hasConstantValue()))
if (isa_and_nonnull<UndefValue>(P->hasConstantValue()))
break;
Known.Zero.setAllBits();

View File

@ -546,7 +546,7 @@ class MetadataLoader::MetadataLoaderImpl {
if (auto *DDI = dyn_cast<DbgDeclareInst>(&I))
if (auto *DIExpr = DDI->getExpression())
if (DIExpr->startsWithDeref() &&
dyn_cast_or_null<Argument>(DDI->getAddress())) {
isa_and_nonnull<Argument>(DDI->getAddress())) {
SmallVector<uint64_t, 8> Ops;
Ops.append(std::next(DIExpr->elements_begin()),
DIExpr->elements_end());

View File

@ -366,7 +366,7 @@ bool TargetInstrInfo::hasLoadFromStackSlot(
oe = MI.memoperands_end();
o != oe; ++o) {
if ((*o)->isLoad() &&
dyn_cast_or_null<FixedStackPseudoSourceValue>((*o)->getPseudoValue()))
isa_and_nonnull<FixedStackPseudoSourceValue>((*o)->getPseudoValue()))
Accesses.push_back(*o);
}
return Accesses.size() != StartSize;
@ -380,7 +380,7 @@ bool TargetInstrInfo::hasStoreToStackSlot(
oe = MI.memoperands_end();
o != oe; ++o) {
if ((*o)->isStore() &&
dyn_cast_or_null<FixedStackPseudoSourceValue>((*o)->getPseudoValue()))
isa_and_nonnull<FixedStackPseudoSourceValue>((*o)->getPseudoValue()))
Accesses.push_back(*o);
}
return Accesses.size() != StartSize;

View File

@ -345,7 +345,7 @@ ReplaceableMetadataImpl *ReplaceableMetadataImpl::getIfExists(Metadata &MD) {
bool ReplaceableMetadataImpl::isReplaceable(const Metadata &MD) {
if (auto *N = dyn_cast<MDNode>(&MD))
return !N->isResolved();
return dyn_cast<ValueAsMetadata>(&MD);
return isa<ValueAsMetadata>(&MD);
}
static DISubprogram *getLocalFunctionMetadata(Value *V) {

View File

@ -6166,11 +6166,7 @@ static bool isNewFormatTBAATypeNode(llvm::MDNode *Type) {
// In the new format type nodes shall have a reference to the parent type as
// its first operand.
MDNode *Parent = dyn_cast_or_null<MDNode>(Type->getOperand(0));
if (!Parent)
return false;
return true;
return isa_and_nonnull<MDNode>(Type->getOperand(0));
}
bool TBAAVerifier::visitTBAAMetadata(Instruction &I, const MDNode *MD) {

View File

@ -1201,8 +1201,7 @@ bool MVEGatherScatterLowering::optimiseAddress(Value *Address, BasicBlock *BB,
if (!GEP)
return false;
bool Changed = false;
if (GEP->hasOneUse() &&
dyn_cast<GetElementPtrInst>(GEP->getPointerOperand())) {
if (GEP->hasOneUse() && isa<GetElementPtrInst>(GEP->getPointerOperand())) {
IRBuilder<> Builder(GEP->getContext());
Builder.SetInsertPoint(GEP);
Builder.SetCurrentDebugLocation(GEP->getDebugLoc());

View File

@ -5254,7 +5254,7 @@ static SDValue transformCallee(const SDValue &Callee, SelectionDAG &DAG,
const GlobalValue *GV = G ? G->getGlobal() : nullptr;
return DAG.getTarget().shouldAssumeDSOLocal(*Mod, GV) &&
!dyn_cast_or_null<GlobalIFunc>(GV);
!isa_and_nonnull<GlobalIFunc>(GV);
};
// The PLT is only used in 32-bit ELF PIC mode. Attempting to use the PLT in
@ -10769,7 +10769,7 @@ SDValue PPCTargetLowering::LowerINSERT_VECTOR_ELT(SDValue Op,
// For f32 we also have legal lowering when the element is loaded from
// memory.
if (VT == MVT::v4f32 || VT == MVT::v2f64) {
if (!C || (VT == MVT::v4f32 && dyn_cast<LoadSDNode>(V2)))
if (!C || (VT == MVT::v4f32 && isa<LoadSDNode>(V2)))
return DAG.getNode(PPCISD::VECINSERT, dl, VT, V1, V2, V3);
return Op;
}

View File

@ -669,7 +669,7 @@ void CoroCloner::salvageDebugInfo() {
for (DbgVariableIntrinsic *DVI : Worklist) {
if (IsUnreachableBlock(DVI->getParent()))
DVI->eraseFromParent();
else if (dyn_cast_or_null<AllocaInst>(DVI->getVariableLocationOp(0))) {
else if (isa_and_nonnull<AllocaInst>(DVI->getVariableLocationOp(0))) {
// Count all non-debuginfo uses in reachable blocks.
unsigned Uses = 0;
for (auto *User : DVI->getVariableLocationOp(0)->users())

View File

@ -2810,7 +2810,7 @@ struct AAHeapToSharedFunction : public AAHeapToShared {
const auto &ED = A.getAAFor<AAExecutionDomain>(
*this, IRPosition::function(*F), DepClassTy::REQUIRED);
if (CallBase *CB = dyn_cast<CallBase>(U))
if (!dyn_cast<ConstantInt>(CB->getArgOperand(0)) ||
if (!isa<ConstantInt>(CB->getArgOperand(0)) ||
!ED.isExecutedByInitialThreadOnly(*CB))
MallocCalls.erase(CB);
}

View File

@ -1819,7 +1819,7 @@ NewGVN::ExprResult NewGVN::performSymbolicCmpEvaluation(Instruction *I) const {
// See if we know something about the comparison itself, like it is the target
// of an assume.
auto *CmpPI = PredInfo->getPredicateInfoFor(I);
if (dyn_cast_or_null<PredicateAssume>(CmpPI))
if (isa_and_nonnull<PredicateAssume>(CmpPI))
return ExprResult::some(
createConstantExpression(ConstantInt::getTrue(CI->getType())));