summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/MLxExpansionPass.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-09-11 18:51:28 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-09-11 18:51:28 +0000
commit1872096f1e2befed2a3be6617eddfb18a06f80d7 (patch)
tree568ba73e708d1bb44439df5204006b88b8dabff9 /llvm/lib/Target/ARM/MLxExpansionPass.cpp
parente98bc7af8bb4eb8cf45413bf2826b1dbd8c9c57d (diff)
downloadbcm5719-llvm-1872096f1e2befed2a3be6617eddfb18a06f80d7.tar.gz
bcm5719-llvm-1872096f1e2befed2a3be6617eddfb18a06f80d7.zip
CodeGen: Give MachineBasicBlock::reverse_iterator a handle to the current MI
Now that MachineBasicBlock::reverse_instr_iterator knows when it's at the end (since r281168 and r281170), implement MachineBasicBlock::reverse_iterator directly on top of an ilist::reverse_iterator by adding an IsReverse template parameter to MachineInstrBundleIterator. This replaces another hard-to-reason-about use of std::reverse_iterator on list iterators, matching the changes for ilist::reverse_iterator from r280032 (see the "out of scope" section at the end of that commit message). MachineBasicBlock::reverse_iterator now has a handle to the current node and has obvious invalidation semantics. r280032 has a more detailed explanation of how list-style reverse iterators (invalidated when the pointed-at node is deleted) are different from vector-style reverse iterators like std::reverse_iterator (invalidated on every operation). A great motivating example is this commit's changes to lib/CodeGen/DeadMachineInstructionElim.cpp. Note: If your out-of-tree backend deletes instructions while iterating on a MachineBasicBlock::reverse_iterator or converts between MachineBasicBlock::iterator and MachineBasicBlock::reverse_iterator, you'll need to update your code in similar ways to r280032. The following table might help: [Old] ==> [New] delete &*RI, RE = end() delete &*RI++ RI->erase(), RE = end() RI++->erase() reverse_iterator(I) std::prev(I).getReverse() reverse_iterator(I) ++I.getReverse() --reverse_iterator(I) I.getReverse() reverse_iterator(std::next(I)) I.getReverse() RI.base() std::prev(RI).getReverse() RI.base() ++RI.getReverse() --RI.base() RI.getReverse() std::next(RI).base() RI.getReverse() (For more details, have a look at r280032.) llvm-svn: 281172
Diffstat (limited to 'llvm/lib/Target/ARM/MLxExpansionPass.cpp')
-rw-r--r--llvm/lib/Target/ARM/MLxExpansionPass.cpp11
1 files changed, 2 insertions, 9 deletions
diff --git a/llvm/lib/Target/ARM/MLxExpansionPass.cpp b/llvm/lib/Target/ARM/MLxExpansionPass.cpp
index 7f212403398..26745be947e 100644
--- a/llvm/lib/Target/ARM/MLxExpansionPass.cpp
+++ b/llvm/lib/Target/ARM/MLxExpansionPass.cpp
@@ -334,18 +334,15 @@ bool MLxExpansion::ExpandFPMLxInstructions(MachineBasicBlock &MBB) {
unsigned Skip = 0;
MachineBasicBlock::reverse_iterator MII = MBB.rbegin(), E = MBB.rend();
while (MII != E) {
- MachineInstr *MI = &*MII;
+ MachineInstr *MI = &*MII++;
- if (MI->isPosition() || MI->isImplicitDef() || MI->isCopy()) {
- ++MII;
+ if (MI->isPosition() || MI->isImplicitDef() || MI->isCopy())
continue;
- }
const MCInstrDesc &MCID = MI->getDesc();
if (MI->isBarrier()) {
clearStack();
Skip = 0;
- ++MII;
continue;
}
@@ -365,13 +362,9 @@ bool MLxExpansion::ExpandFPMLxInstructions(MachineBasicBlock &MBB) {
pushStack(MI);
else {
ExpandFPMLxInstruction(MBB, MI, MulOpc, AddSubOpc, NegAcc, HasLane);
- E = MBB.rend(); // May have changed if MI was the 1st instruction.
Changed = true;
- continue;
}
}
-
- ++MII;
}
return Changed;
OpenPOWER on IntegriCloud