Skip to content

[llvm] Migrate away from PointerUnion::{is,get} (NFC) #119679

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1813,19 +1813,19 @@ DwarfUnit *CompileUnit::OutputUnitVariantPtr::operator->() {
}

bool CompileUnit::OutputUnitVariantPtr::isCompileUnit() {
return Ptr.is<CompileUnit *>();
return isa<CompileUnit *>(Ptr);
}

bool CompileUnit::OutputUnitVariantPtr::isTypeUnit() {
return Ptr.is<TypeUnit *>();
return isa<TypeUnit *>(Ptr);
}

CompileUnit *CompileUnit::OutputUnitVariantPtr::getAsCompileUnit() {
return Ptr.get<CompileUnit *>();
return cast<CompileUnit *>(Ptr);
}

TypeUnit *CompileUnit::OutputUnitVariantPtr::getAsTypeUnit() {
return Ptr.get<TypeUnit *>();
return cast<TypeUnit *>(Ptr);
}

bool CompileUnit::resolveDependenciesAndMarkLiveness(
Expand Down
30 changes: 15 additions & 15 deletions llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10218,9 +10218,9 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
// sub-Mask into the CommonMask to estimate it later and avoid double cost
// estimation.
if ((InVectors.size() == 2 &&
InVectors.front().get<const TreeEntry *>() == &E1 &&
InVectors.back().get<const TreeEntry *>() == E2) ||
(!E2 && InVectors.front().get<const TreeEntry *>() == &E1)) {
cast<const TreeEntry *>(InVectors.front()) == &E1 &&
cast<const TreeEntry *>(InVectors.back()) == E2) ||
(!E2 && cast<const TreeEntry *>(InVectors.front()) == &E1)) {
unsigned Limit = getNumElems(Mask.size(), SliceSize, Part);
assert(all_of(ArrayRef(CommonMask).slice(Part * SliceSize, Limit),
[](int Idx) { return Idx == PoisonMaskElem; }) &&
Expand All @@ -10246,7 +10246,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
VF = std::max(VF,
cast<FixedVectorType>(V1->getType())->getNumElements());
} else {
const auto *E = InVectors.front().get<const TreeEntry *>();
const auto *E = cast<const TreeEntry *>(InVectors.front());
VF = std::max(VF, E->getVectorFactor());
}
for (unsigned Idx = 0, Sz = CommonMask.size(); Idx < Sz; ++Idx)
Expand All @@ -10262,7 +10262,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
VF = std::max(VF,
getNumElements(V1->getType()));
} else {
const auto *E = P.get<const TreeEntry *>();
const auto *E = cast<const TreeEntry *>(P);
VF = std::max(VF, E->getVectorFactor());
}
for (unsigned Idx = 0, Sz = CommonMask.size(); Idx < Sz; ++Idx)
Expand Down Expand Up @@ -10368,9 +10368,9 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
};
if (!V1 && !V2 && !P2.isNull()) {
// Shuffle 2 entry nodes.
const TreeEntry *E = P1.get<const TreeEntry *>();
const TreeEntry *E = cast<const TreeEntry *>(P1);
unsigned VF = E->getVectorFactor();
const TreeEntry *E2 = P2.get<const TreeEntry *>();
const TreeEntry *E2 = cast<const TreeEntry *>(P2);
CommonVF = std::max(VF, E2->getVectorFactor());
assert(all_of(Mask,
[=](int Idx) {
Expand Down Expand Up @@ -10402,7 +10402,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
V2 = getAllOnesValue(*R.DL, getWidenedType(ScalarTy, CommonVF));
} else if (!V1 && P2.isNull()) {
// Shuffle single entry node.
const TreeEntry *E = P1.get<const TreeEntry *>();
const TreeEntry *E = cast<const TreeEntry *>(P1);
unsigned VF = E->getVectorFactor();
CommonVF = VF;
assert(
Expand Down Expand Up @@ -10451,7 +10451,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
} else if (V1 && !V2) {
// Shuffle vector and tree node.
unsigned VF = getVF(V1);
const TreeEntry *E2 = P2.get<const TreeEntry *>();
const TreeEntry *E2 = cast<const TreeEntry *>(P2);
CommonVF = std::max(VF, E2->getVectorFactor());
assert(all_of(Mask,
[=](int Idx) {
Expand All @@ -10477,7 +10477,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
} else if (!V1 && V2) {
// Shuffle vector and tree node.
unsigned VF = getVF(V2);
const TreeEntry *E1 = P1.get<const TreeEntry *>();
const TreeEntry *E1 = cast<const TreeEntry *>(P1);
CommonVF = std::max(VF, E1->getVectorFactor());
assert(all_of(Mask,
[=](int Idx) {
Expand Down Expand Up @@ -10715,8 +10715,8 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
if (P.value() == PoisonMaskElem)
return Mask[P.index()] == PoisonMaskElem;
auto *EI = cast<ExtractElementInst>(
InVectors.front().get<const TreeEntry *>()->getOrdered(
P.index()));
cast<const TreeEntry *>(InVectors.front())
->getOrdered(P.index()));
return EI->getVectorOperand() == V1 ||
EI->getVectorOperand() == V2;
}) &&
Expand All @@ -10734,7 +10734,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
if (ForExtracts) {
// No need to add vectors here, already handled them in adjustExtracts.
assert(
InVectors.size() == 1 && InVectors.front().is<const TreeEntry *>() &&
InVectors.size() == 1 && isa<const TreeEntry *>(InVectors.front()) &&
!CommonMask.empty() &&
all_of(enumerate(CommonMask),
[&](auto P) {
Expand Down Expand Up @@ -10764,7 +10764,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
VF = std::max(VF, InTE->getVectorFactor());
} else {
VF = std::max(
VF, cast<FixedVectorType>(InVectors.front().get<Value *>()->getType())
VF, cast<FixedVectorType>(cast<Value *>(InVectors.front())->getType())
->getNumElements());
}
InVectors.push_back(V1);
Expand Down Expand Up @@ -10834,7 +10834,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
CommonMask[Idx] = Idx;
assert(VF > 0 &&
"Expected vector length for the final value before action.");
Value *V = Vec.get<Value *>();
Value *V = cast<Value *>(Vec);
Action(V, CommonMask);
InVectors.front() = V;
}
Expand Down
8 changes: 4 additions & 4 deletions llvm/unittests/IR/IRBuilderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,12 +881,12 @@ TEST_F(IRBuilderTest, DIBuilder) {

auto ExpectOrder = [&](DbgInstPtr First, BasicBlock::iterator Second) {
if (M->IsNewDbgInfoFormat) {
EXPECT_TRUE(First.is<DbgRecord *>());
EXPECT_TRUE(isa<DbgRecord *>(First));
EXPECT_FALSE(Second->getDbgRecordRange().empty());
EXPECT_EQ(GetLastDbgRecord(&*Second), First.get<DbgRecord *>());
EXPECT_EQ(GetLastDbgRecord(&*Second), cast<DbgRecord *>(First));
} else {
EXPECT_TRUE(First.is<Instruction *>());
EXPECT_EQ(&*std::prev(Second), First.get<Instruction *>());
EXPECT_TRUE(isa<Instruction *>(First));
EXPECT_EQ(&*std::prev(Second), cast<Instruction *>(First));
}
};

Expand Down
Loading