[llvm] 5b19ed8 - [llvm] Migrate away from PointerUnion::{is,get,dyn_cast} (NFC) (#115626)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 10 07:24:09 PST 2024
Author: Kazu Hirata
Date: 2024-11-10T07:24:06-08:00
New Revision: 5b19ed8bb4a36bd0b96f18151932aebd7a67f0e1
URL: https://github.com/llvm/llvm-project/commit/5b19ed8bb4a36bd0b96f18151932aebd7a67f0e1
DIFF: https://github.com/llvm/llvm-project/commit/5b19ed8bb4a36bd0b96f18151932aebd7a67f0e1.diff
LOG: [llvm] Migrate away from PointerUnion::{is,get,dyn_cast} (NFC) (#115626)
Note that PointerUnion::{is,get,dyn_cast} 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>
Added:
Modified:
llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
llvm/lib/CodeGen/GlobalISel/Utils.cpp
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/DebugInfo.cpp
llvm/lib/IR/Metadata.cpp
llvm/lib/SandboxIR/Tracker.cpp
llvm/lib/Transforms/Scalar/SROA.cpp
llvm/lib/Transforms/Utils/Local.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
index 59257fd6aadd52..a465f52bfd5936 100644
--- a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
+++ b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
@@ -1051,10 +1051,10 @@ class AssignmentTrackingLowering {
OS << ", s=";
if (Source.isNull())
OS << "null";
- else if (isa<DbgAssignIntrinsic *>(Source))
- OS << Source.get<DbgAssignIntrinsic *>();
+ else if (const auto *DAI = dyn_cast<DbgAssignIntrinsic *>(Source))
+ OS << DAI;
else
- OS << Source.get<DbgVariableRecord *>();
+ OS << cast<DbgVariableRecord *>(Source);
OS << ")";
}
diff --git a/llvm/lib/CodeGen/GlobalISel/Utils.cpp b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
index 5cee07461d7e22..45807a6818ee5e 100644
--- a/llvm/lib/CodeGen/GlobalISel/Utils.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
@@ -214,8 +214,8 @@ bool llvm::canReplaceReg(Register DstReg, Register SrcReg,
// Otherwise match if the Src is already a regclass that is covered by the Dst
// RegBank.
- return DstRBC.is<const RegisterBank *>() && MRI.getRegClassOrNull(SrcReg) &&
- DstRBC.get<const RegisterBank *>()->covers(
+ return isa<const RegisterBank *>(DstRBC) && MRI.getRegClassOrNull(SrcReg) &&
+ cast<const RegisterBank *>(DstRBC)->covers(
*MRI.getRegClassOrNull(SrcReg));
}
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 665eda28c7d871..3d8e12e95b774f 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -1033,8 +1033,8 @@ DbgInstPtr DIBuilder::insertDbgValueIntrinsic(Value *V,
DbgInstPtr DVI = insertDbgValueIntrinsic(
V, VarInfo, Expr, DL, InsertBefore ? InsertBefore->getParent() : nullptr,
InsertBefore);
- if (DVI.is<Instruction *>())
- cast<CallInst>(DVI.get<Instruction *>())->setTailCall();
+ if (auto *Inst = dyn_cast<Instruction *>(DVI))
+ cast<CallInst>(Inst)->setTailCall();
return DVI;
}
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index e20a0f053481ed..e5b45e0082a823 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -2099,10 +2099,10 @@ static void emitDbgAssign(AssignmentInfo Info, Value *Val, Value *Dest,
AddrExpr, VarRec.DL);
(void)Assign;
LLVM_DEBUG(if (!Assign.isNull()) {
- if (Assign.is<DbgRecord *>())
- errs() << " > INSERT: " << *Assign.get<DbgRecord *>() << "\n";
+ if (const auto *Record = dyn_cast<DbgRecord *>(Assign))
+ errs() << " > INSERT: " << *Record << "\n";
else
- errs() << " > INSERT: " << *Assign.get<Instruction *>() << "\n";
+ errs() << " > INSERT: " << *cast<Instruction *>(Assign) << "\n";
});
}
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index 28f2ca550f5ec9..98cfbd11fde58f 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -274,7 +274,7 @@ ReplaceableMetadataImpl::getAllDbgVariableRecordUsers() {
OwnerTy Owner = Pair.second.first;
if (Owner.isNull())
continue;
- if (!Owner.is<DebugValueUser *>())
+ if (!isa<DebugValueUser *>(Owner))
continue;
DVRUsersWithID.push_back(&UseMap[Pair.first]);
}
@@ -288,7 +288,7 @@ ReplaceableMetadataImpl::getAllDbgVariableRecordUsers() {
});
SmallVector<DbgVariableRecord *> DVRUsers;
for (auto UserWithID : DVRUsersWithID)
- DVRUsers.push_back(UserWithID->first.get<DebugValueUser *>()->getUser());
+ DVRUsers.push_back(cast<DebugValueUser *>(UserWithID->first)->getUser());
return DVRUsers;
}
@@ -396,8 +396,8 @@ void ReplaceableMetadataImpl::replaceAllUsesWith(Metadata *MD) {
continue;
}
- if (Owner.is<DebugValueUser *>()) {
- Owner.get<DebugValueUser *>()->handleChangedValue(Pair.first, MD);
+ if (auto *DVU = dyn_cast<DebugValueUser *>(Owner)) {
+ DVU->handleChangedValue(Pair.first, MD);
continue;
}
@@ -436,7 +436,7 @@ void ReplaceableMetadataImpl::resolveAllUses(bool ResolveUsers) {
auto Owner = Pair.second.first;
if (!Owner)
continue;
- if (!Owner.is<Metadata *>())
+ if (!isa<Metadata *>(Owner))
continue;
// Resolve MDNodes that point at this.
diff --git a/llvm/lib/SandboxIR/Tracker.cpp b/llvm/lib/SandboxIR/Tracker.cpp
index abcad39330094d..e4f84dee07e4da 100644
--- a/llvm/lib/SandboxIR/Tracker.cpp
+++ b/llvm/lib/SandboxIR/Tracker.cpp
@@ -111,10 +111,10 @@ void EraseFromParent::accept() {
void EraseFromParent::revert(Tracker &Tracker) {
// Place the bottom-most instruction first.
auto [Operands, BotLLVMI] = InstrData[0];
- if (auto *NextLLVMI = NextLLVMIOrBB.dyn_cast<llvm::Instruction *>()) {
+ if (auto *NextLLVMI = dyn_cast<llvm::Instruction *>(NextLLVMIOrBB)) {
BotLLVMI->insertBefore(NextLLVMI);
} else {
- auto *LLVMBB = NextLLVMIOrBB.get<llvm::BasicBlock *>();
+ auto *LLVMBB = cast<llvm::BasicBlock *>(NextLLVMIOrBB);
BotLLVMI->insertInto(LLVMBB, LLVMBB->end());
}
for (auto [OpNum, Op] : enumerate(Operands))
@@ -145,10 +145,10 @@ RemoveFromParent::RemoveFromParent(Instruction *RemovedI) : RemovedI(RemovedI) {
}
void RemoveFromParent::revert(Tracker &Tracker) {
- if (auto *NextI = NextInstrOrBB.dyn_cast<Instruction *>()) {
+ if (auto *NextI = dyn_cast<Instruction *>(NextInstrOrBB)) {
RemovedI->insertBefore(NextI);
} else {
- auto *BB = NextInstrOrBB.get<BasicBlock *>();
+ auto *BB = cast<BasicBlock *>(NextInstrOrBB);
RemovedI->insertInto(BB, BB->end());
}
}
@@ -199,10 +199,10 @@ MoveInstr::MoveInstr(Instruction *MovedI) : MovedI(MovedI) {
}
void MoveInstr::revert(Tracker &Tracker) {
- if (auto *NextI = NextInstrOrBB.dyn_cast<Instruction *>()) {
+ if (auto *NextI = dyn_cast<Instruction *>(NextInstrOrBB)) {
MovedI->moveBefore(NextI);
} else {
- auto *BB = NextInstrOrBB.get<BasicBlock *>();
+ auto *BB = cast<BasicBlock *>(NextInstrOrBB);
MovedI->moveBefore(*BB, BB->end());
}
}
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp
index 4a23e2bee5ba25..d80af26451ac75 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -5166,11 +5166,9 @@ insertNewDbgInst(DIBuilder &DIB, DbgAssignIntrinsic *Orig, AllocaInst *NewAddr,
DIAssignID::getDistinct(NewAddr->getContext()));
}
- Instruction *NewAssign =
- DIB.insertDbgAssign(NewAddr, Orig->getValue(), Orig->getVariable(),
- NewFragmentExpr, NewAddr, NewAddrExpr,
- Orig->getDebugLoc())
- .get<Instruction *>();
+ Instruction *NewAssign = cast<Instruction *>(DIB.insertDbgAssign(
+ NewAddr, Orig->getValue(), Orig->getVariable(), NewFragmentExpr, NewAddr,
+ NewAddrExpr, Orig->getDebugLoc()));
LLVM_DEBUG(dbgs() << "Created new assign intrinsic: " << *NewAssign << "\n");
(void)NewAssign;
}
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 768765b6c1e632..509b6d62265517 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1696,7 +1696,7 @@ static void insertDbgValueOrDbgVariableRecord(DIBuilder &Builder, Value *DV,
if (!UseNewDbgInfoFormat) {
auto DbgVal = Builder.insertDbgValueIntrinsic(DV, DIVar, DIExpr, NewLoc,
(Instruction *)nullptr);
- DbgVal.get<Instruction *>()->insertBefore(Instr);
+ cast<Instruction *>(DbgVal)->insertBefore(Instr);
} else {
// RemoveDIs: if we're using the new debug-info format, allocate a
// DbgVariableRecord directly instead of a dbg.value intrinsic.
@@ -1713,7 +1713,7 @@ static void insertDbgValueOrDbgVariableRecordAfter(
if (!UseNewDbgInfoFormat) {
auto DbgVal = Builder.insertDbgValueIntrinsic(DV, DIVar, DIExpr, NewLoc,
(Instruction *)nullptr);
- DbgVal.get<Instruction *>()->insertAfter(&*Instr);
+ cast<Instruction *>(DbgVal)->insertAfter(&*Instr);
} else {
// RemoveDIs: if we're using the new debug-info format, allocate a
// DbgVariableRecord directly instead of a dbg.value intrinsic.
More information about the llvm-commits
mailing list