@@ -6128,8 +6128,8 @@ struct AAValueSimplifyImpl : AAValueSimplify {
6128
6128
return TypedV;
6129
6129
if (CtxI && V.getType ()->canLosslesslyBitCastTo (&Ty))
6130
6130
return Check ? &V
6131
- : BitCastInst::CreatePointerBitCastOrAddrSpaceCast (&V, &Ty,
6132
- " " , CtxI);
6131
+ : BitCastInst::CreatePointerBitCastOrAddrSpaceCast (
6132
+ &V, &Ty, " " , CtxI-> getIterator () );
6133
6133
return nullptr ;
6134
6134
}
6135
6135
@@ -6731,8 +6731,9 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
6731
6731
Size = SizeOffsetPair.Size ;
6732
6732
}
6733
6733
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 ();
6736
6737
6737
6738
Align Alignment (1 );
6738
6739
if (MaybeAlign RetAlign = AI.CB ->getRetAlign ())
@@ -6753,7 +6754,7 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
6753
6754
6754
6755
if (Alloca->getType () != AI.CB ->getType ())
6755
6756
Alloca = BitCastInst::CreatePointerBitCastOrAddrSpaceCast (
6756
- Alloca, AI.CB ->getType (), " malloc_cast" , AI.CB );
6757
+ Alloca, AI.CB ->getType (), " malloc_cast" , AI.CB -> getIterator () );
6757
6758
6758
6759
auto *I8Ty = Type::getInt8Ty (F->getContext ());
6759
6760
auto *InitVal = getInitialValueOfAllocation (AI.CB , TLI, I8Ty);
@@ -7450,10 +7451,10 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
7450
7451
// / The values needed are taken from the arguments of \p F starting at
7451
7452
// / position \p ArgNo.
7452
7453
static void createInitialization (Type *PrivType, Value &Base, Function &F,
7453
- unsigned ArgNo, Instruction & IP) {
7454
+ unsigned ArgNo, BasicBlock::iterator IP) {
7454
7455
assert (PrivType && " Expected privatizable type!" );
7455
7456
7456
- IRBuilder<NoFolder> IRB (& IP);
7457
+ IRBuilder<NoFolder> IRB (IP-> getParent (), IP);
7457
7458
const DataLayout &DL = F.getParent ()->getDataLayout ();
7458
7459
7459
7460
// Traverse the type, build GEPs and stores.
@@ -7462,17 +7463,17 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
7462
7463
for (unsigned u = 0 , e = PrivStructType->getNumElements (); u < e; u++) {
7463
7464
Value *Ptr =
7464
7465
constructPointer (&Base, PrivStructLayout->getElementOffset (u), IRB);
7465
- new StoreInst (F.getArg (ArgNo + u), Ptr, & IP);
7466
+ new StoreInst (F.getArg (ArgNo + u), Ptr, IP);
7466
7467
}
7467
7468
} else if (auto *PrivArrayType = dyn_cast<ArrayType>(PrivType)) {
7468
7469
Type *PointeeTy = PrivArrayType->getElementType ();
7469
7470
uint64_t PointeeTySize = DL.getTypeStoreSize (PointeeTy);
7470
7471
for (unsigned u = 0 , e = PrivArrayType->getNumElements (); u < e; u++) {
7471
7472
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);
7473
7474
}
7474
7475
} else {
7475
- new StoreInst (F.getArg (ArgNo), &Base, & IP);
7476
+ new StoreInst (F.getArg (ArgNo), &Base, IP);
7476
7477
}
7477
7478
}
7478
7479
@@ -7495,7 +7496,7 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
7495
7496
Type *PointeeTy = PrivStructType->getElementType (u);
7496
7497
Value *Ptr =
7497
7498
constructPointer (Base, PrivStructLayout->getElementOffset (u), IRB);
7498
- LoadInst *L = new LoadInst (PointeeTy, Ptr, " " , IP);
7499
+ LoadInst *L = new LoadInst (PointeeTy, Ptr, " " , IP-> getIterator () );
7499
7500
L->setAlignment (Alignment);
7500
7501
ReplacementValues.push_back (L);
7501
7502
}
@@ -7504,12 +7505,12 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
7504
7505
uint64_t PointeeTySize = DL.getTypeStoreSize (PointeeTy);
7505
7506
for (unsigned u = 0 , e = PrivArrayType->getNumElements (); u < e; u++) {
7506
7507
Value *Ptr = constructPointer (Base, u * PointeeTySize, IRB);
7507
- LoadInst *L = new LoadInst (PointeeTy, Ptr, " " , IP);
7508
+ LoadInst *L = new LoadInst (PointeeTy, Ptr, " " , IP-> getIterator () );
7508
7509
L->setAlignment (Alignment);
7509
7510
ReplacementValues.push_back (L);
7510
7511
}
7511
7512
} else {
7512
- LoadInst *L = new LoadInst (PrivType, Base, " " , IP);
7513
+ LoadInst *L = new LoadInst (PrivType, Base, " " , IP-> getIterator () );
7513
7514
L->setAlignment (Alignment);
7514
7515
ReplacementValues.push_back (L);
7515
7516
}
@@ -7549,13 +7550,13 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
7549
7550
[=](const Attributor::ArgumentReplacementInfo &ARI,
7550
7551
Function &ReplacementFn, Function::arg_iterator ArgIt) {
7551
7552
BasicBlock &EntryBB = ReplacementFn.getEntryBlock ();
7552
- Instruction * IP = &* EntryBB.getFirstInsertionPt ();
7553
+ BasicBlock::iterator IP = EntryBB.getFirstInsertionPt ();
7553
7554
const DataLayout &DL = IP->getModule ()->getDataLayout ();
7554
7555
unsigned AS = DL.getAllocaAddrSpace ();
7555
7556
Instruction *AI = new AllocaInst (*PrivatizableType, AS,
7556
7557
Arg->getName () + " .priv" , IP);
7557
7558
createInitialization (*PrivatizableType, *AI, ReplacementFn,
7558
- ArgIt->getArgNo (), * IP);
7559
+ ArgIt->getArgNo (), IP);
7559
7560
7560
7561
if (AI->getType () != Arg->getType ())
7561
7562
AI = BitCastInst::CreatePointerBitCastOrAddrSpaceCast (
@@ -12313,10 +12314,10 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
12313
12314
Value *FP = CB->getCalledOperand ();
12314
12315
if (FP->getType ()->getPointerAddressSpace ())
12315
12316
FP = new AddrSpaceCastInst (FP, PointerType::get (FP->getType (), 0 ),
12316
- FP->getName () + " .as0" , CB);
12317
+ FP->getName () + " .as0" , CB-> getIterator () );
12317
12318
12318
12319
bool CBIsVoid = CB->getType ()->isVoidTy ();
12319
- Instruction * IP = CB;
12320
+ BasicBlock::iterator IP = CB-> getIterator () ;
12320
12321
FunctionType *CSFT = CB->getFunctionType ();
12321
12322
SmallVector<Value *> CSArgs (CB->arg_begin (), CB->arg_end ());
12322
12323
@@ -12336,8 +12337,9 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
12336
12337
promoteCall (*CB, NewCallee, nullptr );
12337
12338
return ChangeStatus::CHANGED;
12338
12339
}
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 ());
12341
12343
if (!CBIsVoid)
12342
12344
A.changeAfterManifest (IRPosition::callsite_returned (*CB), *NewCall);
12343
12345
A.deleteAfterManifest (*CB);
@@ -12372,11 +12374,11 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
12372
12374
A.registerManifestAddedBasicBlock (*CBBB);
12373
12375
auto *SplitTI = cast<BranchInst>(LastCmp->getNextNode ());
12374
12376
BasicBlock *ElseBB;
12375
- if (IP == CB) {
12377
+ if (&* IP == CB) {
12376
12378
ElseBB = BasicBlock::Create (ThenTI->getContext (), " " ,
12377
12379
ThenTI->getFunction (), CBBB);
12378
12380
A.registerManifestAddedBasicBlock (*ElseBB);
12379
- IP = BranchInst::Create (CBBB, ElseBB);
12381
+ IP = BranchInst::Create (CBBB, ElseBB)-> getIterator () ;
12380
12382
SplitTI->replaceUsesOfWith (CBBB, ElseBB);
12381
12383
} else {
12382
12384
ElseBB = IP->getParent ();
@@ -12390,7 +12392,7 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
12390
12392
NewCall = &cast<CallInst>(promoteCall (*CBClone, NewCallee, &RetBC));
12391
12393
} else {
12392
12394
NewCall = CallInst::Create (FunctionCallee (CSFT, NewCallee), CSArgs,
12393
- CB->getName (), ThenTI);
12395
+ CB->getName (), ThenTI-> getIterator () );
12394
12396
}
12395
12397
NewCalls.push_back ({NewCall, RetBC});
12396
12398
}
@@ -12416,7 +12418,7 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
12416
12418
} else {
12417
12419
auto *CBClone = cast<CallInst>(CB->clone ());
12418
12420
CBClone->setName (CB->getName ());
12419
- CBClone->insertBefore (IP);
12421
+ CBClone->insertBefore (*IP-> getParent (), IP);
12420
12422
NewCalls.push_back ({CBClone, nullptr });
12421
12423
AttachCalleeMetadata (*CBClone);
12422
12424
}
@@ -12425,7 +12427,7 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
12425
12427
if (!CBIsVoid) {
12426
12428
auto *PHI = PHINode::Create (CB->getType (), NewCalls.size (),
12427
12429
CB->getName () + " .phi" ,
12428
- &* CB->getParent ()->getFirstInsertionPt ());
12430
+ CB->getParent ()->getFirstInsertionPt ());
12429
12431
for (auto &It : NewCalls) {
12430
12432
CallBase *NewCall = It.first ;
12431
12433
Instruction *CallRet = It.second ? It.second : It.first ;
@@ -12783,9 +12785,11 @@ struct AAAllocationInfoImpl : public AAAllocationInfo {
12783
12785
auto *NumBytesToValue =
12784
12786
ConstantInt::get (I->getContext (), APInt (32 , NumBytesToAllocate));
12785
12787
12788
+ BasicBlock::iterator insertPt = AI->getIterator ();
12789
+ insertPt = std::next (insertPt);
12786
12790
AllocaInst *NewAllocaInst =
12787
12791
new AllocaInst (CharType, AI->getAddressSpace (), NumBytesToValue,
12788
- AI->getAlign (), AI->getName (), AI-> getNextNode () );
12792
+ AI->getAlign (), AI->getName (), insertPt );
12789
12793
12790
12794
if (A.changeAfterManifest (IRPosition::inst (*AI), *NewAllocaInst))
12791
12795
return ChangeStatus::CHANGED;
0 commit comments