Skip to content

Commit 34b1395

Browse files
authored
[NFC][DebugInfo] Switch more call-sites to using iterator-insertion (#124283)
To finalise the "RemoveDIs" work removing debug intrinsics, we're updating call sites that insert instructions to use iterators instead. This set of changes are those where it's not immediately obvious that just calling getIterator to fetch an iterator is correct, and one or two places where more than one line needs to change. Overall the same rule holds though: iterators generated for the start of a block such as getFirstNonPHIIt need to be passed into insert/move methods without being unwrapped/rewrapped, everything else can use getIterator.
1 parent 038b42b commit 34b1395

File tree

16 files changed

+55
-53
lines changed

16 files changed

+55
-53
lines changed

llvm/include/llvm/Transforms/Coroutines/CoroInstr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class CoroIdInst : public AnyCoroIdInst {
170170
Inst->eraseFromParent();
171171
return;
172172
}
173-
Inst->moveBefore(getCoroBegin()->getNextNode());
173+
Inst->moveBefore(std::next(getCoroBegin()->getIterator()));
174174
}
175175

176176
// Info argument of coro.id is

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ void OpenMPIRBuilder::initialize() { initializeTypes(M); }
678678
static void raiseUserConstantDataAllocasToEntryBlock(IRBuilderBase &Builder,
679679
Function *Function) {
680680
BasicBlock &EntryBlock = Function->getEntryBlock();
681-
Instruction *MoveLocInst = EntryBlock.getFirstNonPHI();
681+
BasicBlock::iterator MoveLocInst = EntryBlock.getFirstNonPHIIt();
682682

683683
// Loop over blocks looking for constant allocas, skipping the entry block
684684
// as any allocas there are already in the desired location.
@@ -6918,7 +6918,7 @@ static Expected<Function *> createOutlinedFunction(
69186918
Builder.CreateRetVoid();
69196919

69206920
// New Alloca IP at entry point of created device function.
6921-
Builder.SetInsertPoint(EntryBB->getFirstNonPHI());
6921+
Builder.SetInsertPoint(EntryBB->getFirstNonPHIIt());
69226922
auto AllocaIP = Builder.saveIP();
69236923

69246924
Builder.SetInsertPoint(UserCodeEntryBB->getFirstNonPHIOrDbg());

llvm/lib/IR/BasicBlock.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ void BasicBlock::removePredecessor(BasicBlock *Pred,
555555
}
556556

557557
bool BasicBlock::canSplitPredecessors() const {
558-
const Instruction *FirstNonPHI = getFirstNonPHI();
558+
const_iterator FirstNonPHI = getFirstNonPHIIt();
559559
if (isa<LandingPadInst>(FirstNonPHI))
560560
return true;
561561
// This is perhaps a little conservative because constructs like
@@ -687,11 +687,11 @@ void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *New) {
687687
}
688688

689689
bool BasicBlock::isLandingPad() const {
690-
return isa<LandingPadInst>(getFirstNonPHI());
690+
return isa<LandingPadInst>(getFirstNonPHIIt());
691691
}
692692

693693
const LandingPadInst *BasicBlock::getLandingPadInst() const {
694-
return dyn_cast<LandingPadInst>(getFirstNonPHI());
694+
return dyn_cast<LandingPadInst>(getFirstNonPHIIt());
695695
}
696696

697697
std::optional<uint64_t> BasicBlock::getIrrLoopHeaderWeight() const {

llvm/lib/Target/Hexagon/HexagonOptimizeSZextends.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ bool HexagonOptimizeSZextends::runOnFunction(Function &F) {
8181
assert (EVT::getEVT(SI->getType()) ==
8282
(EVT::getEVT(Use->getType())));
8383
Use->replaceAllUsesWith(SI);
84-
Instruction* First = &F.getEntryBlock().front();
84+
BasicBlock::iterator First = F.getEntryBlock().begin();
8585
SI->insertBefore(First);
8686
Use->eraseFromParent();
8787
}

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3414,7 +3414,7 @@ void FunctionStackPoisoner::processStaticAllocas() {
34143414
assert(InsBeforeB == &F.getEntryBlock());
34153415
for (auto *AI : StaticAllocasToMoveUp)
34163416
if (AI->getParent() == InsBeforeB)
3417-
AI->moveBefore(InsBefore);
3417+
AI->moveBefore(InsBefore->getIterator());
34183418

34193419
// Move stores of arguments into entry-block allocas as well. This prevents
34203420
// extra stack slots from being generated (to house the argument values until
@@ -3423,10 +3423,11 @@ void FunctionStackPoisoner::processStaticAllocas() {
34233423
SmallVector<Instruction *, 8> ArgInitInsts;
34243424
findStoresToUninstrumentedArgAllocas(ASan, *InsBefore, ArgInitInsts);
34253425
for (Instruction *ArgInitInst : ArgInitInsts)
3426-
ArgInitInst->moveBefore(InsBefore);
3426+
ArgInitInst->moveBefore(InsBefore->getIterator());
34273427

34283428
// If we have a call to llvm.localescape, keep it in the entry block.
3429-
if (LocalEscapeCall) LocalEscapeCall->moveBefore(InsBefore);
3429+
if (LocalEscapeCall)
3430+
LocalEscapeCall->moveBefore(InsBefore->getIterator());
34303431

34313432
SmallVector<ASanStackVariableDescription, 16> SVD;
34323433
SVD.reserve(AllocaVec.size());

llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ static bool canSplitCallSite(CallBase &CB, TargetTransformInfo &TTI) {
218218
return true;
219219
}
220220

221-
static Instruction *cloneInstForMustTail(Instruction *I, Instruction *Before,
222-
Value *V) {
221+
static Instruction *
222+
cloneInstForMustTail(Instruction *I, BasicBlock::iterator Before, Value *V) {
223223
Instruction *Copy = I->clone();
224224
Copy->setName(I->getName());
225225
Copy->insertBefore(Before);
@@ -251,8 +251,8 @@ static void copyMustTailReturn(BasicBlock *SplitBB, Instruction *CI,
251251
Instruction *TI = SplitBB->getTerminator();
252252
Value *V = NewCI;
253253
if (BCI)
254-
V = cloneInstForMustTail(BCI, TI, V);
255-
cloneInstForMustTail(RI, TI, IsVoid ? nullptr : V);
254+
V = cloneInstForMustTail(BCI, TI->getIterator(), V);
255+
cloneInstForMustTail(RI, TI->getIterator(), IsVoid ? nullptr : V);
256256

257257
// FIXME: remove TI here, `DuplicateInstructionsInSplitBetween` has a bug
258258
// that prevents doing this now.

llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6176,11 +6176,11 @@ LSRInstance::LSRInstance(Loop *L, IVUsers &IU, ScalarEvolution &SE,
61766176
// CatchSwitchInst. Because the CatchSwitchInst cannot be split, there is
61776177
// no good place to stick any instructions.
61786178
if (auto *PN = dyn_cast<PHINode>(U.getUser())) {
6179-
auto *FirstNonPHI = PN->getParent()->getFirstNonPHI();
6179+
auto FirstNonPHI = PN->getParent()->getFirstNonPHIIt();
61806180
if (isa<FuncletPadInst>(FirstNonPHI) ||
61816181
isa<CatchSwitchInst>(FirstNonPHI))
61826182
for (BasicBlock *PredBB : PN->blocks())
6183-
if (isa<CatchSwitchInst>(PredBB->getFirstNonPHI()))
6183+
if (isa<CatchSwitchInst>(PredBB->getFirstNonPHIIt()))
61846184
return;
61856185
}
61866186
}

llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void MergedLoadStoreMotion::sinkStoresAndGEPs(BasicBlock *BB, StoreInst *S0,
281281
auto *GEP0 = cast<GetElementPtrInst>(Ptr0);
282282
auto *GEP1 = cast<GetElementPtrInst>(Ptr1);
283283
Instruction *GEPNew = GEP0->clone();
284-
GEPNew->insertBefore(SNew);
284+
GEPNew->insertBefore(SNew->getIterator());
285285
GEPNew->applyMergedLocation(GEP0->getDebugLoc(), GEP1->getDebugLoc());
286286
SNew->setOperand(1, GEPNew);
287287
GEP0->replaceAllUsesWith(GEPNew);

llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ static void recomputeLiveInValues(
13711371
// and inserts them before "InsertBefore". Returns rematerialized value
13721372
// which should be used after statepoint.
13731373
static Instruction *rematerializeChain(ArrayRef<Instruction *> ChainToBase,
1374-
Instruction *InsertBefore,
1374+
BasicBlock::iterator InsertBefore,
13751375
Value *RootOfChain,
13761376
Value *AlternateLiveBase) {
13771377
Instruction *LastClonedValue = nullptr;
@@ -2185,16 +2185,16 @@ static void relocationViaAlloca(
21852185
// InvokeInst is a terminator so the store need to be inserted into its
21862186
// normal destination block.
21872187
BasicBlock *NormalDest = Invoke->getNormalDest();
2188-
Store->insertBefore(NormalDest->getFirstNonPHI());
2188+
Store->insertBefore(NormalDest->getFirstNonPHIIt());
21892189
} else {
21902190
assert(!Inst->isTerminator() &&
21912191
"The only terminator that can produce a value is "
21922192
"InvokeInst which is handled above.");
2193-
Store->insertAfter(Inst);
2193+
Store->insertAfter(Inst->getIterator());
21942194
}
21952195
} else {
21962196
assert(isa<Argument>(Def));
2197-
Store->insertAfter(cast<Instruction>(Alloca));
2197+
Store->insertAfter(cast<Instruction>(Alloca)->getIterator());
21982198
}
21992199
}
22002200

@@ -2499,8 +2499,9 @@ static void rematerializeLiveValuesAtUses(
24992499
// statepoint between uses in the block.
25002500
while (!Cand->user_empty()) {
25012501
Instruction *UserI = cast<Instruction>(*Cand->user_begin());
2502-
Instruction *RematChain = rematerializeChain(
2503-
Record.ChainToBase, UserI, Record.RootOfChain, PointerToBase[Cand]);
2502+
Instruction *RematChain =
2503+
rematerializeChain(Record.ChainToBase, UserI->getIterator(),
2504+
Record.RootOfChain, PointerToBase[Cand]);
25042505
UserI->replaceUsesOfWith(Cand, RematChain);
25052506
PointerToBase[RematChain] = PointerToBase[Cand];
25062507
}
@@ -2573,16 +2574,16 @@ static void rematerializeLiveValues(CallBase *Call,
25732574
Instruction *InsertBefore = Call->getNextNode();
25742575
assert(InsertBefore);
25752576
Instruction *RematerializedValue =
2576-
rematerializeChain(Record.ChainToBase, InsertBefore,
2577+
rematerializeChain(Record.ChainToBase, InsertBefore->getIterator(),
25772578
Record.RootOfChain, PointerToBase[LiveValue]);
25782579
Info.RematerializedValues[RematerializedValue] = LiveValue;
25792580
} else {
25802581
auto *Invoke = cast<InvokeInst>(Call);
25812582

2582-
Instruction *NormalInsertBefore =
2583-
&*Invoke->getNormalDest()->getFirstInsertionPt();
2584-
Instruction *UnwindInsertBefore =
2585-
&*Invoke->getUnwindDest()->getFirstInsertionPt();
2583+
BasicBlock::iterator NormalInsertBefore =
2584+
Invoke->getNormalDest()->getFirstInsertionPt();
2585+
BasicBlock::iterator UnwindInsertBefore =
2586+
Invoke->getUnwindDest()->getFirstInsertionPt();
25862587

25872588
Instruction *NormalRematerializedValue =
25882589
rematerializeChain(Record.ChainToBase, NormalInsertBefore,
@@ -3131,7 +3132,7 @@ bool RewriteStatepointsForGC::runOnFunction(Function &F, DominatorTree &DT,
31313132
// most instructions without side effects or memory access.
31323133
if (isa<ICmpInst>(Cond) && Cond->hasOneUse()) {
31333134
MadeChange = true;
3134-
Cond->moveBefore(TI);
3135+
Cond->moveBefore(TI->getIterator());
31353136
}
31363137
}
31373138

llvm/lib/Transforms/Scalar/SROA.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ static void migrateDebugInfo(AllocaInst *OldAlloca, bool IsSplit,
480480
// noted as slightly offset (in code) from the store. In practice this
481481
// should have little effect on the debugging experience due to the fact
482482
// that all the split stores should get the same line number.
483-
NewAssign->moveBefore(DbgAssign);
483+
NewAssign->moveBefore(DbgAssign->getIterator());
484484

485485
NewAssign->setDebugLoc(DbgAssign->getDebugLoc());
486486
LLVM_DEBUG(dbgs() << "Created new assign: " << *NewAssign << "\n");
@@ -1843,7 +1843,7 @@ static void rewriteMemOpOfSelect(SelectInst &SI, T &I,
18431843
CondMemOp.dropUBImplyingAttrsAndMetadata();
18441844
++NumLoadsSpeculated;
18451845
}
1846-
CondMemOp.insertBefore(NewMemOpBB->getTerminator());
1846+
CondMemOp.insertBefore(NewMemOpBB->getTerminator()->getIterator());
18471847
Value *Ptr = SI.getOperand(1 + SuccIdx);
18481848
CondMemOp.setOperand(I.getPointerOperandIndex(), Ptr);
18491849
if (isa<LoadInst>(I)) {

llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3303,8 +3303,8 @@ static bool isSafeForNoNTrivialUnswitching(Loop &L, LoopInfo &LI) {
33033303
// FIXME: We should teach SplitBlock to handle this and remove this
33043304
// restriction.
33053305
for (auto *ExitBB : ExitBlocks) {
3306-
auto *I = ExitBB->getFirstNonPHI();
3307-
if (isa<CleanupPadInst>(I) || isa<CatchSwitchInst>(I)) {
3306+
auto It = ExitBB->getFirstNonPHIIt();
3307+
if (isa<CleanupPadInst>(It) || isa<CatchSwitchInst>(It)) {
33083308
LLVM_DEBUG(dbgs() << "Cannot unswitch because of cleanuppad/catchswitch "
33093309
"in exit block\n");
33103310
return false;

llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,9 @@ struct AssumeSimplify {
474474
AssumeBuilderState Builder(F.getParent());
475475

476476
/// For now it is initialized to the best value it could have
477-
Instruction *InsertPt = BB->getFirstNonPHI();
477+
BasicBlock::iterator InsertPt = BB->getFirstNonPHIIt();
478478
if (isa<LandingPadInst>(InsertPt))
479-
InsertPt = InsertPt->getNextNode();
479+
InsertPt = std::next(InsertPt);
480480
for (IntrinsicInst *I : make_range(Begin, End)) {
481481
CleanupToDo.insert(I);
482482
for (CallInst::BundleOpInfo &BOI : I->bundle_op_infos()) {
@@ -487,8 +487,8 @@ struct AssumeSimplify {
487487
Builder.addKnowledge(RK);
488488
if (auto *I = dyn_cast_or_null<Instruction>(RK.WasOn))
489489
if (I->getParent() == InsertPt->getParent() &&
490-
(InsertPt->comesBefore(I) || InsertPt == I))
491-
InsertPt = I->getNextNode();
490+
(InsertPt->comesBefore(I) || &*InsertPt == I))
491+
InsertPt = I->getNextNode()->getIterator();
492492
}
493493
}
494494

@@ -498,7 +498,7 @@ struct AssumeSimplify {
498498
for (auto It = (*Begin)->getIterator(), E = InsertPt->getIterator();
499499
It != E; --It)
500500
if (!isGuaranteedToTransferExecutionToSuccessor(&*It)) {
501-
InsertPt = It->getNextNode();
501+
InsertPt = std::next(It);
502502
break;
503503
}
504504
auto *MergedAssume = Builder.build();

llvm/lib/Transforms/Utils/BasicBlockUtils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ BasicBlock *llvm::ehAwareSplitEdge(BasicBlock *BB, BasicBlock *Succ,
836836
const CriticalEdgeSplittingOptions &Options,
837837
const Twine &BBName) {
838838

839-
auto *PadInst = Succ->getFirstNonPHI();
839+
auto PadInst = Succ->getFirstNonPHIIt();
840840
if (!LandingPadReplacement && !PadInst->isEHPad())
841841
return SplitEdge(BB, Succ, Options.DT, Options.LI, Options.MSSAU, BBName);
842842

@@ -981,7 +981,7 @@ BasicBlock *llvm::ehAwareSplitEdge(BasicBlock *BB, BasicBlock *Succ,
981981
void llvm::createPHIsForSplitLoopExit(ArrayRef<BasicBlock *> Preds,
982982
BasicBlock *SplitBB, BasicBlock *DestBB) {
983983
// SplitBB shouldn't have anything non-trivial in it yet.
984-
assert((SplitBB->getFirstNonPHI() == SplitBB->getTerminator() ||
984+
assert((&*SplitBB->getFirstNonPHIIt() == SplitBB->getTerminator() ||
985985
SplitBB->isLandingPad()) &&
986986
"SplitBB has non-PHI nodes!");
987987

@@ -1450,7 +1450,7 @@ static void SplitLandingPadPredecessorsImpl(
14501450

14511451
// The new block unconditionally branches to the old block.
14521452
BranchInst *BI1 = BranchInst::Create(OrigBB, NewBB1);
1453-
BI1->setDebugLoc(OrigBB->getFirstNonPHI()->getDebugLoc());
1453+
BI1->setDebugLoc(OrigBB->getFirstNonPHIIt()->getDebugLoc());
14541454

14551455
// Move the edges from Preds to point to NewBB1 instead of OrigBB.
14561456
for (BasicBlock *Pred : Preds) {
@@ -1491,7 +1491,7 @@ static void SplitLandingPadPredecessorsImpl(
14911491

14921492
// The new block unconditionally branches to the old block.
14931493
BranchInst *BI2 = BranchInst::Create(OrigBB, NewBB2);
1494-
BI2->setDebugLoc(OrigBB->getFirstNonPHI()->getDebugLoc());
1494+
BI2->setDebugLoc(OrigBB->getFirstNonPHIIt()->getDebugLoc());
14951495

14961496
// Move the remaining edges from OrigBB to point to NewBB2.
14971497
for (BasicBlock *NewBB2Pred : NewBB2Preds)

llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static bool processHeaderPhiOperands(BasicBlock *Header, BasicBlock *Latch,
165165
// Move the phi operands of Header from Latch out of AftBlocks to InsertLoc.
166166
static void moveHeaderPhiOperandsToForeBlocks(BasicBlock *Header,
167167
BasicBlock *Latch,
168-
Instruction *InsertLoc,
168+
BasicBlock::iterator InsertLoc,
169169
BasicBlockSet &AftBlocks) {
170170
// We need to ensure we move the instructions in the correct order,
171171
// starting with the earliest required instruction and moving forward.
@@ -329,7 +329,8 @@ llvm::UnrollAndJamLoop(Loop *L, unsigned Count, unsigned TripCount,
329329

330330
// Move any instructions from fore phi operands from AftBlocks into Fore.
331331
moveHeaderPhiOperandsToForeBlocks(
332-
Header, LatchBlock, ForeBlocksLast[0]->getTerminator(), AftBlocks);
332+
Header, LatchBlock, ForeBlocksLast[0]->getTerminator()->getIterator(),
333+
AftBlocks);
333334

334335
// The current on-the-fly SSA update requires blocks to be processed in
335336
// reverse postorder so that LastValueMap contains the correct value at each

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5262,8 +5262,8 @@ bool SimplifyCFGOpt::simplifyBranchOnICmpChain(BranchInst *BI,
52625262
bool SimplifyCFGOpt::simplifyResume(ResumeInst *RI, IRBuilder<> &Builder) {
52635263
if (isa<PHINode>(RI->getValue()))
52645264
return simplifyCommonResume(RI);
5265-
else if (isa<LandingPadInst>(RI->getParent()->getFirstNonPHI()) &&
5266-
RI->getValue() == RI->getParent()->getFirstNonPHI())
5265+
else if (isa<LandingPadInst>(RI->getParent()->getFirstNonPHIIt()) &&
5266+
RI->getValue() == &*RI->getParent()->getFirstNonPHIIt())
52675267
// The resume must unwind the exception that caused control to branch here.
52685268
return simplifySingleResume(RI);
52695269

@@ -5297,8 +5297,8 @@ bool SimplifyCFGOpt::simplifyCommonResume(ResumeInst *RI) {
52975297

52985298
// Check that there are no other instructions except for debug and lifetime
52995299
// intrinsics between the phi's and resume instruction.
5300-
if (!isCleanupBlockEmpty(
5301-
make_range(RI->getParent()->getFirstNonPHI(), BB->getTerminator())))
5300+
if (!isCleanupBlockEmpty(make_range(RI->getParent()->getFirstNonPHIIt(),
5301+
BB->getTerminator()->getIterator())))
53025302
return false;
53035303

53045304
SmallSetVector<BasicBlock *, 4> TrivialUnwindBlocks;
@@ -5315,7 +5315,7 @@ bool SimplifyCFGOpt::simplifyCommonResume(ResumeInst *RI) {
53155315
if (IncomingBB->getUniqueSuccessor() != BB)
53165316
continue;
53175317

5318-
auto *LandingPad = dyn_cast<LandingPadInst>(IncomingBB->getFirstNonPHI());
5318+
auto *LandingPad = dyn_cast<LandingPadInst>(IncomingBB->getFirstNonPHIIt());
53195319
// Not the landing pad that caused the control to branch here.
53205320
if (IncomingValue != LandingPad)
53215321
continue;
@@ -5364,7 +5364,7 @@ bool SimplifyCFGOpt::simplifyCommonResume(ResumeInst *RI) {
53645364
// Simplify resume that is only used by a single (non-phi) landing pad.
53655365
bool SimplifyCFGOpt::simplifySingleResume(ResumeInst *RI) {
53665366
BasicBlock *BB = RI->getParent();
5367-
auto *LPInst = cast<LandingPadInst>(BB->getFirstNonPHI());
5367+
auto *LPInst = cast<LandingPadInst>(BB->getFirstNonPHIIt());
53685368
assert(RI->getValue() == LPInst &&
53695369
"Resume must unwind the exception that caused control to here");
53705370

@@ -5412,7 +5412,6 @@ static bool removeEmptyCleanup(CleanupReturnInst *RI, DomTreeUpdater *DTU) {
54125412
// If the cleanup return we are simplifying unwinds to the caller, this will
54135413
// set UnwindDest to nullptr.
54145414
BasicBlock *UnwindDest = RI->getUnwindDest();
5415-
Instruction *DestEHPad = UnwindDest ? UnwindDest->getFirstNonPHI() : nullptr;
54165415

54175416
// We're about to remove BB from the control flow. Before we do, sink any
54185417
// PHINodes into the unwind destination. Doing this before changing the
@@ -5449,7 +5448,7 @@ static bool removeEmptyCleanup(CleanupReturnInst *RI, DomTreeUpdater *DTU) {
54495448
}
54505449

54515450
// Sink any remaining PHI nodes directly into UnwindDest.
5452-
Instruction *InsertPt = DestEHPad;
5451+
BasicBlock::iterator InsertPt = UnwindDest->getFirstNonPHIIt();
54535452
for (PHINode &PN : make_early_inc_range(BB->phis())) {
54545453
if (PN.use_empty() || !PN.isUsedOutsideOfBlock(BB))
54555454
// If the PHI node has no uses or all of its uses are in this basic

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ void VPlan::execute(VPTransformState *State) {
10241024
// Move the last step to the end of the latch block. This ensures
10251025
// consistent placement of all induction updates.
10261026
Instruction *Inc = cast<Instruction>(Phi->getIncomingValue(1));
1027-
Inc->moveBefore(VectorLatchBB->getTerminator()->getPrevNode());
1027+
Inc->moveBefore(std::prev(VectorLatchBB->getTerminator()->getIterator()));
10281028

10291029
// Use the steps for the last part as backedge value for the induction.
10301030
if (auto *IV = dyn_cast<VPWidenIntOrFpInductionRecipe>(&R))

0 commit comments

Comments
 (0)