diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2024-03-04 14:51:56 +0000 |
---|---|---|
committer | Jeremy Morse <jeremy.morse@sony.com> | 2024-03-05 15:12:22 +0000 |
commit | 2fe81edef6f0b35abffbbc59b649b30ea9c15a62 (patch) | |
tree | 34690d759ee0440c77187ffcedd986cbd96acb11 /llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | |
parent | a691f65a845d6d5e639a83e8240a2543663c103a (diff) | |
download | llvm-2fe81edef6f0b35abffbbc59b649b30ea9c15a62.zip llvm-2fe81edef6f0b35abffbbc59b649b30ea9c15a62.tar.gz llvm-2fe81edef6f0b35abffbbc59b649b30ea9c15a62.tar.bz2 |
[NFC][RemoveDIs] Insert instruction using iterators in Transforms/
As part of the RemoveDIs project we need LLVM to insert instructions using
iterators wherever possible, so that the iterators can carry a bit of
debug-info. This commit implements some of that by updating the contents of
llvm/lib/Transforms/Utils to always use iterator-versions of instruction
constructors.
There are two general flavours of update:
* Almost all call-sites just call getIterator on an instruction
* Several make use of an existing iterator (scenarios where the code is
actually significant for debug-info)
The underlying logic is that any call to getFirstInsertionPt or similar
APIs that identify the start of a block need to have that iterator passed
directly to the insertion function, without being converted to a bare
Instruction pointer along the way.
Noteworthy changes:
* FindInsertedValue now takes an optional iterator rather than an
instruction pointer, as we need to always insert with iterators,
* I've added a few iterator-taking versions of some value-tracking and
DomTree methods -- they just unwrap the iterator. These are purely
convenience methods to avoid extra syntax in some passes.
* A few calls to getNextNode become std::next instead (to keep in the
theme of using iterators for positions),
* SeparateConstOffsetFromGEP has it's insertion-position field changed.
Noteworthy because it's not a purely localised spelling change.
All this should be NFC.
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp index 7eb0ba1..3d14608 100644 --- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -2347,8 +2347,7 @@ static void unswitchNontrivialInvariants( BI->setSuccessor(1 - ClonedSucc, LoopPH); Value *Cond = skipTrivialSelect(BI->getCondition()); if (InsertFreeze) - Cond = new FreezeInst( - Cond, Cond->getName() + ".fr", BI); + Cond = new FreezeInst(Cond, Cond->getName() + ".fr", BI->getIterator()); BI->setCondition(Cond); DTUpdates.push_back({DominatorTree::Insert, SplitBB, ClonedPH}); } else { @@ -2365,8 +2364,9 @@ static void unswitchNontrivialInvariants( Case.setSuccessor(ClonedPHs.find(Case.getCaseSuccessor())->second); if (InsertFreeze) - SI->setCondition(new FreezeInst( - SI->getCondition(), SI->getCondition()->getName() + ".fr", SI)); + SI->setCondition(new FreezeInst(SI->getCondition(), + SI->getCondition()->getName() + ".fr", + SI->getIterator())); // We need to use the set to populate domtree updates as even when there // are multiple cases pointing at the same successor we only want to @@ -2704,7 +2704,8 @@ static BranchInst *turnSelectIntoBranch(SelectInst *SI, DominatorTree &DT, if (MSSAU) MSSAU->moveAllAfterSpliceBlocks(HeadBB, TailBB, SI); - PHINode *Phi = PHINode::Create(SI->getType(), 2, "unswitched.select", SI); + PHINode *Phi = + PHINode::Create(SI->getType(), 2, "unswitched.select", SI->getIterator()); Phi->addIncoming(SI->getTrueValue(), ThenBB); Phi->addIncoming(SI->getFalseValue(), HeadBB); SI->replaceAllUsesWith(Phi); @@ -3092,7 +3093,7 @@ injectPendingInvariantConditions(NonTrivialUnswitchCandidate Candidate, Loop &L, // unswitching will break. Better optimize it away later. auto *InjectedCond = ICmpInst::Create(Instruction::ICmp, Pred, LHS, RHS, "injected.cond", - Preheader->getTerminator()); + Preheader->getTerminator()->getIterator()); BasicBlock *CheckBlock = BasicBlock::Create(Ctx, BB->getName() + ".check", BB->getParent(), InLoopSucc); |