diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2025-01-27 15:25:17 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-27 15:25:17 +0000 |
commit | e14962a39cc6476bebba65e5639b74b0318c7fc3 (patch) | |
tree | 2c5f513c4703b51bc8ea723fe2890910fe7b30e6 /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | 5aafc6d58f3405662902cee006be11e599801b88 (diff) | |
download | llvm-e14962a39cc6476bebba65e5639b74b0318c7fc3.zip llvm-e14962a39cc6476bebba65e5639b74b0318c7fc3.tar.gz llvm-e14962a39cc6476bebba65e5639b74b0318c7fc3.tar.bz2 |
[NFC][DebugInfo] Use iterators for instruction insertion in more places (#124291)
As part of the "RemoveDIs" work to eliminate debug intrinsics, we're
replacing methods that use Instruction*'s as positions with iterators.
This patch changes some more complex call-sites, those crossing file
boundaries and where I've had to perform some minor rewrites.
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 7e9d705..94101cc 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -2935,13 +2935,13 @@ bool CodeGenPrepare::dupRetToEnableTailCallOpts(BasicBlock *BB, // Make sure there are no instructions between the first instruction // and return. - const Instruction *BI = BB->getFirstNonPHI(); + BasicBlock::const_iterator BI = BB->getFirstNonPHIIt(); // Skip over debug and the bitcast. - while (isa<DbgInfoIntrinsic>(BI) || BI == BCI || BI == EVI || - isa<PseudoProbeInst>(BI) || isLifetimeEndOrBitCastFor(BI) || - isFakeUse(BI)) - BI = BI->getNextNode(); - if (BI != RetI) + while (isa<DbgInfoIntrinsic>(BI) || &*BI == BCI || &*BI == EVI || + isa<PseudoProbeInst>(BI) || isLifetimeEndOrBitCastFor(&*BI) || + isFakeUse(&*BI)) + BI = std::next(BI); + if (&*BI != RetI) return false; /// Only dup the ReturnInst if the CallInst is likely to be emitted as a tail @@ -3265,8 +3265,8 @@ class TypePromotionTransaction { /// Either an instruction: /// - Is the first in a basic block: BB is used. /// - Has a previous instruction: PrevInst is used. - union { - Instruction *PrevInst; + struct { + BasicBlock::iterator PrevInst; BasicBlock *BB; } Point; std::optional<DbgRecord::self_iterator> BeforeDbgRecord = std::nullopt; @@ -3286,7 +3286,7 @@ class TypePromotionTransaction { BeforeDbgRecord = Inst->getDbgReinsertionPosition(); if (HasPrevInstruction) { - Point.PrevInst = &*std::prev(Inst->getIterator()); + Point.PrevInst = std::prev(Inst->getIterator()); } else { Point.BB = BB; } @@ -3297,7 +3297,7 @@ class TypePromotionTransaction { if (HasPrevInstruction) { if (Inst->getParent()) Inst->removeFromParent(); - Inst->insertAfter(&*Point.PrevInst); + Inst->insertAfter(Point.PrevInst); } else { BasicBlock::iterator Position = Point.BB->getFirstInsertionPt(); if (Inst->getParent()) @@ -3317,7 +3317,7 @@ class TypePromotionTransaction { public: /// Move \p Inst before \p Before. - InstructionMoveBefore(Instruction *Inst, Instruction *Before) + InstructionMoveBefore(Instruction *Inst, BasicBlock::iterator Before) : TypePromotionAction(Inst), Position(Inst) { LLVM_DEBUG(dbgs() << "Do: move: " << *Inst << "\nbefore: " << *Before << "\n"); |