From e14962a39cc6476bebba65e5639b74b0318c7fc3 Mon Sep 17 00:00:00 2001 From: Jeremy Morse Date: Mon, 27 Jan 2025 15:25:17 +0000 Subject: [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. --- llvm/lib/Transforms/Utils/BasicBlockUtils.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'llvm/lib/Transforms/Utils/BasicBlockUtils.cpp') 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 -llvm::SplitBlockAndInsertSimpleForLoop(Value *End, Instruction *SplitBefore) { +std::pair +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 Func) { +void llvm::SplitBlockAndInsertForEachLane( + ElementCount EC, Type *IndexTy, BasicBlock::iterator InsertBefore, + std::function 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 Func) { - IRBuilder<> IRB(InsertBefore); + IRBuilder<> IRB(InsertBefore->getParent(), InsertBefore); Type *Ty = EVL->getType(); if (!isa(EVL)) { -- cgit v1.1