@@ -3542,7 +3542,7 @@ void ModuleCallsiteContextGraph::updateAllocationCall(
35423542
35433543void IndexCallsiteContextGraph::updateAllocationCall (CallInfo &Call,
35443544 AllocationType AllocType) {
3545- auto *AI = Call. call (). dyn_cast <AllocInfo *>();
3545+ auto *AI = dyn_cast_if_present <AllocInfo *>(Call. call () );
35463546 assert (AI);
35473547 assert (AI->Versions .size () > Call.cloneNo ());
35483548 AI->Versions [Call.cloneNo ()] = (uint8_t )AllocType;
@@ -3560,7 +3560,7 @@ ModuleCallsiteContextGraph::getAllocationCallType(const CallInfo &Call) const {
35603560
35613561AllocationType
35623562IndexCallsiteContextGraph::getAllocationCallType (const CallInfo &Call) const {
3563- const auto *AI = Call. call (). dyn_cast <AllocInfo *>();
3563+ const auto *AI = dyn_cast_if_present <AllocInfo *>(Call. call () );
35643564 assert (AI->Versions .size () > Call.cloneNo ());
35653565 return (AllocationType)AI->Versions [Call.cloneNo ()];
35663566}
@@ -3579,7 +3579,7 @@ void ModuleCallsiteContextGraph::updateCall(CallInfo &CallerCall,
35793579
35803580void IndexCallsiteContextGraph::updateCall (CallInfo &CallerCall,
35813581 FuncInfo CalleeFunc) {
3582- auto *CI = CallerCall. call (). dyn_cast <CallsiteInfo *>();
3582+ auto *CI = dyn_cast_if_present <CallsiteInfo *>(CallerCall. call () );
35833583 assert (CI &&
35843584 " Caller cannot be an allocation which should not have profiled calls" );
35853585 assert (CI->Clones .size () > CallerCall.cloneNo ());
@@ -3617,10 +3617,11 @@ IndexCallsiteContextGraph::cloneFunctionForCallsite(
36173617 // The next clone number is the current size of versions array.
36183618 // Confirm this matches the CloneNo provided by the caller, which is based on
36193619 // the number of function clones we have.
3620- assert (CloneNo ==
3621- (isa<AllocInfo *>(Call.call ())
3622- ? Call.call ().dyn_cast <AllocInfo *>()->Versions .size ()
3623- : Call.call ().dyn_cast <CallsiteInfo *>()->Clones .size ()));
3620+ assert (
3621+ CloneNo ==
3622+ (isa<AllocInfo *>(Call.call ())
3623+ ? dyn_cast_if_present<AllocInfo *>(Call.call ())->Versions .size ()
3624+ : dyn_cast_if_present<CallsiteInfo *>(Call.call ())->Clones .size ()));
36243625 // Walk all the instructions in this function. Create a new version for
36253626 // each (by adding an entry to the Versions/Clones summary array), and copy
36263627 // over the version being called for the function clone being cloned here.
@@ -3630,13 +3631,13 @@ IndexCallsiteContextGraph::cloneFunctionForCallsite(
36303631 for (auto &Inst : CallsWithMetadataInFunc) {
36313632 // This map always has the initial version in it.
36323633 assert (Inst.cloneNo () == 0 );
3633- if (auto *AI = Inst. call (). dyn_cast <AllocInfo *>()) {
3634+ if (auto *AI = dyn_cast_if_present <AllocInfo *>(Inst. call () )) {
36343635 assert (AI->Versions .size () == CloneNo);
36353636 // We assign the allocation type later (in updateAllocationCall), just add
36363637 // an entry for it here.
36373638 AI->Versions .push_back (0 );
36383639 } else {
3639- auto *CI = Inst. call (). dyn_cast <CallsiteInfo *>();
3640+ auto *CI = dyn_cast_if_present <CallsiteInfo *>(Inst. call () );
36403641 assert (CI && CI->Clones .size () == CloneNo);
36413642 // We assign the clone number later (in updateCall), just add an entry for
36423643 // it here.
0 commit comments