CodeGen: Avoid ilist iterator implicit conversions in a few more places, NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249880 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2015-10-09 19:23:20 +00:00
parent 3f2c43f3c5
commit b1510c25d9
3 changed files with 21 additions and 23 deletions

View File

@ -966,7 +966,7 @@ void BlockFrequencyInfoImpl<BT>::calculate(const FunctionT &F,
} }
template <class BT> void BlockFrequencyInfoImpl<BT>::initializeRPOT() { template <class BT> void BlockFrequencyInfoImpl<BT>::initializeRPOT() {
const BlockT *Entry = F->begin(); const BlockT *Entry = &F->front();
RPOT.reserve(F->size()); RPOT.reserve(F->size());
std::copy(po_begin(Entry), po_end(Entry), std::back_inserter(RPOT)); std::copy(po_begin(Entry), po_end(Entry), std::back_inserter(RPOT));
std::reverse(RPOT.begin(), RPOT.end()); std::reverse(RPOT.begin(), RPOT.end());

View File

@ -302,8 +302,8 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST,
for (const_instr_iterator I = instr_begin(); I != instr_end(); ++I) { for (const_instr_iterator I = instr_begin(); I != instr_end(); ++I) {
if (Indexes) { if (Indexes) {
if (Indexes->hasIndex(I)) if (Indexes->hasIndex(&*I))
OS << Indexes->getInstructionIndex(I); OS << Indexes->getInstructionIndex(&*I);
OS << '\t'; OS << '\t';
} }
OS << '\t'; OS << '\t';
@ -402,12 +402,11 @@ MachineBasicBlock::addLiveIn(MCPhysReg PhysReg, const TargetRegisterClass *RC) {
} }
void MachineBasicBlock::moveBefore(MachineBasicBlock *NewAfter) { void MachineBasicBlock::moveBefore(MachineBasicBlock *NewAfter) {
getParent()->splice(NewAfter, this); getParent()->splice(NewAfter->getIterator(), getIterator());
} }
void MachineBasicBlock::moveAfter(MachineBasicBlock *NewBefore) { void MachineBasicBlock::moveAfter(MachineBasicBlock *NewBefore) {
MachineFunction::iterator BBI = NewBefore; getParent()->splice(++NewBefore->getIterator(), getIterator());
getParent()->splice(++BBI, this);
} }
void MachineBasicBlock::updateTerminator() { void MachineBasicBlock::updateTerminator() {
@ -653,14 +652,14 @@ bool MachineBasicBlock::isLayoutSuccessor(const MachineBasicBlock *MBB) const {
} }
bool MachineBasicBlock::canFallThrough() { bool MachineBasicBlock::canFallThrough() {
MachineFunction::iterator Fallthrough = this; MachineFunction::iterator Fallthrough = getIterator();
++Fallthrough; ++Fallthrough;
// If FallthroughBlock is off the end of the function, it can't fall through. // If FallthroughBlock is off the end of the function, it can't fall through.
if (Fallthrough == getParent()->end()) if (Fallthrough == getParent()->end())
return false; return false;
// If FallthroughBlock isn't a successor, no fallthrough is possible. // If FallthroughBlock isn't a successor, no fallthrough is possible.
if (!isSuccessor(Fallthrough)) if (!isSuccessor(&*Fallthrough))
return false; return false;
// Analyze the branches, if any, at the end of the block. // Analyze the branches, if any, at the end of the block.
@ -751,7 +750,7 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) {
if (LV) if (LV)
for (instr_iterator I = getFirstInstrTerminator(), E = instr_end(); for (instr_iterator I = getFirstInstrTerminator(), E = instr_end();
I != E; ++I) { I != E; ++I) {
MachineInstr *MI = I; MachineInstr *MI = &*I;
for (MachineInstr::mop_iterator OI = MI->operands_begin(), for (MachineInstr::mop_iterator OI = MI->operands_begin(),
OE = MI->operands_end(); OI != OE; ++OI) { OE = MI->operands_end(); OI != OE; ++OI) {
if (!OI->isReg() || OI->getReg() == 0 || if (!OI->isReg() || OI->getReg() == 0 ||
@ -771,7 +770,7 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) {
if (LIS) { if (LIS) {
for (instr_iterator I = getFirstInstrTerminator(), E = instr_end(); for (instr_iterator I = getFirstInstrTerminator(), E = instr_end();
I != E; ++I) { I != E; ++I) {
MachineInstr *MI = I; MachineInstr *MI = &*I;
for (MachineInstr::mop_iterator OI = MI->operands_begin(), for (MachineInstr::mop_iterator OI = MI->operands_begin(),
OE = MI->operands_end(); OI != OE; ++OI) { OE = MI->operands_end(); OI != OE; ++OI) {
@ -793,7 +792,7 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) {
if (Indexes) { if (Indexes) {
for (instr_iterator I = getFirstInstrTerminator(), E = instr_end(); for (instr_iterator I = getFirstInstrTerminator(), E = instr_end();
I != E; ++I) I != E; ++I)
Terminators.push_back(I); Terminators.push_back(&*I);
} }
updateTerminator(); updateTerminator();
@ -802,7 +801,7 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) {
SmallVector<MachineInstr*, 4> NewTerminators; SmallVector<MachineInstr*, 4> NewTerminators;
for (instr_iterator I = getFirstInstrTerminator(), E = instr_end(); for (instr_iterator I = getFirstInstrTerminator(), E = instr_end();
I != E; ++I) I != E; ++I)
NewTerminators.push_back(I); NewTerminators.push_back(&*I);
for (SmallVectorImpl<MachineInstr*>::iterator I = Terminators.begin(), for (SmallVectorImpl<MachineInstr*>::iterator I = Terminators.begin(),
E = Terminators.end(); I != E; ++I) { E = Terminators.end(); I != E; ++I) {
@ -823,9 +822,9 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) {
I != E; ++I) { I != E; ++I) {
// Some instructions may have been moved to NMBB by updateTerminator(), // Some instructions may have been moved to NMBB by updateTerminator(),
// so we first remove any instruction that already has an index. // so we first remove any instruction that already has an index.
if (Indexes->hasIndex(I)) if (Indexes->hasIndex(&*I))
Indexes->removeMachineInstrFromMaps(I); Indexes->removeMachineInstrFromMaps(&*I);
Indexes->insertMachineInstrInMaps(I); Indexes->insertMachineInstrInMaps(&*I);
} }
} }
} }
@ -852,7 +851,7 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) {
if (!(--I)->addRegisterKilled(Reg, TRI, /* addIfNotFound= */ false)) if (!(--I)->addRegisterKilled(Reg, TRI, /* addIfNotFound= */ false))
continue; continue;
if (TargetRegisterInfo::isVirtualRegister(Reg)) if (TargetRegisterInfo::isVirtualRegister(Reg))
LV->getVarInfo(Reg).Kills.push_back(I); LV->getVarInfo(Reg).Kills.push_back(&*I);
DEBUG(dbgs() << "Restored terminator kill: " << *I); DEBUG(dbgs() << "Restored terminator kill: " << *I);
break; break;
} }
@ -972,7 +971,7 @@ static void unbundleSingleMI(MachineInstr *MI) {
MachineBasicBlock::instr_iterator MachineBasicBlock::instr_iterator
MachineBasicBlock::erase(MachineBasicBlock::instr_iterator I) { MachineBasicBlock::erase(MachineBasicBlock::instr_iterator I) {
unbundleSingleMI(I); unbundleSingleMI(&*I);
return Insts.erase(I); return Insts.erase(I);
} }
@ -1058,17 +1057,16 @@ bool MachineBasicBlock::CorrectExtraCFGEdges(MachineBasicBlock *DestA,
bool Changed = false; bool Changed = false;
MachineFunction::iterator FallThru = MachineFunction::iterator FallThru = std::next(getIterator());
std::next(MachineFunction::iterator(this));
if (!DestA && !DestB) { if (!DestA && !DestB) {
// Block falls through to successor. // Block falls through to successor.
DestA = FallThru; DestA = &*FallThru;
DestB = FallThru; DestB = &*FallThru;
} else if (DestA && !DestB) { } else if (DestA && !DestB) {
if (IsCond) if (IsCond)
// Block ends in conditional jump that falls through to successor. // Block ends in conditional jump that falls through to successor.
DestB = FallThru; DestB = &*FallThru;
} else { } else {
assert(DestA && DestB && IsCond && assert(DestA && DestB && IsCond &&
"CFG in a bad state. Cannot correct CFG edges"); "CFG in a bad state. Cannot correct CFG edges");

View File

@ -57,7 +57,7 @@ struct GraphTraits<MachineBlockFrequencyInfo *> {
static inline static inline
const NodeType *getEntryNode(const MachineBlockFrequencyInfo *G) { const NodeType *getEntryNode(const MachineBlockFrequencyInfo *G) {
return G->getFunction()->begin(); return &G->getFunction()->front();
} }
static ChildIteratorType child_begin(const NodeType *N) { static ChildIteratorType child_begin(const NodeType *N) {