Skip to content

Commit 5b19ed8

Browse files
[llvm] Migrate away from PointerUnion::{is,get,dyn_cast} (NFC) (llvm#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>
1 parent 91a48e0 commit 5b19ed8

File tree

8 files changed

+26
-28
lines changed

8 files changed

+26
-28
lines changed

llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,10 +1051,10 @@ class AssignmentTrackingLowering {
10511051
OS << ", s=";
10521052
if (Source.isNull())
10531053
OS << "null";
1054-
else if (isa<DbgAssignIntrinsic *>(Source))
1055-
OS << Source.get<DbgAssignIntrinsic *>();
1054+
else if (const auto *DAI = dyn_cast<DbgAssignIntrinsic *>(Source))
1055+
OS << DAI;
10561056
else
1057-
OS << Source.get<DbgVariableRecord *>();
1057+
OS << cast<DbgVariableRecord *>(Source);
10581058
OS << ")";
10591059
}
10601060

llvm/lib/CodeGen/GlobalISel/Utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ bool llvm::canReplaceReg(Register DstReg, Register SrcReg,
214214

215215
// Otherwise match if the Src is already a regclass that is covered by the Dst
216216
// RegBank.
217-
return DstRBC.is<const RegisterBank *>() && MRI.getRegClassOrNull(SrcReg) &&
218-
DstRBC.get<const RegisterBank *>()->covers(
217+
return isa<const RegisterBank *>(DstRBC) && MRI.getRegClassOrNull(SrcReg) &&
218+
cast<const RegisterBank *>(DstRBC)->covers(
219219
*MRI.getRegClassOrNull(SrcReg));
220220
}
221221

llvm/lib/IR/DIBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,8 +1033,8 @@ DbgInstPtr DIBuilder::insertDbgValueIntrinsic(Value *V,
10331033
DbgInstPtr DVI = insertDbgValueIntrinsic(
10341034
V, VarInfo, Expr, DL, InsertBefore ? InsertBefore->getParent() : nullptr,
10351035
InsertBefore);
1036-
if (DVI.is<Instruction *>())
1037-
cast<CallInst>(DVI.get<Instruction *>())->setTailCall();
1036+
if (auto *Inst = dyn_cast<Instruction *>(DVI))
1037+
cast<CallInst>(Inst)->setTailCall();
10381038
return DVI;
10391039
}
10401040

llvm/lib/IR/DebugInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,10 +2099,10 @@ static void emitDbgAssign(AssignmentInfo Info, Value *Val, Value *Dest,
20992099
AddrExpr, VarRec.DL);
21002100
(void)Assign;
21012101
LLVM_DEBUG(if (!Assign.isNull()) {
2102-
if (Assign.is<DbgRecord *>())
2103-
errs() << " > INSERT: " << *Assign.get<DbgRecord *>() << "\n";
2102+
if (const auto *Record = dyn_cast<DbgRecord *>(Assign))
2103+
errs() << " > INSERT: " << *Record << "\n";
21042104
else
2105-
errs() << " > INSERT: " << *Assign.get<Instruction *>() << "\n";
2105+
errs() << " > INSERT: " << *cast<Instruction *>(Assign) << "\n";
21062106
});
21072107
}
21082108

llvm/lib/IR/Metadata.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ ReplaceableMetadataImpl::getAllDbgVariableRecordUsers() {
274274
OwnerTy Owner = Pair.second.first;
275275
if (Owner.isNull())
276276
continue;
277-
if (!Owner.is<DebugValueUser *>())
277+
if (!isa<DebugValueUser *>(Owner))
278278
continue;
279279
DVRUsersWithID.push_back(&UseMap[Pair.first]);
280280
}
@@ -288,7 +288,7 @@ ReplaceableMetadataImpl::getAllDbgVariableRecordUsers() {
288288
});
289289
SmallVector<DbgVariableRecord *> DVRUsers;
290290
for (auto UserWithID : DVRUsersWithID)
291-
DVRUsers.push_back(UserWithID->first.get<DebugValueUser *>()->getUser());
291+
DVRUsers.push_back(cast<DebugValueUser *>(UserWithID->first)->getUser());
292292
return DVRUsers;
293293
}
294294

@@ -396,8 +396,8 @@ void ReplaceableMetadataImpl::replaceAllUsesWith(Metadata *MD) {
396396
continue;
397397
}
398398

399-
if (Owner.is<DebugValueUser *>()) {
400-
Owner.get<DebugValueUser *>()->handleChangedValue(Pair.first, MD);
399+
if (auto *DVU = dyn_cast<DebugValueUser *>(Owner)) {
400+
DVU->handleChangedValue(Pair.first, MD);
401401
continue;
402402
}
403403

@@ -436,7 +436,7 @@ void ReplaceableMetadataImpl::resolveAllUses(bool ResolveUsers) {
436436
auto Owner = Pair.second.first;
437437
if (!Owner)
438438
continue;
439-
if (!Owner.is<Metadata *>())
439+
if (!isa<Metadata *>(Owner))
440440
continue;
441441

442442
// Resolve MDNodes that point at this.

llvm/lib/SandboxIR/Tracker.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ void EraseFromParent::accept() {
111111
void EraseFromParent::revert(Tracker &Tracker) {
112112
// Place the bottom-most instruction first.
113113
auto [Operands, BotLLVMI] = InstrData[0];
114-
if (auto *NextLLVMI = NextLLVMIOrBB.dyn_cast<llvm::Instruction *>()) {
114+
if (auto *NextLLVMI = dyn_cast<llvm::Instruction *>(NextLLVMIOrBB)) {
115115
BotLLVMI->insertBefore(NextLLVMI);
116116
} else {
117-
auto *LLVMBB = NextLLVMIOrBB.get<llvm::BasicBlock *>();
117+
auto *LLVMBB = cast<llvm::BasicBlock *>(NextLLVMIOrBB);
118118
BotLLVMI->insertInto(LLVMBB, LLVMBB->end());
119119
}
120120
for (auto [OpNum, Op] : enumerate(Operands))
@@ -145,10 +145,10 @@ RemoveFromParent::RemoveFromParent(Instruction *RemovedI) : RemovedI(RemovedI) {
145145
}
146146

147147
void RemoveFromParent::revert(Tracker &Tracker) {
148-
if (auto *NextI = NextInstrOrBB.dyn_cast<Instruction *>()) {
148+
if (auto *NextI = dyn_cast<Instruction *>(NextInstrOrBB)) {
149149
RemovedI->insertBefore(NextI);
150150
} else {
151-
auto *BB = NextInstrOrBB.get<BasicBlock *>();
151+
auto *BB = cast<BasicBlock *>(NextInstrOrBB);
152152
RemovedI->insertInto(BB, BB->end());
153153
}
154154
}
@@ -199,10 +199,10 @@ MoveInstr::MoveInstr(Instruction *MovedI) : MovedI(MovedI) {
199199
}
200200

201201
void MoveInstr::revert(Tracker &Tracker) {
202-
if (auto *NextI = NextInstrOrBB.dyn_cast<Instruction *>()) {
202+
if (auto *NextI = dyn_cast<Instruction *>(NextInstrOrBB)) {
203203
MovedI->moveBefore(NextI);
204204
} else {
205-
auto *BB = NextInstrOrBB.get<BasicBlock *>();
205+
auto *BB = cast<BasicBlock *>(NextInstrOrBB);
206206
MovedI->moveBefore(*BB, BB->end());
207207
}
208208
}

llvm/lib/Transforms/Scalar/SROA.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5166,11 +5166,9 @@ insertNewDbgInst(DIBuilder &DIB, DbgAssignIntrinsic *Orig, AllocaInst *NewAddr,
51665166
DIAssignID::getDistinct(NewAddr->getContext()));
51675167
}
51685168

5169-
Instruction *NewAssign =
5170-
DIB.insertDbgAssign(NewAddr, Orig->getValue(), Orig->getVariable(),
5171-
NewFragmentExpr, NewAddr, NewAddrExpr,
5172-
Orig->getDebugLoc())
5173-
.get<Instruction *>();
5169+
Instruction *NewAssign = cast<Instruction *>(DIB.insertDbgAssign(
5170+
NewAddr, Orig->getValue(), Orig->getVariable(), NewFragmentExpr, NewAddr,
5171+
NewAddrExpr, Orig->getDebugLoc()));
51745172
LLVM_DEBUG(dbgs() << "Created new assign intrinsic: " << *NewAssign << "\n");
51755173
(void)NewAssign;
51765174
}

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,7 @@ static void insertDbgValueOrDbgVariableRecord(DIBuilder &Builder, Value *DV,
16961696
if (!UseNewDbgInfoFormat) {
16971697
auto DbgVal = Builder.insertDbgValueIntrinsic(DV, DIVar, DIExpr, NewLoc,
16981698
(Instruction *)nullptr);
1699-
DbgVal.get<Instruction *>()->insertBefore(Instr);
1699+
cast<Instruction *>(DbgVal)->insertBefore(Instr);
17001700
} else {
17011701
// RemoveDIs: if we're using the new debug-info format, allocate a
17021702
// DbgVariableRecord directly instead of a dbg.value intrinsic.
@@ -1713,7 +1713,7 @@ static void insertDbgValueOrDbgVariableRecordAfter(
17131713
if (!UseNewDbgInfoFormat) {
17141714
auto DbgVal = Builder.insertDbgValueIntrinsic(DV, DIVar, DIExpr, NewLoc,
17151715
(Instruction *)nullptr);
1716-
DbgVal.get<Instruction *>()->insertAfter(&*Instr);
1716+
cast<Instruction *>(DbgVal)->insertAfter(&*Instr);
17171717
} else {
17181718
// RemoveDIs: if we're using the new debug-info format, allocate a
17191719
// DbgVariableRecord directly instead of a dbg.value intrinsic.

0 commit comments

Comments
 (0)