diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2025-01-24 10:53:11 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-24 10:53:11 +0000 |
commit | 8e702735090388a3231a863e343f880d0f96fecb (patch) | |
tree | 0de8577ecae863327fe271a2e56f3705af105e5e /llvm/lib/Transforms/Utils/Local.cpp | |
parent | e6030d389571b3f1b0f0c5a35b7fa45937ed0f6c (diff) | |
download | llvm-8e702735090388a3231a863e343f880d0f96fecb.zip llvm-8e702735090388a3231a863e343f880d0f96fecb.tar.gz llvm-8e702735090388a3231a863e343f880d0f96fecb.tar.bz2 |
[NFC][DebugInfo] Use iterator moveBefore at many call-sites (#123583)
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 moveBefore use iterators.
This patch adds a (guaranteed dereferenceable) iterator-taking
moveBefore, and changes a bunch of call-sites where it's obviously safe
to change to use it by just calling getIterator() on an instruction
pointer. A follow-up patch will contain less-obviously-safe changes.
We'll eventually deprecate and remove the instruction-pointer
insertBefore, but not before adding concise documentation of what
considerations are needed (very few).
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 2d6f6a3..94cf118 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1715,7 +1715,7 @@ static void insertDbgValueOrDbgVariableRecordAfter( if (!UseNewDbgInfoFormat) { auto DbgVal = Builder.insertDbgValueIntrinsic(DV, DIVar, DIExpr, NewLoc, (Instruction *)nullptr); - cast<Instruction *>(DbgVal)->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. @@ -2197,7 +2197,7 @@ void llvm::insertDebugValuesForPHIs(BasicBlock *BB, auto *NewDbgII = DI.second; auto InsertionPt = Parent->getFirstInsertionPt(); assert(InsertionPt != Parent->end() && "Ill-formed basic block"); - NewDbgII->insertBefore(&*InsertionPt); + NewDbgII->insertBefore(InsertionPt); } } @@ -2975,7 +2975,7 @@ CallInst *llvm::createCallMatchingInvoke(InvokeInst *II) { CallInst *llvm::changeToCall(InvokeInst *II, DomTreeUpdater *DTU) { CallInst *NewCall = createCallMatchingInvoke(II); NewCall->takeName(II); - NewCall->insertBefore(II); + NewCall->insertBefore(II->getIterator()); II->replaceAllUsesWith(NewCall); // Follow the call by a branch to the normal destination. @@ -4307,9 +4307,9 @@ Value *llvm::invertCondition(Value *Condition) { auto *Inverted = BinaryOperator::CreateNot(Condition, Condition->getName() + ".inv"); if (Inst && !isa<PHINode>(Inst)) - Inverted->insertAfter(Inst); + Inverted->insertAfter(Inst->getIterator()); else - Inverted->insertBefore(&*Parent->getFirstInsertionPt()); + Inverted->insertBefore(Parent->getFirstInsertionPt()); return Inverted; } |