diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-02-27 06:40:41 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-02-27 06:40:41 +0000 |
commit | 3ac9cc615694361653d51148995f1fead69f9487 (patch) | |
tree | 940feeaeb882518bc7728d0809085607793097c2 /llvm/lib/CodeGen/MachineBasicBlock.cpp | |
parent | 0bed1eab3937cc9c78baaef88ae85da9f3f91402 (diff) | |
download | llvm-3ac9cc615694361653d51148995f1fead69f9487.zip llvm-3ac9cc615694361653d51148995f1fead69f9487.tar.gz llvm-3ac9cc615694361653d51148995f1fead69f9487.tar.bz2 |
CodeGen: Take MachineInstr& in SlotIndexes and LiveIntervals, NFC
Take MachineInstr by reference instead of by pointer in SlotIndexes and
the SlotIndex wrappers in LiveIntervals. The MachineInstrs here are
never null, so this cleans up the API a bit. It also incidentally
removes a few implicit conversions from MachineInstrBundleIterator to
MachineInstr* (see PR26753).
At a couple of call sites it was convenient to convert to a range-based
for loop over MachineBasicBlock::instr_begin/instr_end, so I added
MachineBasicBlock::instrs.
llvm-svn: 262115
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBasicBlock.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 6421b8c..de1f1c7 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -302,16 +302,16 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST, OS << '\n'; } - for (const_instr_iterator I = instr_begin(); I != instr_end(); ++I) { + for (auto &I : instrs()) { if (Indexes) { - if (Indexes->hasIndex(&*I)) - OS << Indexes->getInstructionIndex(&*I); + if (Indexes->hasIndex(I)) + OS << Indexes->getInstructionIndex(I); OS << '\t'; } OS << '\t'; - if (I->isInsideBundle()) + if (I.isInsideBundle()) OS << " * "; - I->print(OS, MST); + I.print(OS, MST); } // Print the successors of this block according to the CFG. @@ -826,7 +826,7 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) { E = Terminators.end(); I != E; ++I) { if (std::find(NewTerminators.begin(), NewTerminators.end(), *I) == NewTerminators.end()) - Indexes->removeMachineInstrFromMaps(*I); + Indexes->removeMachineInstrFromMaps(**I); } } @@ -837,13 +837,12 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) { TII->InsertBranch(*NMBB, Succ, nullptr, Cond, DL); if (Indexes) { - for (instr_iterator I = NMBB->instr_begin(), E = NMBB->instr_end(); - I != E; ++I) { + for (MachineInstr &MI : NMBB->instrs()) { // Some instructions may have been moved to NMBB by updateTerminator(), // so we first remove any instruction that already has an index. - if (Indexes->hasIndex(&*I)) - Indexes->removeMachineInstrFromMaps(&*I); - Indexes->insertMachineInstrInMaps(&*I); + if (Indexes->hasIndex(MI)) + Indexes->removeMachineInstrFromMaps(MI); + Indexes->insertMachineInstrInMaps(MI); } } } |