From a926547925e61293b6f32c0906f9affd85ec6db7 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 9 Oct 2015 16:54:49 +0000 Subject: [PATCH] CodeGen: Start removing implicit conversions to/from list iterators, NFC Start removing implicit conversions to/from list iterators in CodeGen, ala r249782 for IR. A lot more to go after this. llvm-svn: 249851 --- include/llvm/CodeGen/BasicTTIImpl.h | 2 +- include/llvm/CodeGen/MachineBasicBlock.h | 4 ++-- include/llvm/CodeGen/MachineInstrBuilder.h | 6 +++--- include/llvm/CodeGen/MachineInstrBundle.h | 16 ++++++++-------- lib/CodeGen/AtomicExpandPass.cpp | 6 +++--- lib/CodeGen/ExecutionDepsFix.cpp | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/llvm/CodeGen/BasicTTIImpl.h b/include/llvm/CodeGen/BasicTTIImpl.h index d631fd60484..aebed66bd73 100644 --- a/include/llvm/CodeGen/BasicTTIImpl.h +++ b/include/llvm/CodeGen/BasicTTIImpl.h @@ -260,7 +260,7 @@ public: for (BasicBlock::iterator J = BB->begin(), JE = BB->end(); J != JE; ++J) if (isa(J) || isa(J)) { - ImmutableCallSite CS(J); + ImmutableCallSite CS(&*J); if (const Function *F = CS.getCalledFunction()) { if (!static_cast(this)->isLoweredToCall(F)) continue; diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index 8ebc8bd02cb..07fa3f603d7 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -181,7 +181,7 @@ public: Ty &operator*() const { return *MII; } Ty *operator->() const { return &operator*(); } - operator Ty*() const { return MII; } + operator Ty *() const { return MII.getNodePtrUnchecked(); } bool operator==(const bundle_iterator &X) const { return MII == X.MII; @@ -600,7 +600,7 @@ public: /// remove_instr to remove individual instructions from a bundle. MachineInstr *remove(MachineInstr *I) { assert(!I->isBundled() && "Cannot remove bundled instructions"); - return Insts.remove(I); + return Insts.remove(instr_iterator(I)); } /// Remove the possibly bundled instruction from the instruction list diff --git a/include/llvm/CodeGen/MachineInstrBuilder.h b/include/llvm/CodeGen/MachineInstrBuilder.h index e5e106e71cf..947fcc70442 100644 --- a/include/llvm/CodeGen/MachineInstrBuilder.h +++ b/include/llvm/CodeGen/MachineInstrBuilder.h @@ -274,7 +274,7 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, const MCInstrDesc &MCID, unsigned DestReg) { if (I->isInsideBundle()) { - MachineBasicBlock::instr_iterator MII = I; + MachineBasicBlock::instr_iterator MII(I); return BuildMI(BB, MII, DL, MCID, DestReg); } @@ -310,7 +310,7 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, DebugLoc DL, const MCInstrDesc &MCID) { if (I->isInsideBundle()) { - MachineBasicBlock::instr_iterator MII = I; + MachineBasicBlock::instr_iterator MII(I); return BuildMI(BB, MII, DL, MCID); } @@ -462,7 +462,7 @@ public: if (I == Begin) { if (!empty()) MI->bundleWithSucc(); - Begin = MI; + Begin = MI->getIterator(); return *this; } if (I == End) { diff --git a/include/llvm/CodeGen/MachineInstrBundle.h b/include/llvm/CodeGen/MachineInstrBundle.h index ef35cea92b2..0ce42dda55b 100644 --- a/include/llvm/CodeGen/MachineInstrBundle.h +++ b/include/llvm/CodeGen/MachineInstrBundle.h @@ -44,23 +44,23 @@ bool finalizeBundles(MachineFunction &MF); /// getBundleStart - Returns the first instruction in the bundle containing MI. /// inline MachineInstr *getBundleStart(MachineInstr *MI) { - MachineBasicBlock::instr_iterator I = MI; + MachineBasicBlock::instr_iterator I(MI); while (I->isBundledWithPred()) --I; - return I; + return &*I; } inline const MachineInstr *getBundleStart(const MachineInstr *MI) { - MachineBasicBlock::const_instr_iterator I = MI; + MachineBasicBlock::const_instr_iterator I(MI); while (I->isBundledWithPred()) --I; - return I; + return &*I; } /// Return an iterator pointing beyond the bundle containing MI. inline MachineBasicBlock::instr_iterator getBundleEnd(MachineInstr *MI) { - MachineBasicBlock::instr_iterator I = MI; + MachineBasicBlock::instr_iterator I(MI); while (I->isBundledWithSucc()) ++I; return ++I; @@ -69,7 +69,7 @@ getBundleEnd(MachineInstr *MI) { /// Return an iterator pointing beyond the bundle containing MI. inline MachineBasicBlock::const_instr_iterator getBundleEnd(const MachineInstr *MI) { - MachineBasicBlock::const_instr_iterator I = MI; + MachineBasicBlock::const_instr_iterator I(MI); while (I->isBundledWithSucc()) ++I; return ++I; @@ -116,10 +116,10 @@ protected: /// explicit MachineOperandIteratorBase(MachineInstr *MI, bool WholeBundle) { if (WholeBundle) { - InstrI = getBundleStart(MI); + InstrI = getBundleStart(MI)->getIterator(); InstrE = MI->getParent()->instr_end(); } else { - InstrI = InstrE = MI; + InstrI = InstrE = MI->getIterator(); ++InstrE; } OpI = InstrI->operands_begin(); diff --git a/lib/CodeGen/AtomicExpandPass.cpp b/lib/CodeGen/AtomicExpandPass.cpp index 0e5b62a3e34..e7998db4a7c 100644 --- a/lib/CodeGen/AtomicExpandPass.cpp +++ b/lib/CodeGen/AtomicExpandPass.cpp @@ -317,7 +317,7 @@ bool AtomicExpand::expandAtomicRMWToLLSC(AtomicRMWInst *AI) { // atomicrmw.end: // fence? // [...] - BasicBlock *ExitBB = BB->splitBasicBlock(AI, "atomicrmw.end"); + BasicBlock *ExitBB = BB->splitBasicBlock(AI->getIterator(), "atomicrmw.end"); BasicBlock *LoopBB = BasicBlock::Create(Ctx, "atomicrmw.start", F, ExitBB); // This grabs the DebugLoc from AI. @@ -393,7 +393,7 @@ bool AtomicExpand::expandAtomicCmpXchg(AtomicCmpXchgInst *CI) { // %restmp = insertvalue { iN, i1 } undef, iN %loaded, 0 // %res = insertvalue { iN, i1 } %restmp, i1 %success, 1 // [...] - BasicBlock *ExitBB = BB->splitBasicBlock(CI, "cmpxchg.end"); + BasicBlock *ExitBB = BB->splitBasicBlock(CI->getIterator(), "cmpxchg.end"); auto FailureBB = BasicBlock::Create(Ctx, "cmpxchg.failure", F, ExitBB); auto NoStoreBB = BasicBlock::Create(Ctx, "cmpxchg.nostore", F, FailureBB); auto SuccessBB = BasicBlock::Create(Ctx, "cmpxchg.success", F, NoStoreBB); @@ -549,7 +549,7 @@ bool llvm::expandAtomicRMWToCmpXchg(AtomicRMWInst *AI, // br i1 %success, label %atomicrmw.end, label %loop // atomicrmw.end: // [...] - BasicBlock *ExitBB = BB->splitBasicBlock(AI, "atomicrmw.end"); + BasicBlock *ExitBB = BB->splitBasicBlock(AI->getIterator(), "atomicrmw.end"); BasicBlock *LoopBB = BasicBlock::Create(Ctx, "atomicrmw.start", F, ExitBB); // This grabs the DebugLoc from AI. diff --git a/lib/CodeGen/ExecutionDepsFix.cpp b/lib/CodeGen/ExecutionDepsFix.cpp index 3eee1e2e7f0..deacb233f17 100644 --- a/lib/CodeGen/ExecutionDepsFix.cpp +++ b/lib/CodeGen/ExecutionDepsFix.cpp @@ -751,7 +751,7 @@ bool ExeDepsFix::runOnMachineFunction(MachineFunction &mf) { AliasMap[*AI].push_back(i); } - MachineBasicBlock *Entry = MF->begin(); + MachineBasicBlock *Entry = &*MF->begin(); ReversePostOrderTraversal RPOT(Entry); SmallVector Loops; for (ReversePostOrderTraversal::rpo_iterator