Skip to content

Commit 6481dc5

Browse files
authored
[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.
1 parent 317277e commit 6481dc5

File tree

97 files changed

+252
-326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+252
-326
lines changed

clang/lib/CodeGen/CGBlocks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,7 @@ llvm::Function *CodeGenFunction::GenerateBlockFunction(
15451545
entry_ptr = entry_ptr->getNextNonDebugInstruction()->getIterator();
15461546
else
15471547
entry_ptr = entry->end();
1548-
Builder.SetInsertPoint(entry, entry_ptr);
1548+
Builder.SetInsertPoint(entry_ptr);
15491549

15501550
// Emit debug information for all the DeclRefExprs.
15511551
// FIXME: also for 'this'

clang/lib/CodeGen/CGGPUBuiltin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ RValue CodeGenFunction::EmitAMDGPUDevicePrintfCallExpr(const CallExpr *E) {
202202
Args.push_back(Arg);
203203
}
204204

205-
llvm::IRBuilder<> IRB(Builder.GetInsertBlock(), Builder.GetInsertPoint());
205+
llvm::IRBuilder<> IRB(Builder.GetInsertPoint());
206206
IRB.SetCurrentDebugLocation(Builder.getCurrentDebugLocation());
207207

208208
bool isBuffered = (CGM.getTarget().getTargetOpts().AMDGPUPrintfKindVal ==
209209
clang::TargetOptions::AMDGPUPrintfKind::Buffered);
210210
auto Printf = llvm::emitAMDGPUPrintfCall(IRB, Args, isBuffered);
211-
Builder.SetInsertPoint(IRB.GetInsertBlock(), IRB.GetInsertPoint());
211+
Builder.SetInsertPoint(IRB.GetInsertPoint());
212212
return RValue::get(Printf);
213213
}
214214

clang/lib/CodeGen/CGHLSLRuntime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ void CGHLSLRuntime::generateGlobalCtorDtorCalls() {
436436
for (auto &F : M.functions()) {
437437
if (!F.hasFnAttribute("hlsl.shader"))
438438
continue;
439-
IRBuilder<> B(&F.getEntryBlock(), F.getEntryBlock().begin());
439+
IRBuilder<> B(F.getEntryBlock().begin());
440440
for (auto *Fn : CtorFns)
441441
B.CreateCall(FunctionCallee(Fn));
442442

clang/lib/CodeGen/CGObjC.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,21 +2970,20 @@ static llvm::Value *emitARCOperationAfterCall(CodeGenFunction &CGF,
29702970
value = doFallback(CGF, value);
29712971
} else if (llvm::CallInst *call = dyn_cast<llvm::CallInst>(value)) {
29722972
// Place the retain immediately following the call.
2973-
CGF.Builder.SetInsertPoint(call->getParent(),
2974-
++llvm::BasicBlock::iterator(call));
2973+
CGF.Builder.SetInsertPoint(++llvm::BasicBlock::iterator(call));
29752974
value = doAfterCall(CGF, value);
29762975
} else if (llvm::InvokeInst *invoke = dyn_cast<llvm::InvokeInst>(value)) {
29772976
// Place the retain at the beginning of the normal destination block.
29782977
llvm::BasicBlock *BB = invoke->getNormalDest();
2979-
CGF.Builder.SetInsertPoint(BB, BB->begin());
2978+
CGF.Builder.SetInsertPoint(BB->begin());
29802979
value = doAfterCall(CGF, value);
29812980

29822981
// Bitcasts can arise because of related-result returns. Rewrite
29832982
// the operand.
29842983
} else if (llvm::BitCastInst *bitcast = dyn_cast<llvm::BitCastInst>(value)) {
29852984
// Change the insert point to avoid emitting the fall-back call after the
29862985
// bitcast.
2987-
CGF.Builder.SetInsertPoint(bitcast->getParent(), bitcast->getIterator());
2986+
CGF.Builder.SetInsertPoint(bitcast->getIterator());
29882987
llvm::Value *operand = bitcast->getOperand(0);
29892988
operand = emitARCOperationAfterCall(CGF, operand, doAfterCall, doFallback);
29902989
bitcast->setOperand(0, operand);

clang/lib/CodeGen/CGObjCMac.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4417,7 +4417,7 @@ void FragileHazards::emitHazardsInNewBlocks() {
44174417
// call. If the call throws, then this is sufficient to
44184418
// guarantee correctness as long as it doesn't also write to any
44194419
// locals.
4420-
Builder.SetInsertPoint(&BB, BI);
4420+
Builder.SetInsertPoint(BI);
44214421
emitReadHazard(Builder);
44224422
}
44234423
}

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction &CGF,
14471447
if (!Elem.second.ServiceInsertPt)
14481448
setLocThreadIdInsertPt(CGF);
14491449
CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
1450-
CGF.Builder.SetInsertPoint(Elem.second.ServiceInsertPt);
1450+
CGF.Builder.SetInsertPoint(&*Elem.second.ServiceInsertPt);
14511451
auto DL = ApplyDebugLocation::CreateDefaultArtificial(CGF, Loc);
14521452
llvm::CallInst *Call = CGF.Builder.CreateCall(
14531453
OMPBuilder.getOrCreateRuntimeFunction(CGM.getModule(),

clang/lib/CodeGen/CGStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3076,7 +3076,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
30763076
if (IsGCCAsmGoto && !CBRRegResults.empty()) {
30773077
for (llvm::BasicBlock *Succ : CBR->getIndirectDests()) {
30783078
llvm::IRBuilderBase::InsertPointGuard IPG(Builder);
3079-
Builder.SetInsertPoint(Succ, --(Succ->end()));
3079+
Builder.SetInsertPoint(--(Succ->end()));
30803080
EmitAsmStores(*this, S, CBRRegResults[Succ], ResultRegTypes,
30813081
ResultTruncRegTypes, ResultRegDests, ResultRegQualTys,
30823082
ResultTypeRequiresCast, ResultRegIsFlagReg);

clang/lib/CodeGen/CodeGenABITypes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ llvm::Value *CodeGen::getCXXDestructorImplicitParam(
123123
CGF.CurCodeDecl = D;
124124
CGF.CurFuncDecl = D;
125125
CGF.CurFn = InsertBlock->getParent();
126-
CGF.Builder.SetInsertPoint(InsertBlock, InsertPoint);
126+
CGF.Builder.SetInsertPoint(InsertPoint);
127127
return CGM.getCXXABI().getCXXDestructorImplicitParam(
128128
CGF, D, Type, ForVirtualBase, Delegating);
129129
}

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2764,7 +2764,7 @@ void CodeGenFunction::EmitSanitizerStatReport(llvm::SanitizerStatKind SSK) {
27642764
if (!CGM.getCodeGenOpts().SanitizeStats)
27652765
return;
27662766

2767-
llvm::IRBuilder<> IRB(Builder.GetInsertBlock(), Builder.GetInsertPoint());
2767+
llvm::IRBuilder<> IRB(Builder.GetInsertPoint());
27682768
IRB.SetCurrentDebugLocation(Builder.getCurrentDebugLocation());
27692769
CGM.getSanStats().create(IRB, SSK);
27702770
}
@@ -2883,7 +2883,7 @@ void CodeGenFunction::EmitAArch64MultiVersionResolver(
28832883
}
28842884

28852885
if (!AArch64CpuInitialized) {
2886-
Builder.SetInsertPoint(CurBlock, CurBlock->begin());
2886+
Builder.SetInsertPoint(CurBlock->begin());
28872887
EmitAArch64CpuInit();
28882888
AArch64CpuInitialized = true;
28892889
Builder.SetInsertPoint(CurBlock);

llvm/include/llvm/IR/IRBuilder.h

Lines changed: 15 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -173,37 +173,13 @@ class IRBuilderBase {
173173
BasicBlock::iterator GetInsertPoint() const { return InsertPt; }
174174
LLVMContext &getContext() const { return Context; }
175175

176-
/// This specifies that created instructions should be appended to the
177-
/// end of the specified block.
178-
void SetInsertPoint(BasicBlock *TheBB) {
179-
BB = TheBB;
180-
InsertPt = BB->end();
181-
}
182-
183-
/// This specifies that created instructions should be inserted before
184-
/// the specified instruction.
185-
void SetInsertPoint(Instruction *I) {
186-
BB = I->getParent();
187-
InsertPt = I->getIterator();
188-
assert(InsertPt != BB->end() && "Can't read debug loc from end()");
189-
SetCurrentDebugLocation(I->getStableDebugLoc());
190-
}
191-
192176
/// This specifies that created instructions should be inserted at the
193-
/// specified point.
194-
void SetInsertPoint(BasicBlock *TheBB, BasicBlock::iterator IP) {
195-
BB = TheBB;
196-
InsertPt = IP;
197-
if (IP != TheBB->end())
198-
SetCurrentDebugLocation(IP->getStableDebugLoc());
199-
}
200-
201-
/// This specifies that created instructions should be inserted at
202-
/// the specified point, but also requires that \p IP is dereferencable.
203-
void SetInsertPoint(BasicBlock::iterator IP) {
204-
BB = IP->getParent();
177+
/// specified insert position.
178+
void SetInsertPoint(InsertPosition IP) {
179+
BB = IP.getBasicBlock();
205180
InsertPt = IP;
206-
SetCurrentDebugLocation(IP->getStableDebugLoc());
181+
if (InsertPt != BB->end())
182+
SetCurrentDebugLocation(InsertPt->getStableDebugLoc());
207183
}
208184

209185
/// This specifies that created instructions should inserted at the beginning
@@ -286,7 +262,7 @@ class IRBuilderBase {
286262
/// Sets the current insert point to a previously-saved location.
287263
void restoreIP(InsertPoint IP) {
288264
if (IP.isSet())
289-
SetInsertPoint(IP.getBlock(), IP.getPoint());
265+
SetInsertPoint(IP.getPoint());
290266
else
291267
ClearInsertionPoint();
292268
}
@@ -2677,44 +2653,20 @@ class IRBuilder : public IRBuilderBase {
26772653
ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
26782654
: IRBuilderBase(C, this->Folder, this->Inserter, FPMathTag, OpBundles) {}
26792655

2680-
explicit IRBuilder(BasicBlock *TheBB, FolderTy Folder,
2681-
MDNode *FPMathTag = nullptr,
2682-
ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
2683-
: IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
2684-
FPMathTag, OpBundles),
2685-
Folder(Folder) {
2686-
SetInsertPoint(TheBB);
2687-
}
2688-
2689-
explicit IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag = nullptr,
2656+
explicit IRBuilder(InsertPosition IP, MDNode *FPMathTag = nullptr,
26902657
ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
2691-
: IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
2692-
FPMathTag, OpBundles) {
2693-
SetInsertPoint(TheBB);
2694-
}
2695-
2696-
explicit IRBuilder(Instruction *IP, MDNode *FPMathTag = nullptr,
2697-
ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
2698-
: IRBuilderBase(IP->getContext(), this->Folder, this->Inserter, FPMathTag,
2699-
OpBundles) {
2658+
: IRBuilderBase(IP.getBasicBlock()->getContext(), this->Folder,
2659+
this->Inserter, FPMathTag, OpBundles) {
27002660
SetInsertPoint(IP);
27012661
}
27022662

2703-
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, FolderTy Folder,
2704-
MDNode *FPMathTag = nullptr,
2705-
ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
2706-
: IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
2707-
FPMathTag, OpBundles),
2663+
explicit IRBuilder(InsertPosition IP, FolderTy Folder,
2664+
MDNode *FPMathTag = nullptr,
2665+
ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
2666+
: IRBuilderBase(IP.getBasicBlock()->getContext(), this->Folder,
2667+
this->Inserter, FPMathTag, OpBundles),
27082668
Folder(Folder) {
2709-
SetInsertPoint(TheBB, IP);
2710-
}
2711-
2712-
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP,
2713-
MDNode *FPMathTag = nullptr,
2714-
ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
2715-
: IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
2716-
FPMathTag, OpBundles) {
2717-
SetInsertPoint(TheBB, IP);
2669+
SetInsertPoint(IP);
27182670
}
27192671

27202672
/// Avoid copying the full IRBuilder. Prefer using InsertPointGuard

llvm/include/llvm/IR/Instruction.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,20 @@ template <> struct ilist_alloc_traits<Instruction> {
4444
iterator_range<simple_ilist<DbgRecord>::iterator>
4545
getDbgRecordRange(DbgMarker *);
4646

47+
/// Class used to generate an insert position (ultimately always a
48+
/// BasicBlock::iterator, which it will implicitly convert to) from either:
49+
/// - An Instruction, inserting immediately prior. This will soon be marked as
50+
/// deprecated.
51+
/// - A BasicBlock, inserting at the end.
52+
/// - An iterator, inserting at its position.
53+
/// - Any nullptr value, giving a blank iterator (not valid for insertion).
4754
class InsertPosition {
4855
using InstListType = SymbolTableList<Instruction, ilist_iterator_bits<true>,
4956
ilist_parent<BasicBlock>>;
5057
InstListType::iterator InsertAt;
5158

5259
public:
5360
InsertPosition(std::nullptr_t) : InsertAt() {}
54-
// LLVM_DEPRECATED("Use BasicBlock::iterators for insertion instead",
55-
// "BasicBlock::iterator")
5661
InsertPosition(Instruction *InsertBefore);
5762
InsertPosition(BasicBlock *InsertAtEnd);
5863
InsertPosition(InstListType::iterator InsertAt) : InsertAt(InsertAt) {}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,7 @@ class SCEVExpander : public SCEVVisitor<SCEVExpander, Value *> {
376376
Builder.SetInsertPoint(IP);
377377
}
378378

379-
void setInsertPoint(BasicBlock::iterator IP) {
380-
Builder.SetInsertPoint(IP->getParent(), IP);
381-
}
379+
void setInsertPoint(BasicBlock::iterator IP) { Builder.SetInsertPoint(IP); }
382380

383381
/// Clear the current insertion point. This is useful if the instruction
384382
/// that had been serving as the insertion point may have been deleted.

llvm/lib/Analysis/MemoryBuiltins.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ SizeOffsetValue ObjectSizeOffsetEvaluator::visitPHINode(PHINode &PHI) {
12171217
// Compute offset/size for each PHI incoming pointer.
12181218
for (unsigned i = 0, e = PHI.getNumIncomingValues(); i != e; ++i) {
12191219
BasicBlock *IncomingBlock = PHI.getIncomingBlock(i);
1220-
Builder.SetInsertPoint(IncomingBlock, IncomingBlock->getFirstInsertionPt());
1220+
Builder.SetInsertPoint(IncomingBlock->getFirstInsertionPt());
12211221
SizeOffsetValue EdgeData = compute_(PHI.getIncomingValue(i));
12221222

12231223
if (!EdgeData.bothKnown()) {

llvm/lib/CodeGen/AtomicExpandPass.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ Value *AtomicExpandImpl::insertRMWLLSCLoop(
12421242
StoreSuccess, ConstantInt::get(IntegerType::get(Ctx, 32), 0), "tryagain");
12431243
Builder.CreateCondBr(TryAgain, LoopBB, ExitBB);
12441244

1245-
Builder.SetInsertPoint(ExitBB, ExitBB->begin());
1245+
Builder.SetInsertPoint(ExitBB->begin());
12461246
return Loaded;
12471247
}
12481248

@@ -1478,7 +1478,7 @@ bool AtomicExpandImpl::expandAtomicCmpXchg(AtomicCmpXchgInst *CI) {
14781478
// succeeded or not. We expose this to later passes by converting any
14791479
// subsequent "icmp eq/ne %loaded, %oldval" into a use of an appropriate
14801480
// PHI.
1481-
Builder.SetInsertPoint(ExitBB, ExitBB->begin());
1481+
Builder.SetInsertPoint(ExitBB->begin());
14821482
PHINode *LoadedExit =
14831483
Builder.CreatePHI(UnreleasedLoad->getType(), 2, "loaded.exit");
14841484
LoadedExit->addIncoming(LoadedTryStore, SuccessBB);
@@ -1491,7 +1491,7 @@ bool AtomicExpandImpl::expandAtomicCmpXchg(AtomicCmpXchgInst *CI) {
14911491
// a type wider than the one in the cmpxchg instruction.
14921492
Value *LoadedFull = LoadedExit;
14931493

1494-
Builder.SetInsertPoint(ExitBB, std::next(Success->getIterator()));
1494+
Builder.SetInsertPoint(std::next(Success->getIterator()));
14951495
Value *Loaded = extractMaskedValue(Builder, LoadedFull, PMV);
14961496

14971497
// Look for any users of the cmpxchg that are just comparing the loaded value
@@ -1616,7 +1616,7 @@ Value *AtomicExpandImpl::insertRMWCmpXchgLoop(
16161616

16171617
Builder.CreateCondBr(Success, ExitBB, LoopBB);
16181618

1619-
Builder.SetInsertPoint(ExitBB, ExitBB->begin());
1619+
Builder.SetInsertPoint(ExitBB->begin());
16201620
return NewLoaded;
16211621
}
16221622

llvm/lib/CodeGen/CodeGenPrepare.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,7 +2355,7 @@ static bool despeculateCountZeros(IntrinsicInst *CountZeros,
23552355

23562356
// Create a PHI in the end block to select either the output of the intrinsic
23572357
// or the bit width of the operand.
2358-
Builder.SetInsertPoint(EndBlock, EndBlock->begin());
2358+
Builder.SetInsertPoint(EndBlock->begin());
23592359
PHINode *PN = Builder.CreatePHI(Ty, 2, "ctz");
23602360
replaceAllUsesWith(CountZeros, PN, FreshBBs, IsHugeFunc);
23612361
Value *BitWidth = Builder.getInt(APInt(SizeInBits, SizeInBits));
@@ -6306,7 +6306,7 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
63066306
NewBaseInsertBB = &BaseGEP->getFunction()->getEntryBlock();
63076307
NewBaseInsertPt = NewBaseInsertBB->getFirstInsertionPt();
63086308
}
6309-
IRBuilder<> NewBaseBuilder(NewBaseInsertBB, NewBaseInsertPt);
6309+
IRBuilder<> NewBaseBuilder(NewBaseInsertPt);
63106310
// Create a new base.
63116311
Value *BaseIndex = ConstantInt::get(PtrIdxTy, BaseOffset);
63126312
NewBaseGEP = OldBase;

llvm/lib/CodeGen/ExpandLargeFpConvert.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ static void expandFPToI(Instruction *FPToI) {
212212
Builder.CreateBr(End);
213213

214214
// cleanup:
215-
Builder.SetInsertPoint(End, End->begin());
215+
Builder.SetInsertPoint(End->begin());
216216
PHINode *Retval0 = Builder.CreatePHI(FPToI->getType(), 4);
217217

218218
Retval0->addIncoming(Cond8, IfThen5);
@@ -560,7 +560,7 @@ static void expandIToFP(Instruction *IToFP) {
560560
Builder.CreateBr(End);
561561

562562
// return:
563-
Builder.SetInsertPoint(End, End->begin());
563+
Builder.SetInsertPoint(End->begin());
564564
PHINode *Retval0 = Builder.CreatePHI(IToFP->getType(), 2);
565565
Retval0->addIncoming(A4, IfEnd26);
566566
Retval0->addIncoming(ConstantFP::getZero(IToFP->getType(), false), Entry);

llvm/lib/CodeGen/ExpandMemCmp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ void MemCmpExpansion::emitMemCmpResultBlock() {
574574
// need to be calculated and can simply return 1.
575575
if (IsUsedForZeroCmp) {
576576
BasicBlock::iterator InsertPt = ResBlock.BB->getFirstInsertionPt();
577-
Builder.SetInsertPoint(ResBlock.BB, InsertPt);
577+
Builder.SetInsertPoint(InsertPt);
578578
Value *Res = ConstantInt::get(Type::getInt32Ty(CI->getContext()), 1);
579579
PhiRes->addIncoming(Res, ResBlock.BB);
580580
BranchInst *NewBr = BranchInst::Create(EndBlock);
@@ -584,7 +584,7 @@ void MemCmpExpansion::emitMemCmpResultBlock() {
584584
return;
585585
}
586586
BasicBlock::iterator InsertPt = ResBlock.BB->getFirstInsertionPt();
587-
Builder.SetInsertPoint(ResBlock.BB, InsertPt);
587+
Builder.SetInsertPoint(InsertPt);
588588

589589
Value *Cmp = Builder.CreateICmp(ICmpInst::ICMP_ULT, ResBlock.PhiSrc1,
590590
ResBlock.PhiSrc2);
@@ -611,7 +611,7 @@ void MemCmpExpansion::setupResultBlockPHINodes() {
611611
}
612612

613613
void MemCmpExpansion::setupEndBlockPHINodes() {
614-
Builder.SetInsertPoint(EndBlock, EndBlock->begin());
614+
Builder.SetInsertPoint(EndBlock->begin());
615615
PhiRes = Builder.CreatePHI(Type::getInt32Ty(CI->getContext()), 2, "phi.res");
616616
}
617617

llvm/lib/CodeGen/ExpandVectorPredication.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ void CachingVPExpander::discardEVLParameter(VPIntrinsic &VPI) {
667667
auto *M = VPI.getModule();
668668
Function *VScaleFunc =
669669
Intrinsic::getDeclaration(M, Intrinsic::vscale, Int32Ty);
670-
IRBuilder<> Builder(VPI.getParent(), VPI.getIterator());
670+
IRBuilder<> Builder(VPI.getIterator());
671671
Value *FactorConst = Builder.getInt32(StaticElemCount.getKnownMinValue());
672672
Value *VScale = Builder.CreateCall(VScaleFunc, {}, "vscale");
673673
MaxEVL = Builder.CreateMul(VScale, FactorConst, "scalable_size",

llvm/lib/CodeGen/HardwareLoops.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ PHINode* HardwareLoop::InsertPHICounter(Value *NumElts, Value *EltsRem) {
580580
BasicBlock *Preheader = L->getLoopPreheader();
581581
BasicBlock *Header = L->getHeader();
582582
BasicBlock *Latch = ExitBranch->getParent();
583-
IRBuilder<> Builder(Header, Header->getFirstNonPHIIt());
583+
IRBuilder<> Builder(Header->getFirstNonPHIIt());
584584
PHINode *Index = Builder.CreatePHI(NumElts->getType(), 2);
585585
Index->addIncoming(NumElts, Preheader);
586586
Index->addIncoming(EltsRem, Latch);

llvm/lib/CodeGen/IntrinsicLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI,
4040
FunctionCallee FCache =
4141
M->getOrInsertFunction(NewFn, FunctionType::get(RetTy, ParamTys, false));
4242

43-
IRBuilder<> Builder(CI->getParent(), CI->getIterator());
43+
IRBuilder<> Builder(CI->getIterator());
4444
SmallVector<Value *, 8> Args(ArgBegin, ArgEnd);
4545
CallInst *NewCI = Builder.CreateCall(FCache, Args);
4646
NewCI->setName(CI->getName());

llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static bool lowerObjCCall(Function &F, const char *NewFn,
144144
auto *CI = cast<CallInst>(CB);
145145
assert(CI->getCalledFunction() && "Cannot lower an indirect call!");
146146

147-
IRBuilder<> Builder(CI->getParent(), CI->getIterator());
147+
IRBuilder<> Builder(CI->getIterator());
148148
SmallVector<Value *, 8> Args(CI->args());
149149
SmallVector<llvm::OperandBundleDef, 1> BundleList;
150150
CI->getOperandBundlesAsDefs(BundleList);

0 commit comments

Comments
 (0)