Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/Transforms/Coroutines/CoroInstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class CoroIdInst : public AnyCoroIdInst {
Inst->eraseFromParent();
return;
}
Inst->moveBefore(getCoroBegin()->getNextNode());
Inst->moveBefore(std::next(getCoroBegin()->getIterator()));
}

// Info argument of coro.id is
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ void OpenMPIRBuilder::initialize() { initializeTypes(M); }
static void raiseUserConstantDataAllocasToEntryBlock(IRBuilderBase &Builder,
Function *Function) {
BasicBlock &EntryBlock = Function->getEntryBlock();
Instruction *MoveLocInst = EntryBlock.getFirstNonPHI();
BasicBlock::iterator MoveLocInst = EntryBlock.getFirstNonPHIIt();

// Loop over blocks looking for constant allocas, skipping the entry block
// as any allocas there are already in the desired location.
Expand Down Expand Up @@ -6916,7 +6916,7 @@ static Expected<Function *> createOutlinedFunction(
Builder.CreateRetVoid();

// New Alloca IP at entry point of created device function.
Builder.SetInsertPoint(EntryBB->getFirstNonPHI());
Builder.SetInsertPoint(EntryBB->getFirstNonPHIIt());
auto AllocaIP = Builder.saveIP();

Builder.SetInsertPoint(UserCodeEntryBB->getFirstNonPHIOrDbg());
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/IR/BasicBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ void BasicBlock::removePredecessor(BasicBlock *Pred,
}

bool BasicBlock::canSplitPredecessors() const {
const Instruction *FirstNonPHI = getFirstNonPHI();
const_iterator FirstNonPHI = getFirstNonPHIIt();
if (isa<LandingPadInst>(FirstNonPHI))
return true;
// This is perhaps a little conservative because constructs like
Expand Down Expand Up @@ -675,11 +675,11 @@ void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *New) {
}

bool BasicBlock::isLandingPad() const {
return isa<LandingPadInst>(getFirstNonPHI());
return isa<LandingPadInst>(getFirstNonPHIIt());
}

const LandingPadInst *BasicBlock::getLandingPadInst() const {
return dyn_cast<LandingPadInst>(getFirstNonPHI());
return dyn_cast<LandingPadInst>(getFirstNonPHIIt());
}

std::optional<uint64_t> BasicBlock::getIrrLoopHeaderWeight() const {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/Hexagon/HexagonOptimizeSZextends.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ bool HexagonOptimizeSZextends::runOnFunction(Function &F) {
assert (EVT::getEVT(SI->getType()) ==
(EVT::getEVT(Use->getType())));
Use->replaceAllUsesWith(SI);
Instruction* First = &F.getEntryBlock().front();
BasicBlock::iterator First = F.getEntryBlock().begin();
SI->insertBefore(First);
Use->eraseFromParent();
}
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3414,7 +3414,7 @@ void FunctionStackPoisoner::processStaticAllocas() {
assert(InsBeforeB == &F.getEntryBlock());
for (auto *AI : StaticAllocasToMoveUp)
if (AI->getParent() == InsBeforeB)
AI->moveBefore(InsBefore);
AI->moveBefore(InsBefore->getIterator());

// Move stores of arguments into entry-block allocas as well. This prevents
// extra stack slots from being generated (to house the argument values until
Expand All @@ -3423,10 +3423,10 @@ void FunctionStackPoisoner::processStaticAllocas() {
SmallVector<Instruction *, 8> ArgInitInsts;
findStoresToUninstrumentedArgAllocas(ASan, *InsBefore, ArgInitInsts);
for (Instruction *ArgInitInst : ArgInitInsts)
ArgInitInst->moveBefore(InsBefore);
ArgInitInst->moveBefore(InsBefore->getIterator());

// If we have a call to llvm.localescape, keep it in the entry block.
if (LocalEscapeCall) LocalEscapeCall->moveBefore(InsBefore);
if (LocalEscapeCall) LocalEscapeCall->moveBefore(InsBefore->getIterator());

SmallVector<ASanStackVariableDescription, 16> SVD;
SVD.reserve(AllocaVec.size());
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ static bool canSplitCallSite(CallBase &CB, TargetTransformInfo &TTI) {
return true;
}

static Instruction *cloneInstForMustTail(Instruction *I, Instruction *Before,
static Instruction *cloneInstForMustTail(Instruction *I, BasicBlock::iterator Before,
Value *V) {
Instruction *Copy = I->clone();
Copy->setName(I->getName());
Expand Down Expand Up @@ -251,8 +251,8 @@ static void copyMustTailReturn(BasicBlock *SplitBB, Instruction *CI,
Instruction *TI = SplitBB->getTerminator();
Value *V = NewCI;
if (BCI)
V = cloneInstForMustTail(BCI, TI, V);
cloneInstForMustTail(RI, TI, IsVoid ? nullptr : V);
V = cloneInstForMustTail(BCI, TI->getIterator(), V);
cloneInstForMustTail(RI, TI->getIterator(), IsVoid ? nullptr : V);

// FIXME: remove TI here, `DuplicateInstructionsInSplitBetween` has a bug
// that prevents doing this now.
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6176,11 +6176,11 @@ LSRInstance::LSRInstance(Loop *L, IVUsers &IU, ScalarEvolution &SE,
// CatchSwitchInst. Because the CatchSwitchInst cannot be split, there is
// no good place to stick any instructions.
if (auto *PN = dyn_cast<PHINode>(U.getUser())) {
auto *FirstNonPHI = PN->getParent()->getFirstNonPHI();
auto FirstNonPHI = PN->getParent()->getFirstNonPHIIt();
if (isa<FuncletPadInst>(FirstNonPHI) ||
isa<CatchSwitchInst>(FirstNonPHI))
for (BasicBlock *PredBB : PN->blocks())
if (isa<CatchSwitchInst>(PredBB->getFirstNonPHI()))
if (isa<CatchSwitchInst>(PredBB->getFirstNonPHIIt()))
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ void MergedLoadStoreMotion::sinkStoresAndGEPs(BasicBlock *BB, StoreInst *S0,
auto *GEP0 = cast<GetElementPtrInst>(Ptr0);
auto *GEP1 = cast<GetElementPtrInst>(Ptr1);
Instruction *GEPNew = GEP0->clone();
GEPNew->insertBefore(SNew);
GEPNew->insertBefore(SNew->getIterator());
GEPNew->applyMergedLocation(GEP0->getDebugLoc(), GEP1->getDebugLoc());
SNew->setOperand(1, GEPNew);
GEP0->replaceAllUsesWith(GEPNew);
Expand Down
22 changes: 11 additions & 11 deletions llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ static void recomputeLiveInValues(
// and inserts them before "InsertBefore". Returns rematerialized value
// which should be used after statepoint.
static Instruction *rematerializeChain(ArrayRef<Instruction *> ChainToBase,
Instruction *InsertBefore,
BasicBlock::iterator InsertBefore,
Value *RootOfChain,
Value *AlternateLiveBase) {
Instruction *LastClonedValue = nullptr;
Expand Down Expand Up @@ -2185,16 +2185,16 @@ static void relocationViaAlloca(
// InvokeInst is a terminator so the store need to be inserted into its
// normal destination block.
BasicBlock *NormalDest = Invoke->getNormalDest();
Store->insertBefore(NormalDest->getFirstNonPHI());
Store->insertBefore(NormalDest->getFirstNonPHIIt());
} else {
assert(!Inst->isTerminator() &&
"The only terminator that can produce a value is "
"InvokeInst which is handled above.");
Store->insertAfter(Inst);
Store->insertAfter(Inst->getIterator());
}
} else {
assert(isa<Argument>(Def));
Store->insertAfter(cast<Instruction>(Alloca));
Store->insertAfter(cast<Instruction>(Alloca)->getIterator());
}
}

Expand Down Expand Up @@ -2500,7 +2500,7 @@ static void rematerializeLiveValuesAtUses(
while (!Cand->user_empty()) {
Instruction *UserI = cast<Instruction>(*Cand->user_begin());
Instruction *RematChain = rematerializeChain(
Record.ChainToBase, UserI, Record.RootOfChain, PointerToBase[Cand]);
Record.ChainToBase, UserI->getIterator(), Record.RootOfChain, PointerToBase[Cand]);
UserI->replaceUsesOfWith(Cand, RematChain);
PointerToBase[RematChain] = PointerToBase[Cand];
}
Expand Down Expand Up @@ -2573,16 +2573,16 @@ static void rematerializeLiveValues(CallBase *Call,
Instruction *InsertBefore = Call->getNextNode();
assert(InsertBefore);
Instruction *RematerializedValue =
rematerializeChain(Record.ChainToBase, InsertBefore,
rematerializeChain(Record.ChainToBase, InsertBefore->getIterator(),
Record.RootOfChain, PointerToBase[LiveValue]);
Info.RematerializedValues[RematerializedValue] = LiveValue;
} else {
auto *Invoke = cast<InvokeInst>(Call);

Instruction *NormalInsertBefore =
&*Invoke->getNormalDest()->getFirstInsertionPt();
Instruction *UnwindInsertBefore =
&*Invoke->getUnwindDest()->getFirstInsertionPt();
BasicBlock::iterator NormalInsertBefore =
Invoke->getNormalDest()->getFirstInsertionPt();
BasicBlock::iterator UnwindInsertBefore =
Invoke->getUnwindDest()->getFirstInsertionPt();

Instruction *NormalRematerializedValue =
rematerializeChain(Record.ChainToBase, NormalInsertBefore,
Expand Down Expand Up @@ -3131,7 +3131,7 @@ bool RewriteStatepointsForGC::runOnFunction(Function &F, DominatorTree &DT,
// most instructions without side effects or memory access.
if (isa<ICmpInst>(Cond) && Cond->hasOneUse()) {
MadeChange = true;
Cond->moveBefore(TI);
Cond->moveBefore(TI->getIterator());
}
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/SROA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ static void migrateDebugInfo(AllocaInst *OldAlloca, bool IsSplit,
// noted as slightly offset (in code) from the store. In practice this
// should have little effect on the debugging experience due to the fact
// that all the split stores should get the same line number.
NewAssign->moveBefore(DbgAssign);
NewAssign->moveBefore(DbgAssign->getIterator());

NewAssign->setDebugLoc(DbgAssign->getDebugLoc());
LLVM_DEBUG(dbgs() << "Created new assign: " << *NewAssign << "\n");
Expand Down Expand Up @@ -1843,7 +1843,7 @@ static void rewriteMemOpOfSelect(SelectInst &SI, T &I,
CondMemOp.dropUBImplyingAttrsAndMetadata();
++NumLoadsSpeculated;
}
CondMemOp.insertBefore(NewMemOpBB->getTerminator());
CondMemOp.insertBefore(NewMemOpBB->getTerminator()->getIterator());
Value *Ptr = SI.getOperand(1 + SuccIdx);
CondMemOp.setOperand(I.getPointerOperandIndex(), Ptr);
if (isa<LoadInst>(I)) {
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3303,8 +3303,8 @@ static bool isSafeForNoNTrivialUnswitching(Loop &L, LoopInfo &LI) {
// FIXME: We should teach SplitBlock to handle this and remove this
// restriction.
for (auto *ExitBB : ExitBlocks) {
auto *I = ExitBB->getFirstNonPHI();
if (isa<CleanupPadInst>(I) || isa<CatchSwitchInst>(I)) {
auto It = ExitBB->getFirstNonPHIIt();
if (isa<CleanupPadInst>(It) || isa<CatchSwitchInst>(It)) {
LLVM_DEBUG(dbgs() << "Cannot unswitch because of cleanuppad/catchswitch "
"in exit block\n");
return false;
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,9 @@ struct AssumeSimplify {
AssumeBuilderState Builder(F.getParent());

/// For now it is initialized to the best value it could have
Instruction *InsertPt = BB->getFirstNonPHI();
BasicBlock::iterator InsertPt = BB->getFirstNonPHIIt();
if (isa<LandingPadInst>(InsertPt))
InsertPt = InsertPt->getNextNode();
InsertPt = std::next(InsertPt);
for (IntrinsicInst *I : make_range(Begin, End)) {
CleanupToDo.insert(I);
for (CallInst::BundleOpInfo &BOI : I->bundle_op_infos()) {
Expand All @@ -487,8 +487,8 @@ struct AssumeSimplify {
Builder.addKnowledge(RK);
if (auto *I = dyn_cast_or_null<Instruction>(RK.WasOn))
if (I->getParent() == InsertPt->getParent() &&
(InsertPt->comesBefore(I) || InsertPt == I))
InsertPt = I->getNextNode();
(InsertPt->comesBefore(I) || &*InsertPt == I))
InsertPt = I->getNextNode()->getIterator();
}
}

Expand All @@ -498,7 +498,7 @@ struct AssumeSimplify {
for (auto It = (*Begin)->getIterator(), E = InsertPt->getIterator();
It != E; --It)
if (!isGuaranteedToTransferExecutionToSuccessor(&*It)) {
InsertPt = It->getNextNode();
InsertPt = std::next(It);
break;
}
auto *MergedAssume = Builder.build();
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ BasicBlock *llvm::ehAwareSplitEdge(BasicBlock *BB, BasicBlock *Succ,
const CriticalEdgeSplittingOptions &Options,
const Twine &BBName) {

auto *PadInst = Succ->getFirstNonPHI();
auto PadInst = Succ->getFirstNonPHIIt();
if (!LandingPadReplacement && !PadInst->isEHPad())
return SplitEdge(BB, Succ, Options.DT, Options.LI, Options.MSSAU, BBName);

Expand Down Expand Up @@ -981,7 +981,7 @@ BasicBlock *llvm::ehAwareSplitEdge(BasicBlock *BB, BasicBlock *Succ,
void llvm::createPHIsForSplitLoopExit(ArrayRef<BasicBlock *> Preds,
BasicBlock *SplitBB, BasicBlock *DestBB) {
// SplitBB shouldn't have anything non-trivial in it yet.
assert((SplitBB->getFirstNonPHI() == SplitBB->getTerminator() ||
assert((&*SplitBB->getFirstNonPHIIt() == SplitBB->getTerminator() ||
SplitBB->isLandingPad()) &&
"SplitBB has non-PHI nodes!");

Expand Down Expand Up @@ -1450,7 +1450,7 @@ static void SplitLandingPadPredecessorsImpl(

// The new block unconditionally branches to the old block.
BranchInst *BI1 = BranchInst::Create(OrigBB, NewBB1);
BI1->setDebugLoc(OrigBB->getFirstNonPHI()->getDebugLoc());
BI1->setDebugLoc(OrigBB->getFirstNonPHIIt()->getDebugLoc());

// Move the edges from Preds to point to NewBB1 instead of OrigBB.
for (BasicBlock *Pred : Preds) {
Expand Down Expand Up @@ -1491,7 +1491,7 @@ static void SplitLandingPadPredecessorsImpl(

// The new block unconditionally branches to the old block.
BranchInst *BI2 = BranchInst::Create(OrigBB, NewBB2);
BI2->setDebugLoc(OrigBB->getFirstNonPHI()->getDebugLoc());
BI2->setDebugLoc(OrigBB->getFirstNonPHIIt()->getDebugLoc());

// Move the remaining edges from OrigBB to point to NewBB2.
for (BasicBlock *NewBB2Pred : NewBB2Preds)
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static bool processHeaderPhiOperands(BasicBlock *Header, BasicBlock *Latch,
// Move the phi operands of Header from Latch out of AftBlocks to InsertLoc.
static void moveHeaderPhiOperandsToForeBlocks(BasicBlock *Header,
BasicBlock *Latch,
Instruction *InsertLoc,
BasicBlock::iterator InsertLoc,
BasicBlockSet &AftBlocks) {
// We need to ensure we move the instructions in the correct order,
// starting with the earliest required instruction and moving forward.
Expand Down Expand Up @@ -329,7 +329,7 @@ llvm::UnrollAndJamLoop(Loop *L, unsigned Count, unsigned TripCount,

// Move any instructions from fore phi operands from AftBlocks into Fore.
moveHeaderPhiOperandsToForeBlocks(
Header, LatchBlock, ForeBlocksLast[0]->getTerminator(), AftBlocks);
Header, LatchBlock, ForeBlocksLast[0]->getTerminator()->getIterator(), AftBlocks);

// The current on-the-fly SSA update requires blocks to be processed in
// reverse postorder so that LastValueMap contains the correct value at each
Expand Down
13 changes: 6 additions & 7 deletions llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5262,8 +5262,8 @@ bool SimplifyCFGOpt::simplifyBranchOnICmpChain(BranchInst *BI,
bool SimplifyCFGOpt::simplifyResume(ResumeInst *RI, IRBuilder<> &Builder) {
if (isa<PHINode>(RI->getValue()))
return simplifyCommonResume(RI);
else if (isa<LandingPadInst>(RI->getParent()->getFirstNonPHI()) &&
RI->getValue() == RI->getParent()->getFirstNonPHI())
else if (isa<LandingPadInst>(RI->getParent()->getFirstNonPHIIt()) &&
RI->getValue() == &*RI->getParent()->getFirstNonPHIIt())
// The resume must unwind the exception that caused control to branch here.
return simplifySingleResume(RI);

Expand Down Expand Up @@ -5298,7 +5298,7 @@ bool SimplifyCFGOpt::simplifyCommonResume(ResumeInst *RI) {
// Check that there are no other instructions except for debug and lifetime
// intrinsics between the phi's and resume instruction.
if (!isCleanupBlockEmpty(
make_range(RI->getParent()->getFirstNonPHI(), BB->getTerminator())))
make_range(RI->getParent()->getFirstNonPHIIt(), BB->getTerminator()->getIterator())))
return false;

SmallSetVector<BasicBlock *, 4> TrivialUnwindBlocks;
Expand All @@ -5315,7 +5315,7 @@ bool SimplifyCFGOpt::simplifyCommonResume(ResumeInst *RI) {
if (IncomingBB->getUniqueSuccessor() != BB)
continue;

auto *LandingPad = dyn_cast<LandingPadInst>(IncomingBB->getFirstNonPHI());
auto *LandingPad = dyn_cast<LandingPadInst>(IncomingBB->getFirstNonPHIIt());
// Not the landing pad that caused the control to branch here.
if (IncomingValue != LandingPad)
continue;
Expand Down Expand Up @@ -5364,7 +5364,7 @@ bool SimplifyCFGOpt::simplifyCommonResume(ResumeInst *RI) {
// Simplify resume that is only used by a single (non-phi) landing pad.
bool SimplifyCFGOpt::simplifySingleResume(ResumeInst *RI) {
BasicBlock *BB = RI->getParent();
auto *LPInst = cast<LandingPadInst>(BB->getFirstNonPHI());
auto *LPInst = cast<LandingPadInst>(BB->getFirstNonPHIIt());
assert(RI->getValue() == LPInst &&
"Resume must unwind the exception that caused control to here");

Expand Down Expand Up @@ -5412,7 +5412,6 @@ static bool removeEmptyCleanup(CleanupReturnInst *RI, DomTreeUpdater *DTU) {
// If the cleanup return we are simplifying unwinds to the caller, this will
// set UnwindDest to nullptr.
BasicBlock *UnwindDest = RI->getUnwindDest();
Instruction *DestEHPad = UnwindDest ? UnwindDest->getFirstNonPHI() : nullptr;

// We're about to remove BB from the control flow. Before we do, sink any
// PHINodes into the unwind destination. Doing this before changing the
Expand Down Expand Up @@ -5449,7 +5448,7 @@ static bool removeEmptyCleanup(CleanupReturnInst *RI, DomTreeUpdater *DTU) {
}

// Sink any remaining PHI nodes directly into UnwindDest.
Instruction *InsertPt = DestEHPad;
BasicBlock::iterator InsertPt = UnwindDest->getFirstNonPHIIt(); // XXX unsafe faff
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment leftover from development? And why is it unsafe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left over indeed, removing -- it was uh, "unsafe" because I thought some of these call-sites wouldn't recompile cleanly without touching headers, and I was on a laptop which didn't have enough energy left to totally recompile LLVM X_X.

for (PHINode &PN : make_early_inc_range(BB->phis())) {
if (PN.use_empty() || !PN.isUsedOutsideOfBlock(BB))
// If the PHI node has no uses or all of its uses are in this basic
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/VPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ void VPlan::execute(VPTransformState *State) {
// Move the last step to the end of the latch block. This ensures
// consistent placement of all induction updates.
Instruction *Inc = cast<Instruction>(Phi->getIncomingValue(1));
Inc->moveBefore(VectorLatchBB->getTerminator()->getPrevNode());
Inc->moveBefore(std::prev(VectorLatchBB->getTerminator()->getIterator()));

// Use the steps for the last part as backedge value for the induction.
if (auto *IV = dyn_cast<VPWidenIntOrFpInductionRecipe>(&R))
Expand Down
Loading