Skip to content

Commit 767de86

Browse files
[llvm] Migrate away from PointerUnion::dyn_cast (NFC)
Note that PointerUnion::dyn_cast has been soft deprecated in PointerUnion.h: // FIXME: Replace the uses of is(), get() and dyn_cast() with // isa<T>, cast<T> and the llvm::dyn_cast<T>
1 parent 79231a8 commit 767de86

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3542,7 +3542,7 @@ void ModuleCallsiteContextGraph::updateAllocationCall(
35423542

35433543
void 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

35613561
AllocationType
35623562
IndexCallsiteContextGraph::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

35803580
void 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.

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10354,7 +10354,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
1035410354
SameNodesEstimated = false;
1035510355
if (!E2 && InVectors.size() == 1) {
1035610356
unsigned VF = E1.getVectorFactor();
10357-
if (Value *V1 = InVectors.front().dyn_cast<Value *>()) {
10357+
if (Value *V1 = dyn_cast_if_present<Value *>(InVectors.front())) {
1035810358
VF = std::max(VF,
1035910359
cast<FixedVectorType>(V1->getType())->getNumElements());
1036010360
} else {
@@ -10370,7 +10370,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
1037010370
auto P = InVectors.front();
1037110371
Cost += createShuffle(&E1, E2, Mask);
1037210372
unsigned VF = Mask.size();
10373-
if (Value *V1 = P.dyn_cast<Value *>()) {
10373+
if (Value *V1 = dyn_cast_if_present<Value *>(P)) {
1037410374
VF = std::max(VF,
1037510375
getNumElements(V1->getType()));
1037610376
} else {
@@ -10435,7 +10435,8 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
1043510435
ArrayRef<int> Mask) {
1043610436
ShuffleCostBuilder Builder(TTI);
1043710437
SmallVector<int> CommonMask(Mask);
10438-
Value *V1 = P1.dyn_cast<Value *>(), *V2 = P2.dyn_cast<Value *>();
10438+
Value *V1 = dyn_cast_if_present<Value *>(P1);
10439+
Value *V2 = dyn_cast_if_present<Value *>(P2);
1043910440
unsigned CommonVF = Mask.size();
1044010441
InstructionCost ExtraCost = 0;
1044110442
auto GetNodeMinBWAffectedCost = [&](const TreeEntry &E,
@@ -10870,7 +10871,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
1087010871
transformMaskAfterShuffle(CommonMask, CommonMask);
1087110872
VF = std::max<unsigned>(VF, CommonMask.size());
1087210873
} else if (const auto *InTE =
10873-
InVectors.front().dyn_cast<const TreeEntry *>()) {
10874+
dyn_cast_if_present<const TreeEntry *>(InVectors.front())) {
1087410875
VF = std::max(VF, InTE->getVectorFactor());
1087510876
} else {
1087610877
VF = std::max(

0 commit comments

Comments
 (0)