[NFC][RemoveDIs] Use iterators for insertion at various call-sites (#84736)
These are the last remaining "trivial" changes to passes that use Instruction pointers for insertion. All of this should be NFC, it's just changing the spelling of how we identify a position. In one or two locations, I'm also switching uses of getNextNode etc to using std::next with iterators. This too should be NFC. --------- Merged by: Stephen Tozer <stephen.tozer@sony.com>
This commit is contained in:
parent
c63a291c64
commit
b9d83eff25
@ -369,7 +369,7 @@ Value *PHITransAddr::insertTranslatedSubExpr(
|
||||
// Otherwise insert a cast at the end of PredBB.
|
||||
CastInst *New = CastInst::Create(Cast->getOpcode(), OpVal, InVal->getType(),
|
||||
InVal->getName() + ".phi.trans.insert",
|
||||
PredBB->getTerminator());
|
||||
PredBB->getTerminator()->getIterator());
|
||||
New->setDebugLoc(Inst->getDebugLoc());
|
||||
NewInsts.push_back(New);
|
||||
return New;
|
||||
@ -387,7 +387,8 @@ Value *PHITransAddr::insertTranslatedSubExpr(
|
||||
|
||||
GetElementPtrInst *Result = GetElementPtrInst::Create(
|
||||
GEP->getSourceElementType(), GEPOps[0], ArrayRef(GEPOps).slice(1),
|
||||
InVal->getName() + ".phi.trans.insert", PredBB->getTerminator());
|
||||
InVal->getName() + ".phi.trans.insert",
|
||||
PredBB->getTerminator()->getIterator());
|
||||
Result->setDebugLoc(Inst->getDebugLoc());
|
||||
Result->setIsInBounds(GEP->isInBounds());
|
||||
NewInsts.push_back(Result);
|
||||
@ -408,9 +409,9 @@ Value *PHITransAddr::insertTranslatedSubExpr(
|
||||
if (OpVal == nullptr)
|
||||
return nullptr;
|
||||
|
||||
BinaryOperator *Res = BinaryOperator::CreateAdd(OpVal, Inst->getOperand(1),
|
||||
InVal->getName()+".phi.trans.insert",
|
||||
PredBB->getTerminator());
|
||||
BinaryOperator *Res = BinaryOperator::CreateAdd(
|
||||
OpVal, Inst->getOperand(1), InVal->getName() + ".phi.trans.insert",
|
||||
PredBB->getTerminator()->getIterator());
|
||||
Res->setHasNoSignedWrap(cast<BinaryOperator>(Inst)->hasNoSignedWrap());
|
||||
Res->setHasNoUnsignedWrap(cast<BinaryOperator>(Inst)->hasNoUnsignedWrap());
|
||||
NewInsts.push_back(Res);
|
||||
|
@ -2057,9 +2057,9 @@ static bool sinkAndCmp0Expression(Instruction *AndI, const TargetLowering &TLI,
|
||||
// Keep the 'and' in the same place if the use is already in the same block.
|
||||
Instruction *InsertPt =
|
||||
User->getParent() == AndI->getParent() ? AndI : User;
|
||||
Instruction *InsertedAnd =
|
||||
BinaryOperator::Create(Instruction::And, AndI->getOperand(0),
|
||||
AndI->getOperand(1), "", InsertPt);
|
||||
Instruction *InsertedAnd = BinaryOperator::Create(
|
||||
Instruction::And, AndI->getOperand(0), AndI->getOperand(1), "",
|
||||
InsertPt->getIterator());
|
||||
// Propagate the debug info.
|
||||
InsertedAnd->setDebugLoc(AndI->getDebugLoc());
|
||||
|
||||
@ -4153,9 +4153,10 @@ private:
|
||||
if (SelectInst *CurrentSelect = dyn_cast<SelectInst>(Current)) {
|
||||
// Is it OK to get metadata from OrigSelect?!
|
||||
// Create a Select placeholder with dummy value.
|
||||
SelectInst *Select = SelectInst::Create(
|
||||
CurrentSelect->getCondition(), Dummy, Dummy,
|
||||
CurrentSelect->getName(), CurrentSelect, CurrentSelect);
|
||||
SelectInst *Select =
|
||||
SelectInst::Create(CurrentSelect->getCondition(), Dummy, Dummy,
|
||||
CurrentSelect->getName(),
|
||||
CurrentSelect->getIterator(), CurrentSelect);
|
||||
Map[Current] = Select;
|
||||
ST.insertNewSelect(Select);
|
||||
// We are interested in True and False values.
|
||||
@ -6466,8 +6467,8 @@ bool CodeGenPrepare::optimizePhiType(
|
||||
ValMap[D] = D->getOperand(0);
|
||||
DeletedInstrs.insert(D);
|
||||
} else {
|
||||
ValMap[D] =
|
||||
new BitCastInst(D, ConvertTy, D->getName() + ".bc", D->getNextNode());
|
||||
BasicBlock::iterator insertPt = std::next(D->getIterator());
|
||||
ValMap[D] = new BitCastInst(D, ConvertTy, D->getName() + ".bc", insertPt);
|
||||
}
|
||||
}
|
||||
for (PHINode *Phi : PhiNodes)
|
||||
@ -6487,8 +6488,8 @@ bool CodeGenPrepare::optimizePhiType(
|
||||
DeletedInstrs.insert(U);
|
||||
replaceAllUsesWith(U, ValMap[U->getOperand(0)], FreshBBs, IsHugeFunc);
|
||||
} else {
|
||||
U->setOperand(0,
|
||||
new BitCastInst(ValMap[U->getOperand(0)], PhiTy, "bc", U));
|
||||
U->setOperand(0, new BitCastInst(ValMap[U->getOperand(0)], PhiTy, "bc",
|
||||
U->getIterator()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -8384,7 +8385,7 @@ bool CodeGenPrepare::optimizeInst(Instruction *I, ModifyDT &ModifiedDT) {
|
||||
if (GEPI->hasAllZeroIndices()) {
|
||||
/// The GEP operand must be a pointer, so must its result -> BitCast
|
||||
Instruction *NC = new BitCastInst(GEPI->getOperand(0), GEPI->getType(),
|
||||
GEPI->getName(), GEPI);
|
||||
GEPI->getName(), GEPI->getIterator());
|
||||
NC->setDebugLoc(GEPI->getDebugLoc());
|
||||
replaceAllUsesWith(GEPI, NC, FreshBBs, IsHugeFunc);
|
||||
RecursivelyDeleteTriviallyDeadInstructions(
|
||||
@ -8416,7 +8417,7 @@ bool CodeGenPrepare::optimizeInst(Instruction *I, ModifyDT &ModifiedDT) {
|
||||
isa<ConstantPointerNull>(Op1);
|
||||
if (Const0 || Const1) {
|
||||
if (!Const0 || !Const1) {
|
||||
auto *F = new FreezeInst(Const0 ? Op1 : Op0, "", CmpI);
|
||||
auto *F = new FreezeInst(Const0 ? Op1 : Op0, "", CmpI->getIterator());
|
||||
F->takeName(FI);
|
||||
CmpI->setOperand(Const0 ? 1 : 0, F);
|
||||
}
|
||||
|
@ -111,7 +111,8 @@ Value *DwarfEHPrepare::GetExceptionObject(ResumeInst *RI) {
|
||||
}
|
||||
|
||||
if (!ExnObj)
|
||||
ExnObj = ExtractValueInst::Create(RI->getOperand(0), 0, "exn.obj", RI);
|
||||
ExnObj = ExtractValueInst::Create(RI->getOperand(0), 0, "exn.obj",
|
||||
RI->getIterator());
|
||||
|
||||
RI->eraseFromParent();
|
||||
|
||||
@ -158,7 +159,7 @@ size_t DwarfEHPrepare::pruneUnreachableResumes(
|
||||
Resumes[ResumesLeft++] = RI;
|
||||
} else {
|
||||
BasicBlock *BB = RI->getParent();
|
||||
new UnreachableInst(Ctx, RI);
|
||||
new UnreachableInst(Ctx, RI->getIterator());
|
||||
RI->eraseFromParent();
|
||||
simplifyCFG(BB, *TTI, DTU);
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ static bool InsertRootInitializers(Function &F, ArrayRef<AllocaInst *> Roots) {
|
||||
if (!InitedRoots.count(Root)) {
|
||||
new StoreInst(
|
||||
ConstantPointerNull::get(cast<PointerType>(Root->getAllocatedType())),
|
||||
Root, Root->getNextNode());
|
||||
Root, std::next(Root->getIterator()));
|
||||
MadeChange = true;
|
||||
}
|
||||
|
||||
@ -216,8 +216,8 @@ bool DoLowering(Function &F, GCStrategy &S) {
|
||||
default: break;
|
||||
case Intrinsic::gcwrite: {
|
||||
// Replace a write barrier with a simple store.
|
||||
Value *St = new StoreInst(CI->getArgOperand(0),
|
||||
CI->getArgOperand(2), CI);
|
||||
Value *St = new StoreInst(CI->getArgOperand(0), CI->getArgOperand(2),
|
||||
CI->getIterator());
|
||||
CI->replaceAllUsesWith(St);
|
||||
CI->eraseFromParent();
|
||||
MadeChange = true;
|
||||
@ -225,7 +225,8 @@ bool DoLowering(Function &F, GCStrategy &S) {
|
||||
}
|
||||
case Intrinsic::gcread: {
|
||||
// Replace a read barrier with a simple load.
|
||||
Value *Ld = new LoadInst(CI->getType(), CI->getArgOperand(1), "", CI);
|
||||
Value *Ld = new LoadInst(CI->getType(), CI->getArgOperand(1), "",
|
||||
CI->getIterator());
|
||||
Ld->takeName(CI);
|
||||
CI->replaceAllUsesWith(Ld);
|
||||
CI->eraseFromParent();
|
||||
|
@ -113,7 +113,7 @@ bool runImpl(Function &F, const TargetLowering *TLI, DomTreeUpdater *DTU) {
|
||||
// Handle the degenerate case of no successors by replacing the indirectbr
|
||||
// with unreachable as there is no successor available.
|
||||
if (IBr->getNumSuccessors() == 0) {
|
||||
(void)new UnreachableInst(F.getContext(), IBr);
|
||||
(void)new UnreachableInst(F.getContext(), IBr->getIterator());
|
||||
IBr->eraseFromParent();
|
||||
continue;
|
||||
}
|
||||
@ -183,7 +183,7 @@ bool runImpl(Function &F, const TargetLowering *TLI, DomTreeUpdater *DTU) {
|
||||
for (BasicBlock *SuccBB : IBr->successors())
|
||||
Updates.push_back({DominatorTree::Delete, IBr->getParent(), SuccBB});
|
||||
}
|
||||
(void)new UnreachableInst(F.getContext(), IBr);
|
||||
(void)new UnreachableInst(F.getContext(), IBr->getIterator());
|
||||
IBr->eraseFromParent();
|
||||
}
|
||||
if (DTU) {
|
||||
@ -207,9 +207,10 @@ bool runImpl(Function &F, const TargetLowering *TLI, DomTreeUpdater *DTU) {
|
||||
}
|
||||
|
||||
auto GetSwitchValue = [CommonITy](IndirectBrInst *IBr) {
|
||||
return CastInst::CreatePointerCast(
|
||||
IBr->getAddress(), CommonITy,
|
||||
Twine(IBr->getAddress()->getName()) + ".switch_cast", IBr);
|
||||
return CastInst::CreatePointerCast(IBr->getAddress(), CommonITy,
|
||||
Twine(IBr->getAddress()->getName()) +
|
||||
".switch_cast",
|
||||
IBr->getIterator());
|
||||
};
|
||||
|
||||
SmallVector<DominatorTree::UpdateType, 8> Updates;
|
||||
@ -243,7 +244,7 @@ bool runImpl(Function &F, const TargetLowering *TLI, DomTreeUpdater *DTU) {
|
||||
Updates.reserve(IndirectBrs.size() + 2 * IndirectBrSuccs.size());
|
||||
for (auto *IBr : IndirectBrs) {
|
||||
SwitchPN->addIncoming(GetSwitchValue(IBr), IBr->getParent());
|
||||
BranchInst::Create(SwitchBB, IBr);
|
||||
BranchInst::Create(SwitchBB, IBr->getIterator());
|
||||
if (DTU) {
|
||||
Updates.push_back({DominatorTree::Insert, IBr->getParent(), SwitchBB});
|
||||
for (BasicBlock *SuccBB : IBr->successors())
|
||||
|
@ -388,14 +388,15 @@ bool InterleavedAccessImpl::replaceBinOpShuffles(
|
||||
return Idx < (int)cast<FixedVectorType>(BIOp0Ty)->getNumElements();
|
||||
}));
|
||||
|
||||
BasicBlock::iterator insertPos = SVI->getIterator();
|
||||
auto *NewSVI1 =
|
||||
new ShuffleVectorInst(BI->getOperand(0), PoisonValue::get(BIOp0Ty),
|
||||
Mask, SVI->getName(), SVI);
|
||||
Mask, SVI->getName(), insertPos);
|
||||
auto *NewSVI2 = new ShuffleVectorInst(
|
||||
BI->getOperand(1), PoisonValue::get(BI->getOperand(1)->getType()), Mask,
|
||||
SVI->getName(), SVI);
|
||||
SVI->getName(), insertPos);
|
||||
BinaryOperator *NewBI = BinaryOperator::CreateWithCopiedFlags(
|
||||
BI->getOpcode(), NewSVI1, NewSVI2, BI, BI->getName(), SVI);
|
||||
BI->getOpcode(), NewSVI1, NewSVI2, BI, BI->getName(), insertPos);
|
||||
SVI->replaceAllUsesWith(NewBI);
|
||||
LLVM_DEBUG(dbgs() << " Replaced: " << *BI << "\n And : " << *SVI
|
||||
<< "\n With : " << *NewSVI1 << "\n And : "
|
||||
|
@ -472,7 +472,7 @@ bool IntrinsicLowering::LowerToByteSwap(CallInst *CI) {
|
||||
Function *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Ty);
|
||||
|
||||
Value *Op = CI->getArgOperand(0);
|
||||
Op = CallInst::Create(Int, Op, CI->getName(), CI);
|
||||
Op = CallInst::Create(Int, Op, CI->getName(), CI->getIterator());
|
||||
|
||||
CI->replaceAllUsesWith(Op);
|
||||
CI->eraseFromParent();
|
||||
|
@ -227,7 +227,7 @@ bool runImpl(Module &M) {
|
||||
// FIXME: it would be nice to make CI scheduling boundary, although in
|
||||
// practice it does not matter much.
|
||||
auto *CI = CallInst::Create(getCheckFunctionType(Ctx), CheckFunction,
|
||||
{Flag}, "", &*F.begin()->getFirstInsertionPt());
|
||||
{Flag}, "", F.begin()->getFirstInsertionPt());
|
||||
CI->addParamAttr(0, Attribute::NoUndef);
|
||||
if (UseX86FastCall) {
|
||||
CI->setCallingConv(CallingConv::X86_FastCall);
|
||||
|
@ -202,7 +202,7 @@ SjLjEHPrepareImpl::setupFunctionContext(Function &F,
|
||||
auto &DL = F.getParent()->getDataLayout();
|
||||
const Align Alignment = DL.getPrefTypeAlign(FunctionContextTy);
|
||||
FuncCtx = new AllocaInst(FunctionContextTy, DL.getAllocaAddrSpace(), nullptr,
|
||||
Alignment, "fn_context", &EntryBB->front());
|
||||
Alignment, "fn_context", EntryBB->begin());
|
||||
|
||||
// Fill in the function context structure.
|
||||
for (LandingPadInst *LPI : LPads) {
|
||||
@ -271,7 +271,7 @@ void SjLjEHPrepareImpl::lowerIncomingArguments(Function &F) {
|
||||
Value *TrueValue = ConstantInt::getTrue(F.getContext());
|
||||
Value *UndefValue = UndefValue::get(Ty);
|
||||
Instruction *SI = SelectInst::Create(
|
||||
TrueValue, &AI, UndefValue, AI.getName() + ".tmp", &*AfterAllocaInsPt);
|
||||
TrueValue, &AI, UndefValue, AI.getName() + ".tmp", AfterAllocaInsPt);
|
||||
AI.replaceAllUsesWith(SI);
|
||||
|
||||
// Reset the operand, because it was clobbered by the RAUW above.
|
||||
@ -386,7 +386,7 @@ bool SjLjEHPrepareImpl::setupEntryBlockAndCallSites(Function &F) {
|
||||
if (Function *Callee = II->getCalledFunction())
|
||||
if (Callee->getIntrinsicID() == Intrinsic::donothing) {
|
||||
// Remove the NOP invoke.
|
||||
BranchInst::Create(II->getNormalDest(), II);
|
||||
BranchInst::Create(II->getNormalDest(), II->getIterator());
|
||||
II->eraseFromParent();
|
||||
continue;
|
||||
}
|
||||
@ -445,7 +445,7 @@ bool SjLjEHPrepareImpl::setupEntryBlockAndCallSites(Function &F) {
|
||||
|
||||
// Record the call site value for the back end so it stays associated with
|
||||
// the invoke.
|
||||
CallInst::Create(CallSiteFn, CallSiteNum, "", Invokes[I]);
|
||||
CallInst::Create(CallSiteFn, CallSiteNum, "", Invokes[I]->getIterator());
|
||||
}
|
||||
|
||||
// Mark call instructions that aren't nounwind as no-action (call_site ==
|
||||
@ -462,8 +462,8 @@ bool SjLjEHPrepareImpl::setupEntryBlockAndCallSites(Function &F) {
|
||||
}
|
||||
|
||||
// Register the function context and make sure it's known to not throw
|
||||
CallInst *Register =
|
||||
CallInst::Create(RegisterFn, FuncCtx, "", EntryBB->getTerminator());
|
||||
CallInst *Register = CallInst::Create(
|
||||
RegisterFn, FuncCtx, "", EntryBB->getTerminator()->getIterator());
|
||||
Register->setDoesNotThrow();
|
||||
|
||||
// Following any allocas not in the entry block, update the saved SP in the
|
||||
@ -480,7 +480,8 @@ bool SjLjEHPrepareImpl::setupEntryBlockAndCallSites(Function &F) {
|
||||
}
|
||||
Instruction *StackAddr = CallInst::Create(StackAddrFn, "sp");
|
||||
StackAddr->insertAfter(&I);
|
||||
new StoreInst(StackAddr, StackPtr, true, StackAddr->getNextNode());
|
||||
new StoreInst(StackAddr, StackPtr, true,
|
||||
std::next(StackAddr->getIterator()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -490,7 +491,7 @@ bool SjLjEHPrepareImpl::setupEntryBlockAndCallSites(Function &F) {
|
||||
Instruction *InsertPoint = Return;
|
||||
if (CallInst *CI = Return->getParent()->getTerminatingMustTailCall())
|
||||
InsertPoint = CI;
|
||||
CallInst::Create(UnregisterFn, FuncCtx, "", InsertPoint);
|
||||
CallInst::Create(UnregisterFn, FuncCtx, "", InsertPoint->getIterator());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1234,10 +1234,10 @@ AllocaInst *WinEHPrepareImpl::insertPHILoads(PHINode *PN, Function &F) {
|
||||
// that will dominate all uses.
|
||||
SpillSlot = new AllocaInst(PN->getType(), DL->getAllocaAddrSpace(), nullptr,
|
||||
Twine(PN->getName(), ".wineh.spillslot"),
|
||||
&F.getEntryBlock().front());
|
||||
F.getEntryBlock().begin());
|
||||
Value *V = new LoadInst(PN->getType(), SpillSlot,
|
||||
Twine(PN->getName(), ".wineh.reload"),
|
||||
&*PHIBlock->getFirstInsertionPt());
|
||||
PHIBlock->getFirstInsertionPt());
|
||||
PN->replaceAllUsesWith(V);
|
||||
return SpillSlot;
|
||||
}
|
||||
@ -1309,7 +1309,7 @@ void WinEHPrepareImpl::insertPHIStore(
|
||||
}
|
||||
|
||||
// Otherwise, insert the store at the end of the basic block.
|
||||
new StoreInst(PredVal, SpillSlot, PredBlock->getTerminator());
|
||||
new StoreInst(PredVal, SpillSlot, PredBlock->getTerminator()->getIterator());
|
||||
}
|
||||
|
||||
void WinEHPrepareImpl::replaceUseWithLoad(
|
||||
@ -1319,7 +1319,7 @@ void WinEHPrepareImpl::replaceUseWithLoad(
|
||||
if (!SpillSlot)
|
||||
SpillSlot = new AllocaInst(V->getType(), DL->getAllocaAddrSpace(), nullptr,
|
||||
Twine(V->getName(), ".wineh.spillslot"),
|
||||
&F.getEntryBlock().front());
|
||||
F.getEntryBlock().begin());
|
||||
|
||||
auto *UsingInst = cast<Instruction>(U.getUser());
|
||||
if (auto *UsingPHI = dyn_cast<PHINode>(UsingInst)) {
|
||||
@ -1376,16 +1376,16 @@ void WinEHPrepareImpl::replaceUseWithLoad(
|
||||
Value *&Load = Loads[IncomingBlock];
|
||||
// Insert the load into the predecessor block
|
||||
if (!Load)
|
||||
Load = new LoadInst(V->getType(), SpillSlot,
|
||||
Twine(V->getName(), ".wineh.reload"),
|
||||
/*isVolatile=*/false, IncomingBlock->getTerminator());
|
||||
Load = new LoadInst(
|
||||
V->getType(), SpillSlot, Twine(V->getName(), ".wineh.reload"),
|
||||
/*isVolatile=*/false, IncomingBlock->getTerminator()->getIterator());
|
||||
|
||||
U.set(Load);
|
||||
} else {
|
||||
// Reload right before the old use.
|
||||
auto *Load = new LoadInst(V->getType(), SpillSlot,
|
||||
Twine(V->getName(), ".wineh.reload"),
|
||||
/*isVolatile=*/false, UsingInst);
|
||||
/*isVolatile=*/false, UsingInst->getIterator());
|
||||
U.set(Load);
|
||||
}
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ public:
|
||||
// Intentionally break the Function by inserting a terminator
|
||||
// instruction in the middle of a basic block.
|
||||
BasicBlock &BB = F.getEntryBlock();
|
||||
new UnreachableInst(F.getContext(), BB.getTerminator());
|
||||
new UnreachableInst(F.getContext(), BB.getTerminator()->getIterator());
|
||||
return PreservedAnalyses::none();
|
||||
}
|
||||
|
||||
|
@ -1129,7 +1129,7 @@ static std::optional<Instruction *> instCombineSVELast(InstCombiner &IC,
|
||||
auto *NewRHS =
|
||||
IC.Builder.CreateIntrinsic(IntrinsicID, {Vec->getType()}, {Pg, RHS});
|
||||
auto *NewBinOp = BinaryOperator::CreateWithCopiedFlags(
|
||||
OpC, NewLHS, NewRHS, OldBinOp, OldBinOp->getName(), &II);
|
||||
OpC, NewLHS, NewRHS, OldBinOp, OldBinOp->getName(), II.getIterator());
|
||||
return IC.replaceInstUsesWith(II, NewBinOp);
|
||||
}
|
||||
}
|
||||
|
@ -470,9 +470,11 @@ bool AMDGPULibCalls::sincosUseNative(CallInst *aCI, const FuncInfo &FInfo) {
|
||||
nf.setId(AMDGPULibFunc::EI_COS);
|
||||
FunctionCallee cosExpr = getFunction(M, nf);
|
||||
if (sinExpr && cosExpr) {
|
||||
Value *sinval = CallInst::Create(sinExpr, opr0, "splitsin", aCI);
|
||||
Value *cosval = CallInst::Create(cosExpr, opr0, "splitcos", aCI);
|
||||
new StoreInst(cosval, aCI->getArgOperand(1), aCI);
|
||||
Value *sinval =
|
||||
CallInst::Create(sinExpr, opr0, "splitsin", aCI->getIterator());
|
||||
Value *cosval =
|
||||
CallInst::Create(cosExpr, opr0, "splitcos", aCI->getIterator());
|
||||
new StoreInst(cosval, aCI->getArgOperand(1), aCI->getIterator());
|
||||
|
||||
DEBUG_WITH_TYPE("usenative", dbgs() << "<useNative> replace " << *aCI
|
||||
<< " with native version of sin/cos");
|
||||
@ -1655,7 +1657,7 @@ bool AMDGPULibCalls::evaluateCall(CallInst *aCI, const FuncInfo &FInfo) {
|
||||
// sincos
|
||||
assert(FInfo.getId() == AMDGPULibFunc::EI_SINCOS &&
|
||||
"math function with ptr arg not supported yet");
|
||||
new StoreInst(nval1, aCI->getArgOperand(1), aCI);
|
||||
new StoreInst(nval1, aCI->getArgOperand(1), aCI->getIterator());
|
||||
}
|
||||
|
||||
replaceCall(aCI, nval0);
|
||||
|
@ -290,8 +290,8 @@ bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {
|
||||
Value *sumC = ConstantInt::get(SizetTy, Sum, false);
|
||||
SmallVector<Value *, 1> alloc_args;
|
||||
alloc_args.push_back(sumC);
|
||||
CallInst *pcall =
|
||||
CallInst::Create(PrintfAllocFn, alloc_args, "printf_alloc_fn", CI);
|
||||
CallInst *pcall = CallInst::Create(PrintfAllocFn, alloc_args,
|
||||
"printf_alloc_fn", CI->getIterator());
|
||||
|
||||
//
|
||||
// Insert code to split basicblock with a
|
||||
@ -309,25 +309,27 @@ bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {
|
||||
SplitBlock(CI->getParent(), cmp);
|
||||
Instruction *Brnch =
|
||||
SplitBlockAndInsertIfThen(cmp, cmp->getNextNode(), false);
|
||||
BasicBlock::iterator BrnchPoint = Brnch->getIterator();
|
||||
|
||||
Builder.SetInsertPoint(Brnch);
|
||||
|
||||
// store unique printf id in the buffer
|
||||
//
|
||||
GetElementPtrInst *BufferIdx = GetElementPtrInst::Create(
|
||||
I8Ty, pcall, ConstantInt::get(Ctx, APInt(32, 0)), "PrintBuffID", Brnch);
|
||||
I8Ty, pcall, ConstantInt::get(Ctx, APInt(32, 0)), "PrintBuffID",
|
||||
BrnchPoint);
|
||||
|
||||
Type *idPointer = PointerType::get(I32Ty, AMDGPUAS::GLOBAL_ADDRESS);
|
||||
Value *id_gep_cast =
|
||||
new BitCastInst(BufferIdx, idPointer, "PrintBuffIdCast", Brnch);
|
||||
new BitCastInst(BufferIdx, idPointer, "PrintBuffIdCast", BrnchPoint);
|
||||
|
||||
new StoreInst(ConstantInt::get(I32Ty, UniqID), id_gep_cast, Brnch);
|
||||
new StoreInst(ConstantInt::get(I32Ty, UniqID), id_gep_cast, BrnchPoint);
|
||||
|
||||
// 1st 4 bytes hold the printf_id
|
||||
// the following GEP is the buffer pointer
|
||||
BufferIdx = GetElementPtrInst::Create(I8Ty, pcall,
|
||||
ConstantInt::get(Ctx, APInt(32, 4)),
|
||||
"PrintBuffGep", Brnch);
|
||||
"PrintBuffGep", BrnchPoint);
|
||||
|
||||
Type *Int32Ty = Type::getInt32Ty(Ctx);
|
||||
for (unsigned ArgCount = 1;
|
||||
@ -405,7 +407,7 @@ bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {
|
||||
for (unsigned I = 0, E = WhatToStore.size(); I != E; ++I) {
|
||||
Value *TheBtCast = WhatToStore[I];
|
||||
unsigned ArgSize = TD->getTypeAllocSize(TheBtCast->getType());
|
||||
StoreInst *StBuff = new StoreInst(TheBtCast, BufferIdx, Brnch);
|
||||
StoreInst *StBuff = new StoreInst(TheBtCast, BufferIdx, BrnchPoint);
|
||||
LLVM_DEBUG(dbgs() << "inserting store to printf buffer:\n"
|
||||
<< *StBuff << '\n');
|
||||
(void)StBuff;
|
||||
@ -413,7 +415,7 @@ bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {
|
||||
break;
|
||||
BufferIdx = GetElementPtrInst::Create(
|
||||
I8Ty, BufferIdx, {ConstantInt::get(I32Ty, ArgSize)},
|
||||
"PrintBuffNextPtr", Brnch);
|
||||
"PrintBuffNextPtr", BrnchPoint);
|
||||
LLVM_DEBUG(dbgs() << "inserting gep to the printf buffer:\n"
|
||||
<< *BufferIdx << '\n');
|
||||
}
|
||||
|
@ -780,8 +780,9 @@ Instruction *MVEGatherScatterLowering::tryCreateIncrementingGatScat(
|
||||
// Make sure the offsets are scaled correctly
|
||||
Instruction *ScaledOffsets = BinaryOperator::Create(
|
||||
Instruction::Shl, OffsetsIncoming,
|
||||
Builder.CreateVectorSplat(Ty->getNumElements(), Builder.getInt32(TypeScale)),
|
||||
"ScaledIndex", I);
|
||||
Builder.CreateVectorSplat(Ty->getNumElements(),
|
||||
Builder.getInt32(TypeScale)),
|
||||
"ScaledIndex", I->getIterator());
|
||||
// Add the base to the offsets
|
||||
OffsetsIncoming = BinaryOperator::Create(
|
||||
Instruction::Add, ScaledOffsets,
|
||||
@ -790,7 +791,7 @@ Instruction *MVEGatherScatterLowering::tryCreateIncrementingGatScat(
|
||||
Builder.CreatePtrToInt(
|
||||
BasePtr,
|
||||
cast<VectorType>(ScaledOffsets->getType())->getElementType())),
|
||||
"StartIndex", I);
|
||||
"StartIndex", I->getIterator());
|
||||
|
||||
if (I->getIntrinsicID() == Intrinsic::masked_gather)
|
||||
return tryCreateMaskedGatherBase(I, OffsetsIncoming, Builder, Immediate);
|
||||
@ -838,7 +839,8 @@ Instruction *MVEGatherScatterLowering::tryCreateIncrementingWBGatScat(
|
||||
Instruction *ScaledOffsets = BinaryOperator::Create(
|
||||
Instruction::Shl, Phi->getIncomingValue(1 - IncrementIndex),
|
||||
Builder.CreateVectorSplat(NumElems, Builder.getInt32(TypeScale)),
|
||||
"ScaledIndex", &Phi->getIncomingBlock(1 - IncrementIndex)->back());
|
||||
"ScaledIndex",
|
||||
Phi->getIncomingBlock(1 - IncrementIndex)->back().getIterator());
|
||||
// Add the base to the offsets
|
||||
OffsetsIncoming = BinaryOperator::Create(
|
||||
Instruction::Add, ScaledOffsets,
|
||||
@ -847,13 +849,14 @@ Instruction *MVEGatherScatterLowering::tryCreateIncrementingWBGatScat(
|
||||
Builder.CreatePtrToInt(
|
||||
BasePtr,
|
||||
cast<VectorType>(ScaledOffsets->getType())->getElementType())),
|
||||
"StartIndex", &Phi->getIncomingBlock(1 - IncrementIndex)->back());
|
||||
"StartIndex",
|
||||
Phi->getIncomingBlock(1 - IncrementIndex)->back().getIterator());
|
||||
// The gather is pre-incrementing
|
||||
OffsetsIncoming = BinaryOperator::Create(
|
||||
Instruction::Sub, OffsetsIncoming,
|
||||
Builder.CreateVectorSplat(NumElems, Builder.getInt32(Immediate)),
|
||||
"PreIncrementStartIndex",
|
||||
&Phi->getIncomingBlock(1 - IncrementIndex)->back());
|
||||
Phi->getIncomingBlock(1 - IncrementIndex)->back().getIterator());
|
||||
Phi->setIncomingValue(1 - IncrementIndex, OffsetsIncoming);
|
||||
|
||||
Builder.SetInsertPoint(I);
|
||||
@ -886,8 +889,8 @@ void MVEGatherScatterLowering::pushOutAdd(PHINode *&Phi,
|
||||
Value *OffsSecondOperand,
|
||||
unsigned StartIndex) {
|
||||
LLVM_DEBUG(dbgs() << "masked gathers/scatters: optimising add instruction\n");
|
||||
Instruction *InsertionPoint =
|
||||
&cast<Instruction>(Phi->getIncomingBlock(StartIndex)->back());
|
||||
BasicBlock::iterator InsertionPoint =
|
||||
Phi->getIncomingBlock(StartIndex)->back().getIterator();
|
||||
// Initialize the phi with a vector that contains a sum of the constants
|
||||
Instruction *NewIndex = BinaryOperator::Create(
|
||||
Instruction::Add, Phi->getIncomingValue(StartIndex), OffsSecondOperand,
|
||||
@ -911,8 +914,8 @@ void MVEGatherScatterLowering::pushOutMulShl(unsigned Opcode, PHINode *&Phi,
|
||||
|
||||
// Create a new scalar add outside of the loop and transform it to a splat
|
||||
// by which loop variable can be incremented
|
||||
Instruction *InsertionPoint = &cast<Instruction>(
|
||||
Phi->getIncomingBlock(LoopIncrement == 1 ? 0 : 1)->back());
|
||||
BasicBlock::iterator InsertionPoint =
|
||||
Phi->getIncomingBlock(LoopIncrement == 1 ? 0 : 1)->back().getIterator();
|
||||
|
||||
// Create a new index
|
||||
Value *StartIndex =
|
||||
@ -923,11 +926,14 @@ void MVEGatherScatterLowering::pushOutMulShl(unsigned Opcode, PHINode *&Phi,
|
||||
Instruction *Product =
|
||||
BinaryOperator::Create((Instruction::BinaryOps)Opcode, IncrementPerRound,
|
||||
OffsSecondOperand, "Product", InsertionPoint);
|
||||
|
||||
BasicBlock::iterator NewIncrInsertPt =
|
||||
Phi->getIncomingBlock(LoopIncrement)->back().getIterator();
|
||||
NewIncrInsertPt = std::prev(NewIncrInsertPt);
|
||||
|
||||
// Increment NewIndex by Product instead of the multiplication
|
||||
Instruction *NewIncrement = BinaryOperator::Create(
|
||||
Instruction::Add, Phi, Product, "IncrementPushedOutMul",
|
||||
cast<Instruction>(Phi->getIncomingBlock(LoopIncrement)->back())
|
||||
.getPrevNode());
|
||||
Instruction::Add, Phi, Product, "IncrementPushedOutMul", NewIncrInsertPt);
|
||||
|
||||
Phi->addIncoming(StartIndex,
|
||||
Phi->getIncomingBlock(LoopIncrement == 1 ? 0 : 1));
|
||||
@ -1054,7 +1060,7 @@ bool MVEGatherScatterLowering::optimiseOffsets(Value *Offsets, BasicBlock *BB,
|
||||
// our phi, we need to copy it
|
||||
IncInstruction = BinaryOperator::Create(
|
||||
Instruction::BinaryOps(IncInstruction->getOpcode()), Phi,
|
||||
IncrementPerRound, "LoopIncrement", IncInstruction);
|
||||
IncrementPerRound, "LoopIncrement", IncInstruction->getIterator());
|
||||
Phi->setIncomingValue(IncrementingBlock, IncInstruction);
|
||||
}
|
||||
NewPhi = Phi;
|
||||
@ -1066,7 +1072,7 @@ bool MVEGatherScatterLowering::optimiseOffsets(Value *Offsets, BasicBlock *BB,
|
||||
Phi->getIncomingBlock(IncrementingBlock == 1 ? 0 : 1));
|
||||
IncInstruction = BinaryOperator::Create(
|
||||
Instruction::BinaryOps(IncInstruction->getOpcode()), NewPhi,
|
||||
IncrementPerRound, "LoopIncrement", IncInstruction);
|
||||
IncrementPerRound, "LoopIncrement", IncInstruction->getIterator());
|
||||
NewPhi->addIncoming(IncInstruction,
|
||||
Phi->getIncomingBlock(IncrementingBlock));
|
||||
IncrementingBlock = 1;
|
||||
@ -1229,7 +1235,7 @@ bool MVEGatherScatterLowering::optimiseAddress(Value *Address, BasicBlock *BB,
|
||||
BaseTy = FixedVectorType::get(BaseTy, VecTy);
|
||||
GetElementPtrInst *NewAddress = GetElementPtrInst::Create(
|
||||
Builder.getInt8Ty(), Builder.CreateBitCast(Base, BaseTy), Offsets,
|
||||
"gep.merged", GEP);
|
||||
"gep.merged", GEP->getIterator());
|
||||
LLVM_DEBUG(dbgs() << "Folded GEP: " << *GEP
|
||||
<< "\n new : " << *NewAddress << "\n");
|
||||
GEP->replaceAllUsesWith(
|
||||
|
@ -426,8 +426,9 @@ static void replaceWithGEP(CallInst *Call, uint32_t DimensionIndex,
|
||||
IdxList.push_back(Zero);
|
||||
IdxList.push_back(Call->getArgOperand(GEPIndex));
|
||||
|
||||
auto *GEP = GetElementPtrInst::CreateInBounds(
|
||||
getBaseElementType(Call), Call->getArgOperand(0), IdxList, "", Call);
|
||||
auto *GEP = GetElementPtrInst::CreateInBounds(getBaseElementType(Call),
|
||||
Call->getArgOperand(0), IdxList,
|
||||
"", Call->getIterator());
|
||||
Call->replaceAllUsesWith(GEP);
|
||||
Call->eraseFromParent();
|
||||
}
|
||||
@ -1091,9 +1092,11 @@ bool BPFAbstractMemberAccess::transformGEPChain(CallInst *Call,
|
||||
// Load the global variable which represents the returned field info.
|
||||
LoadInst *LDInst;
|
||||
if (IsInt32Ret)
|
||||
LDInst = new LoadInst(Type::getInt32Ty(BB->getContext()), GV, "", Call);
|
||||
LDInst = new LoadInst(Type::getInt32Ty(BB->getContext()), GV, "",
|
||||
Call->getIterator());
|
||||
else
|
||||
LDInst = new LoadInst(Type::getInt64Ty(BB->getContext()), GV, "", Call);
|
||||
LDInst = new LoadInst(Type::getInt64Ty(BB->getContext()), GV, "",
|
||||
Call->getIterator());
|
||||
|
||||
Instruction *PassThroughInst =
|
||||
BPFCoreSharedInfo::insertPassThrough(M, BB, LDInst, Call);
|
||||
@ -1113,7 +1116,8 @@ bool BPFAbstractMemberAccess::transformGEPChain(CallInst *Call,
|
||||
// The original Call inst is removed.
|
||||
|
||||
// Load the global variable.
|
||||
auto *LDInst = new LoadInst(Type::getInt64Ty(BB->getContext()), GV, "", Call);
|
||||
auto *LDInst = new LoadInst(Type::getInt64Ty(BB->getContext()), GV, "",
|
||||
Call->getIterator());
|
||||
|
||||
// Generate a BitCast
|
||||
auto *BCInst =
|
||||
|
@ -116,8 +116,8 @@ static bool BPFPreserveDITypeImpl(Function &F) {
|
||||
GV->setMetadata(LLVMContext::MD_preserve_access_index, MD);
|
||||
|
||||
// Load the global variable which represents the type info.
|
||||
auto *LDInst =
|
||||
new LoadInst(Type::getInt64Ty(BB->getContext()), GV, "", Call);
|
||||
auto *LDInst = new LoadInst(Type::getInt64Ty(BB->getContext()), GV, "",
|
||||
Call->getIterator());
|
||||
Instruction *PassThroughInst =
|
||||
BPFCoreSharedInfo::insertPassThrough(M, BB, LDInst, Call);
|
||||
Call->replaceAllUsesWith(PassThroughInst);
|
||||
|
@ -1109,7 +1109,7 @@ Value *HexagonCommonGEP::fabricateGEP(NodeVect &NA, BasicBlock::iterator At,
|
||||
break;
|
||||
}
|
||||
}
|
||||
NewInst = GetElementPtrInst::Create(InpTy, Input, IdxList, "cgep", &*At);
|
||||
NewInst = GetElementPtrInst::Create(InpTy, Input, IdxList, "cgep", At);
|
||||
NewInst->setIsInBounds(RN->Flags & GepNode::InBounds);
|
||||
LLVM_DEBUG(dbgs() << "new GEP: " << *NewInst << '\n');
|
||||
if (Idx < Num) {
|
||||
|
@ -414,7 +414,7 @@ static bool fixupFPReturnAndCall(Function &F, Module *M,
|
||||
C, Attribute::getWithMemoryEffects(C, MemoryEffects::none()));
|
||||
A = A.addFnAttribute(C, Attribute::NoInline);
|
||||
FunctionCallee F = (M->getOrInsertFunction(Name, A, MyVoid, T));
|
||||
CallInst::Create(F, Params, "", &I);
|
||||
CallInst::Create(F, Params, "", I.getIterator());
|
||||
} else if (const CallInst *CI = dyn_cast<CallInst>(&I)) {
|
||||
FunctionType *FT = CI->getFunctionType();
|
||||
Function *F_ = CI->getCalledFunction();
|
||||
|
@ -157,7 +157,7 @@ void NVPTXImageOptimizer::replaceWith(Instruction *From, ConstantInt *To) {
|
||||
else
|
||||
// Get true block
|
||||
Dest = BI->getSuccessor(0);
|
||||
BranchInst::Create(Dest, BI);
|
||||
BranchInst::Create(Dest, BI->getIterator());
|
||||
InstrToDelete.push_back(BI);
|
||||
}
|
||||
}
|
||||
|
@ -183,16 +183,16 @@ static void convertToParamAS(Value *OldUser, Value *Param) {
|
||||
}
|
||||
if (auto *GEP = dyn_cast<GetElementPtrInst>(I.OldInstruction)) {
|
||||
SmallVector<Value *, 4> Indices(GEP->indices());
|
||||
auto *NewGEP = GetElementPtrInst::Create(GEP->getSourceElementType(),
|
||||
I.NewParam, Indices,
|
||||
GEP->getName(), GEP);
|
||||
auto *NewGEP = GetElementPtrInst::Create(
|
||||
GEP->getSourceElementType(), I.NewParam, Indices, GEP->getName(),
|
||||
GEP->getIterator());
|
||||
NewGEP->setIsInBounds(GEP->isInBounds());
|
||||
return NewGEP;
|
||||
}
|
||||
if (auto *BC = dyn_cast<BitCastInst>(I.OldInstruction)) {
|
||||
auto *NewBCType = PointerType::get(BC->getContext(), ADDRESS_SPACE_PARAM);
|
||||
return BitCastInst::Create(BC->getOpcode(), I.NewParam, NewBCType,
|
||||
BC->getName(), BC);
|
||||
BC->getName(), BC->getIterator());
|
||||
}
|
||||
if (auto *ASC = dyn_cast<AddrSpaceCastInst>(I.OldInstruction)) {
|
||||
assert(ASC->getDestAddressSpace() == ADDRESS_SPACE_PARAM);
|
||||
@ -316,7 +316,7 @@ static void adjustByValArgAlignment(Argument *Arg, Value *ArgInParamAS,
|
||||
void NVPTXLowerArgs::handleByValParam(const NVPTXTargetMachine &TM,
|
||||
Argument *Arg) {
|
||||
Function *Func = Arg->getParent();
|
||||
Instruction *FirstInst = &(Func->getEntryBlock().front());
|
||||
BasicBlock::iterator FirstInst = Func->getEntryBlock().begin();
|
||||
Type *StructType = Arg->getParamByValType();
|
||||
assert(StructType && "Missing byval type");
|
||||
|
||||
@ -407,9 +407,9 @@ void NVPTXLowerArgs::markPointerAsGlobal(Value *Ptr) {
|
||||
|
||||
Instruction *PtrInGlobal = new AddrSpaceCastInst(
|
||||
Ptr, PointerType::get(Ptr->getContext(), ADDRESS_SPACE_GLOBAL),
|
||||
Ptr->getName(), &*InsertPt);
|
||||
Ptr->getName(), InsertPt);
|
||||
Value *PtrInGeneric = new AddrSpaceCastInst(PtrInGlobal, Ptr->getType(),
|
||||
Ptr->getName(), &*InsertPt);
|
||||
Ptr->getName(), InsertPt);
|
||||
// Replace with PtrInGeneric all uses of Ptr except PtrInGlobal.
|
||||
Ptr->replaceAllUsesWith(PtrInGeneric);
|
||||
PtrInGlobal->setOperand(0, Ptr);
|
||||
|
@ -143,7 +143,7 @@ bool NVPTXLowerUnreachable::runOnFunction(Function &F) {
|
||||
if (auto unreachableInst = dyn_cast<UnreachableInst>(&I)) {
|
||||
if (isLoweredToTrap(*unreachableInst))
|
||||
continue; // trap is emitted as `trap; exit;`.
|
||||
CallInst::Create(ExitFTy, Exit, "", unreachableInst);
|
||||
CallInst::Create(ExitFTy, Exit, "", unreachableInst->getIterator());
|
||||
Changed = true;
|
||||
}
|
||||
}
|
||||
|
@ -263,7 +263,8 @@ class PPCBoolRetToInt : public FunctionPass {
|
||||
Value *IntRetVal = BoolToIntMap[U];
|
||||
Type *Int1Ty = Type::getInt1Ty(U->getContext());
|
||||
auto *I = cast<Instruction>(U.getUser());
|
||||
Value *BackToBool = new TruncInst(IntRetVal, Int1Ty, "backToBool", I);
|
||||
Value *BackToBool =
|
||||
new TruncInst(IntRetVal, Int1Ty, "backToBool", I->getIterator());
|
||||
U.set(BackToBool);
|
||||
|
||||
return true;
|
||||
|
@ -725,7 +725,7 @@ PPCLoopInstrFormPrep::rewriteForBase(Loop *L, const SCEVAddRecExpr *BasePtrSCEV,
|
||||
Instruction *PtrInc = nullptr;
|
||||
Instruction *NewBasePtr = nullptr;
|
||||
if (CanPreInc) {
|
||||
Instruction *InsPoint = &*Header->getFirstInsertionPt();
|
||||
BasicBlock::iterator InsPoint = Header->getFirstInsertionPt();
|
||||
PtrInc = GetElementPtrInst::Create(
|
||||
I8Ty, NewPHI, IncNode, getInstrName(BaseMemI, GEPNodeIncNameSuffix),
|
||||
InsPoint);
|
||||
@ -752,7 +752,7 @@ PPCLoopInstrFormPrep::rewriteForBase(Loop *L, const SCEVAddRecExpr *BasePtrSCEV,
|
||||
// For the latch predecessor, we need to insert a GEP just before the
|
||||
// terminator to increase the address.
|
||||
BasicBlock *BB = PI;
|
||||
Instruction *InsPoint = BB->getTerminator();
|
||||
BasicBlock::iterator InsPoint = BB->getTerminator()->getIterator();
|
||||
PtrInc = GetElementPtrInst::Create(
|
||||
I8Ty, NewPHI, IncNode, getInstrName(BaseMemI, GEPNodeIncNameSuffix),
|
||||
InsPoint);
|
||||
@ -764,7 +764,7 @@ PPCLoopInstrFormPrep::rewriteForBase(Loop *L, const SCEVAddRecExpr *BasePtrSCEV,
|
||||
if (NewPHI->getType() != BasePtr->getType())
|
||||
NewBasePtr = new BitCastInst(NewPHI, BasePtr->getType(),
|
||||
getInstrName(NewPHI, CastNodeNameSuffix),
|
||||
&*Header->getFirstInsertionPt());
|
||||
Header->getFirstInsertionPt());
|
||||
else
|
||||
NewBasePtr = NewPHI;
|
||||
}
|
||||
@ -794,20 +794,25 @@ Instruction *PPCLoopInstrFormPrep::rewriteForBucketElement(
|
||||
cast<SCEVConstant>(Element.Offset)->getValue()->isZero())) {
|
||||
RealNewPtr = NewBasePtr;
|
||||
} else {
|
||||
Instruction *PtrIP = dyn_cast<Instruction>(Ptr);
|
||||
std::optional<BasicBlock::iterator> PtrIP = std::nullopt;
|
||||
if (Instruction *I = dyn_cast<Instruction>(Ptr))
|
||||
PtrIP = I->getIterator();
|
||||
|
||||
if (PtrIP && isa<Instruction>(NewBasePtr) &&
|
||||
cast<Instruction>(NewBasePtr)->getParent() == PtrIP->getParent())
|
||||
PtrIP = nullptr;
|
||||
else if (PtrIP && isa<PHINode>(PtrIP))
|
||||
PtrIP = &*PtrIP->getParent()->getFirstInsertionPt();
|
||||
cast<Instruction>(NewBasePtr)->getParent() == (*PtrIP)->getParent())
|
||||
PtrIP = std::nullopt;
|
||||
else if (PtrIP && isa<PHINode>(*PtrIP))
|
||||
PtrIP = (*PtrIP)->getParent()->getFirstInsertionPt();
|
||||
else if (!PtrIP)
|
||||
PtrIP = Element.Instr;
|
||||
PtrIP = Element.Instr->getIterator();
|
||||
|
||||
assert(OffToBase && "There should be an offset for non base element!\n");
|
||||
GetElementPtrInst *NewPtr = GetElementPtrInst::Create(
|
||||
I8Ty, PtrInc, OffToBase,
|
||||
getInstrName(Element.Instr, GEPNodeOffNameSuffix), PtrIP);
|
||||
if (!PtrIP)
|
||||
getInstrName(Element.Instr, GEPNodeOffNameSuffix));
|
||||
if (PtrIP)
|
||||
NewPtr->insertBefore(*(*PtrIP)->getParent(), *PtrIP);
|
||||
else
|
||||
NewPtr->insertAfter(cast<Instruction>(PtrInc));
|
||||
NewPtr->setIsInBounds(IsPtrInBounds(Ptr));
|
||||
RealNewPtr = NewPtr;
|
||||
|
@ -231,7 +231,7 @@ bool RISCVGatherScatterLowering::matchStridedRecurrence(Value *Index, Loop *L,
|
||||
BasePtr =
|
||||
PHINode::Create(Start->getType(), 2, Phi->getName() + ".scalar", Phi->getIterator());
|
||||
Inc = BinaryOperator::CreateAdd(BasePtr, Step, Inc->getName() + ".scalar",
|
||||
Inc);
|
||||
Inc->getIterator());
|
||||
BasePtr->addIncoming(Start, Phi->getIncomingBlock(1 - IncrementingBlock));
|
||||
BasePtr->addIncoming(Inc, Phi->getIncomingBlock(IncrementingBlock));
|
||||
|
||||
|
@ -1283,9 +1283,9 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runSjLjOnFunction(Function &F) {
|
||||
DebugLoc FirstDL = getOrCreateDebugLoc(&*Entry->begin(), F.getSubprogram());
|
||||
SplitBlock(Entry, &*Entry->getFirstInsertionPt());
|
||||
|
||||
BinaryOperator *SetjmpTableSize =
|
||||
BinaryOperator::Create(Instruction::Add, IRB.getInt32(4), IRB.getInt32(0),
|
||||
"setjmpTableSize", Entry->getTerminator());
|
||||
BinaryOperator *SetjmpTableSize = BinaryOperator::Create(
|
||||
Instruction::Add, IRB.getInt32(4), IRB.getInt32(0), "setjmpTableSize",
|
||||
Entry->getTerminator()->getIterator());
|
||||
SetjmpTableSize->setDebugLoc(FirstDL);
|
||||
// setjmpTable = (int *) malloc(40);
|
||||
Type *IntPtrTy = getAddrIntType(&M);
|
||||
|
@ -73,7 +73,7 @@ bool WebAssemblyLowerRefTypesIntPtrConv::runOnFunction(Function &F) {
|
||||
|
||||
Function *TrapIntrin =
|
||||
Intrinsic::getDeclaration(F.getParent(), Intrinsic::debugtrap);
|
||||
CallInst::Create(TrapIntrin, {}, "", &*I);
|
||||
CallInst::Create(TrapIntrin, {}, "", I->getIterator());
|
||||
|
||||
worklist.insert(&*I);
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ static AllocaInst *createAllocaInstAtEntry(IRBuilder<> &Builder, BasicBlock *BB,
|
||||
auto AllocaAlignment = DL.getPrefTypeAlign(Type::getX86_AMXTy(Ctx));
|
||||
unsigned AllocaAS = DL.getAllocaAddrSpace();
|
||||
AllocaInst *AllocaRes =
|
||||
new AllocaInst(Ty, AllocaAS, "", &F.getEntryBlock().front());
|
||||
new AllocaInst(Ty, AllocaAS, "", F.getEntryBlock().begin());
|
||||
AllocaRes->setAlignment(AllocaAlignment);
|
||||
return AllocaRes;
|
||||
}
|
||||
@ -453,7 +453,7 @@ static Value *getAllocaPos(BasicBlock *BB) {
|
||||
unsigned AllocaAS = DL.getAllocaAddrSpace();
|
||||
Type *V256I32Ty = VectorType::get(Builder.getInt32Ty(), 256, false);
|
||||
AllocaInst *AllocaRes =
|
||||
new AllocaInst(V256I32Ty, AllocaAS, "", &F->getEntryBlock().front());
|
||||
new AllocaInst(V256I32Ty, AllocaAS, "", F->getEntryBlock().begin());
|
||||
BasicBlock::iterator Iter = AllocaRes->getIterator();
|
||||
++Iter;
|
||||
Builder.SetInsertPoint(&*Iter);
|
||||
|
@ -1212,7 +1212,7 @@ bool IslNodeBuilder::preloadInvariantEquivClass(
|
||||
BasicBlock *EntryBB = &Builder.GetInsertBlock()->getParent()->getEntryBlock();
|
||||
auto *Alloca = new AllocaInst(AccInstTy, DL.getAllocaAddrSpace(),
|
||||
AccInst->getName() + ".preload.s2a",
|
||||
&*EntryBB->getFirstInsertionPt());
|
||||
EntryBB->getFirstInsertionPt());
|
||||
Builder.CreateStore(PreloadVal, Alloca);
|
||||
ValueMapT PreloadedPointer;
|
||||
PreloadedPointer[PreloadVal] = AccInst;
|
||||
@ -1308,10 +1308,11 @@ void IslNodeBuilder::allocateNewArrays(BBPair StartExitBlocks) {
|
||||
auto InstIt = Builder.GetInsertBlock()
|
||||
->getParent()
|
||||
->getEntryBlock()
|
||||
.getTerminator();
|
||||
.getTerminator()
|
||||
->getIterator();
|
||||
|
||||
auto *CreatedArray = new AllocaInst(NewArrayType, DL.getAllocaAddrSpace(),
|
||||
SAI->getName(), &*InstIt);
|
||||
SAI->getName(), InstIt);
|
||||
if (PollyTargetFirstLevelCacheLineSize)
|
||||
CreatedArray->setAlignment(Align(PollyTargetFirstLevelCacheLineSize));
|
||||
SAI->setBasePtr(CreatedArray);
|
||||
|
@ -225,7 +225,7 @@ ParallelLoopGenerator::storeValuesIntoStruct(SetVector<Value *> &Values) {
|
||||
// in the entry block of the function and use annotations to denote the actual
|
||||
// live span (similar to clang).
|
||||
BasicBlock &EntryBB = Builder.GetInsertBlock()->getParent()->getEntryBlock();
|
||||
Instruction *IP = &*EntryBB.getFirstInsertionPt();
|
||||
BasicBlock::iterator IP = EntryBB.getFirstInsertionPt();
|
||||
StructType *Ty = StructType::get(Builder.getContext(), Members);
|
||||
AllocaInst *Struct = new AllocaInst(Ty, DL.getAllocaAddrSpace(), nullptr,
|
||||
"polly.par.userContext", IP);
|
||||
|
@ -328,8 +328,9 @@ private:
|
||||
Value *LHS = expandCodeFor(LHSScev, E->getType(), IP);
|
||||
Value *RHS = expandCodeFor(RHSScev, E->getType(), IP);
|
||||
|
||||
Inst = BinaryOperator::Create((Instruction::BinaryOps)Inst->getOpcode(),
|
||||
LHS, RHS, Inst->getName() + Name, IP);
|
||||
Inst =
|
||||
BinaryOperator::Create((Instruction::BinaryOps)Inst->getOpcode(), LHS,
|
||||
RHS, Inst->getName() + Name, IP->getIterator());
|
||||
return SE.getSCEV(Inst);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user