aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
diff options
context:
space:
mode:
authorStephen Tozer <stephen.tozer@sony.com>2024-06-24 17:27:43 +0100
committerGitHub <noreply@github.com>2024-06-24 17:27:43 +0100
commit6481dc57612671ebe77fe9c34214fba94e1b3b27 (patch)
tree54fb3108460b2540d24118af14b32d613f6244c7 /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
parent317277e4f961edf13132914a58a26408db4ab0aa (diff)
downloadllvm-6481dc57612671ebe77fe9c34214fba94e1b3b27.zip
llvm-6481dc57612671ebe77fe9c34214fba94e1b3b27.tar.gz
llvm-6481dc57612671ebe77fe9c34214fba94e1b3b27.tar.bz2
[IR][NFC] Update IRBuilder to use InsertPosition (#96497)
Uses the new InsertPosition class (added in #94226) to simplify some of the IRBuilder interface, and removes the need to pass a BasicBlock alongside a BasicBlock::iterator, using the fact that we can now get the parent basic block from the iterator even if it points to the sentinel. This patch removes the BasicBlock argument from each constructor or call to setInsertPoint. This has no functional effect, but later on as we look to remove the `Instruction *InsertBefore` argument from instruction-creation (discussed [here](https://discourse.llvm.org/t/psa-instruction-constructors-changing-to-iterator-only-insertion/77845)), this will simplify the process by allowing us to deprecate the InsertPosition constructor directly and catch all the cases where we use instructions rather than iterators.
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index c7d758a..be5ff67 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -1069,7 +1069,7 @@ SCEVExpander::getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized,
// Create the PHI.
BasicBlock *Header = L->getHeader();
- Builder.SetInsertPoint(Header, Header->begin());
+ Builder.SetInsertPoint(Header->begin());
PHINode *PN =
Builder.CreatePHI(ExpandTy, pred_size(Header), Twine(IVName) + ".iv");
@@ -1521,7 +1521,7 @@ Value *SCEVExpander::expand(const SCEV *S) {
return I->second;
SCEVInsertPointGuard Guard(Builder, this);
- Builder.SetInsertPoint(InsertPt->getParent(), InsertPt);
+ Builder.SetInsertPoint(InsertPt);
// Expand the expression into instructions.
SmallVector<Instruction *> DropPoisonGeneratingInsts;
@@ -1656,7 +1656,7 @@ void SCEVExpander::replaceCongruentIVInc(
else
IP = OrigInc->getNextNonDebugInstruction()->getIterator();
- IRBuilder<> Builder(IP->getParent(), IP);
+ IRBuilder<> Builder(IP);
Builder.SetCurrentDebugLocation(IsomorphicInc->getDebugLoc());
NewInc =
Builder.CreateTruncOrBitCast(OrigInc, IsomorphicInc->getType(), IVName);
@@ -1759,8 +1759,7 @@ SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT,
++NumElim;
Value *NewIV = OrigPhiRef;
if (OrigPhiRef->getType() != Phi->getType()) {
- IRBuilder<> Builder(L->getHeader(),
- L->getHeader()->getFirstInsertionPt());
+ IRBuilder<> Builder(L->getHeader()->getFirstInsertionPt());
Builder.SetCurrentDebugLocation(Phi->getDebugLoc());
NewIV = Builder.CreateTruncOrBitCast(OrigPhiRef, Phi->getType(), IVName);
}