diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp index 988e912b2de83..9e23888d8cb83 100644 --- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp +++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp @@ -3542,7 +3542,7 @@ void ModuleCallsiteContextGraph::updateAllocationCall( void IndexCallsiteContextGraph::updateAllocationCall(CallInfo &Call, AllocationType AllocType) { - auto *AI = Call.call().dyn_cast(); + auto *AI = dyn_cast_if_present(Call.call()); assert(AI); assert(AI->Versions.size() > Call.cloneNo()); AI->Versions[Call.cloneNo()] = (uint8_t)AllocType; @@ -3560,7 +3560,7 @@ ModuleCallsiteContextGraph::getAllocationCallType(const CallInfo &Call) const { AllocationType IndexCallsiteContextGraph::getAllocationCallType(const CallInfo &Call) const { - const auto *AI = Call.call().dyn_cast(); + const auto *AI = dyn_cast_if_present(Call.call()); assert(AI->Versions.size() > Call.cloneNo()); return (AllocationType)AI->Versions[Call.cloneNo()]; } @@ -3579,7 +3579,7 @@ void ModuleCallsiteContextGraph::updateCall(CallInfo &CallerCall, void IndexCallsiteContextGraph::updateCall(CallInfo &CallerCall, FuncInfo CalleeFunc) { - auto *CI = CallerCall.call().dyn_cast(); + auto *CI = dyn_cast_if_present(CallerCall.call()); assert(CI && "Caller cannot be an allocation which should not have profiled calls"); assert(CI->Clones.size() > CallerCall.cloneNo()); @@ -3617,10 +3617,11 @@ IndexCallsiteContextGraph::cloneFunctionForCallsite( // The next clone number is the current size of versions array. // Confirm this matches the CloneNo provided by the caller, which is based on // the number of function clones we have. - assert(CloneNo == - (isa(Call.call()) - ? Call.call().dyn_cast()->Versions.size() - : Call.call().dyn_cast()->Clones.size())); + assert( + CloneNo == + (isa(Call.call()) + ? dyn_cast_if_present(Call.call())->Versions.size() + : dyn_cast_if_present(Call.call())->Clones.size())); // Walk all the instructions in this function. Create a new version for // each (by adding an entry to the Versions/Clones summary array), and copy // over the version being called for the function clone being cloned here. @@ -3630,13 +3631,13 @@ IndexCallsiteContextGraph::cloneFunctionForCallsite( for (auto &Inst : CallsWithMetadataInFunc) { // This map always has the initial version in it. assert(Inst.cloneNo() == 0); - if (auto *AI = Inst.call().dyn_cast()) { + if (auto *AI = dyn_cast_if_present(Inst.call())) { assert(AI->Versions.size() == CloneNo); // We assign the allocation type later (in updateAllocationCall), just add // an entry for it here. AI->Versions.push_back(0); } else { - auto *CI = Inst.call().dyn_cast(); + auto *CI = dyn_cast_if_present(Inst.call()); assert(CI && CI->Clones.size() == CloneNo); // We assign the clone number later (in updateCall), just add an entry for // it here. diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index ad4855d908747..05af64075e053 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -10354,7 +10354,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis { SameNodesEstimated = false; if (!E2 && InVectors.size() == 1) { unsigned VF = E1.getVectorFactor(); - if (Value *V1 = InVectors.front().dyn_cast()) { + if (Value *V1 = dyn_cast_if_present(InVectors.front())) { VF = std::max(VF, cast(V1->getType())->getNumElements()); } else { @@ -10370,7 +10370,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis { auto P = InVectors.front(); Cost += createShuffle(&E1, E2, Mask); unsigned VF = Mask.size(); - if (Value *V1 = P.dyn_cast()) { + if (Value *V1 = dyn_cast_if_present(P)) { VF = std::max(VF, getNumElements(V1->getType())); } else { @@ -10435,7 +10435,8 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis { ArrayRef Mask) { ShuffleCostBuilder Builder(TTI); SmallVector CommonMask(Mask); - Value *V1 = P1.dyn_cast(), *V2 = P2.dyn_cast(); + Value *V1 = dyn_cast_if_present(P1); + Value *V2 = dyn_cast_if_present(P2); unsigned CommonVF = Mask.size(); InstructionCost ExtraCost = 0; auto GetNodeMinBWAffectedCost = [&](const TreeEntry &E, @@ -10870,7 +10871,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis { transformMaskAfterShuffle(CommonMask, CommonMask); VF = std::max(VF, CommonMask.size()); } else if (const auto *InTE = - InVectors.front().dyn_cast()) { + dyn_cast_if_present(InVectors.front())) { VF = std::max(VF, InTE->getVectorFactor()); } else { VF = std::max(