Skip to content

Commit 2f8238f

Browse files
[llvm] Migrate away from PointerUnion::{is,get} (NFC) (#119679)
Note that PointerUnion::{is,get} have 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> I'm not touching PointerUnion::dyn_cast for now because it's a bit complicated; we could blindly migrate it to dyn_cast_if_present, but we should probably use dyn_cast when the operand is known to be non-null.
1 parent a8e66d7 commit 2f8238f

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,19 +1813,19 @@ DwarfUnit *CompileUnit::OutputUnitVariantPtr::operator->() {
18131813
}
18141814

18151815
bool CompileUnit::OutputUnitVariantPtr::isCompileUnit() {
1816-
return Ptr.is<CompileUnit *>();
1816+
return isa<CompileUnit *>(Ptr);
18171817
}
18181818

18191819
bool CompileUnit::OutputUnitVariantPtr::isTypeUnit() {
1820-
return Ptr.is<TypeUnit *>();
1820+
return isa<TypeUnit *>(Ptr);
18211821
}
18221822

18231823
CompileUnit *CompileUnit::OutputUnitVariantPtr::getAsCompileUnit() {
1824-
return Ptr.get<CompileUnit *>();
1824+
return cast<CompileUnit *>(Ptr);
18251825
}
18261826

18271827
TypeUnit *CompileUnit::OutputUnitVariantPtr::getAsTypeUnit() {
1828-
return Ptr.get<TypeUnit *>();
1828+
return cast<TypeUnit *>(Ptr);
18291829
}
18301830

18311831
bool CompileUnit::resolveDependenciesAndMarkLiveness(

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10218,9 +10218,9 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
1021810218
// sub-Mask into the CommonMask to estimate it later and avoid double cost
1021910219
// estimation.
1022010220
if ((InVectors.size() == 2 &&
10221-
InVectors.front().get<const TreeEntry *>() == &E1 &&
10222-
InVectors.back().get<const TreeEntry *>() == E2) ||
10223-
(!E2 && InVectors.front().get<const TreeEntry *>() == &E1)) {
10221+
cast<const TreeEntry *>(InVectors.front()) == &E1 &&
10222+
cast<const TreeEntry *>(InVectors.back()) == E2) ||
10223+
(!E2 && cast<const TreeEntry *>(InVectors.front()) == &E1)) {
1022410224
unsigned Limit = getNumElems(Mask.size(), SliceSize, Part);
1022510225
assert(all_of(ArrayRef(CommonMask).slice(Part * SliceSize, Limit),
1022610226
[](int Idx) { return Idx == PoisonMaskElem; }) &&
@@ -10246,7 +10246,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
1024610246
VF = std::max(VF,
1024710247
cast<FixedVectorType>(V1->getType())->getNumElements());
1024810248
} else {
10249-
const auto *E = InVectors.front().get<const TreeEntry *>();
10249+
const auto *E = cast<const TreeEntry *>(InVectors.front());
1025010250
VF = std::max(VF, E->getVectorFactor());
1025110251
}
1025210252
for (unsigned Idx = 0, Sz = CommonMask.size(); Idx < Sz; ++Idx)
@@ -10262,7 +10262,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
1026210262
VF = std::max(VF,
1026310263
getNumElements(V1->getType()));
1026410264
} else {
10265-
const auto *E = P.get<const TreeEntry *>();
10265+
const auto *E = cast<const TreeEntry *>(P);
1026610266
VF = std::max(VF, E->getVectorFactor());
1026710267
}
1026810268
for (unsigned Idx = 0, Sz = CommonMask.size(); Idx < Sz; ++Idx)
@@ -10368,9 +10368,9 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
1036810368
};
1036910369
if (!V1 && !V2 && !P2.isNull()) {
1037010370
// Shuffle 2 entry nodes.
10371-
const TreeEntry *E = P1.get<const TreeEntry *>();
10371+
const TreeEntry *E = cast<const TreeEntry *>(P1);
1037210372
unsigned VF = E->getVectorFactor();
10373-
const TreeEntry *E2 = P2.get<const TreeEntry *>();
10373+
const TreeEntry *E2 = cast<const TreeEntry *>(P2);
1037410374
CommonVF = std::max(VF, E2->getVectorFactor());
1037510375
assert(all_of(Mask,
1037610376
[=](int Idx) {
@@ -10402,7 +10402,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
1040210402
V2 = getAllOnesValue(*R.DL, getWidenedType(ScalarTy, CommonVF));
1040310403
} else if (!V1 && P2.isNull()) {
1040410404
// Shuffle single entry node.
10405-
const TreeEntry *E = P1.get<const TreeEntry *>();
10405+
const TreeEntry *E = cast<const TreeEntry *>(P1);
1040610406
unsigned VF = E->getVectorFactor();
1040710407
CommonVF = VF;
1040810408
assert(
@@ -10451,7 +10451,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
1045110451
} else if (V1 && !V2) {
1045210452
// Shuffle vector and tree node.
1045310453
unsigned VF = getVF(V1);
10454-
const TreeEntry *E2 = P2.get<const TreeEntry *>();
10454+
const TreeEntry *E2 = cast<const TreeEntry *>(P2);
1045510455
CommonVF = std::max(VF, E2->getVectorFactor());
1045610456
assert(all_of(Mask,
1045710457
[=](int Idx) {
@@ -10477,7 +10477,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
1047710477
} else if (!V1 && V2) {
1047810478
// Shuffle vector and tree node.
1047910479
unsigned VF = getVF(V2);
10480-
const TreeEntry *E1 = P1.get<const TreeEntry *>();
10480+
const TreeEntry *E1 = cast<const TreeEntry *>(P1);
1048110481
CommonVF = std::max(VF, E1->getVectorFactor());
1048210482
assert(all_of(Mask,
1048310483
[=](int Idx) {
@@ -10715,8 +10715,8 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
1071510715
if (P.value() == PoisonMaskElem)
1071610716
return Mask[P.index()] == PoisonMaskElem;
1071710717
auto *EI = cast<ExtractElementInst>(
10718-
InVectors.front().get<const TreeEntry *>()->getOrdered(
10719-
P.index()));
10718+
cast<const TreeEntry *>(InVectors.front())
10719+
->getOrdered(P.index()));
1072010720
return EI->getVectorOperand() == V1 ||
1072110721
EI->getVectorOperand() == V2;
1072210722
}) &&
@@ -10734,7 +10734,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
1073410734
if (ForExtracts) {
1073510735
// No need to add vectors here, already handled them in adjustExtracts.
1073610736
assert(
10737-
InVectors.size() == 1 && InVectors.front().is<const TreeEntry *>() &&
10737+
InVectors.size() == 1 && isa<const TreeEntry *>(InVectors.front()) &&
1073810738
!CommonMask.empty() &&
1073910739
all_of(enumerate(CommonMask),
1074010740
[&](auto P) {
@@ -10764,7 +10764,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
1076410764
VF = std::max(VF, InTE->getVectorFactor());
1076510765
} else {
1076610766
VF = std::max(
10767-
VF, cast<FixedVectorType>(InVectors.front().get<Value *>()->getType())
10767+
VF, cast<FixedVectorType>(cast<Value *>(InVectors.front())->getType())
1076810768
->getNumElements());
1076910769
}
1077010770
InVectors.push_back(V1);
@@ -10834,7 +10834,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
1083410834
CommonMask[Idx] = Idx;
1083510835
assert(VF > 0 &&
1083610836
"Expected vector length for the final value before action.");
10837-
Value *V = Vec.get<Value *>();
10837+
Value *V = cast<Value *>(Vec);
1083810838
Action(V, CommonMask);
1083910839
InVectors.front() = V;
1084010840
}

llvm/unittests/IR/IRBuilderTest.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -881,12 +881,12 @@ TEST_F(IRBuilderTest, DIBuilder) {
881881

882882
auto ExpectOrder = [&](DbgInstPtr First, BasicBlock::iterator Second) {
883883
if (M->IsNewDbgInfoFormat) {
884-
EXPECT_TRUE(First.is<DbgRecord *>());
884+
EXPECT_TRUE(isa<DbgRecord *>(First));
885885
EXPECT_FALSE(Second->getDbgRecordRange().empty());
886-
EXPECT_EQ(GetLastDbgRecord(&*Second), First.get<DbgRecord *>());
886+
EXPECT_EQ(GetLastDbgRecord(&*Second), cast<DbgRecord *>(First));
887887
} else {
888-
EXPECT_TRUE(First.is<Instruction *>());
889-
EXPECT_EQ(&*std::prev(Second), First.get<Instruction *>());
888+
EXPECT_TRUE(isa<Instruction *>(First));
889+
EXPECT_EQ(&*std::prev(Second), cast<Instruction *>(First));
890890
}
891891
};
892892

0 commit comments

Comments
 (0)