mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-13 14:46:53 +00:00
Hexagon: Remove implicit ilist iterator conversions, NFC
There are two things out of the ordinary in this commit. First, I made a loop obviously "infinite" in HexagonInstrInfo.cpp. After checking if an instruction was at the beginning of a basic block (in which case, `break`), the loop decremented and checked the iterator for `nullptr` as the loop condition. This has never been possible (the prev pointers are always been circular, so even with the weird ilist/iplist implementation, this isn't been possible), so I removed the condition. Second, in HexagonAsmPrinter.cpp there was another case of comparing a `MachineBasicBlock::instr_iterator` against `MachineBasicBlock::end()` (which returns `MachineBasicBlock::iterator`). While not incorrect, it's fragile. I switched this to `::instr_end()`. All that said, no functionality change intended here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250778 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9f16772a3d
commit
8525f3a7bc
@ -955,7 +955,7 @@ void BT::visitBranchesFrom(const MachineInstr *BI) {
|
||||
Targets.insert(SB);
|
||||
}
|
||||
if (FallsThrough) {
|
||||
MachineFunction::const_iterator BIt = &B;
|
||||
MachineFunction::const_iterator BIt = B.getIterator();
|
||||
MachineFunction::const_iterator Next = std::next(BIt);
|
||||
if (Next != MF.end())
|
||||
Targets.insert(&*Next);
|
||||
@ -1104,7 +1104,7 @@ void BT::run() {
|
||||
}
|
||||
// If block end has been reached, add the fall-through edge to the queue.
|
||||
if (It == End) {
|
||||
MachineFunction::const_iterator BIt = &B;
|
||||
MachineFunction::const_iterator BIt = B.getIterator();
|
||||
MachineFunction::const_iterator Next = std::next(BIt);
|
||||
if (Next != MF.end()) {
|
||||
int ThisN = B.getNumber();
|
||||
|
@ -184,15 +184,15 @@ void HexagonAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
||||
|
||||
if (MI->isBundle()) {
|
||||
const MachineBasicBlock* MBB = MI->getParent();
|
||||
MachineBasicBlock::const_instr_iterator MII = MI;
|
||||
MachineBasicBlock::const_instr_iterator MII = MI->getIterator();
|
||||
unsigned IgnoreCount = 0;
|
||||
|
||||
for (++MII; MII != MBB->end() && MII->isInsideBundle(); ++MII) {
|
||||
for (++MII; MII != MBB->instr_end() && MII->isInsideBundle(); ++MII) {
|
||||
if (MII->getOpcode() == TargetOpcode::DBG_VALUE ||
|
||||
MII->getOpcode() == TargetOpcode::IMPLICIT_DEF)
|
||||
++IgnoreCount;
|
||||
else {
|
||||
HexagonLowerToMC(MII, MCB, *this);
|
||||
HexagonLowerToMC(&*MII, MCB, *this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ bool HexagonCFGOptimizer::runOnMachineFunction(MachineFunction &Fn) {
|
||||
// Loop over all of the basic blocks.
|
||||
for (MachineFunction::iterator MBBb = Fn.begin(), MBBe = Fn.end();
|
||||
MBBb != MBBe; ++MBBb) {
|
||||
MachineBasicBlock* MBB = MBBb;
|
||||
MachineBasicBlock *MBB = &*MBBb;
|
||||
|
||||
// Traverse the basic block.
|
||||
MachineBasicBlock::iterator MII = MBB->getFirstTerminator();
|
||||
|
@ -389,7 +389,7 @@ void HexagonCommonGEP::processGepInst(GetElementPtrInst *GepI,
|
||||
void HexagonCommonGEP::collect() {
|
||||
// Establish depth-first traversal order of the dominator tree.
|
||||
ValueVect BO;
|
||||
getBlockTraversalOrder(Fn->begin(), BO);
|
||||
getBlockTraversalOrder(&Fn->front(), BO);
|
||||
|
||||
// The creation of gep nodes requires DT-traversal. When processing a GEP
|
||||
// instruction that uses another GEP instruction as the base pointer, the
|
||||
@ -722,7 +722,7 @@ namespace {
|
||||
Instruction *In = cast<Instruction>(V);
|
||||
if (In->getParent() != B)
|
||||
continue;
|
||||
BasicBlock::iterator It = In;
|
||||
BasicBlock::iterator It = In->getIterator();
|
||||
if (std::distance(FirstUse, BEnd) < std::distance(It, BEnd))
|
||||
FirstUse = It;
|
||||
}
|
||||
@ -1120,7 +1120,7 @@ Value *HexagonCommonGEP::fabricateGEP(NodeVect &NA, BasicBlock::iterator At,
|
||||
ArrayRef<Value*> A(IdxList, IdxC);
|
||||
Type *InpTy = Input->getType();
|
||||
Type *ElTy = cast<PointerType>(InpTy->getScalarType())->getElementType();
|
||||
NewInst = GetElementPtrInst::Create(ElTy, Input, A, "cgep", At);
|
||||
NewInst = GetElementPtrInst::Create(ElTy, Input, A, "cgep", &*At);
|
||||
DEBUG(dbgs() << "new GEP: " << *NewInst << '\n');
|
||||
Input = NewInst;
|
||||
} while (nax <= Num);
|
||||
@ -1198,7 +1198,7 @@ void HexagonCommonGEP::materialize(NodeToValueMap &Loc) {
|
||||
Last = Child;
|
||||
} while (true);
|
||||
|
||||
BasicBlock::iterator InsertAt = LastB->getTerminator();
|
||||
BasicBlock::iterator InsertAt = LastB->getTerminator()->getIterator();
|
||||
if (LastUsed || LastCN > 0) {
|
||||
ValueVect Urs;
|
||||
getAllUsersForNode(Root, Urs, NCM);
|
||||
|
@ -943,8 +943,7 @@ void HexagonEarlyIfConversion::removeBlock(MachineBasicBlock *B) {
|
||||
|
||||
Deleted.insert(B);
|
||||
MDT->eraseNode(B);
|
||||
MachineFunction::iterator BI = B;
|
||||
MFN->erase(BI);
|
||||
MFN->erase(B->getIterator());
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,7 +74,7 @@ bool HexagonExpandPredSpillCode::runOnMachineFunction(MachineFunction &Fn) {
|
||||
// Loop over all of the basic blocks.
|
||||
for (MachineFunction::iterator MBBb = Fn.begin(), MBBe = Fn.end();
|
||||
MBBb != MBBe; ++MBBb) {
|
||||
MachineBasicBlock* MBB = MBBb;
|
||||
MachineBasicBlock *MBB = &*MBBb;
|
||||
// Traverse the basic block.
|
||||
for (MachineBasicBlock::iterator MII = MBB->begin(); MII != MBB->end();
|
||||
++MII) {
|
||||
|
@ -1083,7 +1083,7 @@ bool HexagonFrameLowering::replacePredRegPseudoSpillCode(MachineFunction &MF)
|
||||
// Loop over all of the basic blocks.
|
||||
for (MachineFunction::iterator MBBb = MF.begin(), MBBe = MF.end();
|
||||
MBBb != MBBe; ++MBBb) {
|
||||
MachineBasicBlock* MBB = MBBb;
|
||||
MachineBasicBlock *MBB = &*MBBb;
|
||||
// Traverse the basic block.
|
||||
MachineBasicBlock::iterator NextII;
|
||||
for (MachineBasicBlock::iterator MII = MBB->begin(); MII != MBB->end();
|
||||
|
@ -195,7 +195,7 @@ bool HexagonGenExtract::convert(Instruction *In) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IRBuilder<> IRB(BB, In);
|
||||
IRBuilder<> IRB(In);
|
||||
Intrinsic::ID IntId = (BW == 32) ? Intrinsic::hexagon_S2_extractu
|
||||
: Intrinsic::hexagon_S2_extractup;
|
||||
Module *Mod = BB->getParent()->getParent();
|
||||
|
@ -1288,14 +1288,14 @@ bool HexagonHardwareLoops::orderBumpCompare(MachineInstr *BumpI,
|
||||
|
||||
typedef MachineBasicBlock::instr_iterator instr_iterator;
|
||||
// Check if things are in order to begin with.
|
||||
for (instr_iterator I = BumpI, E = BB->instr_end(); I != E; ++I)
|
||||
for (instr_iterator I(BumpI), E = BB->instr_end(); I != E; ++I)
|
||||
if (&*I == CmpI)
|
||||
return true;
|
||||
|
||||
// Out of order.
|
||||
unsigned PredR = CmpI->getOperand(0).getReg();
|
||||
bool FoundBump = false;
|
||||
instr_iterator CmpIt = CmpI, NextIt = std::next(CmpIt);
|
||||
instr_iterator CmpIt = CmpI->getIterator(), NextIt = std::next(CmpIt);
|
||||
for (instr_iterator I = NextIt, E = BB->instr_end(); I != E; ++I) {
|
||||
MachineInstr *In = &*I;
|
||||
for (unsigned i = 0, n = In->getNumOperands(); i < n; ++i) {
|
||||
@ -1307,9 +1307,7 @@ bool HexagonHardwareLoops::orderBumpCompare(MachineInstr *BumpI,
|
||||
}
|
||||
|
||||
if (In == BumpI) {
|
||||
instr_iterator After = BumpI;
|
||||
instr_iterator From = CmpI;
|
||||
BB->splice(std::next(After), BB, From);
|
||||
BB->splice(++BumpI->getIterator(), BB, CmpI->getIterator());
|
||||
FoundBump = true;
|
||||
break;
|
||||
}
|
||||
@ -1850,7 +1848,7 @@ MachineBasicBlock *HexagonHardwareLoops::createPreheaderForLoop(
|
||||
}
|
||||
|
||||
MachineBasicBlock *NewPH = MF->CreateMachineBasicBlock();
|
||||
MF->insert(Header, NewPH);
|
||||
MF->insert(Header->getIterator(), NewPH);
|
||||
|
||||
if (Header->pred_size() > 2) {
|
||||
// Ensure that the header has only two predecessors: the preheader and
|
||||
|
@ -1397,7 +1397,7 @@ void HexagonDAGToDAGISel::EmitFunctionEntryCode() {
|
||||
return;
|
||||
|
||||
MachineFrameInfo *MFI = MF->getFrameInfo();
|
||||
MachineBasicBlock *EntryBB = MF->begin();
|
||||
MachineBasicBlock *EntryBB = &MF->front();
|
||||
unsigned AR = FuncInfo->CreateReg(MVT::i32);
|
||||
unsigned MaxA = MFI->getMaxAlignment();
|
||||
auto &HII = *HST.getInstrInfo();
|
||||
|
@ -183,8 +183,7 @@ unsigned HexagonInstrInfo::InsertBranch(
|
||||
MachineInstr *Term = MBB.getFirstTerminator();
|
||||
if (Term != MBB.end() && isPredicated(Term) &&
|
||||
!AnalyzeBranch(MBB, NewTBB, NewFBB, Cond, false)) {
|
||||
MachineBasicBlock *NextBB =
|
||||
std::next(MachineFunction::iterator(&MBB));
|
||||
MachineBasicBlock *NextBB = &*++MBB.getIterator();
|
||||
if (NewTBB == NextBB) {
|
||||
ReverseBranchCondition(Cond);
|
||||
RemoveBranch(MBB);
|
||||
@ -327,17 +326,17 @@ bool HexagonInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,
|
||||
return false;
|
||||
--I;
|
||||
}
|
||||
if (!isUnpredicatedTerminator(I))
|
||||
if (!isUnpredicatedTerminator(&*I))
|
||||
return false;
|
||||
|
||||
// Get the last instruction in the block.
|
||||
MachineInstr *LastInst = I;
|
||||
MachineInstr *LastInst = &*I;
|
||||
MachineInstr *SecondLastInst = nullptr;
|
||||
// Find one more terminator if present.
|
||||
do {
|
||||
if (&*I != LastInst && !I->isBundle() && isUnpredicatedTerminator(I)) {
|
||||
for (;;) {
|
||||
if (&*I != LastInst && !I->isBundle() && isUnpredicatedTerminator(&*I)) {
|
||||
if (!SecondLastInst)
|
||||
SecondLastInst = I;
|
||||
SecondLastInst = &*I;
|
||||
else
|
||||
// This is a third branch.
|
||||
return true;
|
||||
@ -345,7 +344,7 @@ bool HexagonInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,
|
||||
if (I == MBB.instr_begin())
|
||||
break;
|
||||
--I;
|
||||
} while(I);
|
||||
}
|
||||
|
||||
int LastOpcode = LastInst->getOpcode();
|
||||
int SecLastOpcode = SecondLastInst ? SecondLastInst->getOpcode() : 0;
|
||||
@ -418,7 +417,7 @@ bool HexagonInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,
|
||||
// executed, so remove it.
|
||||
if (SecLastOpcode == Hexagon::J2_jump && LastOpcode == Hexagon::J2_jump) {
|
||||
TBB = SecondLastInst->getOperand(0).getMBB();
|
||||
I = LastInst;
|
||||
I = LastInst->getIterator();
|
||||
if (AllowModify)
|
||||
I->eraseFromParent();
|
||||
return false;
|
||||
@ -1072,7 +1071,7 @@ PredicateInstruction(MachineInstr *MI,
|
||||
for (unsigned i = 0, n = T->getNumOperands(); i < n; ++i)
|
||||
MI->addOperand(T->getOperand(i));
|
||||
|
||||
MachineBasicBlock::instr_iterator TI = &*T;
|
||||
MachineBasicBlock::instr_iterator TI = T->getIterator();
|
||||
B.erase(TI);
|
||||
|
||||
MachineRegisterInfo &MRI = B.getParent()->getRegInfo();
|
||||
|
@ -372,7 +372,7 @@ bool HexagonNewValueJump::runOnMachineFunction(MachineFunction &MF) {
|
||||
// Loop through all the bb's of the function
|
||||
for (MachineFunction::iterator MBBb = MF.begin(), MBBe = MF.end();
|
||||
MBBb != MBBe; ++MBBb) {
|
||||
MachineBasicBlock* MBB = MBBb;
|
||||
MachineBasicBlock *MBB = &*MBBb;
|
||||
|
||||
DEBUG(dbgs() << "** dumping bb ** "
|
||||
<< MBB->getNumber() << "\n");
|
||||
|
@ -84,7 +84,7 @@ bool HexagonOptimizeSZextends::runOnFunction(Function &F) {
|
||||
(EVT::getEVT(Use->getType())));
|
||||
++UI;
|
||||
Use->replaceAllUsesWith(SI);
|
||||
Instruction* First = F.getEntryBlock().begin();
|
||||
Instruction* First = &F.getEntryBlock().front();
|
||||
SI->insertBefore(First);
|
||||
Use->eraseFromParent();
|
||||
} else {
|
||||
|
@ -124,7 +124,7 @@ bool HexagonPeephole::runOnMachineFunction(MachineFunction &MF) {
|
||||
// Loop over all of the basic blocks.
|
||||
for (MachineFunction::iterator MBBb = MF.begin(), MBBe = MF.end();
|
||||
MBBb != MBBe; ++MBBb) {
|
||||
MachineBasicBlock* MBB = MBBb;
|
||||
MachineBasicBlock *MBB = &*MBBb;
|
||||
PeepholeMap.clear();
|
||||
PeepholeDoubleRegsMap.clear();
|
||||
|
||||
|
@ -81,7 +81,7 @@ bool HexagonSplitConst32AndConst64::runOnMachineFunction(MachineFunction &Fn) {
|
||||
// Loop over all of the basic blocks
|
||||
for (MachineFunction::iterator MBBb = Fn.begin(), MBBe = Fn.end();
|
||||
MBBb != MBBe; ++MBBb) {
|
||||
MachineBasicBlock* MBB = MBBb;
|
||||
MachineBasicBlock *MBB = &*MBBb;
|
||||
// Traverse the basic block
|
||||
MachineBasicBlock::iterator MII = MBB->begin();
|
||||
MachineBasicBlock::iterator MIE = MBB->end ();
|
||||
|
@ -238,7 +238,7 @@ bool HexagonPacketizer::runOnMachineFunction(MachineFunction &Fn) {
|
||||
// instruction stream until we find the nearest boundary.
|
||||
MachineBasicBlock::iterator I = RegionEnd;
|
||||
for(;I != MBB->begin(); --I, --RemainingCount) {
|
||||
if (TII->isSchedulingBoundary(std::prev(I), MBB, Fn))
|
||||
if (TII->isSchedulingBoundary(std::prev(I), &*MBB, Fn))
|
||||
break;
|
||||
}
|
||||
I = MBB->begin();
|
||||
@ -255,7 +255,7 @@ bool HexagonPacketizer::runOnMachineFunction(MachineFunction &Fn) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Packetizer.PacketizeMIs(MBB, I, RegionEnd);
|
||||
Packetizer.PacketizeMIs(&*MBB, I, RegionEnd);
|
||||
RegionEnd = I;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user