aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Verifier.cpp
diff options
context:
space:
mode:
authorJeremy Morse <jeremy.morse@sony.com>2025-01-24 13:27:56 +0000
committerGitHub <noreply@github.com>2025-01-24 13:27:56 +0000
commit6292a808b3524d9ba6f4ce55bc5b9e547b088dd8 (patch)
tree75d8253ec7b5085328930a26daf1f20c39682f80 /llvm/lib/IR/Verifier.cpp
parenta5cc897cdedfdca018a83fac5734ebe086acb817 (diff)
downloadllvm-6292a808b3524d9ba6f4ce55bc5b9e547b088dd8.zip
llvm-6292a808b3524d9ba6f4ce55bc5b9e547b088dd8.tar.gz
llvm-6292a808b3524d9ba6f4ce55bc5b9e547b088dd8.tar.bz2
[NFC][DebugInfo] Use iterator-flavour getFirstNonPHI at many call-sites (#123737)
As part of the "RemoveDIs" project, BasicBlock::iterator now carries a debug-info bit that's needed when getFirstNonPHI and similar feed into instruction insertion positions. Call-sites where that's necessary were updated a year ago; but to ensure some type safety however, we'd like to have all calls to getFirstNonPHI use the iterator-returning version. This patch changes a bunch of call-sites calling getFirstNonPHI to use getFirstNonPHIIt, which returns an iterator. All these call sites are where it's obviously safe to fetch the iterator then dereference it. A follow-up patch will contain less-obviously-safe changes. We'll eventually deprecate and remove the instruction-pointer getFirstNonPHI, but not before adding concise documentation of what considerations are needed (very few). --------- Co-authored-by: Stephen Tozer <Melamoto@gmail.com>
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r--llvm/lib/IR/Verifier.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 00280db..54de812 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2726,7 +2726,7 @@ static Instruction *getSuccPad(Instruction *Terminator) {
UnwindDest = CSI->getUnwindDest();
else
UnwindDest = cast<CleanupReturnInst>(Terminator)->getUnwindDest();
- return UnwindDest->getFirstNonPHI();
+ return &*UnwindDest->getFirstNonPHIIt();
}
void Verifier::verifySiblingFuncletUnwinds() {
@@ -4585,7 +4585,7 @@ void Verifier::visitCatchPadInst(CatchPadInst &CPI) {
// The catchpad instruction must be the first non-PHI instruction in the
// block.
- Check(BB->getFirstNonPHI() == &CPI,
+ Check(&*BB->getFirstNonPHIIt() == &CPI,
"CatchPadInst not the first non-PHI instruction in the block.", &CPI);
visitEHPadPredecessors(CPI);
@@ -4609,7 +4609,7 @@ void Verifier::visitCleanupPadInst(CleanupPadInst &CPI) {
// The cleanuppad instruction must be the first non-PHI instruction in the
// block.
- Check(BB->getFirstNonPHI() == &CPI,
+ Check(&*BB->getFirstNonPHIIt() == &CPI,
"CleanupPadInst not the first non-PHI instruction in the block.", &CPI);
auto *ParentPad = CPI.getParentPad();
@@ -4664,7 +4664,7 @@ void Verifier::visitFuncletPadInst(FuncletPadInst &FPI) {
Value *UnwindPad;
bool ExitsFPI;
if (UnwindDest) {
- UnwindPad = UnwindDest->getFirstNonPHI();
+ UnwindPad = &*UnwindDest->getFirstNonPHIIt();
if (!cast<Instruction>(UnwindPad)->isEHPad())
continue;
Value *UnwindParent = getParentPad(UnwindPad);
@@ -4767,7 +4767,7 @@ void Verifier::visitFuncletPadInst(FuncletPadInst &FPI) {
BasicBlock *SwitchUnwindDest = CatchSwitch->getUnwindDest();
Value *SwitchUnwindPad;
if (SwitchUnwindDest)
- SwitchUnwindPad = SwitchUnwindDest->getFirstNonPHI();
+ SwitchUnwindPad = &*SwitchUnwindDest->getFirstNonPHIIt();
else
SwitchUnwindPad = ConstantTokenNone::get(FPI.getContext());
Check(SwitchUnwindPad == FirstUnwindPad,
@@ -4790,7 +4790,7 @@ void Verifier::visitCatchSwitchInst(CatchSwitchInst &CatchSwitch) {
// The catchswitch instruction must be the first non-PHI instruction in the
// block.
- Check(BB->getFirstNonPHI() == &CatchSwitch,
+ Check(&*BB->getFirstNonPHIIt() == &CatchSwitch,
"CatchSwitchInst not the first non-PHI instruction in the block.",
&CatchSwitch);
@@ -4799,14 +4799,14 @@ void Verifier::visitCatchSwitchInst(CatchSwitchInst &CatchSwitch) {
"CatchSwitchInst has an invalid parent.", ParentPad);
if (BasicBlock *UnwindDest = CatchSwitch.getUnwindDest()) {
- Instruction *I = UnwindDest->getFirstNonPHI();
+ BasicBlock::iterator I = UnwindDest->getFirstNonPHIIt();
Check(I->isEHPad() && !isa<LandingPadInst>(I),
"CatchSwitchInst must unwind to an EH block which is not a "
"landingpad.",
&CatchSwitch);
// Record catchswitch sibling unwinds for verifySiblingFuncletUnwinds
- if (getParentPad(I) == ParentPad)
+ if (getParentPad(&*I) == ParentPad)
SiblingFuncletInfo[&CatchSwitch] = &CatchSwitch;
}
@@ -4814,7 +4814,7 @@ void Verifier::visitCatchSwitchInst(CatchSwitchInst &CatchSwitch) {
"CatchSwitchInst cannot have empty handler list", &CatchSwitch);
for (BasicBlock *Handler : CatchSwitch.handlers()) {
- Check(isa<CatchPadInst>(Handler->getFirstNonPHI()),
+ Check(isa<CatchPadInst>(Handler->getFirstNonPHIIt()),
"CatchSwitchInst handlers must be catchpads", &CatchSwitch, Handler);
}
@@ -4828,7 +4828,7 @@ void Verifier::visitCleanupReturnInst(CleanupReturnInst &CRI) {
CRI.getOperand(0));
if (BasicBlock *UnwindDest = CRI.getUnwindDest()) {
- Instruction *I = UnwindDest->getFirstNonPHI();
+ BasicBlock::iterator I = UnwindDest->getFirstNonPHIIt();
Check(I->isEHPad() && !isa<LandingPadInst>(I),
"CleanupReturnInst must unwind to an EH block which is not a "
"landingpad.",