ADT: Remove == and != comparisons between ilist iterators and pointers

I missed == and != when I removed implicit conversions between iterators
and pointers in r252380 since they were defined outside ilist_iterator.

Since they depend on getNodePtrUnchecked(), they indirectly rely on UB.
This commit removes all uses of these operators.  (I'll delete the
operators themselves in a separate commit so that it can be easily
reverted if necessary.)

There should be NFC here.

llvm-svn: 261498
This commit is contained in:
Duncan P. N. Exon Smith 2016-02-21 20:39:50 +00:00
parent ec6f7fed54
commit e9bc579c37
14 changed files with 25 additions and 23 deletions

View File

@ -277,7 +277,7 @@ void LoopBase<BlockT, LoopT>::verifyLoop() const {
}
assert(HasInsideLoopPreds && "Loop block has no in-loop predecessors!");
assert(HasInsideLoopSuccs && "Loop block has no in-loop successors!");
assert(BB != getHeader()->getParent()->begin() &&
assert(BB != &getHeader()->getParent()->front() &&
"Loop contains function entry block!");
NumVisited++;

View File

@ -1654,9 +1654,9 @@ Value *SCEVExpander::expand(const SCEV *S) {
// there) so that it is guaranteed to dominate any user inside the loop.
if (L && SE.hasComputableLoopEvolution(S, L) && !PostIncLoops.count(L))
InsertPt = &*L->getHeader()->getFirstInsertionPt();
while (InsertPt != Builder.GetInsertPoint()
&& (isInsertedInstruction(InsertPt)
|| isa<DbgInfoIntrinsic>(InsertPt))) {
while (InsertPt->getIterator() != Builder.GetInsertPoint() &&
(isInsertedInstruction(InsertPt) ||
isa<DbgInfoIntrinsic>(InsertPt))) {
InsertPt = &*std::next(InsertPt->getIterator());
}
break;

View File

@ -50,11 +50,12 @@ void MachineLoopInfo::getAnalysisUsage(AnalysisUsage &AU) const {
MachineBasicBlock *MachineLoop::getTopBlock() {
MachineBasicBlock *TopMBB = getHeader();
MachineFunction::iterator Begin = TopMBB->getParent()->begin();
if (TopMBB != Begin) {
if (TopMBB->getIterator() != Begin) {
MachineBasicBlock *PriorMBB = &*std::prev(TopMBB->getIterator());
while (contains(PriorMBB)) {
TopMBB = PriorMBB;
if (TopMBB == Begin) break;
if (TopMBB->getIterator() == Begin)
break;
PriorMBB = &*std::prev(TopMBB->getIterator());
}
}
@ -64,7 +65,7 @@ MachineBasicBlock *MachineLoop::getTopBlock() {
MachineBasicBlock *MachineLoop::getBottomBlock() {
MachineBasicBlock *BotMBB = getHeader();
MachineFunction::iterator End = BotMBB->getParent()->end();
if (BotMBB != std::prev(End)) {
if (BotMBB->getIterator() != std::prev(End)) {
MachineBasicBlock *NextMBB = &*std::next(BotMBB->getIterator());
while (contains(NextMBB)) {
BotMBB = NextMBB;

View File

@ -560,7 +560,7 @@ MachineVerifier::visitMachineBasicBlockBefore(const MachineBasicBlock *MBB) {
// it is an entry block or landing pad.
for (const auto &LI : MBB->liveins()) {
if (isAllocatable(LI.PhysReg) && !MBB->isEHPad() &&
MBB != MBB->getParent()->begin()) {
MBB->getIterator() != MBB->getParent()->begin()) {
report("MBB has allocable live-in, but isn't entry or landing-pad.", MBB);
}
}

View File

@ -644,7 +644,8 @@ void SelectionDAG::DeleteNode(SDNode *N) {
}
void SelectionDAG::DeleteNodeNotInCSEMaps(SDNode *N) {
assert(N != AllNodes.begin() && "Cannot delete the entry node!");
assert(N->getIterator() != AllNodes.begin() &&
"Cannot delete the entry node!");
assert(N->use_empty() && "Cannot delete a node that is not dead!");
// Drop all of the operands and decrement used node's use counts.
@ -6653,7 +6654,7 @@ unsigned SelectionDAG::AssignTopologicalOrder() {
if (Degree == 0) {
// All of P's operands are sorted, so P may sorted now.
P->setNodeId(DAGSize++);
if (P != SortedPos)
if (P->getIterator() != SortedPos)
SortedPos = AllNodes.insert(SortedPos, AllNodes.remove(P));
assert(SortedPos != AllNodes.end() && "Overran node list");
++SortedPos;
@ -6662,7 +6663,7 @@ unsigned SelectionDAG::AssignTopologicalOrder() {
P->setNodeId(Degree);
}
}
if (&Node == SortedPos) {
if (Node.getIterator() == SortedPos) {
#ifndef NDEBUG
allnodes_iterator I(N);
SDNode *S = &*++I;

View File

@ -419,7 +419,7 @@ bool SjLjEHPrepare::setupEntryBlockAndCallSites(Function &F) {
// directly to the caller's context, which is what we want anyway, so no need
// to do anything here.
for (BasicBlock &BB : F) {
if (&BB == F.begin())
if (&BB == &F.front())
continue;
for (Instruction &I : BB)
if (I.mayThrow())
@ -434,7 +434,7 @@ bool SjLjEHPrepare::setupEntryBlockAndCallSites(Function &F) {
// Following any allocas not in the entry block, update the saved SP in the
// jmpbuf to the new value.
for (BasicBlock &BB : F) {
if (&BB == F.begin())
if (&BB == &F.front())
continue;
for (Instruction &I : BB) {
if (auto *CI = dyn_cast<CallInst>(&I)) {

View File

@ -2251,7 +2251,7 @@ adjustJTTargetBlockForward(MachineBasicBlock *BB, MachineBasicBlock *JTBB) {
// If the block ends in an unconditional branch, move it. The prior block
// has to have an analyzable terminator for us to move this one. Be paranoid
// and make sure we're not trying to move the entry block of the function.
if (!B && Cond.empty() && BB != MF->begin() &&
if (!B && Cond.empty() && BB != &MF->front() &&
!TII->AnalyzeBranch(*OldPrior, TBB, FBB, CondPrior)) {
BB->moveAfter(JTBB);
OldPrior->updateTerminator();

View File

@ -988,7 +988,7 @@ static MachineBasicBlock::const_iterator
PrevCrossBBInst(MachineBasicBlock::const_iterator MBBI) {
const MachineBasicBlock *MBB = MBBI->getParent();
while (MBBI == MBB->begin()) {
if (MBB == MBB->getParent()->begin())
if (MBB == &MBB->getParent()->front())
return nullptr;
MBB = MBB->getPrevNode();
MBBI = MBB->end();

View File

@ -535,7 +535,7 @@ static bool addArgumentAttrs(const SCCNodeSet &SCCNodes) {
UE = Tracker.Uses.end();
UI != UE; ++UI) {
Node->Uses.push_back(AG[*UI]);
if (*UI != A)
if (*UI != &*A)
HasNonLocalUses = true;
}
}

View File

@ -436,7 +436,7 @@ bool ObjCARCContract::tryToPeepholeInstruction(
// If it's an invoke, we have to cross a block boundary. And we have
// to carefully dodge no-op instructions.
do {
if (&*BBI == InstParent->begin()) {
if (BBI == InstParent->begin()) {
BasicBlock *Pred = InstParent->getSinglePredecessor();
if (!Pred)
goto decline_rv_optimization;

View File

@ -2286,7 +2286,7 @@ bool Reassociate::runOnFunction(Function &F) {
EraseInst(&*II++);
} else {
OptimizeInst(&*II);
assert(II->getParent() == BI && "Moved to a different block!");
assert(II->getParent() == &*BI && "Moved to a different block!");
++II;
}

View File

@ -1226,7 +1226,7 @@ unsigned llvm::removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB) {
// Delete the instructions backwards, as it has a reduced likelihood of
// having to update as many def-use and use-def chains.
Instruction *EndInst = BB->getTerminator(); // Last not to be deleted.
while (EndInst != BB->begin()) {
while (EndInst != &BB->front()) {
// Delete the next to last instruction.
Instruction *Inst = &*--EndInst->getIterator();
if (!Inst->use_empty() && !Inst->getType()->isTokenTy())

View File

@ -1382,7 +1382,7 @@ static bool SinkThenElseCodeToEnd(BranchInst *BI1) {
// We need to update RE1 and RE2 if we are going to sink the first
// instruction in the basic block down.
bool UpdateRE1 = (I1 == BB1->begin()), UpdateRE2 = (I2 == BB2->begin());
bool UpdateRE1 = (I1 == &BB1->front()), UpdateRE2 = (I2 == &BB2->front());
// Sink the instruction.
BBEnd->getInstList().splice(FirstNonPhiInBBEnd->getIterator(),
BB1->getInstList(), I1);
@ -2134,7 +2134,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, unsigned BonusInstThreshold) {
// as "bonus instructions", and only allow this transformation when the
// number of the bonus instructions does not exceed a certain threshold.
unsigned NumBonusInsts = 0;
for (auto I = BB->begin(); Cond != I; ++I) {
for (auto I = BB->begin(); Cond != &*I; ++I) {
// Ignore dbg intrinsics.
if (isa<DbgInfoIntrinsic>(I))
continue;
@ -2232,7 +2232,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, unsigned BonusInstThreshold) {
// We already make sure Cond is the last instruction before BI. Therefore,
// all instructions before Cond other than DbgInfoIntrinsic are bonus
// instructions.
for (auto BonusInst = BB->begin(); Cond != BonusInst; ++BonusInst) {
for (auto BonusInst = BB->begin(); Cond != &*BonusInst; ++BonusInst) {
if (isa<DbgInfoIntrinsic>(BonusInst))
continue;
Instruction *NewBonusInst = BonusInst->clone();

View File

@ -1259,7 +1259,7 @@ namespace {
bool JAfterStart = IAfterStart;
BasicBlock::iterator J = std::next(I);
for (unsigned ss = 0; J != E && ss <= Config.SearchLimit; ++J, ++ss) {
if (&*J == Start)
if (J == Start)
JAfterStart = true;
// Determine if J uses I, if so, exit the loop.