Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,9 +1052,9 @@ class AssignmentTrackingLowering {
if (Source.isNull())
OS << "null";
else if (isa<DbgAssignIntrinsic *>(Source))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't these use dyn_cast? It is isa + cast.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's much cleaner. Thanks! Updated in the latest revision.

OS << Source.get<DbgAssignIntrinsic *>();
OS << cast<DbgAssignIntrinsic *>(Source);
else
OS << Source.get<DbgVariableRecord *>();
OS << cast<DbgVariableRecord *>(Source);
OS << ")";
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/GlobalISel/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/IR/DIBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 (isa<Instruction *>(DVI))
cast<CallInst>(cast<Instruction *>(DVI))->setTailCall();
return DVI;
}

Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/IR/DebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 (isa<DbgRecord *>(Assign))
errs() << " > INSERT: " << *cast<DbgRecord *>(Assign) << "\n";
else
errs() << " > INSERT: " << *Assign.get<Instruction *>() << "\n";
errs() << " > INSERT: " << *cast<Instruction *>(Assign) << "\n";
});
}

Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/IR/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -396,8 +396,8 @@ void ReplaceableMetadataImpl::replaceAllUsesWith(Metadata *MD) {
continue;
}

if (Owner.is<DebugValueUser *>()) {
Owner.get<DebugValueUser *>()->handleChangedValue(Pair.first, MD);
if (isa<DebugValueUser *>(Owner)) {
cast<DebugValueUser *>(Owner)->handleChangedValue(Pair.first, MD);
continue;
}

Expand Down Expand Up @@ -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.
Expand Down
12 changes: 6 additions & 6 deletions llvm/lib/SandboxIR/Tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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());
}
}
Expand Down Expand Up @@ -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());
}
}
Expand Down
8 changes: 3 additions & 5 deletions llvm/lib/Transforms/Scalar/SROA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Utils/Local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
Loading