[PATCH] D22924: [GlobalISel] Permit select() to erase.
Ahmed Bougacha via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 8 11:36:52 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286272: [GlobalISel] Permit select() to erase. (authored by ab).
Changed prior to commit:
https://reviews.llvm.org/D22924?vs=65948&id=77221#toc
Repository:
rL LLVM
https://reviews.llvm.org/D22924
Files:
llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelect.cpp
Index: llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelect.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelect.cpp
+++ llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelect.cpp
@@ -89,11 +89,28 @@
bool Failed = false;
for (MachineBasicBlock *MBB : post_order(&MF)) {
- for (MachineBasicBlock::reverse_iterator MII = MBB->rbegin(),
- End = MBB->rend();
- MII != End;) {
- MachineInstr &MI = *MII++;
- DEBUG(dbgs() << "Selecting: " << MI << '\n');
+ if (MBB->empty())
+ continue;
+
+ // Select instructions in reverse block order. We permit erasing so have
+ // to resort to manually iterating and recognizing the begin (rend) case.
+ bool ReachedBegin = false;
+ for (auto MII = std::prev(MBB->end()), Begin = MBB->begin();
+ !ReachedBegin;) {
+ // Keep track of the insertion range for debug printing.
+ const auto AfterIt = std::next(MII);
+
+ // Select this instruction.
+ MachineInstr &MI = *MII;
+
+ // And have our iterator point to the next instruction, if there is one.
+ if (MII == Begin)
+ ReachedBegin = true;
+ else
+ --MII;
+
+ DEBUG(dbgs() << "Selecting: \n " << MI);
+
if (!ISel->select(MI)) {
if (TPC.isGlobalISelAbortEnabled())
// FIXME: It would be nice to dump all inserted instructions. It's
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22924.77221.patch
Type: text/x-patch
Size: 1469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161108/e84b3e46/attachment.bin>
More information about the llvm-commits
mailing list