-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[llvm] Migrate away from PointerUnion::dyn_cast (NFC) #123692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3542,7 +3542,7 @@ void ModuleCallsiteContextGraph::updateAllocationCall( | |
|
|
||
| void IndexCallsiteContextGraph::updateAllocationCall(CallInfo &Call, | ||
| AllocationType AllocType) { | ||
| auto *AI = Call.call().dyn_cast<AllocInfo *>(); | ||
| auto *AI = dyn_cast_if_present<AllocInfo *>(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<AllocInfo *>(); | ||
| const auto *AI = dyn_cast_if_present<AllocInfo *>(Call.call()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, directly dereferenced. |
||
| 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<CallsiteInfo *>(); | ||
| auto *CI = dyn_cast_if_present<CallsiteInfo *>(CallerCall.call()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also has an assert. |
||
| 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<AllocInfo *>(Call.call()) | ||
| ? Call.call().dyn_cast<AllocInfo *>()->Versions.size() | ||
| : Call.call().dyn_cast<CallsiteInfo *>()->Clones.size())); | ||
| assert( | ||
| CloneNo == | ||
| (isa<AllocInfo *>(Call.call()) | ||
| ? dyn_cast_if_present<AllocInfo *>(Call.call())->Versions.size() | ||
| : dyn_cast_if_present<CallsiteInfo *>(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<AllocInfo *>()) { | ||
| if (auto *AI = dyn_cast_if_present<AllocInfo *>(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<CallsiteInfo *>(); | ||
| auto *CI = dyn_cast_if_present<CallsiteInfo *>(Inst.call()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be cast<> which implies above can be dyn_cast<>. |
||
| assert(CI && CI->Clones.size() == CloneNo); | ||
| // We assign the clone number later (in updateCall), just add an entry for | ||
| // it here. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the following assert, this should be just cast<>.