Skip to content

Commit 2fe81ed

Browse files
committed
[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.
1 parent a691f65 commit 2fe81ed

Some content is hidden

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

50 files changed

+526
-430
lines changed

llvm/include/llvm/Analysis/ValueTracking.h

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,11 @@ Value *isBytewiseValue(Value *V, const DataLayout &DL);
596596
/// indexed is already around as a register, for example if it were inserted
597597
/// directly into the aggregate.
598598
///
599-
/// If InsertBefore is not null, this function will duplicate (modified)
599+
/// If InsertBefore is not empty, this function will duplicate (modified)
600600
/// insertvalues when a part of a nested struct is extracted.
601-
Value *FindInsertedValue(Value *V, ArrayRef<unsigned> idx_range,
602-
Instruction *InsertBefore = nullptr);
601+
Value *FindInsertedValue(
602+
Value *V, ArrayRef<unsigned> idx_range,
603+
std::optional<BasicBlock::iterator> InsertBefore = std::nullopt);
603604

604605
/// Analyze the specified pointer to see if it can be expressed as a base
605606
/// pointer plus a constant offset. Return the base and offset to the caller.
@@ -793,6 +794,15 @@ bool isSafeToSpeculativelyExecute(const Instruction *I,
793794
const DominatorTree *DT = nullptr,
794795
const TargetLibraryInfo *TLI = nullptr);
795796

797+
inline bool
798+
isSafeToSpeculativelyExecute(const Instruction *I, BasicBlock::iterator CtxI,
799+
AssumptionCache *AC = nullptr,
800+
const DominatorTree *DT = nullptr,
801+
const TargetLibraryInfo *TLI = nullptr) {
802+
// Take an iterator, and unwrap it into an Instruction *.
803+
return isSafeToSpeculativelyExecute(I, &*CtxI, AC, DT, TLI);
804+
}
805+
796806
/// This returns the same result as isSafeToSpeculativelyExecute if Opcode is
797807
/// the actual opcode of Inst. If the provided and actual opcode differ, the
798808
/// function (virtually) overrides the opcode of Inst with the provided
@@ -1019,6 +1029,15 @@ bool isGuaranteedNotToBePoison(const Value *V, AssumptionCache *AC = nullptr,
10191029
const DominatorTree *DT = nullptr,
10201030
unsigned Depth = 0);
10211031

1032+
inline bool isGuaranteedNotToBePoison(const Value *V, AssumptionCache *AC,
1033+
BasicBlock::iterator CtxI,
1034+
const DominatorTree *DT = nullptr,
1035+
unsigned Depth = 0) {
1036+
// Takes an iterator as a position, passes down to Instruction *
1037+
// implementation.
1038+
return isGuaranteedNotToBePoison(V, AC, &*CtxI, DT, Depth);
1039+
}
1040+
10221041
/// Returns true if V cannot be undef, but may be poison.
10231042
bool isGuaranteedNotToBeUndef(const Value *V, AssumptionCache *AC = nullptr,
10241043
const Instruction *CtxI = nullptr,

llvm/include/llvm/IR/Dominators.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,13 @@ class DominatorTree : public DominatorTreeBase<BasicBlock, false> {
189189
/// like unreachable code or trivial phi cycles).
190190
/// * Invoke Defs only dominate uses in their default destination.
191191
bool dominates(const Value *Def, const Use &U) const;
192+
192193
/// Return true if value Def dominates all possible uses inside instruction
193194
/// User. Same comments as for the Use-based API apply.
194195
bool dominates(const Value *Def, const Instruction *User) const;
196+
bool dominates(const Value *Def, BasicBlock::iterator User) const {
197+
return dominates(Def, &*User);
198+
}
195199

196200
/// Returns true if Def would dominate a use in any instruction in BB.
197201
/// If Def is an instruction in BB, then Def does not dominate BB.

llvm/include/llvm/Transforms/Scalar/Reassociate.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ class ReassociatePass : public PassInfoMixin<ReassociatePass> {
110110
SmallVectorImpl<reassociate::ValueEntry> &Ops);
111111
Value *OptimizeXor(Instruction *I,
112112
SmallVectorImpl<reassociate::ValueEntry> &Ops);
113-
bool CombineXorOpnd(Instruction *I, reassociate::XorOpnd *Opnd1,
113+
bool CombineXorOpnd(BasicBlock::iterator It, reassociate::XorOpnd *Opnd1,
114114
APInt &ConstOpnd, Value *&Res);
115-
bool CombineXorOpnd(Instruction *I, reassociate::XorOpnd *Opnd1,
115+
bool CombineXorOpnd(BasicBlock::iterator It, reassociate::XorOpnd *Opnd1,
116116
reassociate::XorOpnd *Opnd2, APInt &ConstOpnd,
117117
Value *&Res);
118118
Value *buildMinimalMultiplyDAG(IRBuilderBase &Builder,

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5536,10 +5536,10 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout &DL) {
55365536
// indices from Idxs that should be left out when inserting into the resulting
55375537
// struct. To is the result struct built so far, new insertvalue instructions
55385538
// build on that.
5539-
static Value *BuildSubAggregate(Value *From, Value* To, Type *IndexedType,
5539+
static Value *BuildSubAggregate(Value *From, Value *To, Type *IndexedType,
55405540
SmallVectorImpl<unsigned> &Idxs,
55415541
unsigned IdxSkip,
5542-
Instruction *InsertBefore) {
5542+
BasicBlock::iterator InsertBefore) {
55435543
StructType *STy = dyn_cast<StructType>(IndexedType);
55445544
if (STy) {
55455545
// Save the original To argument so we can modify it
@@ -5596,8 +5596,7 @@ static Value *BuildSubAggregate(Value *From, Value* To, Type *IndexedType,
55965596
//
55975597
// All inserted insertvalue instructions are inserted before InsertBefore
55985598
static Value *BuildSubAggregate(Value *From, ArrayRef<unsigned> idx_range,
5599-
Instruction *InsertBefore) {
5600-
assert(InsertBefore && "Must have someplace to insert!");
5599+
BasicBlock::iterator InsertBefore) {
56015600
Type *IndexedType = ExtractValueInst::getIndexedType(From->getType(),
56025601
idx_range);
56035602
Value *To = PoisonValue::get(IndexedType);
@@ -5613,8 +5612,9 @@ static Value *BuildSubAggregate(Value *From, ArrayRef<unsigned> idx_range,
56135612
///
56145613
/// If InsertBefore is not null, this function will duplicate (modified)
56155614
/// insertvalues when a part of a nested struct is extracted.
5616-
Value *llvm::FindInsertedValue(Value *V, ArrayRef<unsigned> idx_range,
5617-
Instruction *InsertBefore) {
5615+
Value *
5616+
llvm::FindInsertedValue(Value *V, ArrayRef<unsigned> idx_range,
5617+
std::optional<BasicBlock::iterator> InsertBefore) {
56185618
// Nothing to index? Just return V then (this is useful at the end of our
56195619
// recursion).
56205620
if (idx_range.empty())
@@ -5653,15 +5653,15 @@ Value *llvm::FindInsertedValue(Value *V, ArrayRef<unsigned> idx_range,
56535653
// which allows the unused 0,0 element from the nested struct to be
56545654
// removed.
56555655
return BuildSubAggregate(V, ArrayRef(idx_range.begin(), req_idx),
5656-
InsertBefore);
5656+
*InsertBefore);
56575657
}
56585658

56595659
// This insert value inserts something else than what we are looking for.
56605660
// See if the (aggregate) value inserted into has the value we are
56615661
// looking for, then.
56625662
if (*req_idx != *i)
56635663
return FindInsertedValue(I->getAggregateOperand(), idx_range,
5664-
InsertBefore);
5664+
*InsertBefore);
56655665
}
56665666
// If we end up here, the indices of the insertvalue match with those
56675667
// requested (though possibly only partially). Now we recursively look at

llvm/lib/Transforms/Coroutines/CoroElide.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ static std::unique_ptr<raw_fd_ostream> getOrCreateLogFile() {
141141
void Lowerer::elideHeapAllocations(Function *F, uint64_t FrameSize,
142142
Align FrameAlign, AAResults &AA) {
143143
LLVMContext &C = F->getContext();
144-
auto *InsertPt =
145-
getFirstNonAllocaInTheEntryBlock(CoroIds.front()->getFunction());
144+
BasicBlock::iterator InsertPt =
145+
getFirstNonAllocaInTheEntryBlock(CoroIds.front()->getFunction())
146+
->getIterator();
146147

147148
// Replacing llvm.coro.alloc with false will suppress dynamic
148149
// allocation as it is expected for the frontend to generate the code that

llvm/lib/Transforms/Coroutines/CoroSplit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ static bool simplifySuspendPoint(CoroSuspendInst *Suspend,
14231423

14241424
// No longer need a call to coro.resume or coro.destroy.
14251425
if (auto *Invoke = dyn_cast<InvokeInst>(CB)) {
1426-
BranchInst::Create(Invoke->getNormalDest(), Invoke);
1426+
BranchInst::Create(Invoke->getNormalDest(), Invoke->getIterator());
14271427
}
14281428

14291429
// Grab the CalledValue from CB before erasing the CallInstr.

llvm/lib/Transforms/Coroutines/Coroutines.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Value *coro::LowererBase::makeSubFnCall(Value *Arg, int Index,
5555
assert(Index >= CoroSubFnInst::IndexFirst &&
5656
Index < CoroSubFnInst::IndexLast &&
5757
"makeSubFnCall: Index value out of range");
58-
return CallInst::Create(Fn, {Arg, IndexVal}, "", InsertPt);
58+
return CallInst::Create(Fn, {Arg, IndexVal}, "", InsertPt->getIterator());
5959
}
6060

6161
// NOTE: Must be sorted!
@@ -157,8 +157,8 @@ static CoroSaveInst *createCoroSave(CoroBeginInst *CoroBegin,
157157
CoroSuspendInst *SuspendInst) {
158158
Module *M = SuspendInst->getModule();
159159
auto *Fn = Intrinsic::getDeclaration(M, Intrinsic::coro_save);
160-
auto *SaveInst =
161-
cast<CoroSaveInst>(CallInst::Create(Fn, CoroBegin, "", SuspendInst));
160+
auto *SaveInst = cast<CoroSaveInst>(
161+
CallInst::Create(Fn, CoroBegin, "", SuspendInst->getIterator()));
162162
assert(!SuspendInst->getCoroSave());
163163
SuspendInst->setArgOperand(0, SaveInst);
164164
return SaveInst;
@@ -362,7 +362,7 @@ void coro::Shape::buildFrom(Function &F) {
362362
// calls, but that messes with our invariants. Re-insert the
363363
// bitcast and ignore this type mismatch.
364364
if (CastInst::isBitCastable(SrcTy, *RI)) {
365-
auto BCI = new BitCastInst(*SI, *RI, "", Suspend);
365+
auto BCI = new BitCastInst(*SI, *RI, "", Suspend->getIterator());
366366
SI->set(BCI);
367367
continue;
368368
}

llvm/lib/Transforms/IPO/ArgumentPromotion.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,10 @@ doPromotion(Function *F, FunctionAnalysisManager &FAM,
266266
CallBase *NewCS = nullptr;
267267
if (InvokeInst *II = dyn_cast<InvokeInst>(&CB)) {
268268
NewCS = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
269-
Args, OpBundles, "", &CB);
269+
Args, OpBundles, "", CB.getIterator());
270270
} else {
271-
auto *NewCall = CallInst::Create(NF, Args, OpBundles, "", &CB);
271+
auto *NewCall =
272+
CallInst::Create(NF, Args, OpBundles, "", CB.getIterator());
272273
NewCall->setTailCallKind(cast<CallInst>(&CB)->getTailCallKind());
273274
NewCS = NewCall;
274275
}

llvm/lib/Transforms/IPO/Attributor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3123,12 +3123,12 @@ ChangeStatus Attributor::rewriteFunctionSignatures(
31233123
// Create a new call or invoke instruction to replace the old one.
31243124
CallBase *NewCB;
31253125
if (InvokeInst *II = dyn_cast<InvokeInst>(OldCB)) {
3126-
NewCB =
3127-
InvokeInst::Create(NewFn, II->getNormalDest(), II->getUnwindDest(),
3128-
NewArgOperands, OperandBundleDefs, "", OldCB);
3126+
NewCB = InvokeInst::Create(NewFn, II->getNormalDest(),
3127+
II->getUnwindDest(), NewArgOperands,
3128+
OperandBundleDefs, "", OldCB->getIterator());
31293129
} else {
31303130
auto *NewCI = CallInst::Create(NewFn, NewArgOperands, OperandBundleDefs,
3131-
"", OldCB);
3131+
"", OldCB->getIterator());
31323132
NewCI->setTailCallKind(cast<CallInst>(OldCB)->getTailCallKind());
31333133
NewCB = NewCI;
31343134
}

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6128,8 +6128,8 @@ struct AAValueSimplifyImpl : AAValueSimplify {
61286128
return TypedV;
61296129
if (CtxI && V.getType()->canLosslesslyBitCastTo(&Ty))
61306130
return Check ? &V
6131-
: BitCastInst::CreatePointerBitCastOrAddrSpaceCast(&V, &Ty,
6132-
"", CtxI);
6131+
: BitCastInst::CreatePointerBitCastOrAddrSpaceCast(
6132+
&V, &Ty, "", CtxI->getIterator());
61336133
return nullptr;
61346134
}
61356135

@@ -6731,8 +6731,9 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
67316731
Size = SizeOffsetPair.Size;
67326732
}
67336733

6734-
Instruction *IP =
6735-
AI.MoveAllocaIntoEntry ? &F->getEntryBlock().front() : AI.CB;
6734+
BasicBlock::iterator IP = AI.MoveAllocaIntoEntry
6735+
? F->getEntryBlock().begin()
6736+
: AI.CB->getIterator();
67366737

67376738
Align Alignment(1);
67386739
if (MaybeAlign RetAlign = AI.CB->getRetAlign())
@@ -6753,7 +6754,7 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
67536754

67546755
if (Alloca->getType() != AI.CB->getType())
67556756
Alloca = BitCastInst::CreatePointerBitCastOrAddrSpaceCast(
6756-
Alloca, AI.CB->getType(), "malloc_cast", AI.CB);
6757+
Alloca, AI.CB->getType(), "malloc_cast", AI.CB->getIterator());
67576758

67586759
auto *I8Ty = Type::getInt8Ty(F->getContext());
67596760
auto *InitVal = getInitialValueOfAllocation(AI.CB, TLI, I8Ty);
@@ -7450,10 +7451,10 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
74507451
/// The values needed are taken from the arguments of \p F starting at
74517452
/// position \p ArgNo.
74527453
static void createInitialization(Type *PrivType, Value &Base, Function &F,
7453-
unsigned ArgNo, Instruction &IP) {
7454+
unsigned ArgNo, BasicBlock::iterator IP) {
74547455
assert(PrivType && "Expected privatizable type!");
74557456

7456-
IRBuilder<NoFolder> IRB(&IP);
7457+
IRBuilder<NoFolder> IRB(IP->getParent(), IP);
74577458
const DataLayout &DL = F.getParent()->getDataLayout();
74587459

74597460
// Traverse the type, build GEPs and stores.
@@ -7462,17 +7463,17 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
74627463
for (unsigned u = 0, e = PrivStructType->getNumElements(); u < e; u++) {
74637464
Value *Ptr =
74647465
constructPointer(&Base, PrivStructLayout->getElementOffset(u), IRB);
7465-
new StoreInst(F.getArg(ArgNo + u), Ptr, &IP);
7466+
new StoreInst(F.getArg(ArgNo + u), Ptr, IP);
74667467
}
74677468
} else if (auto *PrivArrayType = dyn_cast<ArrayType>(PrivType)) {
74687469
Type *PointeeTy = PrivArrayType->getElementType();
74697470
uint64_t PointeeTySize = DL.getTypeStoreSize(PointeeTy);
74707471
for (unsigned u = 0, e = PrivArrayType->getNumElements(); u < e; u++) {
74717472
Value *Ptr = constructPointer(&Base, u * PointeeTySize, IRB);
7472-
new StoreInst(F.getArg(ArgNo + u), Ptr, &IP);
7473+
new StoreInst(F.getArg(ArgNo + u), Ptr, IP);
74737474
}
74747475
} else {
7475-
new StoreInst(F.getArg(ArgNo), &Base, &IP);
7476+
new StoreInst(F.getArg(ArgNo), &Base, IP);
74767477
}
74777478
}
74787479

@@ -7495,7 +7496,7 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
74957496
Type *PointeeTy = PrivStructType->getElementType(u);
74967497
Value *Ptr =
74977498
constructPointer(Base, PrivStructLayout->getElementOffset(u), IRB);
7498-
LoadInst *L = new LoadInst(PointeeTy, Ptr, "", IP);
7499+
LoadInst *L = new LoadInst(PointeeTy, Ptr, "", IP->getIterator());
74997500
L->setAlignment(Alignment);
75007501
ReplacementValues.push_back(L);
75017502
}
@@ -7504,12 +7505,12 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
75047505
uint64_t PointeeTySize = DL.getTypeStoreSize(PointeeTy);
75057506
for (unsigned u = 0, e = PrivArrayType->getNumElements(); u < e; u++) {
75067507
Value *Ptr = constructPointer(Base, u * PointeeTySize, IRB);
7507-
LoadInst *L = new LoadInst(PointeeTy, Ptr, "", IP);
7508+
LoadInst *L = new LoadInst(PointeeTy, Ptr, "", IP->getIterator());
75087509
L->setAlignment(Alignment);
75097510
ReplacementValues.push_back(L);
75107511
}
75117512
} else {
7512-
LoadInst *L = new LoadInst(PrivType, Base, "", IP);
7513+
LoadInst *L = new LoadInst(PrivType, Base, "", IP->getIterator());
75137514
L->setAlignment(Alignment);
75147515
ReplacementValues.push_back(L);
75157516
}
@@ -7549,13 +7550,13 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
75497550
[=](const Attributor::ArgumentReplacementInfo &ARI,
75507551
Function &ReplacementFn, Function::arg_iterator ArgIt) {
75517552
BasicBlock &EntryBB = ReplacementFn.getEntryBlock();
7552-
Instruction *IP = &*EntryBB.getFirstInsertionPt();
7553+
BasicBlock::iterator IP = EntryBB.getFirstInsertionPt();
75537554
const DataLayout &DL = IP->getModule()->getDataLayout();
75547555
unsigned AS = DL.getAllocaAddrSpace();
75557556
Instruction *AI = new AllocaInst(*PrivatizableType, AS,
75567557
Arg->getName() + ".priv", IP);
75577558
createInitialization(*PrivatizableType, *AI, ReplacementFn,
7558-
ArgIt->getArgNo(), *IP);
7559+
ArgIt->getArgNo(), IP);
75597560

75607561
if (AI->getType() != Arg->getType())
75617562
AI = BitCastInst::CreatePointerBitCastOrAddrSpaceCast(
@@ -12313,10 +12314,10 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
1231312314
Value *FP = CB->getCalledOperand();
1231412315
if (FP->getType()->getPointerAddressSpace())
1231512316
FP = new AddrSpaceCastInst(FP, PointerType::get(FP->getType(), 0),
12316-
FP->getName() + ".as0", CB);
12317+
FP->getName() + ".as0", CB->getIterator());
1231712318

1231812319
bool CBIsVoid = CB->getType()->isVoidTy();
12319-
Instruction *IP = CB;
12320+
BasicBlock::iterator IP = CB->getIterator();
1232012321
FunctionType *CSFT = CB->getFunctionType();
1232112322
SmallVector<Value *> CSArgs(CB->arg_begin(), CB->arg_end());
1232212323

@@ -12336,8 +12337,9 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
1233612337
promoteCall(*CB, NewCallee, nullptr);
1233712338
return ChangeStatus::CHANGED;
1233812339
}
12339-
Instruction *NewCall = CallInst::Create(FunctionCallee(CSFT, NewCallee),
12340-
CSArgs, CB->getName(), CB);
12340+
Instruction *NewCall =
12341+
CallInst::Create(FunctionCallee(CSFT, NewCallee), CSArgs,
12342+
CB->getName(), CB->getIterator());
1234112343
if (!CBIsVoid)
1234212344
A.changeAfterManifest(IRPosition::callsite_returned(*CB), *NewCall);
1234312345
A.deleteAfterManifest(*CB);
@@ -12372,11 +12374,11 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
1237212374
A.registerManifestAddedBasicBlock(*CBBB);
1237312375
auto *SplitTI = cast<BranchInst>(LastCmp->getNextNode());
1237412376
BasicBlock *ElseBB;
12375-
if (IP == CB) {
12377+
if (&*IP == CB) {
1237612378
ElseBB = BasicBlock::Create(ThenTI->getContext(), "",
1237712379
ThenTI->getFunction(), CBBB);
1237812380
A.registerManifestAddedBasicBlock(*ElseBB);
12379-
IP = BranchInst::Create(CBBB, ElseBB);
12381+
IP = BranchInst::Create(CBBB, ElseBB)->getIterator();
1238012382
SplitTI->replaceUsesOfWith(CBBB, ElseBB);
1238112383
} else {
1238212384
ElseBB = IP->getParent();
@@ -12390,7 +12392,7 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
1239012392
NewCall = &cast<CallInst>(promoteCall(*CBClone, NewCallee, &RetBC));
1239112393
} else {
1239212394
NewCall = CallInst::Create(FunctionCallee(CSFT, NewCallee), CSArgs,
12393-
CB->getName(), ThenTI);
12395+
CB->getName(), ThenTI->getIterator());
1239412396
}
1239512397
NewCalls.push_back({NewCall, RetBC});
1239612398
}
@@ -12416,7 +12418,7 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
1241612418
} else {
1241712419
auto *CBClone = cast<CallInst>(CB->clone());
1241812420
CBClone->setName(CB->getName());
12419-
CBClone->insertBefore(IP);
12421+
CBClone->insertBefore(*IP->getParent(), IP);
1242012422
NewCalls.push_back({CBClone, nullptr});
1242112423
AttachCalleeMetadata(*CBClone);
1242212424
}
@@ -12425,7 +12427,7 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
1242512427
if (!CBIsVoid) {
1242612428
auto *PHI = PHINode::Create(CB->getType(), NewCalls.size(),
1242712429
CB->getName() + ".phi",
12428-
&*CB->getParent()->getFirstInsertionPt());
12430+
CB->getParent()->getFirstInsertionPt());
1242912431
for (auto &It : NewCalls) {
1243012432
CallBase *NewCall = It.first;
1243112433
Instruction *CallRet = It.second ? It.second : It.first;
@@ -12783,9 +12785,11 @@ struct AAAllocationInfoImpl : public AAAllocationInfo {
1278312785
auto *NumBytesToValue =
1278412786
ConstantInt::get(I->getContext(), APInt(32, NumBytesToAllocate));
1278512787

12788+
BasicBlock::iterator insertPt = AI->getIterator();
12789+
insertPt = std::next(insertPt);
1278612790
AllocaInst *NewAllocaInst =
1278712791
new AllocaInst(CharType, AI->getAddressSpace(), NumBytesToValue,
12788-
AI->getAlign(), AI->getName(), AI->getNextNode());
12792+
AI->getAlign(), AI->getName(), insertPt);
1278912793

1279012794
if (A.changeAfterManifest(IRPosition::inst(*AI), *NewAllocaInst))
1279112795
return ChangeStatus::CHANGED;

0 commit comments

Comments
 (0)