Skip to content

Commit e54277f

Browse files
committed
[NFC][RemoveDIs] Use iterators over inst-pointers when using IRBuilder
This patch adds a two-argument SetInsertPoint method to IRBuilder that takes a block/iterator instead of an instruction, and updates many call sites to use it. The motivating reason for doing this is given here [0], we'd like to pass around more information about the position of debug-info in the iterator object. That necessitates passing iterators around most of the time. [0] https://discourse.llvm.org/t/rfc-instruction-api-changes-needed-to-eliminate-debug-intrinsics-from-ir/68939 Differential Revision: https://reviews.llvm.org/D152468
1 parent d7acc6e commit e54277f

28 files changed

+121
-88
lines changed

llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ class SCEVExpander : public SCEVVisitor<SCEVExpander, Value *> {
351351
Builder.SetInsertPoint(IP);
352352
}
353353

354+
void setInsertPoint(BasicBlock::iterator IP) {
355+
Builder.SetInsertPoint(IP->getParent(), IP);
356+
}
357+
354358
/// Clear the current insertion point. This is useful if the instruction
355359
/// that had been serving as the insertion point may have been deleted.
356360
void clearInsertPoint() { Builder.ClearInsertionPoint(); }
@@ -404,7 +408,10 @@ class SCEVExpander : public SCEVVisitor<SCEVExpander, Value *> {
404408
/// program. The code is inserted into the specified block. If \p
405409
/// Root is true, this indicates that \p SH is the top-level expression to
406410
/// expand passed from an external client call.
407-
Value *expandCodeForImpl(const SCEV *SH, Type *Ty, Instruction *I);
411+
Value *expandCodeForImpl(const SCEV *SH, Type *Ty, BasicBlock::iterator I);
412+
Value *expandCodeForImpl(const SCEV *SH, Type *Ty, Instruction *I) {
413+
return expandCodeForImpl(SH, Ty, I->getIterator());
414+
}
408415

409416
/// Recursive helper function for isHighCostExpansion.
410417
bool isHighCostExpansionHelper(const SCEVOperand &WorkItem, Loop *L,

llvm/lib/Analysis/MemoryBuiltins.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,8 @@ SizeOffsetEvalType ObjectSizeOffsetEvaluator::visitPHINode(PHINode &PHI) {
11911191

11921192
// Compute offset/size for each PHI incoming pointer.
11931193
for (unsigned i = 0, e = PHI.getNumIncomingValues(); i != e; ++i) {
1194-
Builder.SetInsertPoint(&*PHI.getIncomingBlock(i)->getFirstInsertionPt());
1194+
BasicBlock *IncomingBlock = PHI.getIncomingBlock(i);
1195+
Builder.SetInsertPoint(IncomingBlock, IncomingBlock->getFirstInsertionPt());
11951196
SizeOffsetEvalType EdgeData = compute_(PHI.getIncomingValue(i));
11961197

11971198
if (!bothKnown(EdgeData)) {
@@ -1203,8 +1204,8 @@ SizeOffsetEvalType ObjectSizeOffsetEvaluator::visitPHINode(PHINode &PHI) {
12031204
InsertedInstructions.erase(SizePHI);
12041205
return unknown();
12051206
}
1206-
SizePHI->addIncoming(EdgeData.first, PHI.getIncomingBlock(i));
1207-
OffsetPHI->addIncoming(EdgeData.second, PHI.getIncomingBlock(i));
1207+
SizePHI->addIncoming(EdgeData.first, IncomingBlock);
1208+
OffsetPHI->addIncoming(EdgeData.second, IncomingBlock);
12081209
}
12091210

12101211
Value *Size = SizePHI, *Offset = OffsetPHI;

llvm/lib/CodeGen/CodeGenPrepare.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2263,7 +2263,7 @@ static bool despeculateCountZeros(IntrinsicInst *CountZeros,
22632263

22642264
// Create a PHI in the end block to select either the output of the intrinsic
22652265
// or the bit width of the operand.
2266-
Builder.SetInsertPoint(&EndBlock->front());
2266+
Builder.SetInsertPoint(EndBlock, EndBlock->begin());
22672267
PHINode *PN = Builder.CreatePHI(Ty, 2, "ctz");
22682268
replaceAllUsesWith(CountZeros, PN, FreshBBs, IsHugeFunc);
22692269
Value *BitWidth = Builder.getInt(APInt(SizeInBits, SizeInBits));

llvm/lib/CodeGen/ExpandMemCmp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ void MemCmpExpansion::setupResultBlockPHINodes() {
558558
}
559559

560560
void MemCmpExpansion::setupEndBlockPHINodes() {
561-
Builder.SetInsertPoint(&EndBlock->front());
561+
Builder.SetInsertPoint(EndBlock, EndBlock->begin());
562562
PhiRes = Builder.CreatePHI(Type::getInt32Ty(CI->getContext()), 2, "phi.res");
563563
}
564564

llvm/lib/CodeGen/WasmEHPrepare.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ void WasmEHPrepare::prepareEHPad(BasicBlock *BB, bool NeedPersonality,
279279
unsigned Index) {
280280
assert(BB->isEHPad() && "BB is not an EHPad!");
281281
IRBuilder<> IRB(BB->getContext());
282-
IRB.SetInsertPoint(&*BB->getFirstInsertionPt());
282+
IRB.SetInsertPoint(BB, BB->getFirstInsertionPt());
283283

284284
auto *FPI = cast<FuncletPadInst>(BB->getFirstNonPHI());
285285
Instruction *GetExnCI = nullptr, *GetSelectorCI = nullptr;

llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ void AMDGPUAtomicOptimizerImpl::optimizeAtomic(Instruction &I,
984984

985985
if (IsPixelShader) {
986986
// Need a final PHI to reconverge to above the helper lane branch mask.
987-
B.SetInsertPoint(PixelExitBB->getFirstNonPHI());
987+
B.SetInsertPoint(PixelExitBB, PixelExitBB->getFirstNonPHIIt());
988988

989989
PHINode *const PHI = B.CreatePHI(Ty, 2);
990990
PHI->addIncoming(PoisonValue::get(Ty), PixelEntryBB);

llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ class AMDGPULowerModuleLDS {
294294
// equivalent target specific intrinsic which lasts until immediately after
295295
// codegen would suffice for that, but one would still need to ensure that
296296
// the variables are allocated in the anticpated order.
297-
IRBuilder<> Builder(Func->getEntryBlock().getFirstNonPHI());
297+
BasicBlock *Entry = &Func->getEntryBlock();
298+
IRBuilder<> Builder(Entry, Entry->getFirstNonPHIIt());
298299

299300
Function *Decl =
300301
Intrinsic::getDeclaration(Func->getParent(), Intrinsic::donothing, {});

llvm/lib/Target/ARM/MVETailPredication.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ void MVETailPredication::InsertVCTPIntrinsic(IntrinsicInst *ActiveLaneMask,
381381
cast<FixedVectorType>(ActiveLaneMask->getType())->getNumElements();
382382

383383
// Insert a phi to count the number of elements processed by the loop.
384-
Builder.SetInsertPoint(L->getHeader()->getFirstNonPHI());
384+
Builder.SetInsertPoint(L->getHeader(), L->getHeader()->getFirstNonPHIIt());
385385
PHINode *Processed = Builder.CreatePHI(Ty, 2);
386386
Processed->addIncoming(Start, L->getLoopPreheader());
387387

llvm/lib/Target/Hexagon/HexagonVectorLoopCarriedReuse.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ void HexagonVectorLoopCarriedReuse::reuseValue() {
552552
}
553553
BasicBlock *BB = BEInst->getParent();
554554
IRBuilder<> IRB(BB);
555-
IRB.SetInsertPoint(BB->getFirstNonPHI());
555+
IRB.SetInsertPoint(BB, BB->getFirstNonPHIIt());
556556
Value *BEVal = BEInst;
557557
PHINode *NewPhi;
558558
for (int i = Iterations-1; i >=0 ; --i) {

llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ bool SPIRVEmitIntrinsics::runOnFunction(Function &Func) {
474474
AggrStores.insert(&I);
475475
}
476476

477-
IRB->SetInsertPoint(&Func.getEntryBlock().front());
477+
IRB->SetInsertPoint(&Func.getEntryBlock(), Func.getEntryBlock().begin());
478478
for (auto &GV : Func.getParent()->globals())
479479
processGlobalValue(GV);
480480

llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runSjLjOnFunction(Function &F) {
13361336
// Add a phi to the tail, which will be the output of setjmp, which
13371337
// indicates if this is the first call or a longjmp back. The phi directly
13381338
// uses the right value based on where we arrive from
1339-
IRB.SetInsertPoint(Tail->getFirstNonPHI());
1339+
IRB.SetInsertPoint(Tail, Tail->getFirstNonPHIIt());
13401340
PHINode *SetjmpRet = IRB.CreatePHI(IRB.getInt32Ty(), 2, "setjmp.ret");
13411341

13421342
// setjmp initial call returns 0

llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ X86LowerAMXIntrinsics::lowerTileDP(Instruction *TileDP) {
495495
KDWord, C, A, B);
496496
// we cannot assume there always be bitcast after tiledpbssd. So we need to
497497
// insert one bitcast as required
498-
Builder.SetInsertPoint(End->getFirstNonPHI());
498+
Builder.SetInsertPoint(End, End->getFirstNonPHIIt());
499499
Value *ResAMX =
500500
Builder.CreateBitCast(ResVec, Type::getX86_AMXTy(Builder.getContext()));
501501
// Delete TileDP intrinsic and do some clean-up.
@@ -539,7 +539,7 @@ bool X86LowerAMXIntrinsics::lowerTileLoadStore(Instruction *TileLoadStore) {
539539
if (IsTileLoad) {
540540
// we cannot assume there always be bitcast after tileload. So we need to
541541
// insert one bitcast as required
542-
Builder.SetInsertPoint(End->getFirstNonPHI());
542+
Builder.SetInsertPoint(End, End->getFirstNonPHIIt());
543543
Value *ResAMX =
544544
Builder.CreateBitCast(ResVec, Type::getX86_AMXTy(Builder.getContext()));
545545
// Delete tileloadd6 intrinsic and do some clean-up

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

+14-12
Original file line numberDiff line numberDiff line change
@@ -1777,13 +1777,13 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
17771777
auto SpillAlignment = Align(FrameData.getAlign(Def));
17781778
// Create a store instruction storing the value into the
17791779
// coroutine frame.
1780-
Instruction *InsertPt = nullptr;
1780+
BasicBlock::iterator InsertPt;
17811781
Type *ByValTy = nullptr;
17821782
if (auto *Arg = dyn_cast<Argument>(Def)) {
17831783
// For arguments, we will place the store instruction right after
17841784
// the coroutine frame pointer instruction, i.e. bitcast of
17851785
// coro.begin from i8* to %f.frame*.
1786-
InsertPt = Shape.getInsertPtAfterFramePtr();
1786+
InsertPt = Shape.getInsertPtAfterFramePtr()->getIterator();
17871787

17881788
// If we're spilling an Argument, make sure we clear 'nocapture'
17891789
// from the coroutine function.
@@ -1794,35 +1794,35 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
17941794
} else if (auto *CSI = dyn_cast<AnyCoroSuspendInst>(Def)) {
17951795
// Don't spill immediately after a suspend; splitting assumes
17961796
// that the suspend will be followed by a branch.
1797-
InsertPt = CSI->getParent()->getSingleSuccessor()->getFirstNonPHI();
1797+
InsertPt = CSI->getParent()->getSingleSuccessor()->getFirstNonPHIIt();
17981798
} else {
17991799
auto *I = cast<Instruction>(Def);
18001800
if (!DT.dominates(CB, I)) {
18011801
// If it is not dominated by CoroBegin, then spill should be
18021802
// inserted immediately after CoroFrame is computed.
1803-
InsertPt = Shape.getInsertPtAfterFramePtr();
1803+
InsertPt = Shape.getInsertPtAfterFramePtr()->getIterator();
18041804
} else if (auto *II = dyn_cast<InvokeInst>(I)) {
18051805
// If we are spilling the result of the invoke instruction, split
18061806
// the normal edge and insert the spill in the new block.
18071807
auto *NewBB = SplitEdge(II->getParent(), II->getNormalDest());
1808-
InsertPt = NewBB->getTerminator();
1808+
InsertPt = NewBB->getTerminator()->getIterator();
18091809
} else if (isa<PHINode>(I)) {
18101810
// Skip the PHINodes and EH pads instructions.
18111811
BasicBlock *DefBlock = I->getParent();
18121812
if (auto *CSI = dyn_cast<CatchSwitchInst>(DefBlock->getTerminator()))
1813-
InsertPt = splitBeforeCatchSwitch(CSI);
1813+
InsertPt = splitBeforeCatchSwitch(CSI)->getIterator();
18141814
else
1815-
InsertPt = &*DefBlock->getFirstInsertionPt();
1815+
InsertPt = DefBlock->getFirstInsertionPt();
18161816
} else {
18171817
assert(!I->isTerminator() && "unexpected terminator");
18181818
// For all other values, the spill is placed immediately after
18191819
// the definition.
1820-
InsertPt = I->getNextNode();
1820+
InsertPt = I->getNextNode()->getIterator();
18211821
}
18221822
}
18231823

18241824
auto Index = FrameData.getFieldIndex(Def);
1825-
Builder.SetInsertPoint(InsertPt);
1825+
Builder.SetInsertPoint(InsertPt->getParent(), InsertPt);
18261826
auto *G = Builder.CreateConstInBoundsGEP2_32(
18271827
FrameTy, FramePtr, 0, Index, Def->getName() + Twine(".spill.addr"));
18281828
if (ByValTy) {
@@ -1842,7 +1842,8 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
18421842
// reference provided with the frame GEP.
18431843
if (CurrentBlock != U->getParent()) {
18441844
CurrentBlock = U->getParent();
1845-
Builder.SetInsertPoint(&*CurrentBlock->getFirstInsertionPt());
1845+
Builder.SetInsertPoint(CurrentBlock,
1846+
CurrentBlock->getFirstInsertionPt());
18461847

18471848
auto *GEP = GetFramePointer(E.first);
18481849
GEP->setName(E.first->getName() + Twine(".reload.addr"));
@@ -1916,7 +1917,7 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
19161917
if (Shape.ABI == coro::ABI::Retcon || Shape.ABI == coro::ABI::RetconOnce ||
19171918
Shape.ABI == coro::ABI::Async) {
19181919
// If we found any allocas, replace all of their remaining uses with Geps.
1919-
Builder.SetInsertPoint(&SpillBlock->front());
1920+
Builder.SetInsertPoint(SpillBlock, SpillBlock->begin());
19201921
for (const auto &P : FrameData.Allocas) {
19211922
AllocaInst *Alloca = P.Alloca;
19221923
auto *G = GetFramePointer(Alloca);
@@ -1935,7 +1936,8 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
19351936
// dbg.declares and dbg.values with the reload from the frame.
19361937
// Note: We cannot replace the alloca with GEP instructions indiscriminately,
19371938
// as some of the uses may not be dominated by CoroBegin.
1938-
Builder.SetInsertPoint(&Shape.AllocaSpillBlock->front());
1939+
Builder.SetInsertPoint(Shape.AllocaSpillBlock,
1940+
Shape.AllocaSpillBlock->begin());
19391941
SmallVector<Instruction *, 4> UsersToUpdate;
19401942
for (const auto &A : FrameData.Allocas) {
19411943
AllocaInst *Alloca = A.Alloca;

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,8 @@ static bool canRewriteGEPAsOffset(Type *ElemTy, Value *Start, Value *Base,
514514
static void setInsertionPoint(IRBuilder<> &Builder, Value *V,
515515
bool Before = true) {
516516
if (auto *PHI = dyn_cast<PHINode>(V)) {
517-
Builder.SetInsertPoint(&*PHI->getParent()->getFirstInsertionPt());
517+
BasicBlock *Parent = PHI->getParent();
518+
Builder.SetInsertPoint(Parent, Parent->getFirstInsertionPt());
518519
return;
519520
}
520521
if (auto *I = dyn_cast<Instruction>(V)) {
@@ -526,7 +527,7 @@ static void setInsertionPoint(IRBuilder<> &Builder, Value *V,
526527
if (auto *A = dyn_cast<Argument>(V)) {
527528
// Set the insertion point in the entry block.
528529
BasicBlock &Entry = A->getParent()->getEntryBlock();
529-
Builder.SetInsertPoint(&*Entry.getFirstInsertionPt());
530+
Builder.SetInsertPoint(&Entry, Entry.getFirstInsertionPt());
530531
return;
531532
}
532533
// Otherwise, this is a constant and we don't need to set a new

llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ static Value *simplifyUsingControlFlow(InstCombiner &Self, PHINode &PN,
13681368
// sinking.
13691369
auto InsertPt = BB->getFirstInsertionPt();
13701370
if (InsertPt != BB->end()) {
1371-
Self.Builder.SetInsertPoint(&*InsertPt);
1371+
Self.Builder.SetInsertPoint(&*BB, InsertPt);
13721372
return Self.Builder.CreateNot(Cond);
13731373
}
13741374

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2567,7 +2567,7 @@ static Instruction *foldSelectToPhiImpl(SelectInst &Sel, BasicBlock *BB,
25672567
return nullptr;
25682568
}
25692569

2570-
Builder.SetInsertPoint(&*BB->begin());
2570+
Builder.SetInsertPoint(BB, BB->begin());
25712571
auto *PN = Builder.CreatePHI(Sel.getType(), Inputs.size());
25722572
for (auto *Pred : predecessors(BB))
25732573
PN->addIncoming(Inputs[Pred], Pred);

llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ Instruction *InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse(
11211121
// Note that the same block can be a predecessor more than once,
11221122
// and we need to preserve that invariant for the PHI node.
11231123
BuilderTy::InsertPointGuard Guard(Builder);
1124-
Builder.SetInsertPoint(UseBB->getFirstNonPHI());
1124+
Builder.SetInsertPoint(UseBB, UseBB->getFirstNonPHIIt());
11251125
auto *PHI =
11261126
Builder.CreatePHI(AggTy, Preds.size(), OrigIVI.getName() + ".merged");
11271127
for (BasicBlock *Pred : Preds)

llvm/lib/Transforms/Scalar/LoopBoundSplit.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ static bool splitLoopBound(Loop &L, DominatorTree &DT, LoopInfo &LI,
430430
ExitingCond.BI->setSuccessor(1, PostLoopPreHeader);
431431

432432
// Update phi node in exit block of post-loop.
433-
Builder.SetInsertPoint(&PostLoopPreHeader->front());
433+
Builder.SetInsertPoint(PostLoopPreHeader, PostLoopPreHeader->begin());
434434
for (PHINode &PN : PostLoop->getExitBlock()->phis()) {
435435
for (auto i : seq<int>(0, PN.getNumOperands())) {
436436
// Check incoming block is pre-loop's exiting block.

llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -2495,7 +2495,7 @@ bool LoopIdiomRecognize::recognizeShiftUntilBitTest() {
24952495
// Step 4: Rewrite the loop into a countable form, with canonical IV.
24962496

24972497
// The new canonical induction variable.
2498-
Builder.SetInsertPoint(&LoopHeaderBB->front());
2498+
Builder.SetInsertPoint(LoopHeaderBB, LoopHeaderBB->begin());
24992499
auto *IV = Builder.CreatePHI(Ty, 2, CurLoop->getName() + ".iv");
25002500

25012501
// The induction itself.
@@ -2819,11 +2819,11 @@ bool LoopIdiomRecognize::recognizeShiftUntilZero() {
28192819
// Step 3: Rewrite the loop into a countable form, with canonical IV.
28202820

28212821
// The new canonical induction variable.
2822-
Builder.SetInsertPoint(&LoopHeaderBB->front());
2822+
Builder.SetInsertPoint(LoopHeaderBB, LoopHeaderBB->begin());
28232823
auto *CIV = Builder.CreatePHI(Ty, 2, CurLoop->getName() + ".iv");
28242824

28252825
// The induction itself.
2826-
Builder.SetInsertPoint(LoopHeaderBB->getFirstNonPHI());
2826+
Builder.SetInsertPoint(LoopHeaderBB, LoopHeaderBB->getFirstNonPHIIt());
28272827
auto *CIVNext =
28282828
Builder.CreateAdd(CIV, ConstantInt::get(Ty, 1), CIV->getName() + ".next",
28292829
/*HasNUW=*/true, /*HasNSW=*/Bitwidth != 2);

llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,7 @@ makeStatepointExplicitImpl(CallBase *Call, /* to replace */
18271827
UnwindBlock->getUniquePredecessor() &&
18281828
"can't safely insert in this block!");
18291829

1830-
Builder.SetInsertPoint(&*UnwindBlock->getFirstInsertionPt());
1830+
Builder.SetInsertPoint(UnwindBlock, UnwindBlock->getFirstInsertionPt());
18311831
Builder.SetCurrentDebugLocation(II->getDebugLoc());
18321832

18331833
// Attach exceptional gc relocates to the landingpad.
@@ -1842,7 +1842,7 @@ makeStatepointExplicitImpl(CallBase *Call, /* to replace */
18421842
NormalDest->getUniquePredecessor() &&
18431843
"can't safely insert in this block!");
18441844

1845-
Builder.SetInsertPoint(&*NormalDest->getFirstInsertionPt());
1845+
Builder.SetInsertPoint(NormalDest, NormalDest->getFirstInsertionPt());
18461846

18471847
// gc relocates will be generated later as if it were regular call
18481848
// statepoint

llvm/lib/Transforms/Scalar/SROA.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -3438,7 +3438,8 @@ class llvm::sroa::AllocaSliceRewriter
34383438
// dominate the PHI.
34393439
IRBuilderBase::InsertPointGuard Guard(IRB);
34403440
if (isa<PHINode>(OldPtr))
3441-
IRB.SetInsertPoint(&*OldPtr->getParent()->getFirstInsertionPt());
3441+
IRB.SetInsertPoint(OldPtr->getParent(),
3442+
OldPtr->getParent()->getFirstInsertionPt());
34423443
else
34433444
IRB.SetInsertPoint(OldPtr);
34443445
IRB.SetCurrentDebugLocation(OldPtr->getDebugLoc());
@@ -3827,7 +3828,7 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
38273828

38283829
SmallVector<Value *, 4> Index(GEPI.indices());
38293830
bool IsInBounds = GEPI.isInBounds();
3830-
IRB.SetInsertPoint(GEPI.getParent()->getFirstNonPHI());
3831+
IRB.SetInsertPoint(GEPI.getParent(), GEPI.getParent()->getFirstNonPHIIt());
38313832
PHINode *NewPN = IRB.CreatePHI(GEPI.getType(), PHI->getNumIncomingValues(),
38323833
PHI->getName() + ".sroa.phi");
38333834
for (unsigned I = 0, E = PHI->getNumIncomingValues(); I != E; ++I) {

llvm/lib/Transforms/Utils/CallPromotionUtils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static void createRetPHINode(Instruction *OrigInst, Instruction *NewInst,
111111
if (OrigInst->getType()->isVoidTy() || OrigInst->use_empty())
112112
return;
113113

114-
Builder.SetInsertPoint(&MergeBlock->front());
114+
Builder.SetInsertPoint(MergeBlock, MergeBlock->begin());
115115
PHINode *Phi = Builder.CreatePHI(OrigInst->getType(), 0);
116116
SmallVector<User *, 16> UsersToUpdate(OrigInst->users());
117117
for (User *U : UsersToUpdate)

llvm/lib/Transforms/Utils/InlineFunction.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2439,7 +2439,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
24392439
// `Caller->isPresplitCoroutine()` would affect AlwaysInliner at O0 only.
24402440
if ((InsertLifetime || Caller->isPresplitCoroutine()) &&
24412441
!IFI.StaticAllocas.empty()) {
2442-
IRBuilder<> builder(&FirstNewBlock->front());
2442+
IRBuilder<> builder(&*FirstNewBlock, FirstNewBlock->begin());
24432443
for (unsigned ai = 0, ae = IFI.StaticAllocas.size(); ai != ae; ++ai) {
24442444
AllocaInst *AI = IFI.StaticAllocas[ai];
24452445
// Don't mark swifterror allocas. They can't have bitcast uses.

0 commit comments

Comments
 (0)