[llvm] r249875 - CodeGen: Remove a few more ilist iterator implicit conversions, NFC
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 9 11:44:40 PDT 2015
Author: dexonsmith
Date: Fri Oct 9 13:44:40 2015
New Revision: 249875
URL: http://llvm.org/viewvc/llvm-project?rev=249875&view=rev
Log:
CodeGen: Remove a few more ilist iterator implicit conversions, NFC
Modified:
llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
llvm/trunk/lib/CodeGen/DFAPacketizer.cpp
llvm/trunk/lib/CodeGen/ExpandISelPseudos.cpp
llvm/trunk/lib/CodeGen/GCRootLowering.cpp
Modified: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp?rev=249875&r1=249874&r2=249875&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp Fri Oct 9 13:44:40 2015
@@ -245,7 +245,7 @@ bool CodeGenPrepare::runOnFunction(Funct
while (MadeChange) {
MadeChange = false;
for (Function::iterator I = F.begin(); I != F.end(); ) {
- BasicBlock *BB = I++;
+ BasicBlock *BB = &*I++;
bool ModifiedDTOnIteration = false;
MadeChange |= optimizeBlock(*BB, ModifiedDTOnIteration);
@@ -315,7 +315,7 @@ bool CodeGenPrepare::eliminateFallThroug
bool Changed = false;
// Scan all of the blocks in the function, except for the entry block.
for (Function::iterator I = std::next(F.begin()), E = F.end(); I != E;) {
- BasicBlock *BB = I++;
+ BasicBlock *BB = &*I++;
// If the destination block has a single pred, then this is a trivial
// edge, just collapse it.
BasicBlock *SinglePred = BB->getSinglePredecessor();
@@ -336,7 +336,7 @@ bool CodeGenPrepare::eliminateFallThroug
BB->moveBefore(&BB->getParent()->getEntryBlock());
// We have erased a block. Update the iterator.
- I = BB;
+ I = BB->getIterator();
}
}
return Changed;
@@ -350,7 +350,7 @@ bool CodeGenPrepare::eliminateMostlyEmpt
bool MadeChange = false;
// Note that this intentionally skips the entry block.
for (Function::iterator I = std::next(F.begin()), E = F.end(); I != E;) {
- BasicBlock *BB = I++;
+ BasicBlock *BB = &*I++;
// If this block doesn't end with an uncond branch, ignore it.
BranchInst *BI = dyn_cast<BranchInst>(BB->getTerminator());
@@ -359,7 +359,7 @@ bool CodeGenPrepare::eliminateMostlyEmpt
// If the instruction before the branch (skipping debug info) isn't a phi
// node, then other stuff is happening here.
- BasicBlock::iterator BBI = BI;
+ BasicBlock::iterator BBI = BI->getIterator();
if (BBI != BB->begin()) {
--BBI;
while (isa<DbgInfoIntrinsic>(BBI)) {
@@ -724,9 +724,9 @@ static bool SinkCast(CastInst *CI) {
if (!InsertedCast) {
BasicBlock::iterator InsertPt = UserBB->getFirstInsertionPt();
- InsertedCast =
- CastInst::Create(CI->getOpcode(), CI->getOperand(0), CI->getType(), "",
- InsertPt);
+ assert(InsertPt != UserBB->end());
+ InsertedCast = CastInst::Create(CI->getOpcode(), CI->getOperand(0),
+ CI->getType(), "", &*InsertPt);
}
// Replace a use of the cast with a use of the new cast.
@@ -864,10 +864,10 @@ static bool SinkCmpExpression(CmpInst *C
if (!InsertedCmp) {
BasicBlock::iterator InsertPt = UserBB->getFirstInsertionPt();
+ assert(InsertPt != UserBB->end());
InsertedCmp =
- CmpInst::Create(CI->getOpcode(),
- CI->getPredicate(), CI->getOperand(0),
- CI->getOperand(1), "", InsertPt);
+ CmpInst::Create(CI->getOpcode(), CI->getPredicate(),
+ CI->getOperand(0), CI->getOperand(1), "", &*InsertPt);
}
// Replace a use of the cmp with a use of the new cmp.
@@ -961,20 +961,22 @@ SinkShiftAndTruncate(BinaryOperator *Shi
if (!InsertedShift && !InsertedTrunc) {
BasicBlock::iterator InsertPt = TruncUserBB->getFirstInsertionPt();
+ assert(InsertPt != TruncUserBB->end());
// Sink the shift
if (ShiftI->getOpcode() == Instruction::AShr)
- InsertedShift =
- BinaryOperator::CreateAShr(ShiftI->getOperand(0), CI, "", InsertPt);
+ InsertedShift = BinaryOperator::CreateAShr(ShiftI->getOperand(0), CI,
+ "", &*InsertPt);
else
- InsertedShift =
- BinaryOperator::CreateLShr(ShiftI->getOperand(0), CI, "", InsertPt);
+ InsertedShift = BinaryOperator::CreateLShr(ShiftI->getOperand(0), CI,
+ "", &*InsertPt);
// Sink the trunc
BasicBlock::iterator TruncInsertPt = TruncUserBB->getFirstInsertionPt();
TruncInsertPt++;
+ assert(TruncInsertPt != TruncUserBB->end());
InsertedTrunc = CastInst::Create(TruncI->getOpcode(), InsertedShift,
- TruncI->getType(), "", TruncInsertPt);
+ TruncI->getType(), "", &*TruncInsertPt);
MadeChange = true;
@@ -1058,13 +1060,14 @@ static bool OptimizeExtractBits(BinaryOp
if (!InsertedShift) {
BasicBlock::iterator InsertPt = UserBB->getFirstInsertionPt();
+ assert(InsertPt != UserBB->end());
if (ShiftI->getOpcode() == Instruction::AShr)
- InsertedShift =
- BinaryOperator::CreateAShr(ShiftI->getOperand(0), CI, "", InsertPt);
+ InsertedShift = BinaryOperator::CreateAShr(ShiftI->getOperand(0), CI,
+ "", &*InsertPt);
else
- InsertedShift =
- BinaryOperator::CreateLShr(ShiftI->getOperand(0), CI, "", InsertPt);
+ InsertedShift = BinaryOperator::CreateLShr(ShiftI->getOperand(0), CI,
+ "", &*InsertPt);
MadeChange = true;
}
@@ -1173,7 +1176,7 @@ static void ScalarizeMaskedLoad(CallInst
// %Elt = load i32* %EltAddr
// VResult = insertelement <16 x i32> VResult, i32 %Elt, i32 Idx
//
- CondBlock = IfBlock->splitBasicBlock(InsertPt, "cond.load");
+ CondBlock = IfBlock->splitBasicBlock(InsertPt->getIterator(), "cond.load");
Builder.SetInsertPoint(InsertPt);
Value *Gep =
@@ -1182,7 +1185,8 @@ static void ScalarizeMaskedLoad(CallInst
VResult = Builder.CreateInsertElement(VResult, Load, Builder.getInt32(Idx));
// Create "else" block, fill it in the next iteration
- BasicBlock *NewIfBlock = CondBlock->splitBasicBlock(InsertPt, "else");
+ BasicBlock *NewIfBlock =
+ CondBlock->splitBasicBlock(InsertPt->getIterator(), "else");
Builder.SetInsertPoint(InsertPt);
Instruction *OldBr = IfBlock->getTerminator();
BranchInst::Create(CondBlock, NewIfBlock, Cmp, OldBr);
@@ -1267,16 +1271,18 @@ static void ScalarizeMaskedStore(CallIns
// %EltAddr = getelementptr i32* %1, i32 0
// %store i32 %OneElt, i32* %EltAddr
//
- BasicBlock *CondBlock = IfBlock->splitBasicBlock(InsertPt, "cond.store");
+ BasicBlock *CondBlock =
+ IfBlock->splitBasicBlock(InsertPt->getIterator(), "cond.store");
Builder.SetInsertPoint(InsertPt);
-
+
Value *OneElt = Builder.CreateExtractElement(Src, Builder.getInt32(Idx));
Value *Gep =
Builder.CreateInBoundsGEP(EltTy, FirstEltPtr, Builder.getInt32(Idx));
Builder.CreateStore(OneElt, Gep);
// Create "else" block, fill it in the next iteration
- BasicBlock *NewIfBlock = CondBlock->splitBasicBlock(InsertPt, "else");
+ BasicBlock *NewIfBlock =
+ CondBlock->splitBasicBlock(InsertPt->getIterator(), "else");
Builder.SetInsertPoint(InsertPt);
Instruction *OldBr = IfBlock->getTerminator();
BranchInst::Create(CondBlock, NewIfBlock, Cmp, OldBr);
@@ -1363,14 +1369,14 @@ bool CodeGenPrepare::optimizeCallInst(Ca
// Substituting this can cause recursive simplifications, which can
// invalidate our iterator. Use a WeakVH to hold onto it in case this
// happens.
- WeakVH IterHandle(CurInstIterator);
+ WeakVH IterHandle(&*CurInstIterator);
replaceAndRecursivelySimplify(CI, RetVal,
TLInfo, nullptr);
// If the iterator instruction was recursively deleted, start over at the
// start of the block.
- if (IterHandle != CurInstIterator) {
+ if (IterHandle != CurInstIterator.getNodePtrUnchecked()) {
CurInstIterator = BB->begin();
SunkAddrs.clear();
}
@@ -1703,10 +1709,10 @@ class TypePromotionTransaction {
public:
/// \brief Record the position of \p Inst.
InsertionHandler(Instruction *Inst) {
- BasicBlock::iterator It = Inst;
+ BasicBlock::iterator It = Inst->getIterator();
HasPrevInstruction = (It != (Inst->getParent()->begin()));
if (HasPrevInstruction)
- Point.PrevInst = --It;
+ Point.PrevInst = &*--It;
else
Point.BB = Inst->getParent();
}
@@ -1718,7 +1724,7 @@ class TypePromotionTransaction {
Inst->removeFromParent();
Inst->insertAfter(Point.PrevInst);
} else {
- Instruction *Position = Point.BB->getFirstInsertionPt();
+ Instruction *Position = &*Point.BB->getFirstInsertionPt();
if (Inst->getParent())
Inst->moveBefore(Position);
else
@@ -3519,12 +3525,12 @@ bool CodeGenPrepare::optimizeMemoryInst(
if (Repl->use_empty()) {
// This can cause recursive deletion, which can invalidate our iterator.
// Use a WeakVH to hold onto it in case this happens.
- WeakVH IterHandle(CurInstIterator);
+ WeakVH IterHandle(&*CurInstIterator);
BasicBlock *BB = CurInstIterator->getParent();
RecursivelyDeleteTriviallyDeadInstructions(Repl, TLInfo);
- if (IterHandle != CurInstIterator) {
+ if (IterHandle != CurInstIterator.getNodePtrUnchecked()) {
// If the iterator instruction was recursively deleted, start over at the
// start of the block.
CurInstIterator = BB->begin();
@@ -3826,7 +3832,8 @@ bool CodeGenPrepare::optimizeExtUses(Ins
if (!InsertedTrunc) {
BasicBlock::iterator InsertPt = UserBB->getFirstInsertionPt();
- InsertedTrunc = new TruncInst(I, Src->getType(), "", InsertPt);
+ assert(InsertPt != UserBB->end());
+ InsertedTrunc = new TruncInst(I, Src->getType(), "", &*InsertPt);
InsertedInsts.insert(InsertedTrunc);
}
@@ -3912,7 +3919,7 @@ bool CodeGenPrepare::optimizeSelectInst(
BranchInst::Create(NextBlock, SmallBlock, SI->getCondition(), SI);
// The select itself is replaced with a PHI Node.
- PHINode *PN = PHINode::Create(SI->getType(), 2, "", NextBlock->begin());
+ PHINode *PN = PHINode::Create(SI->getType(), 2, "", &NextBlock->front());
PN->takeName(SI);
PN->addIncoming(SI->getTrueValue(), StartBlock);
PN->addIncoming(SI->getFalseValue(), SmallBlock);
@@ -3973,9 +3980,10 @@ bool CodeGenPrepare::optimizeShuffleVect
if (!InsertedShuffle) {
BasicBlock::iterator InsertPt = UserBB->getFirstInsertionPt();
- InsertedShuffle = new ShuffleVectorInst(SVI->getOperand(0),
- SVI->getOperand(1),
- SVI->getOperand(2), "", InsertPt);
+ assert(InsertPt != UserBB->end());
+ InsertedShuffle =
+ new ShuffleVectorInst(SVI->getOperand(0), SVI->getOperand(1),
+ SVI->getOperand(2), "", &*InsertPt);
}
UI->replaceUsesOfWith(SVI, InsertedShuffle);
@@ -4478,7 +4486,7 @@ bool CodeGenPrepare::optimizeBlock(Basic
CurInstIterator = BB.begin();
while (CurInstIterator != BB.end()) {
- MadeChange |= optimizeInst(CurInstIterator++, ModifiedDT);
+ MadeChange |= optimizeInst(&*CurInstIterator++, ModifiedDT);
if (ModifiedDT)
return true;
}
@@ -4495,7 +4503,7 @@ bool CodeGenPrepare::placeDbgValues(Func
for (BasicBlock &BB : F) {
Instruction *PrevNonDbgInst = nullptr;
for (BasicBlock::iterator BI = BB.begin(), BE = BB.end(); BI != BE;) {
- Instruction *Insn = BI++;
+ Instruction *Insn = &*BI++;
DbgValueInst *DVI = dyn_cast<DbgValueInst>(Insn);
// Leave dbg.values that refer to an alloca alone. These
// instrinsics describe the address of a variable (= the alloca)
@@ -4512,7 +4520,7 @@ bool CodeGenPrepare::placeDbgValues(Func
DEBUG(dbgs() << "Moving Debug Value before :\n" << *DVI << ' ' << *VI);
DVI->removeFromParent();
if (isa<PHINode>(VI))
- DVI->insertBefore(VI->getParent()->getFirstInsertionPt());
+ DVI->insertBefore(&*VI->getParent()->getFirstInsertionPt());
else
DVI->insertAfter(VI);
MadeChange = true;
@@ -4536,7 +4544,7 @@ bool CodeGenPrepare::sinkAndCmp(Function
return false;
bool MadeChange = false;
for (Function::iterator I = F.begin(), E = F.end(); I != E; ) {
- BasicBlock *BB = I++;
+ BasicBlock *BB = &*I++;
// Does this BB end with the following?
// %andVal = and %val, #single-bit-set
Modified: llvm/trunk/lib/CodeGen/DFAPacketizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DFAPacketizer.cpp?rev=249875&r1=249874&r2=249875&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/DFAPacketizer.cpp (original)
+++ llvm/trunk/lib/CodeGen/DFAPacketizer.cpp Fri Oct 9 13:44:40 2015
@@ -147,7 +147,7 @@ void VLIWPacketizerList::endPacket(Machi
MachineInstr *MI) {
if (CurrentPacketMIs.size() > 1) {
MachineInstr *MIFirst = CurrentPacketMIs.front();
- finalizeBundle(*MBB, MIFirst, MI);
+ finalizeBundle(*MBB, MIFirst->getIterator(), MI->getIterator());
}
CurrentPacketMIs.clear();
ResourceTracker->clearResources();
Modified: llvm/trunk/lib/CodeGen/ExpandISelPseudos.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ExpandISelPseudos.cpp?rev=249875&r1=249874&r2=249875&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/ExpandISelPseudos.cpp (original)
+++ llvm/trunk/lib/CodeGen/ExpandISelPseudos.cpp Fri Oct 9 13:44:40 2015
@@ -50,7 +50,7 @@ bool ExpandISelPseudos::runOnMachineFunc
// Iterate through each instruction in the function, looking for pseudos.
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
- MachineBasicBlock *MBB = I;
+ MachineBasicBlock *MBB = &*I;
for (MachineBasicBlock::iterator MBBI = MBB->begin(), MBBE = MBB->end();
MBBI != MBBE; ) {
MachineInstr *MI = MBBI++;
@@ -63,7 +63,7 @@ bool ExpandISelPseudos::runOnMachineFunc
// The expansion may involve new basic blocks.
if (NewMBB != MBB) {
MBB = NewMBB;
- I = NewMBB;
+ I = NewMBB->getIterator();
MBBI = NewMBB->begin();
MBBE = NewMBB->end();
}
Modified: llvm/trunk/lib/CodeGen/GCRootLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GCRootLowering.cpp?rev=249875&r1=249874&r2=249875&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GCRootLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/GCRootLowering.cpp Fri Oct 9 13:44:40 2015
@@ -158,7 +158,7 @@ static bool InsertRootInitializers(Funct
// Search for initializers in the initial BB.
SmallPtrSet<AllocaInst *, 16> InitedRoots;
- for (; !CouldBecomeSafePoint(IP); ++IP)
+ for (; !CouldBecomeSafePoint(&*IP); ++IP)
if (StoreInst *SI = dyn_cast<StoreInst>(IP))
if (AllocaInst *AI =
dyn_cast<AllocaInst>(SI->getOperand(1)->stripPointerCasts()))
More information about the llvm-commits
mailing list