aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
diff options
context:
space:
mode:
authorJeremy Morse <jeremy.morse@sony.com>2025-01-27 15:25:17 +0000
committerGitHub <noreply@github.com>2025-01-27 15:25:17 +0000
commite14962a39cc6476bebba65e5639b74b0318c7fc3 (patch)
tree2c5f513c4703b51bc8ea723fe2890910fe7b30e6 /llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
parent5aafc6d58f3405662902cee006be11e599801b88 (diff)
downloadllvm-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/Transforms/Utils/BasicBlockUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/BasicBlockUtils.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index 7811677..5d191c2 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -1728,8 +1728,9 @@ void llvm::SplitBlockAndInsertIfThenElse(
}
}
-std::pair<Instruction*, Value*>
-llvm::SplitBlockAndInsertSimpleForLoop(Value *End, Instruction *SplitBefore) {
+std::pair<Instruction *, Value *>
+llvm::SplitBlockAndInsertSimpleForLoop(Value *End,
+ BasicBlock::iterator SplitBefore) {
BasicBlock *LoopPred = SplitBefore->getParent();
BasicBlock *LoopBody = SplitBlock(SplitBefore->getParent(), SplitBefore);
BasicBlock *LoopExit = SplitBlock(SplitBefore->getParent(), SplitBefore);
@@ -1752,14 +1753,14 @@ llvm::SplitBlockAndInsertSimpleForLoop(Value *End, Instruction *SplitBefore) {
IV->addIncoming(ConstantInt::get(Ty, 0), LoopPred);
IV->addIncoming(IVNext, LoopBody);
- return std::make_pair(LoopBody->getFirstNonPHI(), IV);
+ return std::make_pair(&*LoopBody->getFirstNonPHIIt(), IV);
}
-void llvm::SplitBlockAndInsertForEachLane(ElementCount EC,
- Type *IndexTy, Instruction *InsertBefore,
- std::function<void(IRBuilderBase&, Value*)> Func) {
+void llvm::SplitBlockAndInsertForEachLane(
+ ElementCount EC, Type *IndexTy, BasicBlock::iterator InsertBefore,
+ std::function<void(IRBuilderBase &, Value *)> Func) {
- IRBuilder<> IRB(InsertBefore);
+ IRBuilder<> IRB(InsertBefore->getParent(), InsertBefore);
if (EC.isScalable()) {
Value *NumElements = IRB.CreateElementCount(IndexTy, EC);
@@ -1780,10 +1781,10 @@ void llvm::SplitBlockAndInsertForEachLane(ElementCount EC,
}
void llvm::SplitBlockAndInsertForEachLane(
- Value *EVL, Instruction *InsertBefore,
+ Value *EVL, BasicBlock::iterator InsertBefore,
std::function<void(IRBuilderBase &, Value *)> Func) {
- IRBuilder<> IRB(InsertBefore);
+ IRBuilder<> IRB(InsertBefore->getParent(), InsertBefore);
Type *Ty = EVL->getType();
if (!isa<ConstantInt>(EVL)) {